/* Mobile-first. Single column, large touch targets, nothing that scrolls
   sideways. Light and dark both come from the system preference. */

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --fg: #16181c;
  --muted: #5b6472;
  --line: #dfe3e9;
  --accent: #5b4ce0;
  --accent-fg: #ffffff;
  --good: #1a7f52;
  --good-bg: #eaf7f0;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --warn-bg: #fff6e5;
  --warn-fg: #7a5300;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1c1f25;
    --fg: #e9ecf1;
    --muted: #99a2b0;
    --line: #2c313a;
    --accent: #8f83f5;
    --accent-fg: #14161a;
    --good: #5cd39b;
    --good-bg: #16281f;
    --bad: #ff8a80;
    --bad-bg: #2a1a19;
    --warn-bg: #2b2312;
    --warn-fg: #f0c674;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: max(16px, env(safe-area-inset-top)) 16px
           max(24px, env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 34rem;
  margin: 0 auto;
}

header { margin: 8px 0 20px; }

h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.sub { margin: 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

a { color: var(--accent); }

/* --- state machine: only the active view is shown --------------------- */

[data-view] { display: none; }
body[data-state="loading"] [data-view] { display: none; }
body[data-state="unsupported"] [data-view="unsupported"],
body[data-state="idle"]        [data-view="idle"],
body[data-state="probing"]     [data-view="probing"],
body[data-state="compliant"]   [data-view="compliant"],
body[data-state="plan"]        [data-view="plan"],
body[data-state="converting"]  [data-view="converting"],
body[data-state="done"]        [data-view="done"],
body[data-state="compose"]     [data-view="compose"],
body[data-state="uploading"]   [data-view="uploading"],
body[data-state="posted"]      [data-view="posted"],
body[data-state="error"]       [data-view="error"] { display: block; }

/* --- cards ------------------------------------------------------------ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.card.good { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.card.bad  { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.card.bad h2 { color: var(--bad); }

/* --- dropzone --------------------------------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 44px 20px;
  background: var(--card);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  color: var(--accent);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.dropzone strong { color: var(--fg); font-size: 1.05rem; }
.dropzone:hover,
.dropzone:focus-within,
.dropzone.over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--card));
}

/* --- before / after --------------------------------------------------- */

.compare {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
}

.compare > div {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.compare strong { font-size: 1.35rem; letter-spacing: -0.02em; }
.compare .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.compare .muted { font-size: 0.875rem; }
.arrow { flex: none; color: var(--muted); }

/* --- warnings --------------------------------------------------------- */

.warnings { list-style: none; margin: 0 0 16px; padding: 0; }
.warnings:empty { margin: 0; }
.warnings li {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}
.warnings li + li { margin-top: 8px; }

/* --- progress --------------------------------------------------------- */

.bar {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 10px;
}

.fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .25s ease;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px;
  font-variant-numeric: tabular-nums;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 12px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .fill { transition: none; }
}

/* --- buttons ---------------------------------------------------------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

button, .button {
  flex: 1 1 auto;
  min-height: 48px;              /* comfortable thumb target */
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.primary { background: var(--accent); color: var(--accent-fg); }
.primary:hover { filter: brightness(1.08); }

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--fg);
}
.ghost:hover { background: var(--bg); }
.ghost.quiet { flex: 0 0 auto; color: var(--muted); font-weight: 500; }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- form ------------------------------------------------------------- */

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.875rem;
  font-weight: 600;
}

textarea, input[type="text"], select {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 16px;          /* iOS zooms in on anything smaller */
}

textarea { resize: vertical; }

.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > div { flex: 1 1 12rem; min-width: 0; }

.account {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.account img { width: 24px; height: 24px; border-radius: 50%; }

/* --- misc ------------------------------------------------------------- */

video {
  width: 100%;
  max-height: 60vh;
  margin-top: 12px;
  background: #000;
  border-radius: 10px;
}

pre {
  overflow-x: auto;          /* code scrolls, the page never does */
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.8rem;
}

footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

body.callback {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--muted);
}
