:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --card-soft: #fafafa;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;

  --primary: #111827;
  --primary-text: #ffffff;

  --secondary: #ffffff;
  --secondary-text: #111827;

  --ghost: #f9fafb;
  --ghost-text: #111827;

  --warning-bg: #fff7ed;
  --warning-line: #fed7aa;

  --success-bg: #ecfdf5;
  --success-line: #a7f3d0;

  --error-bg: #fef2f2;
  --error-line: #fecaca;

  --shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

body {
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.hero {
  padding-top: 22px;
  padding-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

h1 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.25;
}

.section-title {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.4;
}

.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.helper {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

input[type="text"] {
  width: 100%;
  min-height: 54px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 14px;
  font-size: 16px;
  color: var(--text);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.05);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 700;
  text-align: center;
  width: 100%;
  transition: transform 0.05s ease, opacity 0.2s ease, background 0.2s ease;
}

.button:active {
  transform: scale(0.99);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

.button.secondary {
  background: var(--secondary);
  color: var(--secondary-text);
}

.button.ghost {
  background: var(--ghost);
  color: var(--ghost-text);
}

.button-row {
  display: grid;
  gap: 10px;
}

.stack-12 > * + * {
  margin-top: 12px;
}

.stack-16 > * + * {
  margin-top: 16px;
}

.message {
  padding: 14px;
  border-radius: var(--radius-md);
  line-height: 1.8;
  border: 1px solid transparent;
  font-size: 14px;
}

.message.success {
  background: var(--success-bg);
  border-color: var(--success-line);
}

.message.error {
  background: var(--error-bg);
  border-color: var(--error-line);
}

.warning {
  background: var(--warning-bg);
  border-color: var(--warning-line);
}

.info-box,
.empty-box,
.progress-box {
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  line-height: 1.8;
}

.badge-row {
  display: grid;
  gap: 6px;
}

.badge-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.badge-value,
.token {
  word-break: break-all;
  font-size: 14px;
  line-height: 1.7;
}

.result-grid {
  margin: 0 0 16px;
  display: grid;
  gap: 14px;
}

.result-grid dt {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.result-grid dd {
  margin: 0;
  font-weight: 700;
  word-break: break-all;
  line-height: 1.6;
}

.file-pick input[type="file"] {
  display: none;
}

.file-list,
.progress-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-item,
.archive-item,
.progress-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.file-item + .file-item,
.progress-item + .progress-item {
  margin-top: 12px;
}

.file-meta {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.file-title {
  font-weight: 700;
  line-height: 1.6;
  word-break: break-word;
}

.file-sub {
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
  line-height: 1.6;
}

.file-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.file-actions .button {
  min-height: 44px;
  font-size: 14px;
}

.archive-grid {
  display: grid;
  gap: 14px;
}

.archive-item {
  overflow: hidden;
}

.archive-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  background: #f3f4f6;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.archive-title {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}

.archive-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
  word-break: break-word;
}

.progress-summary {
  margin: 0 0 12px;
  font-weight: 700;
  line-height: 1.6;
}

.progress-item {
  line-height: 1.7;
}

.progress-item.done {
  border-color: var(--success-line);
  background: var(--success-bg);
}

.progress-item.error {
  border-color: var(--error-line);
  background: var(--error-bg);
}

.hidden {
  display: none !important;
}

@media (min-width: 640px) {
  .container {
    padding-top: 28px;
  }

  .button-row {
    grid-template-columns: 1fr 1fr;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr;
  }

  .archive-grid {
    grid-template-columns: 1fr 1fr;
  }
}
/* ========================================
   Upload UI polish
   styles.css の末尾に追加
======================================== */

.step-indicator {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.step-item {
  padding: 10px 8px;
  border-radius: 12px;
  background: #f3f4f6;
  color: #6b7280;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.step-item.is-active {
  background: #111827;
  color: #ffffff;
}

.info-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.progress-top {
  display: grid;
  gap: 4px;
}

.progress-caption {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: #111827;
  transition: width 0.25s ease;
}

.success-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.success-box .info-title {
  color: #166534;
}

.card h1,
.card h2,
.card p {
  word-break: break-word;
}

.stack-12 {
  display: grid;
  gap: 12px;
}

.stack-16 {
  display: grid;
  gap: 16px;
}

.warning {
  border: 1px solid #fde68a;
  background: #fffbea;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.badge-label {
  min-width: 110px;
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
}

.badge-value {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
}

.badge-value.token {
  word-break: break-all;
}

.file-pick {
  display: inline-block;
}

.file-pick input[type="file"] {
  display: none;
}

.helper {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: #6b7280;
}

.empty-box {
  padding: 18px 16px;
  border: 1px dashed #d1d5db;
  border-radius: 14px;
  background: #fafafa;
  color: #6b7280;
  text-align: center;
}

.file-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
}

.file-meta {
  min-width: 0;
  flex: 1;
}

.file-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  line-height: 1.6;
  word-break: break-word;
}

.file-sub {
  margin-top: 4px;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.6;
  word-break: break-word;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.progress-box {
  padding: 16px;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.progress-summary {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.progress-list {
  margin: 14px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.progress-item {
  color: #374151;
  line-height: 1.6;
  word-break: break-word;
}

.progress-item.done {
  color: #15803d;
  font-weight: 700;
}

.progress-item.error {
  color: #b91c1c;
  font-weight: 700;
}

.message {
  padding: 14px 16px;
  border-radius: 14px;
  line-height: 1.7;
}

.message.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.message.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.hidden {
  display: none !important;
}

/* 既存ボタンが小さく見える場合の補強 */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  box-sizing: border-box;
}

.button.primary {
  background: #111827;
  color: #ffffff;
}

.button.secondary {
  background: #e5e7eb;
  color: #111827;
}

.button.ghost {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .step-indicator {
    grid-template-columns: 1fr 1fr;
  }

  .file-item {
    flex-direction: column;
  }

  .file-actions {
    width: 100%;
  }

  .file-actions .button {
    flex: 1;
  }

  .button-row {
    display: grid;
  }

  .button-row .button,
  .stack-12 .button,
  .stack-16 .button {
    width: 100%;
  }

  .badge-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .badge-label {
    min-width: auto;
  }
}
/* ========================================
   Archive UI polish
   styles.css の末尾に追加
======================================== */

.archive-grid {
  display: grid;
  gap: 14px;
}

.archive-item {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #ffffff;
  padding: 14px;
  overflow: hidden;
}

.archive-thumb-wrap {
  position: relative;
  margin-bottom: 12px;
}

.archive-thumb {
  width: 100%;
  display: block;
  border-radius: 12px;
  background: #f3f4f6;
}

.archive-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.archive-title {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  line-height: 1.6;
}

.archive-sub {
  font-size: 14px;
  color: #4b5563;
  line-height: 1.7;
  word-break: break-word;
}

.badge.latest {
  background: #111827;
  color: #ffffff;
}

.badge.initial {
  background: #e0f2fe;
  color: #075985;
}

.badge.replacement {
  background: #fef3c7;
  color: #92400e;
}

.badge.additional {
  background: #dcfce7;
  color: #166534;
}

.archive-actions {
  margin-top: 12px;
}

.archive-section-empty {
  padding: 14px;
  border: 1px dashed #d1d5db;
  border-radius: 14px;
  color: #6b7280;
  background: #fafafa;
}

@media (min-width: 768px) {
  .archive-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.text-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 16px;
  box-sizing: border-box;
  background: #ffffff;
  color: #111827;
}

.text-input:focus {
  outline: none;
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}
/* ========================================
   Mobile gallery UI
   styles.css の末尾に追加
======================================== */

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.thumb-item {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.thumb-item.is-drag-source {
  opacity: 0.35;
}

.thumb-item.is-drop-target {
  outline: 3px solid rgba(17, 24, 39, 0.18);
  outline-offset: -3px;
}

.thumb-image-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f3f4f6;
}

.thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #f3f4f6;
}

.thumb-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.6;
  background: #f9fafb;
}

.thumb-number {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  min-width: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.88);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.thumb-meta {
  padding: 10px 12px 12px;
}

.thumb-name {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  line-height: 1.5;
  word-break: break-word;
}

.thumb-size {
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  word-break: break-word;
}

.thumb-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.5;
}

.drag-ghost {
  position: fixed;
  z-index: 9999;
  width: 140px;
  pointer-events: none;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  transform: translate(-50%, -50%);
}

.drag-ghost .thumb-image-wrap {
  aspect-ratio: 1 / 1;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.sheet-card {
  width: 100%;
  max-width: 560px;
  border-radius: 20px 20px 0 0;
  background: #ffffff;
  padding: 18px 16px 20px;
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.14);
}

.sheet-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  line-height: 1.6;
  margin-bottom: 14px;
}

.sheet-button-stack {
  display: grid;
  gap: 10px;
}

.button.danger {
  background: #b91c1c;
  color: #ffffff;
  border: 1px solid #b91c1c;
}

body.thumb-dragging {
  overflow: hidden;
}

@media (max-width: 640px) {
  .thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .drag-ghost {
    width: 132px;
  }
}
