/* Ease-o-Stat electronic wheel. Brand: PMS 7474 #00929F, PMS 1645 #F79762 */
:root {
  --teal: #00929F;
  --teal-deep: #006F79;
  --orange: #F79762;
  --bg: #F2F7F7;
  --surface: #FFFFFF;
  --ink: #142B2C;
  --ink-2: #4A6263;
  --line: #D5E4E4;
  --chip: #F5FAFA;
  --pos-ink: #00727C;
  --neg-ink: #B24E19;
  --pos-soft: #E1F2F3;
  --neg-soft: #FDEDE3;
  --card: #FCFEFE;
  --tick-zero: #142B2C;
  --glare: .16;
  --wheel-a: rgba(255, 255, 255, 0.55);
  --wheel-b: rgba(214, 238, 240, 0.70);
  --shadow: 0 1px 2px rgba(0, 40, 44, .06), 0 6px 18px rgba(0, 40, 44, .07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C191A;
    --surface: #132526;
    --ink: #E6F1F1;
    --ink-2: #9FB8B8;
    --line: #23403F;
    --chip: #18302F;
    --pos-ink: #4FC6D0;
    --neg-ink: #F9A577;
    --pos-soft: #12363A;
    --neg-soft: #3A2419;
    --card: #162B2C;
    --tick-zero: #E6F1F1;
    --glare: .05;
    --wheel-a: rgba(40, 70, 72, 0.55);
    --wheel-b: rgba(10, 40, 44, 0.75);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0C191A; --surface: #132526; --ink: #E6F1F1; --ink-2: #9FB8B8; --line: #23403F; --chip: #18302F;
  --pos-ink: #4FC6D0; --neg-ink: #F9A577; --pos-soft: #12363A; --neg-soft: #3A2419; --card: #162B2C;
  --tick-zero: #E6F1F1; --glare: .05; --wheel-a: rgba(40, 70, 72, 0.55); --wheel-b: rgba(10, 40, 44, 0.75);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { line-height: 1.2; }
sup { font-size: .55em; }
button { font: inherit; color: inherit; }
input { font: inherit; }

#app { max-width: 520px; margin: 0 auto; padding: 0 16px calc(88px + env(safe-area-inset-bottom)); }

/* header */
.top { display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 0 4px; }
.top-logo { border-radius: 50%; }
.top-text { flex: 1; min-width: 0; }
.brand { font-weight: 750; font-size: 18px; color: var(--pos-ink); letter-spacing: .01em; }
.date { font-size: 14px; color: var(--ink-2); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; }

.warn { background: var(--neg-soft); color: var(--neg-ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; }

/* readout */
.readout { text-align: center; margin: 6px 0 0; }
.readout-num { font-size: 60px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.readout-label { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; }
.pos { color: var(--pos-ink); }
.neg { color: var(--neg-ink); }
.zero { color: var(--ink); }

/* dial */
.dial-wrap { max-width: 380px; margin: 8px auto 4px; }
#dial { width: 100%; height: auto; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; outline: none; }
#dial.dragging { cursor: grabbing; }
#dial:focus-visible .card { stroke: var(--teal); stroke-width: 3; }
#dial .card { fill: var(--card); stroke: var(--line); stroke-width: 1.5; }
#dial .half-pos { fill: var(--pos-soft); }
#dial .half-neg { fill: var(--neg-soft); }
#dial .ring-edge { fill: none; stroke: var(--line); stroke-width: 1.2; }
#dial .tk-pos { stroke: var(--pos-ink); stroke-width: 1; }
#dial .tk-neg { stroke: var(--neg-ink); stroke-width: 1; }
#dial .tk-zero { stroke: var(--tick-zero); stroke-width: 2; }
#dial .lab { font-size: 11px; font-weight: 650; font-family: inherit; }
#dial .lab-pos { fill: var(--pos-ink); }
#dial .lab-neg { fill: var(--neg-ink); }
#dial .lab-zero { fill: var(--tick-zero); font-weight: 800; }
#dial .side { font-size: 10px; font-weight: 700; letter-spacing: .14em; }
#dial .stop-a { stop-color: var(--wheel-a); stop-opacity: 1; }
#dial .stop-b { stop-color: var(--wheel-b); stop-opacity: 1; }
#dial .wheel-face { stroke: var(--teal); stroke-width: 2; }
#dial .knurl { stroke: var(--teal); stroke-opacity: .35; stroke-width: 1.4; }
#dial .mini { stroke: var(--ink-2); stroke-width: 1; }
#dial .mini-lab { font-size: 9px; font-weight: 700; fill: var(--ink-2); }
#dial .needle { stroke: var(--tick-zero); stroke-width: 3; stroke-linecap: round; }
#dial .cursor-tri { fill: var(--orange); stroke: var(--tick-zero); stroke-width: 1.2; }
#dial .hub { pointer-events: none; }
#dial .glare { fill: #fff; opacity: var(--glare); pointer-events: none; }

.nudge { background: var(--neg-soft); color: var(--neg-ink); border-radius: 14px; padding: 10px 14px; font-size: 15px; margin: 8px 0; }

/* cards */
.card-surface { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); margin: 10px 0; }
.card-surface p { margin: 0 0 10px; }
.card-surface p:last-child { margin-bottom: 0; }

/* entry */
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; color: var(--ink-2); font-size: 15px; }
.entry-head strong { font-size: 26px; font-variant-numeric: tabular-nums; margin-left: 6px; }
#pendWrap { margin-left: auto; font-weight: 600; }
.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.chip { min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--chip); font-weight: 750; font-size: 17px; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip.neg { color: var(--neg-ink); }
.chip.pos { color: var(--pos-ink); }
.chip[aria-pressed="true"].neg { background: var(--neg-soft); border-color: var(--neg-ink); }
.chip[aria-pressed="true"].pos { background: var(--pos-soft); border-color: var(--pos-ink); }
.chip-gap { grid-column: 1 / -1; height: 2px; }
.pend-actions { margin-top: 12px; display: grid; gap: 12px; }
.stepper { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row { display: flex; gap: 10px; }
.row > .btn { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > .btn { flex: 1 1 200px; }

.field { display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
.field input { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 10px 12px; font-size: 16px; }
.field input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }

.btn { min-height: 46px; border-radius: 12px; padding: 10px 16px; font-weight: 700; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.btn.primary { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--chip); }
.btn.step { background: var(--chip); font-size: 18px; }
.btn.danger { background: var(--neg-soft); color: var(--neg-ink); border-color: var(--neg-ink); }
.btn.wide { width: 100%; }
.link-btn { background: none; border: 0; color: var(--ink-2); text-decoration: underline; padding: 12px; cursor: pointer; font-size: 14px; }
.small { font-size: 13px; color: var(--ink-2); }
.err { color: var(--neg-ink); font-size: 14px; font-weight: 600; }

/* log */
.section-h { font-size: 17px; margin: 22px 0 6px; }
.page-h { font-size: 24px; margin: 14px 0 10px; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { display: grid; grid-template-columns: 64px 54px 1fr auto; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.log .t { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.log .v { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.log .n { font-size: 15px; overflow-wrap: anywhere; }
.log .run { display: block; font-size: 12px; color: var(--ink-2); }
.log .del { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; font-size: 18px; line-height: 1; }
.empty { color: var(--ink-2); font-size: 15px; }

/* history */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--chip); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; min-height: 40px; border-radius: 9px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.trend { font-size: 15px; margin: 12px 0 0; }
.chart-card { padding: 10px 6px; }
#chart { width: 100%; height: auto; display: block; }
#chart .axis { stroke: var(--line); stroke-width: 1.2; }
#chart .bar-pos { fill: var(--teal); }
#chart .bar-neg { fill: var(--orange); }
#chart .xl { font-size: 10px; fill: var(--ink-2); font-family: inherit; }
#chart .vl { font-size: 9.5px; font-weight: 700; font-family: inherit; }
#chart .vl.pos { fill: var(--pos-ink); }
#chart .vl.neg { fill: var(--neg-ink); }
.hist details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin: 8px 0; }
.hist summary { list-style: none; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; cursor: pointer; }
.hist summary::-webkit-details-marker { display: none; }
.hist .h-label { font-weight: 650; }
.hist .h-net { font-weight: 800; font-size: 18px; text-align: right; grid-row: span 2; align-self: center; font-variant-numeric: tabular-nums; }
.hist .h-sub { font-size: 13px; color: var(--ink-2); }
.hist .h-body { padding: 0 14px 10px; }
.hist .h-body .log li { grid-template-columns: 64px 54px 1fr; }

/* guide */
.steps { padding-left: 22px; }
.steps li { margin-bottom: 10px; }
.example div { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.example div:last-child { border-bottom: 0; }
.example b { font-size: 18px; text-align: right; }
.example i { font-style: normal; font-size: 13px; color: var(--ink-2); grid-column: 1 / -1; }
.scale-row { display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; gap: 8px; padding: 8px 0; font-weight: 800; }
.scale-row small { font-weight: 500; font-size: 13px; }
.scale-row span:last-child { text-align: right; }
.scale-row i { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--orange), var(--line) 50%, var(--teal)); }
.prose p { font-size: 15px; }
.foot { font-size: 12px; color: var(--ink-2); text-align: center; margin: 18px 0 8px; }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.tabs button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 12px; font-weight: 650; color: var(--ink-2); cursor: pointer; min-height: 48px; }
.tabs svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--pos-ink); }
@media (min-width: 560px) { .tabs { left: 50%; right: auto; width: 520px; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; } }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); }
.overlay-card { max-width: 520px; margin: 0 auto; }
.overlay-card.narrow { max-width: 380px; padding-top: 10vh; text-align: center; }
.overlay-card.narrow .field { text-align: left; }
.overlay-logo { display: block; margin: 0 auto 12px; border-radius: 50%; }
.overlay h1 { font-size: 24px; text-align: center; margin: 0 0 14px; }
.overlay h2 { font-size: 17px; margin: 18px 0 6px; color: var(--pos-ink); }
.overlay p { margin: 0 0 10px; font-size: 15px; }
.check { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 18px 0 14px; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--teal-deep); }
.noscript { padding: 24px; text-align: center; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
