/* app.css — Tier A: mobile-first, tokens, light + dark, inputs ≥ 16px, targets ≥ 44px. */

:root {
  color-scheme: light dark;
  --bg: #f5f4f8;
  --surface: #ffffff;
  --surface-2: #efedf5;
  --text: #1c1a22;
  --text-muted: #6a6676;
  --border: #dcd8e6;
  --primary: #7c4dff;
  --primary-dim: #6a3df0;
  --primary-ink: #ffffff;
  --danger: #d6453d;
  --ok: #2f9e5f;
  --warn: #c98a1a;
  --radius: 14px;
  --radius-sm: 8px;
  --thumb: 72px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181e;
    --surface: #1e222a;
    --surface-2: #262b34;
    --text: #eceef2;
    --text-muted: #9aa1ad;
    --border: #333a46;
    --primary: #9d7bff;
    --primary-dim: #b195ff;
    --primary-ink: #14082b;
    --danger: #ff6b63;
    --ok: #4ccf83;
    --warn: #e6a93a;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 4px 14px rgb(0 0 0 / .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
/* Any author `display` (.btn, .hint, .card-main…) beats the browser's own [hidden] rule; this puts it back on top. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px max(16px, env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 0 10px;
  max-width: 720px;
  margin: 0 auto;
}
.top h1 { font-size: 1.25rem; margin: 0; font-weight: 650; letter-spacing: .01em; flex: 1; }
.logo { display: inline-flex; width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: var(--primary-ink); align-items: center; justify-content: center; flex: none; }
.logo .icon { width: 22px; height: 22px; }

main { max-width: 720px; margin: 0 auto; display: grid; gap: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card h2 { font-size: 1rem; margin: 0 0 12px; font-weight: 650; }
.card-main { display: grid; gap: 10px; }
.muted { color: var(--text-muted); font-size: .85rem; margin: 0 0 8px; }

.icon { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.spin { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* status pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  font-size: .85rem; font-weight: 550;
  background: var(--surface-2); color: var(--text-muted);
  max-width: 45vw; min-height: 32px;
}
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill .icon { width: 18px; height: 18px; }
.pill-on { color: var(--ok); }

/* form */
form { display: grid; gap: 14px; }
label { display: grid; gap: 5px; }
label > span { font-size: .9rem; font-weight: 550; }
label small { color: var(--text-muted); font-size: .8rem; line-height: 1.35; }
input, textarea {
  font: inherit; font-size: 16px;
  min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  width: 100%;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }

.hint { display: flex; gap: 8px; margin: -4px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-muted); font-size: .85rem; }
.hint .icon { color: var(--warn); margin-top: 1px; }
.error { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: .9rem; overflow-wrap: anywhere; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; min-width: 44px; padding: 10px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; font-size: 16px;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-dim); border-color: var(--primary-dim); filter: none; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-icon { padding: 10px; }
form .btn-primary { width: 100%; }

/* THE button */
.btn-big {
  width: 100%; min-height: 76px; padding: 14px 20px; gap: 14px;
  border-radius: var(--radius);
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink);
  font-size: 1.35rem; font-weight: 700; letter-spacing: .01em;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 35%, transparent);
  justify-content: flex-start;
}
.btn-big:hover { background: var(--primary-dim); border-color: var(--primary-dim); filter: none; }
.btn-big:disabled { box-shadow: none; }
.btn-big-icon { display: inline-flex; width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--primary-ink) 18%, transparent); align-items: center; justify-content: center; flex: none; }
.btn-big-icon .icon { width: 28px; height: 28px; }
.btn-big-text { display: grid; text-align: left; gap: 2px; min-width: 0; }
.btn-big-text small { font-size: .85rem; font-weight: 500; opacity: .85; }

.run-row { display: flex; align-items: center; gap: 8px; }
.totals { flex: 1; margin: 0; color: var(--text-muted); font-size: .9rem; min-height: 1.4em; overflow-wrap: anywhere; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .25s ease; }

/* sections */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.section-head h2 { margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px; cursor: pointer; font-size: .9rem; font-weight: 550; color: var(--text); user-select: none; }
.check input { width: 22px; height: 22px; min-height: 0; padding: 0; margin: 0; accent-color: var(--primary); cursor: pointer; }

/* file list */
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.file { display: flex; gap: 12px; padding: 8px 6px; border-radius: var(--radius-sm); align-items: flex-start; }
.file:nth-child(odd) { background: var(--surface-2); }
/* The thumbnail is a button that opens the file. It is --thumb tall; its width follows the picture
   (a portrait shot is narrow, a 16:9 frame wide), capped so the text keeps its room. Without a
   picture yet it is a square with the type icon. */
.thumb {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--thumb); height: var(--thumb); max-width: calc(var(--thumb) * 1.78); border-radius: 8px; overflow: hidden;
  background: color-mix(in srgb, var(--text-muted) 14%, transparent); color: var(--text-muted);
  border: 0; padding: 0; margin: 0; font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.thumb:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.thumb.has-img { width: auto; min-width: 44px; }
.thumb img { height: 100%; width: auto; max-width: 100%; object-fit: contain; display: block; }
.thumb .icon { width: 28px; height: 28px; }
.file-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.file-name { font-weight: 550; font-size: .95rem; overflow-wrap: anywhere; }
.file-meta, .file-out { font-size: .8rem; color: var(--text-muted); overflow-wrap: anywhere; }
.file-turn { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--primary); font-weight: 550; }
.file-turn .icon { width: 16px; height: 16px; }
.file-out:empty, .file-state:empty, .file-turn:empty { display: none; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text); vertical-align: 1px; }
.file-state { display: inline-flex; align-items: flex-start; gap: 6px; font-size: .8rem; color: var(--text-muted); overflow-wrap: anywhere; margin-top: 2px; }
.file-state .icon { width: 16px; height: 16px; margin-top: 1px; }
.row-check { flex: none; align-self: center; padding: 0 2px; }
.row-check span { font-size: .8rem; }
.file-again { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: -2px; }
.file-done .file-state { color: var(--ok); }
.file-error .file-state { color: var(--danger); }
.file-skipped { opacity: .65; }
.file-downloading .file-state, .file-converting .file-state, .file-uploading .file-state { color: var(--primary); }

/* fine print */
.fine ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; color: var(--text-muted); font-size: .9rem; }
.fine li { display: flex; gap: 10px; align-items: flex-start; }
.fine .icon { color: var(--primary); margin-top: 2px; }

/* the viewer */
.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #000; color: #eceef2;
  display: none; flex-direction: column;
}
.viewer[open] { display: flex; }
.viewer::backdrop { background: rgb(0 0 0 / .85); }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.viewer-media { display: block; width: auto; height: auto; transition: transform .2s ease; }
@media (prefers-reduced-motion: reduce) { .viewer-media { transition: none; } }
.viewer-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 16px; max-width: 32em; color: #9aa1ad; font-size: .9rem; }
.viewer-note .icon { flex: none; margin-top: 1px; }
.viewer-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: #15181e; border-top: 1px solid #333a46;
}
.viewer-info { flex: 1 1 220px; display: grid; gap: 2px; min-width: 0; }
.viewer-name { font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; }
.viewer-meta { font-size: .8rem; color: #9aa1ad; overflow-wrap: anywhere; }
.viewer-turn { font-size: .8rem; color: #b195ff; font-weight: 550; }
.viewer-actions { display: flex; gap: 8px; flex: none; margin-left: auto; }
.viewer .btn { background: #262b34; border-color: #333a46; color: #eceef2; }
.viewer .btn-primary { background: #9d7bff; border-color: #9d7bff; color: #14082b; }
.viewer .btn-ghost { background: transparent; border-color: transparent; color: #9aa1ad; }

@media (min-width: 600px) {
  :root { --thumb: 88px; }
  body { padding-left: 24px; padding-right: 24px; }
  .card { padding: 20px; }
}
