:root {
  --ink: #14232b;
  --muted: #66757d;
  --faint: #94a1a7;
  --line: #dce5e8;
  --paper: #f5f7f8;
  --card: #ffffff;
  --teal: #137f78;
  --teal-deep: #0a5d59;
  --teal-pale: #dff2ee;
  --green: #16845f;
  --green-pale: #dff5ea;
  --orange: #d66d13;
  --orange-pale: #fff0d9;
  --hot: #ec2e5b;
  --hot-pale: #ffe4ec;
  --overload: #ff174f;
  --overload-pale: #ffd4e0;
  --shadow: 0 16px 45px rgba(20, 35, 43, .07);
}

:root[data-theme="dark"] {
  --ink: #eff7f7;
  --muted: #a6b8ba;
  --faint: #84999d;
  --line: #30484b;
  --paper: #0d1719;
  --card: #152326;
  --teal: #63c9bd;
  --teal-deep: #7fe0d4;
  --teal-pale: #143d3b;
  --green: #46d69d;
  --green-pale: #123d31;
  --orange: #ffac55;
  --orange-pale: #4a2e16;
  --hot: #ff668a;
  --hot-pale: #4d1e2c;
  --overload: #ff3d68;
  --overload-pale: #571226;
  --shadow: 0 18px 48px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.shell { width: min(100% - 24px, 480px); margin: 0 auto; padding: 18px 0 32px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 44px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.18rem; font-weight: 800; text-decoration: none; letter-spacing: -.035em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; color: white; background: var(--teal); border-radius: 9px; font-size: 1rem; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.beta-tag, .theme-toggle { min-height: 29px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: transparent; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.theme-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font: inherit; letter-spacing: .04em; }
.theme-toggle:hover { color: var(--ink); border-color: var(--teal); }
.theme-toggle input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.theme-switch { position: relative; display: inline-flex; align-items: center; width: 27px; height: 15px; padding: 2px; border-radius: 999px; background: #9caaad; transition: background .2s ease; }
.theme-switch span { display: block; width: 11px; height: 11px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: transform .2s ease; }
.theme-toggle input:checked + .theme-switch { background: var(--teal); }
.theme-toggle input:checked + .theme-switch span { transform: translateX(12px); }
.theme-toggle:focus-within { outline: 3px solid #f2b85f; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.quick-view { margin-bottom: 18px; }
.eyebrow, .card-kicker { margin: 0 0 8px; color: var(--teal); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 22px; font-size: clamp(2rem, 8vw, 3.15rem); line-height: .98; letter-spacing: -.065em; }
.quick-list { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.quick-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 2px; }
.quick-row + .quick-row { border-top: 1px solid var(--line); }
.quick-name, .quick-direction { display: block; }
.quick-name { font-size: 1.1rem; letter-spacing: -.035em; }
.quick-direction { margin-top: 4px; color: var(--muted); font-size: .74rem; }
.quick-result { display: flex; align-items: center; justify-content: flex-end; gap: 9px; text-align: right; }
.quick-dot { width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px var(--orange-pale); }
.quick-dot.green { background: var(--green); box-shadow: 0 0 0 4px var(--green-pale); }
.quick-dot.orange { background: var(--orange); box-shadow: 0 0 0 4px var(--orange-pale); }
.quick-dot.hot { background: var(--hot); box-shadow: 0 0 0 4px var(--hot-pale); }
.quick-dot.overload { background: var(--overload); box-shadow: 0 0 0 4px var(--overload-pale); animation: overload-pulse 1.1s ease-in-out infinite; }
.quick-state { color: var(--orange); font-size: .82rem; }
.quick-state.green { color: var(--green); }
.quick-state.orange { color: var(--orange); }
.quick-state.hot, .quick-state.overload { color: var(--hot); }
.quick-row.overload { margin: 0 -8px; padding-left: 10px; padding-right: 10px; border-radius: 12px; background: linear-gradient(90deg, transparent, var(--overload-pale), transparent); }
.quick-updated { margin: 12px 0 0; color: var(--faint); font-size: .7rem; }
.advanced-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; padding: 0 2px 0 4px; color: var(--teal-deep); border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; font: inherit; font-size: .82rem; font-weight: 800; text-align: left; }
.advanced-toggle:hover { color: var(--ink); }
.advanced-toggle:focus-visible { outline: 3px solid #f2b85f; outline-offset: 3px; }
.toggle-mark { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid #b9d8d4; border-radius: 50%; font-size: 1.1rem; font-weight: 500; }
.advanced-panel { margin-top: 28px; }
.advanced-heading { margin-bottom: 16px; }
.advanced-heading h2 { margin-bottom: 0; font-size: 1.45rem; letter-spacing: -.045em; }

.check-card { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; padding: 25px; border: 1px solid #c9e2dc; border-radius: 22px; background: var(--teal-pale); box-shadow: var(--shadow); }
.check-card h2 { margin-bottom: 6px; font-size: clamp(1.5rem, 4vw, 2.15rem); letter-spacing: -.045em; }
.check-summary { max-width: 530px; margin-bottom: 0; color: #37625f; line-height: 1.48; }
.check-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; padding: 0 18px; color: #fff; border: 0; border-radius: 13px; background: var(--teal-deep); box-shadow: 0 7px 16px rgba(10, 93, 89, .18); cursor: pointer; font: inherit; font-size: .9rem; font-weight: 800; white-space: nowrap; }
.check-button:hover { background: #084b48; }
.check-button:focus-visible, a:focus-visible { outline: 3px solid #f2b85f; outline-offset: 3px; }
.button-icon { font-size: 1.18rem; line-height: 1; }
.checked-line { grid-column: 1 / -1; margin: -4px 0 0; color: #557c79; font-size: .75rem; }

.lane-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
.lane-card, .signal-card, .how-card { border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.lane-card.overload { border-color: var(--overload); box-shadow: 0 0 0 3px var(--overload-pale), 0 16px 45px rgba(255, 23, 79, .2); animation: overload-pulse 1.1s ease-in-out infinite; }
.lane-card { padding: 22px; }
.lane-card-head, .section-heading, .lane-card-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.lane-card h2, .signal-card h2, .how-card h2 { margin-bottom: 0; font-size: 1.36rem; letter-spacing: -.04em; }
.state-dot { width: 12px; height: 12px; flex: 0 0 auto; margin-top: 4px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 5px var(--orange-pale); }
.state-dot.green { background: var(--green); box-shadow: 0 0 0 5px var(--green-pale); }
.state-dot.orange { background: var(--orange); box-shadow: 0 0 0 5px var(--orange-pale); }
.state-dot.hot { background: var(--hot); box-shadow: 0 0 0 5px var(--hot-pale); }
.state-dot.overload { background: var(--overload); box-shadow: 0 0 0 5px var(--overload-pale); animation: overload-pulse 1.1s ease-in-out infinite; }
.lane-state { margin: 28px 0 5px; color: var(--orange); font-size: 1.03rem; font-weight: 800; }
.lane-state.green { color: var(--green); }
.lane-state.orange { color: var(--orange); }
.lane-state.hot, .lane-state.overload { color: var(--hot); }
.lane-detail { min-height: 42px; margin-bottom: 19px; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.lane-meter { position: relative; height: 12px; overflow: hidden; border-radius: 999px; background: #e8edef; }
.meter-fill { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--orange); transition: width .4s ease; }
.meter-fill.green { background: var(--green); }
.meter-fill.orange { background: var(--orange); }
.meter-fill.hot, .meter-fill.overload { background: linear-gradient(90deg, var(--hot), var(--overload)); }
.meter-tick { position: absolute; top: 0; width: 2px; height: 100%; background: rgba(255, 255, 255, .9); }
.tick-1 { left: 25%; } .tick-2 { left: 50%; } .tick-3 { left: 75%; }
.meter-labels { display: flex; justify-content: space-between; margin-top: 6px; color: var(--faint); font-size: .68rem; text-transform: uppercase; }
.lane-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; padding: 13px 0; border-top: 1px solid #edf1f2; border-bottom: 1px solid #edf1f2; }
.lane-stats div { display: flex; flex-direction: column; gap: 5px; }
.stat-label { color: var(--muted); font-size: .72rem; }
.lane-stats strong { font-size: 1.02rem; letter-spacing: -.02em; }
.lane-card-foot { align-items: center; margin-top: 17px; }
.confidence { color: var(--faint); font-size: .7rem; }
.camera-link, .footer a { color: var(--teal-deep); font-size: .74rem; font-weight: 800; text-decoration: none; }
.camera-link:hover, .footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
.show-image-button { padding: 0; color: var(--teal-deep); border: 0; background: transparent; cursor: pointer; font: inherit; font-size: .74rem; font-weight: 800; }
.show-image-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.show-image-button:focus-visible { outline: 3px solid #f2b85f; outline-offset: 3px; }
.lane-image-preview { display: block; width: 100%; margin: 18px 0 0; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); cursor: zoom-out; }
.lane-image-preview[hidden] { display: none; }
.lane-image-preview img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

.signal-card { margin-top: 16px; padding: 22px; }
.signal-badge { padding: 6px 9px; border-radius: 999px; color: var(--teal-deep); background: var(--teal-pale); font-size: .7rem; font-weight: 800; }
.signal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 24px; }
.signal-stat { display: flex; flex-direction: column; gap: 6px; }
.signal-stat strong { font-size: clamp(1.25rem, 3vw, 1.65rem); letter-spacing: -.045em; }
.signal-stat span { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.signal-note { margin: 23px 0 0; padding-top: 16px; border-top: 1px solid #edf1f2; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.how-card { position: relative; display: flex; gap: 14px; margin-top: 16px; padding: 20px 22px; padding-right: 150px; }
.how-card .beta-tag { position: absolute; top: 16px; right: 18px; }
.how-icon { display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto; margin-top: 1px; border: 1px solid #b9d8d4; border-radius: 50%; color: var(--teal-deep); font-size: .8rem; font-weight: 800; }
.how-card h2 { margin-bottom: 7px; font-size: 1rem; }
.how-card p { margin-bottom: 0; color: var(--muted); font-size: .82rem; line-height: 1.52; }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 18px; margin-top: 26px; color: var(--faint); font-size: .69rem; line-height: 1.45; }
.footer a { flex: 0 0 auto; font-size: .69rem; }

.help-shell { max-width: 760px; }
.help-intro { max-width: 650px; }
.help-intro h1 { max-width: 620px; margin-bottom: 18px; }
.help-lede { max-width: 620px; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.help-callout { display: grid; gap: 5px; margin-top: 22px; padding: 16px 18px; border: 1px solid #b9d8d4; border-radius: 16px; color: var(--teal-deep); background: var(--teal-pale); font-size: .86rem; line-height: 1.45; }
.help-callout span { color: var(--muted); }
.help-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 28px 0 14px; }
.help-status { margin: 0; color: var(--muted); font-size: .76rem; }
.refresh-button, .save-label-button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--teal-deep); background: var(--card); cursor: pointer; font: inherit; font-size: .76rem; font-weight: 800; }
.refresh-button:hover, .save-label-button:hover { border-color: var(--teal); background: var(--teal-pale); }
.refresh-button:disabled, .save-label-button:disabled { cursor: wait; opacity: .55; }
.label-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.label-card { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.label-card.is-labeled { border-color: var(--teal); }
.label-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 12px; }
.label-card-head h2 { margin: 0; font-size: 1.08rem; letter-spacing: -.03em; }
.label-card-head .card-kicker { margin-bottom: 5px; }
.priority-badge { max-width: 52%; padding: 5px 8px; border-radius: 8px; color: var(--teal-deep); background: var(--teal-pale); font-size: .62rem; font-weight: 800; line-height: 1.25; text-align: right; }
.sample-image { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #dce5e8; }
.analysis-readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 18px 8px; }
.analysis-readout div { min-width: 0; }
.analysis-readout span { display: block; margin-bottom: 4px; color: var(--faint); font-size: .62rem; line-height: 1.2; }
.analysis-readout strong { display: block; overflow-wrap: anywhere; color: var(--ink); font-size: .73rem; line-height: 1.25; }
.analysis-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px 18px 14px; }
.analysis-chip { padding: 4px 7px; border-radius: 7px; color: var(--muted); background: var(--paper); font-size: .65rem; }
.analysis-chip b { color: var(--teal-deep); }
.label-control { display: grid; gap: 7px; padding: 14px 18px 12px; border-top: 1px solid var(--line); }
.label-control span { color: var(--muted); font-size: .74rem; font-weight: 700; }
.label-control select { width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--paper); font: inherit; font-size: .8rem; }
.label-control select:focus-visible, .refresh-button:focus-visible, .save-label-button:focus-visible { outline: 3px solid #f2b85f; outline-offset: 2px; }
.save-label-button { margin: 0 18px; color: white; border-color: var(--teal-deep); background: var(--teal-deep); }
.label-card > .save-label-button { display: block; width: calc(100% - 36px); }
.save-label-button:hover { color: white; background: #084b48; }
.label-feedback { min-height: 28px; margin: 9px 18px 14px; color: var(--muted); font-size: .69rem; line-height: 1.4; }
.is-labeled .label-feedback { color: var(--teal-deep); }
.help-empty { display: grid; gap: 8px; padding: 28px 20px; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.help-empty strong { color: var(--ink); }
.help-footnote { margin: 20px 0 0; color: var(--faint); font-size: .72rem; line-height: 1.5; }
.analysis-source { margin: 8px 0 0; color: var(--faint); font-size: .68rem; line-height: 1.35; }
.feedback-card { display: grid; gap: 18px; margin-top: 22px; padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.feedback-card h2 { margin-bottom: 7px; font-size: 1.2rem; letter-spacing: -.04em; }
.feedback-lede { margin-bottom: 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.feedback-card textarea { display: block; width: 100%; min-height: 130px; resize: vertical; padding: 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--paper); font: inherit; font-size: .84rem; line-height: 1.45; }
.feedback-card textarea:focus-visible { outline: 3px solid #f2b85f; outline-offset: 2px; }
.feedback-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; }
.feedback-count { color: var(--faint); font-size: .7rem; }
.feedback-result { min-height: 20px; margin: 9px 0 0; color: var(--teal-deep); font-size: .74rem; }
.help-footer { justify-content: flex-end; }
.help-footer-stack { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 4px; margin-left: auto; text-align: right; }

@keyframes overload-pulse {
  0%, 100% { filter: saturate(1); }
  50% { filter: saturate(1.5) brightness(1.08); }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 24px, 540px); padding-top: 16px; }
  .topbar { margin-bottom: 38px; }
  .check-card { grid-template-columns: 1fr; gap: 17px; padding: 20px; }
  .check-button { width: 100%; }
  .lane-grid { grid-template-columns: 1fr; }
  .lane-card { padding: 20px; }
  .signal-grid { gap: 10px; }
  .signal-stat strong { font-size: 1.18rem; }
  .footer { flex-direction: column; gap: 8px; }
  .help-toolbar { align-items: flex-start; flex-direction: column; }
  .refresh-button { width: 100%; }
  .label-grid { grid-template-columns: 1fr; }
  .how-card { padding-right: 22px; padding-top: 62px; }
  .how-card .beta-tag { top: 18px; left: 22px; right: auto; }
  .feedback-form-foot { align-items: stretch; flex-direction: column; }
  .feedback-form-foot .save-label-button { width: 100%; margin: 0; }
}
