:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #15202b;
  --muted: #5b6875;
  --line: #d5dce3;
  --brand: #0f3d5e;
  --brand-text: #ffffff;
  --accent: #1f7a5a;
  --error: #b42318;
  --chip: #e6eef5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1418;
    --card: #162027;
    --text: #e8edf1;
    --muted: #9aa8b4;
    --line: #2b3943;
    --brand: #4b9fd6;
    --brand-text: #06121a;
    --accent: #4cc39a;
    --error: #ff7a6e;
    --chip: #213039;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--brand); color: var(--brand-text);
}
h1 { font-size: 20px; margin: 0; }
.badge { background: #f5b301; color: #1a1300; border-radius: 99px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
main { max-width: 520px; margin: 0 auto; padding: 16px; }

.snap {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  height: 46vh; min-height: 260px;
  border: 2px dashed var(--line); border-radius: 18px; background: var(--card);
  font-size: 22px; font-weight: 600; cursor: pointer;
}
.snap-icon { font-size: 64px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.center { text-align: center; }
.big { font-size: 30px; text-align: center; margin: 32px 0 8px; }

#preview { width: 100%; border-radius: 12px; margin-bottom: 16px; }
#thumb-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
#thumb { width: 120px; border-radius: 8px; border: 1px solid var(--line); }
.small-btn { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--card); font-size: 15px; cursor: pointer; }

fieldset { border: 0; background: var(--card); border-radius: 14px; padding: 12px 14px 14px; margin: 0 0 14px; }
legend { float: left; width: 100%; font-weight: 700; padding: 0; margin-bottom: 4px; }
legend + * { clear: both; }
label { display: block; font-size: 14px; color: var(--muted); margin-top: 10px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
input, select {
  display: block; width: 100%; margin-top: 4px;
  font-size: 17px; padding: 11px 12px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
}
select { appearance: auto; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { background: var(--chip); border-radius: 99px; padding: 3px 10px; font-size: 13px; font-family: ui-monospace, monospace; }

button { font: inherit; cursor: pointer; }
.primary {
  display: block; width: 100%; padding: 15px; margin-top: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  font-size: 18px; font-weight: 700;
}
.primary:disabled { opacity: .6; }
.link { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--brand); text-decoration: underline; }
.note { background: var(--chip); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.error { color: var(--error); font-weight: 600; }
pre { background: var(--card); padding: 12px; border-radius: 10px; font-size: 12px; overflow-x: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.spinner {
  display: inline-block; width: 16px; height: 16px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.home { color: inherit; text-decoration: none; }
.tiles { display: grid; gap: 12px; }
.tile {
  display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
  color: var(--text); text-decoration: none;
}
.tile-icon { grid-row: span 2; font-size: 36px; }
.tile-name { font-weight: 700; font-size: 19px; }
.tile-desc { color: var(--muted); font-size: 14px; }
