:root {
  --bg: #edf0ee;
  --ink: #141b19;
  --muted: #5e6b66;
  --soft: #e0e6e3;
  --soft-2: #d0d9d5;
  --accent: #1d6b58;
  --on-accent: #f4fbf8;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --ink: #e9efec;
    --muted: #92a09a;
    --soft: #18211e;
    --soft-2: #26322e;
    --accent: #5cc4a8;
    --on-accent: #06241c;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { font-family: var(--font-display); margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1:focus, h2:focus { outline: none; }

.app {
  min-height: 100vh;
  min-height: 100svh;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.top { padding: 4px 0 14px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none;
  font: 700 18px var(--font-display); letter-spacing: -0.01em; }
.mark { width: 26px; height: 26px; color: var(--accent); }

#stage { flex: 1; display: flex; flex-direction: column; }
.view { flex: 1; display: flex; flex-direction: column; gap: 22px; animation: enter 0.45s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }

/* Upload area */
.drop {
  flex: 1;
  min-height: 300px;
  width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 24px;
  border: 0;
  border-radius: 44px;
  background: var(--soft);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  transition: background 0.25s, transform 0.25s var(--ease);
}
.drop:active { transform: scale(0.985); }
.drop.is-over { background: var(--soft-2); transform: scale(1.01); }
@media (hover: hover) { .drop:hover { background: var(--soft-2); } }
.rings { width: min(58vw, 230px); height: auto; margin-bottom: 18px; overflow: visible; }
.ring-outer { transform-origin: 100px 100px; animation: spin 80s linear infinite; opacity: 0.55; }
.ring-mid { transform-origin: 100px 100px; animation: breathe 4.6s ease-in-out infinite; opacity: 0.4; }
.core { fill: var(--accent); transform-origin: 100px 100px; transition: transform 0.25s var(--ease); }
.core-arrow { stroke: var(--on-accent); }
.drop:active .core { transform: scale(0.92); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.4; } 50% { transform: scale(1.07); opacity: 0.2; } }
.drop-title { font: 700 22px var(--font-display); color: var(--ink); letter-spacing: -0.01em; }
.drop-sub { font-size: 16px; color: var(--muted); }

/* Working */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.progress { width: 132px; height: 132px; margin-bottom: 14px; transform: rotate(-90deg); }
.progress-track { stroke: var(--soft-2); }
.progress-bar { stroke: var(--accent); stroke-dasharray: 326.73; stroke-dashoffset: 326.73; transition: stroke-dashoffset 0.25s linear; }
.center h2 { font-size: 26px; font-weight: 700; }
.center p { color: var(--muted); }

/* Result */
.preview { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  background: var(--soft); border-radius: 32px; overflow: hidden; }
.preview video { display: block; width: 100%; max-height: 58vh; max-height: 58svh; object-fit: contain; background: transparent; }
.meta { text-align: center; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; margin-top: -6px; display: flex; flex-direction: column; gap: 2px; }
.fname { color: var(--ink); font-weight: 600; word-break: break-all; }
.detail { font-size: 13px !important; opacity: 0.8; word-break: break-word; }
.detail:empty { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.actions { display: flex; flex-direction: column; gap: 6px; }
.hint { text-align: center; color: var(--muted); font-size: 14px; min-height: 0; }
.hint:empty { display: none; }

/* Problem */
.problem { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 0 4px; }
.problem h2 { font-size: clamp(26px, 7.6vw, 34px); line-height: 1.1; font-weight: 700; text-wrap: balance; }
.problem p { color: var(--muted); font-size: 18px; }
.steps { list-style: none; margin: 14px 0 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 14px; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 14px; font-size: 18px; }
.steps li::before { content: counter(step); flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--soft); color: var(--accent); font: 700 16px var(--font-display); }

/* Buttons */
.btn { width: 100%; height: 58px; border: 0; border-radius: 22px; background: var(--accent); color: var(--on-accent);
  font: 650 18px var(--font-body); cursor: pointer; transition: transform 0.2s var(--ease), filter 0.2s; }
.btn:active { transform: scale(0.98); }
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } }
.btn-quiet { height: 50px; background: transparent; color: var(--muted); font-weight: 600; }

/* Footer: privacy */
.foot { padding-top: 14px; display: flex; flex-direction: column; gap: 2px; }

.privacy summary { list-style: none; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 4px; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; }
.privacy summary::-webkit-details-marker { display: none; }
.privacy summary svg { width: 16px; height: 16px; color: var(--accent); }
.privacy p { color: var(--muted); font-size: 14px; text-align: center; padding: 0 6px 10px; animation: enter 0.3s var(--ease) both; }

.sink { position: fixed; left: 0; top: 0; width: 16px; height: 16px; opacity: 0.01; pointer-events: none; overflow: hidden; }
.sink video { width: 16px; height: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Diagnostics page */
.probe { max-width: 640px; margin: 0 auto; padding: 24px 20px 48px; display: flex; flex-direction: column; gap: 18px; }
.probe h1 { font-size: 28px; }
.probe h2 { font-size: 18px; margin-top: 8px; }
.probe p { color: var(--muted); font-size: 15px; }
.probe .btn { width: auto; padding: 0 22px; align-self: flex-start; height: 48px; font-size: 16px; }
.probe table { width: 100%; border-collapse: collapse; font-size: 14px; }
.probe td { padding: 7px 0; vertical-align: top; border-bottom: 1px solid var(--soft-2); }
.probe td:first-child { color: var(--muted); width: 42%; padding-right: 10px; }
.probe td { word-break: break-word; }
.probe .ok { color: var(--accent); font-weight: 600; }
.probe .no { color: #c0392b; font-weight: 600; }
.probe pre { white-space: pre-wrap; background: var(--soft); border-radius: 16px; padding: 14px; font-size: 12px; margin: 0; }
.probe video { width: 100%; border-radius: 16px; background: var(--soft); }
