/* Layout: one phone-width column, big tap targets, primary action docked at the bottom edge. */
:root {
  --bg: #eef1f5; --surface: #ffffff; --ink: #18222f; --muted: #5a6778; --line: #d3dae3;
  --denim: #2b4f81; --denim-ink: #ffffff; --stitch: #c9761a; --good: #23704a; --bad: #a3412f;
  --font: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111821; --surface: #1a2430; --ink: #e6ecf3; --muted: #9aa8b9; --line: #2e3b4b;
    --denim: #8fb4e6; --denim-ink: #0f1722; --stitch: #e6a04a; --good: #6fcf9b; --bad: #f0907c; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font);
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.wrap { max-width: 560px; margin: 0 auto; padding-block: 16px 24px; }
section { display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 1.4rem; line-height: 1.2; margin: 0; font-weight: 650; }
p { margin: 0; }
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.step { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .9rem; }
.stack { display: flex; flex-direction: column; gap: 14px; } .stack-s { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

fieldset { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; margin: 0; padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
legend { font-weight: 650; padding: 0 6px; margin-left: -6px; }
label { font-size: .95rem; color: var(--muted); margin-top: 4px; }
.hint { font-size: .82rem; color: var(--stitch); margin-left: 4px; }
.sub { font-size: .95rem; color: var(--muted); margin-top: 6px; }
input[type="text"], input[type="password"], select, textarea {
  font: inherit; font-size: 16px; /* 16px stops iPhone zooming in on focus */
  width: 100%; min-width: 0; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; -webkit-appearance: none; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
textarea { line-height: 1.4; resize: vertical; min-height: 320px; background: var(--surface); }
input::placeholder { color: var(--muted); opacity: .7; }
:focus-visible { outline: 3px solid var(--stitch); outline-offset: 2px; }

button { font: inherit; font-weight: 600; min-height: 48px; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.primary { background: var(--denim); border-color: var(--denim); color: var(--denim-ink); width: 100%; }
button.ghost { background: transparent; }
button.link { min-height: 0; padding: 4px 0; border: 0; background: none; color: var(--denim); text-decoration: underline; font-weight: 500; text-align: left; }
button:disabled { opacity: .45; cursor: default; }

.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1rem; min-height: 40px; margin: 0; }
.check.big { font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--denim); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 8px 14px; border-radius: 20px; font-weight: 500; background: var(--bg); }
.chip[aria-pressed="true"] { background: var(--denim); border-color: var(--denim); color: var(--denim-ink); }
.chip.off { text-decoration: line-through; color: var(--muted); }
.suggest { display: flex; flex-direction: column; gap: 6px; }
.suggest button { text-align: left; font-weight: 500; border-style: dashed; }

.meas { display: grid; grid-template-columns: auto minmax(70px, 1fr) minmax(90px, 1.3fr); gap: 8px; align-items: center; }
.meas label { margin: 0; color: var(--ink); white-space: nowrap; }
.meas.free { grid-template-columns: 1fr; }
.flaw { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.flaw select { grid-column: 1; }
.flaw .remove { grid-column: 2; grid-row: 1 / span 2; align-self: start; }

.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .n { position: absolute; left: 4px; top: 4px; background: var(--ink); color: var(--bg); font-size: .75rem; font-weight: 700; border-radius: 10px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px; }
.thumb button { position: absolute; right: 2px; top: 2px; min-height: 0; width: 30px; height: 30px; padding: 0; border-radius: 15px; line-height: 1; background: var(--surface); }
.filebtn { display: grid; place-items: center; min-height: 64px; border: 2px dashed var(--line); border-radius: 12px; color: var(--denim); font-weight: 650; font-size: 1.05rem; cursor: pointer; position: relative; margin: 0; }
.filebtn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.filebtn:focus-within { outline: 3px solid var(--stitch); outline-offset: 2px; }

.dock { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--bg) 78%, transparent); margin-top: 4px; }
.dock.two { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.meta { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.warn { color: var(--bad); text-align: right; }
.error { color: var(--bad); font-weight: 500; } .ok { color: var(--good); font-weight: 600; }
.resume { font-size: .95rem; color: var(--muted); }

.busy { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); display: grid; place-content: center; justify-items: center; gap: 14px; z-index: 5; font-weight: 600; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--denim); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* admin page */
.admin { max-width: 900px; }
.admin h2 { font-size: 1.1rem; margin: 18px 0 0; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.pair { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 700px) { .pair { grid-template-columns: 1fr 1fr; } }
pre { font: .88rem/1.4 var(--font); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 0; min-width: 0; }
details { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 8px 12px; }
summary { cursor: pointer; font-weight: 600; }
.admin textarea { min-height: 260px; font-size: 14px; font-family: ui-monospace, Menlo, monospace; }
