:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --ink: #1b1f1c;
  --muted: #667069;
  --line: #e3e7e3;
  --brand: #1e8e3e;
  --excellent: #1e8e3e;
  --good: #7cb342;
  --poor: #f08c00;
  --bad: #e03131;
  --risk0: #2f9e44;
  --risk1: #fab005;
  --risk2: #f76707;
  --risk3: #e03131;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121513;
    --card: #1c201d;
    --ink: #eef1ee;
    --muted: #9aa49c;
    --line: #2c322e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121513; --card: #1c201d; --ink: #eef1ee; --muted: #9aa49c; --line: #2c322e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  min-height: 100vh;
}
.top {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 6px;
}
.top h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.logo { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--excellent) 0 50%, var(--good) 0 70%, var(--poor) 0 85%, var(--bad) 0); }
main { max-width: 520px; margin: 0 auto; padding: 8px 16px 32px; }
.view { display: flex; flex-direction: column; gap: 14px; }
[hidden] { display: none !important; }

.shoot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--brand); color: #fff; border-radius: 28px;
  min-height: 210px; font-size: 21px; font-weight: 600; cursor: pointer;
  box-shadow: 0 10px 30px -12px rgba(30, 142, 62, .6);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.shoot:active { transform: scale(.985); }
.shoot.secondary { min-height: 64px; flex-direction: row; font-size: 17px; background: var(--card); color: var(--brand); border: 2px dashed var(--brand); box-shadow: none; }
.shoot.secondary .shoot-icon svg { width: 24px; height: 24px; }
.lib-link {
  align-self: center; color: var(--brand); font-size: 15px; font-weight: 600;
  padding: 4px 12px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.hint { color: var(--muted); margin: 0; font-size: 14px; text-align: center; }

.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.thumb { position: relative; aspect-ratio: 3/4; border-radius: 12px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 28px; padding: 0;
}

button.primary {
  appearance: none; border: 0; border-radius: 14px; padding: 16px 18px;
  background: var(--ink); color: var(--bg); font-size: 17px; font-weight: 600; width: 100%;
}
button.primary:disabled { opacity: .5; }

.history h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 10px 0 4px; }
.history ul { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.history li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.history li:first-child { border-top: 0; }
.history .h-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history .h-date { color: var(--muted); font-size: 13px; }

.pill { min-width: 42px; text-align: center; padding: 3px 8px; border-radius: 999px; color: #fff; font-weight: 700; font-size: 14px; }
.bg-excellent { background: var(--excellent); } .bg-good { background: var(--good); }
.bg-poor { background: var(--poor); } .bg-bad { background: var(--bad); }

.spinner {
  width: 54px; height: 54px; margin: 80px auto 0; border-radius: 50%;
  border: 5px solid var(--line); border-top-color: var(--brand); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { text-align: center; color: var(--muted); }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; }
.hero { display: flex; gap: 16px; align-items: center; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .val b { font-size: 32px; line-height: 1; }
.ring .val small { color: var(--muted); font-size: 12px; }
.ptype { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
.warn { margin: 0; padding-left: 18px; font-size: 15px; }
.warn li { margin: 4px 0; }
.hero h2 { margin: 0 0 2px; font-size: 19px; line-height: 1.25; }
.hero .brand { color: var(--muted); font-size: 14px; }
.hero .verdict { font-weight: 700; font-size: 18px; margin-top: 6px; }
.c-excellent { color: var(--excellent); } .c-good { color: var(--good); }
.c-poor { color: var(--poor); } .c-bad { color: var(--bad); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--ink); margin-top: 6px; }

.parts { display: grid; gap: 10px; }
.part-row { display: grid; grid-template-columns: 96px 1fr 46px; gap: 10px; align-items: center; font-size: 14px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.part-row span:last-child { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.card h3 { margin: 0 0 10px; font-size: 16px; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--bg); font-size: 14px; }
.chip { min-width: 0; }
.chip b { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.low { background: var(--risk0); } .dot.mid { background: var(--risk1); } .dot.high { background: var(--risk3); }
.dot.r0 { background: var(--risk0); } .dot.r1 { background: var(--risk1); }
.dot.r2 { background: var(--risk2); } .dot.r3 { background: var(--risk3); }

.adds { list-style: none; padding: 0; margin: 0; }
.adds li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.adds li:first-child { border-top: 0; }
.adds .code { color: var(--muted); font-size: 13px; margin-left: auto; text-align: right; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
details summary { cursor: pointer; font-weight: 600; }
details p { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.sources { font-size: 12px; color: var(--muted); text-align: center; margin: 0; }

form { display: flex; flex-direction: column; gap: 10px; }
input[type="password"] {
  font-size: 18px; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
}
.error { background: #ffe3e3; color: #a51111; padding: 12px 14px; border-radius: 12px; font-size: 15px; }
