:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --ink: #1d2320;
  --muted: #5d6662;
  --line: #d9dcd6;
  --brand: #1f5e3b;
  --brand-ink: #ffffff;
  --accent: #e7f0ea;
  --good: #1e7a3c;
  --good-bg: #e2f3e7;
  --bad: #b3261e;
  --bad-bg: #fbe6e4;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #1b211e;
    --ink: #e8ece9;
    --muted: #a3ada8;
    --line: #2f3833;
    --brand: #5fbf86;
    --brand-ink: #0d1a12;
    --accent: #20302a;
    --good: #6fd394;
    --good-bg: #183324;
    --bad: #ff8a80;
    --bad-bg: #3a1c1a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.brand { color: inherit; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.status { font-variant-numeric: tabular-nums; font-weight: 600; }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px max(24px, env(safe-area-inset-bottom)); }
.screen.center { display: flex; flex-direction: column; align-items: center; padding-top: 25vh; color: var(--muted); }

h1 { font-size: 1.5rem; line-height: 1.25; margin: 8px 0; }
h2 { font-size: 1.1rem; margin: 16px 0 8px; }
.lede { color: var(--muted); margin: 0 0 16px; }

fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font: inherit; cursor: pointer; min-height: 40px;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.combo { position: relative; }
input[type="search"] {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
input[type="search"]:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5;
  list-style: none; margin: 0; padding: 4px 0; max-height: 50vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / .15);
}
.suggest li { padding: 10px 14px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--accent); }
.suggest .type { color: var(--muted); font-size: .85rem; margin-left: 6px; }
.suggest .empty { color: var(--muted); cursor: default; }
.picked { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.optional { color: var(--muted); font-weight: 400; }
.picked-filters:not(:empty) { margin-bottom: 8px; }
.chip.filter { background: var(--accent); border-color: var(--brand); }
.chip.filter::after { content: " ×"; color: var(--muted); }
.suggest .meta { display: block; color: var(--muted); font-size: .85rem; }

button { font: inherit; }
.primary, .secondary {
  display: block; width: 100%; min-height: 48px; border-radius: var(--radius);
  font-weight: 600; cursor: pointer; padding: 12px 16px;
}
.primary { background: var(--brand); color: var(--brand-ink); border: 0; }
.primary:disabled { opacity: .45; cursor: default; }
.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 4px 0; text-decoration: underline; }
.error { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: var(--radius); }

.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand);
  animation: spin 0.9s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.progress-fill { height: 100%; width: 0; background: var(--brand); transition: width .3s; }

/* Photo viewer: the image fits the box; zoom and pan move it with a transform. */
.viewer {
  position: relative; overflow: hidden; touch-action: none; user-select: none;
  height: min(46vh, 520px); margin: 0 -16px; background: #000;
}
@media (min-width: 640px) { .viewer { margin: 0; border-radius: var(--radius); } }
.viewer img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  transform-origin: 0 0; will-change: transform; -webkit-user-drag: none;
}
.viewer.dragging img { cursor: grabbing; }
.viewer-tools { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.tool {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 1.25rem; line-height: 1;
  border: 1px solid rgb(255 255 255 / .45);
}
.tool[aria-expanded="true"] { background: var(--brand); color: var(--brand-ink); }
.hint {
  position: absolute; left: 0; right: 0; bottom: 8px; margin: 0; text-align: center;
  color: #fff; font-size: .8rem; text-shadow: 0 1px 2px #000; pointer-events: none;
  transition: opacity .4s;
}
.hint.gone { opacity: 0; }

.adjust {
  display: grid; grid-template-columns: 1fr; gap: 6px; margin-top: 10px;
  padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.adjust label { display: grid; grid-template-columns: 6.5em 1fr; align-items: center; gap: 8px; font-size: .9rem; }
.adjust input { width: 100%; accent-color: var(--brand); }
.adjust .link { justify-self: end; }

.credit { color: var(--muted); font-size: .75rem; margin: 6px 0 0; }
.prompt { margin-top: 12px; }

.choices { display: grid; gap: 8px; }
.choice {
  position: relative; text-align: left; min-height: 52px; padding: 10px 36px 10px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.cn { font-weight: 600; }
.sci { font-style: italic; font-size: .85rem; opacity: .8; }
.sci.only { font-size: 1rem; opacity: 1; }
.choice:disabled { cursor: default; }
.choice.right { border-color: var(--good); background: var(--good-bg); color: var(--good); font-weight: 600; }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.choice.right::after, .choice.wrong::after { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); }
.choice.right::after { content: "✓"; }
.choice.wrong::after { content: "✗"; }

.feedback { margin-top: 14px; display: grid; gap: 10px; }
.verdict { margin: 0; font-weight: 700; font-size: 1.1rem; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.feedback a { color: var(--brand); }

.actions { display: grid; gap: 10px; margin: 16px 0 24px; }
.review { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.review li {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
}
.review img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--line); }
.review .sp { display: flex; flex-direction: column; text-decoration: none; }
.review a.sp .cn, .review a.sp .sci.only { text-decoration: underline; }
.review .you { color: var(--bad); font-size: .85rem; }
.review .ok { color: var(--good); font-size: .85rem; }
.review a { color: inherit; }

/* Accounts */
.bar { gap: 12px; }
.status { margin-left: auto; }
.account { display: flex; align-items: center; gap: 12px; }
.account a { color: inherit; font-weight: 600; text-decoration: none; }
.bar-button {
  background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 999px;
  padding: 4px 12px; font-weight: 600; cursor: pointer;
}
.note { color: var(--muted); font-size: .9rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .8rem; }
.history { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; }
.history a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; color: var(--ink); text-decoration: none;
}
.history .what { font-weight: 600; }
.history .when { color: var(--muted); font-size: .85rem; }
.history .score { grid-row: span 2; font-weight: 700; font-variant-numeric: tabular-nums; }
.history .score.open { color: var(--muted); font-weight: 600; font-size: .85rem; }
