/* CinExposure web — iOS dark grouped-list look, mirrors ContentView.swift */

:root {
  --bg: #000;
  --card: #1c1c1e;
  --sep: rgba(84, 84, 88, 0.6);
  --label: #fff;
  --secondary: rgba(235, 235, 245, 0.6);
  --fill-q: rgba(118, 118, 128, 0.24);
  --fill-t: rgba(118, 118, 128, 0.12);
  --blue: #0a84ff;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --cyan: #64d2ff;
  --indigo: #5e5ce6;
  --bar-h: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--label);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

.good { color: var(--green); }
.warn { color: var(--orange); }
.clip { color: var(--red); }
.dim { color: var(--secondary); }
.plain { color: var(--label); }
.accent { color: var(--cyan); }

.nav {
  position: sticky; top: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  text-align: center;
  background: rgba(18, 18, 20, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--sep);
}
.nav h1 { font-size: 17px; font-weight: 600; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px calc(var(--bar-h) + env(safe-area-inset-bottom) + 24px);
}

/* MARK: grouped sections */

section.grp { margin-top: 22px; }
section.grp:first-child { margin-top: 12px; }

.hdr {
  font-size: 13px; font-weight: 400;
  text-transform: uppercase;
  color: var(--secondary);
  padding: 0 16px 7px;
  letter-spacing: 0.02em;
}

.card {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
}

.ftr {
  font-size: 13px;
  color: var(--secondary);
  padding: 7px 16px 0;
}
.ftr .warn { color: var(--orange); }

.row {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px;
  padding: 6px 16px;
  position: relative;
}
.row + .row::before,
.row + details::before,
details + .row::before,
.reading + .reading::before {
  content: ""; position: absolute; left: 16px; right: 0; top: 0;
  border-top: 0.5px solid var(--sep);
}
.row .lbl { flex: none; }
.row .spacer { flex: 1; }

/* tappable full-width rows (share codes) */
button.btn-row {
  width: 100%;
  border: 0; background: none;
  color: var(--blue);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
button.btn-row:active { opacity: 0.5; }

/* MARK: selects */

select {
  appearance: none; -webkit-appearance: none;
  border: 0; background: transparent;
  color: var(--secondary);
  font: inherit;
  text-align: right;
}
.row > select {
  flex: 1; min-width: 0;
  padding: 8px 18px 8px 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="14" viewBox="0 0 12 14"><path d="M2 5.5 6 1.5 10 5.5 M2 8.5 6 12.5 10 8.5" fill="none" stroke="rgb(142,142,147)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  background-repeat: no-repeat;
  background-position: right center;
}
select:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 1px; border-radius: 6px;
}

/* MARK: reading rows (section 3) */

.reading { display: block; padding: 8px 16px; }
.r-top { display: flex; align-items: center; gap: 8px; }
.r-top .lbl { flex: 1; }
.r-bottom {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; min-height: 26px; margin-top: 4px;
}
.r-bottom.no-toggle { justify-content: flex-end; }

select.pill {
  flex: none;
  font-size: 20px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--label);
  background-color: var(--fill-q);
  background-image: none;
  border-radius: 8px;
  padding: 5px 10px;
  text-align: center; text-align-last: center;
}
select.pill-f { min-width: 74px; }
select.pill-t { min-width: 52px; }

.aim { font-size: 12px; display: flex; align-items: baseline; gap: 4px; }
.aim .rec { color: var(--secondary); }
.aim .val { font-weight: 600; font-variant-numeric: tabular-nums; }
.aim-drives { font-size: 12px; font-weight: 600; }

.nd-val { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--secondary); }
.nd-val.hot { font-size: 20px; color: var(--orange); }

/* MARK: toggles */

.switch { flex: none; display: inline-block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .knob {
  display: block; width: 51px; height: 31px; border-radius: 16px;
  background: rgba(120, 120, 128, 0.32);
  position: relative; transition: background 0.2s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: left 0.2s;
}
.switch input:checked + .knob { background: var(--green); }
.switch input:checked + .knob::after { left: 22px; }
.switch input:focus-visible + .knob { outline: 2px solid var(--blue); outline-offset: 1px; }

/* MARK: disclosure groups */

details > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 16px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary .sum-title { font-weight: 600; }
details > summary .sum-text { font-size: 12px; color: var(--secondary); margin-top: 2px; }
details[open] > summary .sum-text { display: none; }
details > summary .chev {
  margin-left: auto; flex: none;
  color: var(--fill-q);
  transition: transform 0.2s;
  font-size: 14px; font-weight: 700; color: rgb(142, 142, 147);
}
details[open] > summary .chev { transform: rotate(90deg); }
details > summary > div { flex: 1; min-width: 0; }

/* MARK: changes / bring rows */

.item { display: block; padding: 8px 16px; position: relative; }
.item + .item::before {
  content: ""; position: absolute; left: 16px; right: 0; top: 0;
  border-top: 0.5px solid var(--sep);
}
.item .c-label { font-size: 15px; font-weight: 600; color: var(--orange); }
.item .c-text { font-size: 13px; margin-top: 2px; }
.item .c-lights { font-size: 12px; color: var(--secondary); margin-top: 2px; }
.item .b-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.item .b-val { font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; }
.all-good { font-size: 15px; color: var(--secondary); display: flex; align-items: center; gap: 8px; }
.all-good .ok-ic { color: var(--green); }

/* MARK: result */

.pillbadge {
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.pillbadge.good { background: rgba(48, 209, 88, 0.15); }
.pillbadge.warn { background: rgba(255, 159, 10, 0.15); }
.pillbadge.clip { background: rgba(255, 69, 58, 0.15); }

.metric { display: block; padding: 8px 16px; position: relative; }
.metric + .metric::before, .row + .metric::before, .metric + .row::before,
.metric + .item::before, .metric + .rb-wrap::before, .row + .rb-wrap::before,
.item + .rb-wrap::before {
  content: ""; position: absolute; left: 16px; right: 0; top: 0;
  border-top: 0.5px solid var(--sep);
}
.metric .m-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric .m-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .m-sub { font-size: 12px; margin-top: 2px; color: var(--secondary); }
.note-row { font-size: 13px; }

/* MARK: range bar */

.rb-wrap { display: block; padding: 10px 16px 12px; position: relative; }
.rb-cap { font-size: 12px; color: var(--secondary); margin-bottom: 8px; }
.rb-labels, .rb-ticks { position: relative; height: 14px; }
.rb-labels span, .rb-ticks span {
  position: absolute; transform: translateX(-50%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px; white-space: nowrap;
}
.rb-labels span { font-weight: 600; }
.rb-ticks span { color: var(--secondary); }
.rb-bar {
  position: relative; height: 26px; margin: 3px 0;
  background: var(--fill-t); border-radius: 6px; overflow: hidden;
}
.rb-zone { position: absolute; top: 0; bottom: 0; }
.rb-safe {
  position: absolute; top: 0; bottom: 0;
  border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 3px;
}
.rb-marker {
  position: absolute; top: 0; bottom: 0; width: 4px;
  border-radius: 2px; transform: translateX(-2px);
}
.rb-note { font-size: 11px; color: var(--secondary); margin-top: 8px; }
.rb-note + .rb-note { margin-top: 6px; }

.notes-body { padding: 0 16px 12px; font-size: 13px; color: var(--secondary); }

/* MARK: verdict bar */

.vbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  min-height: calc(var(--bar-h) + env(safe-area-inset-bottom));
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  border: 0; border-top: 0.5px solid var(--sep);
  background: rgba(18, 18, 20, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font: inherit; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer;
}
.vbar .v-ic { font-size: 17px; }
.vbar .v-chev { color: var(--secondary); font-size: 13px; }

/* MARK: next-steps sheet */

#sheet-backdrop {
  position: fixed; inset: 0; z-index: 9;
  background: rgba(0, 0, 0, 0.5);
}
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-height: 85vh; overflow-y: auto;
  background: #161618;
  border-radius: 12px 12px 0 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.sheet-nav {
  position: sticky; top: 0;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 16px 10px;
  background: #161618;
  border-bottom: 0.5px solid var(--sep);
}
.sheet-nav .grabber {
  grid-column: 1 / -1; justify-self: center;
  width: 36px; height: 5px; border-radius: 3px;
  background: var(--fill-q); margin: 4px 0 8px;
}
.sheet-nav h2 { grid-column: 2; font-size: 17px; font-weight: 600; text-align: center; }
.sheet-nav button {
  grid-column: 3; justify-self: end;
  border: 0; background: none; color: var(--blue);
  font: inherit; font-weight: 600; cursor: pointer;
}
#sheet-body { padding: 0 16px; max-width: 560px; margin: 0 auto; width: 100%; }
#sheet-body .hdr { padding-top: 18px; }
#sheet-body section.grp { margin-top: 0; }
#sheet-body .card { background: #2c2c2e; }
.v-head { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 12px 16px; }

/* MARK: add-lens dialog */

dialog {
  border: 0; border-radius: 12px;
  background: #2c2c2e; color: var(--label);
  width: min(92vw, 420px);
  padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { font-size: 17px; text-align: center; margin-bottom: 12px; }
dialog .card { background: var(--fill-t); }
dialog input[type="text"] {
  flex: 1; border: 0; background: transparent;
  color: var(--label); font: inherit; padding: 8px 0;
}
dialog input[type="text"]::placeholder { color: var(--secondary); }
.seg { flex: 1; display: flex; background: var(--fill-t); border-radius: 8px; padding: 2px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span {
  display: block; text-align: center; padding: 5px 0;
  font-size: 14px; border-radius: 6px; cursor: pointer;
}
.seg input:checked + span { background: #636366; font-weight: 600; }
.dlg-actions { display: flex; justify-content: space-between; margin-top: 14px; }
.dlg-actions button {
  border: 0; background: none; color: var(--blue);
  font: inherit; padding: 8px 12px; cursor: pointer;
}
.dlg-actions button:disabled { color: var(--secondary); cursor: default; }
#lensSave { font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
