:root {
  --bg: #f4f5f7; --card: #fff; --ink: #14213d; --muted: #5b6475; --line: #d9dde5;
  --brand: #14213d; --accent: #fca311; --ok: #1e7a3c; --warn: #9a5b00; --bad: #b42318;
  --radius: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1220; --card: #181d2e; --ink: #eef1f7; --muted: #a3abbd; --line: #2b3247; --ok: #5ed38a; --warn: #f5b84a; --bad: #ff7b6e; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body.noscroll { overflow: hidden; }
.wrap { max-width: 720px; margin: 0 auto; padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { border: 0; border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; background: #e7e9ee; color: #14213d; }
.chip.ok { background: #d5f2df; color: #0d4d24; }
.chip.warn { background: #ffe8bf; color: #6b3d00; }
.chip.bad { background: #ffd7d2; color: #7a1308; }
.chip.busy { background: #dbe7ff; color: #12306b; }
.tabs { position: sticky; top: calc(48px + env(safe-area-inset-top)); z-index: 4; display: flex; background: var(--card); border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; color: var(--muted); padding: 12px 4px; font: inherit; font-weight: 600; min-height: 48px; border-bottom: 3px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.card > summary { cursor: pointer; min-height: 32px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 0 0 8px; word-break: break-word; }
h3 { font-size: 15px; margin: 14px 0 6px; }
.field { display: grid; gap: 4px; margin: 10px 0; font-weight: 600; font-size: 14px; }
input, textarea, select { font: inherit; font-weight: 400; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); min-height: 48px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
button { font: inherit; cursor: pointer; }
.primary, .secondary, .ghost, .danger, .tool { min-height: 48px; padding: 10px 16px; border-radius: 10px; font-weight: 600; border: 1px solid transparent; }
.primary { background: var(--accent); color: #14213d; }
.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.ghost { background: none; color: var(--ink); border-color: var(--line); }
.danger { background: none; color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 8px; }
.hint, .muted { color: var(--muted); font-size: 14px; margin: 6px 0; }
.status { display: block; font-size: 14px; font-weight: 600; margin: 4px 0; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }
.status small { font-weight: 400; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); padding: 8px 0; word-break: break-word; }
.list li:first-child { border-top: 0; }
.row-btn { display: grid; gap: 2px; width: 100%; text-align: left; background: none; border: 0; padding: 6px 0; color: var(--ink); min-height: 48px; }
.row-btn small { color: var(--muted); }
.photo { display: grid; grid-template-columns: 112px 1fr; gap: 12px; border-top: 1px solid var(--line); padding: 12px 0; }
.thumb { width: 112px; height: 112px; object-fit: cover; border-radius: 10px; background: var(--bg); }
.photo-body { display: grid; gap: 4px; min-width: 0; }
.photo-body .name { color: var(--muted); word-break: break-all; }
.marks { margin: 0; padding-left: 20px; font-size: 14px; }
.marks li.warn { color: var(--warn); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: 22px; height: 22px; min-height: 0; }
.explain { min-height: 280px; font-size: 15px; }
.blockers ul { margin: 0; padding-left: 20px; color: var(--warn); font-size: 14px; }
.history { list-style: none; padding: 0; font-size: 14px; }
.history small { color: var(--muted); }
.extras summary { font-weight: 600; margin-top: 8px; }
.guide summary small { color: var(--muted); }
.checklist { list-style: none; padding: 0; }
.quiz { display: grid; gap: 8px; }
.quiz .right { border-color: var(--ok); color: var(--ok); }
.quiz .wrong { border-color: var(--bad); color: var(--bad); }
.login { margin-top: 15vh; }
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 50; background: #14213d; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.3); }

/* Annotator */
.ann { position: fixed; inset: 0; z-index: 20; background: #0b0d14; color: #fff; display: flex; flex-direction: column; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
.ann-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
.ann-head .ghost { color: #fff; border-color: #444; }
.ann-stage { display: flex; justify-content: center; padding: 0 8px; }
.ann-canvas { touch-action: none; border-radius: 8px; max-width: 100%; }
.ann-tools { display: flex; gap: 6px; padding: 10px 12px 0; }
.ann-tools .tool { flex: 1; background: #1d2233; color: #fff; border-color: #333a50; padding: 10px 4px; }
.ann-tools .tool[aria-pressed="true"] { background: var(--accent); color: #14213d; }
.ann .hint { color: #b9c0d0; padding: 0 12px; }
.ann-list { list-style: none; padding: 0 12px; margin: 0; }
.mark-row { display: grid; width: 100%; text-align: left; background: #1d2233; color: #fff; border: 1px solid #333a50; border-radius: 10px; padding: 10px; margin: 6px 0; min-height: 48px; }
.mark-row.warn { border-color: #f5b84a; }
.mark-row small { color: #b9c0d0; }
.backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet { background: var(--card); color: var(--ink); width: 100%; max-height: 90vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet .hint { color: var(--muted); padding: 0; }

/* Customer view */
.customer-view { background: #fff; color: #14213d; margin: 0 -16px; padding: 16px; min-height: 100vh; }
.customer-view figure { margin: 12px 0; }
.customer-view img { width: 100%; border-radius: 10px; }
.customer-view figcaption { font-size: 14px; color: #5b6475; }
.customer-view .ghost { color: #14213d; border-color: #d9dde5; }
.explain-out p { margin: 6px 0; }
@media (min-width: 560px) { .photo { grid-template-columns: 160px 1fr; } .thumb { width: 160px; height: 160px; } }
