:root {
  color-scheme: light;
  --bg: #f4f5f7; --card: #ffffff; --ink: #111418; --muted: #5d6470; --line: #e2e5ea;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #e1f3f1;
  --chip: #ffffff; --chip-on: #0f766e; --chip-on-ink: #ffffff;
  --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --good: #15803d; --good-soft: #dcfce7;
  --A: #15803d; --B: #b45309; --C: #6b7280;
  --input-bg: #ffffff; --input-ink: #111418;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e1114; --card: #171b20; --ink: #eef1f4; --muted: #9aa3ae; --line: #2a3038;
    --brand: #2bb3a6; --brand-ink: #04211e; --brand-soft: #123532;
    --chip: #1d2228; --chip-on: #2bb3a6; --chip-on-ink: #04211e;
    --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3b1414; --good: #4ade80; --good-soft: #0f2e1a;
    --A: #4ade80; --B: #fbbf24; --C: #9aa3ae;
    --input-bg: #0e1114; --input-ink: #eef1f4;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Noto Sans SC", sans-serif; -webkit-text-size-adjust: 100%; }
#app { max-width: 720px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
p { margin: 6px 0; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
[hidden] { display: none !important; }

header.top { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 0 10px; }
header.top .who { font-size: 13px; color: var(--muted); max-width: 35%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.top h1 { font-size: 20px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bar.block { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; box-shadow: var(--shadow); }
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600; min-height: 48px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); }
.btn.big { width: 100%; font-size: 19px; min-height: 64px; border-radius: 16px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.wa { background: #25d366; border-color: #25d366; color: #062b14; }

input, textarea, select {
  font: inherit; width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 46px;
  background: var(--input-bg); color: var(--input-ink); color-scheme: inherit;
}
textarea { min-height: 84px; resize: vertical; }
label.f { display: block; margin: 8px 0 4px; font-size: 13px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { appearance: none; border: 1px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 999px; padding: 9px 14px; font: inherit; font-size: 15px; min-height: 42px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-ink); font-weight: 600; }
.group { margin: 14px 0; }
.group .lbl { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }

.bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-size: 14px; margin: 8px 0; }
.bar.ok { background: var(--good-soft); color: var(--good); }
.bar.warn { background: var(--warn-soft); color: var(--warn); }
.bar.bad { background: var(--bad-soft); color: var(--bad); }

.list .item { display: flex; gap: 12px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; text-decoration: none; color: inherit; }
.list .item:last-child { border-bottom: 0; }
.grade { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--C); }
.grade.A { background: var(--A); } .grade.B { background: var(--B); } .grade.C { background: var(--C); }
.grade.none { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin: 2px 4px 2px 0; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photos img { width: 140px; height: 105px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.shot { display: flex; gap: 10px; align-items: center; }
.shot img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
a.stat { text-decoration: none; color: inherit; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 12px; color: var(--muted); }
.hbar { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 4px 0; }
.hbar .t { width: 140px; flex: 0 0 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .b { height: 10px; border-radius: 5px; background: var(--brand); }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
nav.tabs a { flex: 1; max-width: 180px; text-align: center; padding: 10px 4px 12px; font-size: 13px; color: var(--muted); text-decoration: none; font-weight: 600; }
nav.tabs a.on { color: var(--brand); }
nav.tabs a .i { display: block; font-size: 20px; line-height: 1.2; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; background: var(--card); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.savebar .in { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; }

.sheet { position: fixed; inset: 0; z-index: 20; background: var(--card); overflow: auto; padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet .lang { font-size: 18px; line-height: 1.5; margin: 0 0 18px; }
.sheet .lang b { display: block; font-size: 12px; color: var(--muted); letter-spacing: .05em; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 30; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.2); }

.ev { font-size: 13px; border-left: 3px solid var(--line); padding: 4px 10px; margin: 6px 0; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 15px; }
.kv div:nth-child(odd) { color: var(--muted); font-size: 13px; padding-top: 2px; }
.rec { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.center { text-align: center; }
.code { font: 600 22px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; }
table.st { width: 100%; border-collapse: collapse; font-size: 15px; }
table.st td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
