/* CalcShot site. One stylesheet for every page; no framework, no build step.
   Palette from the calculator itself: slate body plastic, the green-grey LCD,
   the blue 2nd key and the green ALPHA key. */

:root {
  --paper: #eef1ef;
  --surface: #ffffff;
  --ink: #1d242e;
  --muted: #5a6470;
  --line: #cfd6d2;
  --body: #2b3442;          /* calculator plastic */
  --body-edge: #1a2029;
  --lcd: #b9c4a2;           /* LCD glass */
  --lcd-dark: #a9b58f;
  --lcd-ink: #232d1d;
  --key2nd: #2a65ae;        /* the 2nd key */
  --key2nd-edge: #1b4479;
  --alpha: #2f7d45;         /* the ALPHA key */
  --danger: #a8352a;
  --warn-bg: #fff4d6;
  --warn-ink: #5c4300;
  --focus: #2a65ae;
  --radius: 10px;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "DejaVu Sans Mono", ui-monospace, monospace;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f262f;
    --surface: #283039;
    --ink: #e4e9e4;
    --muted: #a3adb6;
    --line: #3b4550;
    --body: #39434f;
    --body-edge: #151a20;
    --key2nd: #3d7cc9;
    --key2nd-edge: #234f86;
    --alpha: #4fae6c;
    --danger: #e0705f;
    --warn-bg: #3d3420;
    --warn-ink: #f2d998;
    --focus: #8ab8f0;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--key2nd); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.4rem); font-weight: 750; letter-spacing: -0.025em; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 650; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: .92em; background: color-mix(in srgb, var(--line) 45%, transparent); padding: .05em .3em; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---- page chrome --------------------------------------------------------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem max(16px, calc((100% - 1088px) / 2)); background: var(--body); color: #e9eef0;
  border-bottom: 3px solid var(--body-edge);
}
.top nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.top a { color: #e9eef0; text-decoration: none; font-weight: 550; }
.top a:hover { text-decoration: underline; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; letter-spacing: -0.01em; font-size: 1.1rem; }
.brand-mark {
  width: 22px; height: 16px; border-radius: 3px; background: var(--lcd);
  box-shadow: inset 0 0 0 2px var(--lcd-dark), 0 0 0 2px #1a2029;
}
.page { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 2rem 16px 3rem; }
.page.wide { max-width: 1120px; }
.foot {
  display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; justify-content: center;
  padding: 1.4rem 16px 2rem; border-top: 1px solid var(--line); font-size: .92rem;
}
.foot a { color: var(--muted); }
.narrow { max-width: 30rem; }
.lede { font-size: 1.12rem; color: var(--muted); max-width: 36rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.spaced { margin-top: 1.5rem; }

/* ---- the calculator: the one bold element -------------------------------- */
.calc {
  background: var(--body);
  border-radius: 22px 22px 34px 34px;
  padding: 18px 18px 22px;
  box-shadow: inset 0 -6px 0 var(--body-edge), 0 14px 30px -18px rgba(10, 16, 24, .55);
  color: #e9eef0;
  max-width: 460px;
}
.calc-label { font-size: .78rem; font-weight: 700; color: #b9c3cc; margin: 0 0 8px 4px; letter-spacing: .02em; }
.lcd {
  background: var(--lcd);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(35, 45, 29, .05) 2px 3px),
    repeating-linear-gradient(90deg, transparent 0 2px, rgba(35, 45, 29, .05) 2px 3px);
  color: var(--lcd-ink);
  border-radius: 6px;
  box-shadow: inset 0 0 0 3px var(--lcd-dark), inset 0 6px 10px -6px rgba(0, 0, 0, .35);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 1.12rem;
  line-height: 1.45;
  min-height: 8.2em;
}
.lcd p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.lcd .big { font-size: 2.1rem; line-height: 1.15; font-weight: 700; letter-spacing: .02em; }
.lcd input[type="text"] {
  font: inherit; font-size: 1.5rem; letter-spacing: .12em; text-transform: uppercase;
  width: 100%; background: transparent; color: var(--lcd-ink);
  border: 0; border-bottom: 2px dashed rgba(35, 45, 29, .45); padding: 2px 0; border-radius: 0;
}
.lcd input[type="text"]::placeholder { color: rgba(35, 45, 29, .38); }
.lcd input[type="text"]:focus { outline: none; border-bottom-style: solid; border-bottom-color: var(--lcd-ink); }
.lcd .err { color: #7a1d12; }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 16px; }
.keys-note { grid-column: 1 / -1; margin: .2rem 4px 0; color: #c9d2d9; }
.cursor::after { content: "\2588"; animation: blink 1.1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor::after { animation: none; } }

/* ---- keys (buttons) ------------------------------------------------------ */
.key {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: inherit; font-weight: 650; font-size: .98rem; line-height: 1.2; text-decoration: none; text-align: center;
  padding: .62em 1.05em .72em; min-height: 44px;
  border: 0; border-radius: 9px; cursor: pointer;
  background: #4b5666; color: #f4f7f8;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .35);
}
.key:hover { filter: brightness(1.08); }
.key:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .35); }
.key[disabled] { opacity: .55; cursor: not-allowed; filter: none; transform: none; }
.key-primary { background: var(--key2nd); box-shadow: inset 0 -3px 0 var(--key2nd-edge); }
.key-alpha { background: var(--alpha); }
.key-light { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line), inset 0 -3px 0 var(--line); }
.key-danger { background: var(--surface); color: var(--danger); box-shadow: inset 0 0 0 1px var(--line), inset 0 -3px 0 var(--line); }
.key-small { min-height: 36px; padding: .4em .8em .5em; font-size: .9rem; }
.key .price { font-weight: 500; opacity: .85; font-size: .88em; }
.keys .key { flex-direction: column; gap: .1em; padding: .7em .6em .8em; }

/* ---- forms --------------------------------------------------------------- */
label { display: block; font-weight: 600; margin: 0 0 .3rem; }
.field { margin: 0 0 1rem; }
.hint { font-size: .88rem; color: var(--muted); margin: .3rem 0 0; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  width: 100%; padding: .6em .7em; min-height: 44px;
  border: 1px solid var(--line); border-radius: 8px;
}
textarea { min-height: 8rem; resize: vertical; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: transparent; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 12rem; }
.check { display: flex; gap: .65rem; align-items: flex-start; font-weight: 500; }
.check input { width: 1.25rem; height: 1.25rem; margin: .15rem 0 0; flex: none; accent-color: var(--key2nd); }
.turnstile { min-height: 70px; margin: .6rem 0 1rem; }

/* ---- messages ------------------------------------------------------------ */
.msg { padding: .7rem .9rem; border-radius: 8px; margin: .8rem 0; border: 1px solid var(--line); background: var(--surface); }
.msg.ok { border-color: color-mix(in srgb, var(--alpha) 55%, transparent); }
.msg.error { border-color: var(--danger); color: var(--danger); }
.msg.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--body); color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 20;
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, .5); max-width: calc(100vw - 32px);
}

/* ---- home ---------------------------------------------------------------- */
/* Phone: intro, calculator, facts. Wide: intro and facts left, calculator right. */
.hero { display: grid; gap: 1.6rem; align-items: start; grid-template-areas: "intro" "calc" "facts"; }
.hero-intro { grid-area: intro; }
.hero-intro .lede { margin: 0; }
.hero .calc { grid-area: calc; width: 100%; }
.hero .facts { grid-area: facts; }
@media (min-width: 840px) {
  .page.home { max-width: 1040px; }
  .hero { grid-template-columns: minmax(0, 1fr) 460px; grid-template-areas: "intro calc" "facts calc"; column-gap: 3rem; row-gap: 1.4rem; }
}
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; align-content: start; }
.facts li { padding-left: 1rem; border-left: 3px solid var(--lcd-dark); }
.signin-box { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--line); max-width: 30rem; }

/* ---- prose (terms, privacy, changelog) ----------------------------------- */
.prose { max-width: 40rem; }
.prose h2 { margin-top: 2rem; }
.prose h3 { margin-top: 1.6rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: .3rem 0; }
.changelog h2 { padding-top: 1.2rem; border-top: 1px solid var(--line); font-size: 1.15rem; }
.changelog h2:first-child { border-top: 0; padding-top: 0; }

/* ---- tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .5rem 0 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .94rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-weight: 650; color: var(--muted); font-size: .86rem; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap, .nowrap { white-space: nowrap; }
input[type="file"] { max-width: 100%; font: inherit; font-size: .92rem; }
.expired td { color: var(--muted); text-decoration: line-through; }

/* ---- dashboard ----------------------------------------------------------- */
.dash { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
.dash > * { min-width: 0; }
@media (min-width: 900px) { .dash { grid-template-columns: 200px minmax(0, 1fr); gap: 2.5rem; } }
.tabs { display: flex; gap: .3rem; overflow-x: auto; position: sticky; top: 0; z-index: 5; background: var(--paper);
        padding: .5rem 0; margin: -.5rem 0 0; scrollbar-width: thin; }
@media (min-width: 900px) { .tabs { flex-direction: column; top: 1rem; align-self: start; overflow: visible; } }
.tabs a {
  white-space: nowrap; text-decoration: none; color: var(--ink); font-weight: 600;
  padding: .55rem .85rem; border-radius: 8px;
}
.tabs a:hover { background: color-mix(in srgb, var(--line) 50%, transparent); }
.tabs a[aria-current="page"] { background: var(--body); color: #fff; }
.tabs .sep { flex: none; width: 1px; background: var(--line); margin: 0 .3rem; }
@media (min-width: 900px) { .tabs .sep { width: auto; height: 1px; margin: .5rem 0; } }
.panel > h2 { font-size: 1.6rem; letter-spacing: -0.02em; }
.panel section { margin: 0 0 2.2rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stack { display: grid; gap: .8rem; }
.who { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.4rem; }
.who p { margin: 0; }

.balance-lcd { max-width: 380px; min-height: 0; }
.balance-lcd .big { font-size: 2.6rem; }

.device { display: grid; gap: .6rem; }
.device-head { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; align-items: baseline; }
.device-id { font-family: var(--mono); font-size: 1.05rem; font-weight: 700; letter-spacing: .06em; }
.device dl { display: grid; grid-template-columns: max-content 1fr; gap: .15rem 1rem; margin: 0; font-size: .94rem; }
.device dt { color: var(--muted); }
.device dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.pill { display: inline-block; font-size: .8rem; font-weight: 650; padding: .1rem .55rem; border-radius: 99px; background: color-mix(in srgb, var(--line) 60%, transparent); }
.pill.ok { background: color-mix(in srgb, var(--alpha) 22%, transparent); }
.pill.bad { background: color-mix(in srgb, var(--danger) 20%, transparent); }

.models { display: grid; gap: .8rem; }
@media (min-width: 620px) { .models { grid-template-columns: 1fr 1fr; } }
.model { display: flex; gap: .7rem; align-items: flex-start; cursor: pointer; font-weight: 400; margin: 0; }
.model input { margin-top: .3rem; width: 1.15rem; height: 1.15rem; accent-color: var(--key2nd); flex: none; }
.model-name { font-weight: 700; display: block; }
.model.card:has(input:checked) { border-color: var(--key2nd); box-shadow: inset 0 0 0 1px var(--key2nd); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.segmented label { margin: 0; font-weight: 600; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: .55rem 1rem; cursor: pointer; }
.segmented input:checked + span { background: var(--body); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

.meter { height: 12px; border-radius: 99px; background: color-mix(in srgb, var(--line) 70%, transparent); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--alpha); width: 0; }
.meter.over > span { background: var(--danger); }

.hist { display: grid; gap: .7rem; margin-top: 1.2rem; }
.panel > .card { margin-bottom: 2.2rem; }
.hist-item { display: grid; gap: .4rem; }
.hist-meta { font-size: .86rem; color: var(--muted); }
.hist-item img { width: 100%; max-width: 240px; height: auto; border-radius: 6px; border: 1px solid var(--line); }
.hist-q { font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.hist-a { white-space: pre-wrap; font-family: var(--mono); font-size: .88rem; background: var(--paper);
          padding: .6rem .7rem; border-radius: 6px; overflow-x: auto; margin: 0; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.thumbs figure { margin: 0; }
.thumbs img { display: block; width: 100%; border-radius: 6px; border: 1px solid var(--line); background: var(--paper); }
.thumbs figcaption { font-size: .8rem; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }
.stat b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .86rem; color: var(--muted); }
pre.json { font-family: var(--mono); font-size: .82rem; background: var(--surface); border: 1px solid var(--line);
           border-radius: 8px; padding: .7rem; overflow-x: auto; max-height: 24rem; }
details.cfg { border-bottom: 1px solid var(--line); padding: .5rem 0; }
details.cfg summary { cursor: pointer; font-family: var(--mono); font-size: .92rem; }
details.cfg textarea { font-family: var(--mono); font-size: .85rem; min-height: 5rem; margin: .5rem 0; }

/* ---- v2.1: presets, document review, photos, re-ask ---------------------- */
.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; }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .86rem; white-space: nowrap; }
.counter.bad, .bad-text { color: var(--danger); }
.with-counter { display: flex; gap: .6rem; align-items: center; }
.with-counter input { flex: 1; font-family: var(--mono); letter-spacing: .04em; }
.preset { display: grid; gap: .4rem; }
.preset-head { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.preset-head h4 { margin: 0; font-family: var(--mono); font-size: 1rem; letter-spacing: .04em; }
.preset-text { margin: 0; font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.review { margin: 0 0 2.2rem; }
.review h3 { overflow-wrap: anywhere; }
.review .msg p { margin: 0 0 .4rem; }
.review .msg p:last-child { margin: 0; }
.review-text { font-family: var(--mono); font-size: .86rem; min-height: 16rem; }
.review-stats { margin: 0; font-size: .92rem; }
.meter.stacked { display: flex; }
.meter.stacked > .others { display: block; height: 100%; background: color-mix(in srgb, var(--alpha) 45%, transparent); width: 0; }
.hist-note { margin: 0 0 .3rem; font-size: .92rem; font-style: italic; overflow-wrap: anywhere; }
.photos summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: .2rem 0; }
.photos .thumbs { margin-top: .5rem; }
.photo-btn { appearance: none; border: 0; padding: 0; background: none; cursor: zoom-in; display: block; width: 100%; }
.reasks { display: grid; gap: .6rem; border-left: 3px solid var(--key2nd); padding-left: .8rem; margin-top: .2rem; }
.reask .hist-meta { margin-bottom: .3rem; }
.dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
          padding: 1.1rem; width: min(34rem, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.dialog::backdrop { background: rgba(10, 16, 24, .55); }
.dialog h3 { margin-top: 0; }
.photo-dialog { width: min(1100px, calc(100vw - 16px)); padding: .6rem; }
.dialog-bar { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.dialog-bar span { flex: 1; font-size: .9rem; color: var(--muted); }
.photo-full { display: block; width: 100%; height: auto; max-height: calc(100vh - 110px); object-fit: contain; background: var(--paper); border-radius: 6px; }

/* ---- /try demo ----------------------------------------------------------- */
.page.try { max-width: 1120px; }
.top nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; }
.picker { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.4rem 0; }
.picker .key[aria-pressed="true"] { background: var(--key2nd); color: #fff; box-shadow: inset 0 -3px 0 var(--key2nd-edge); }
.problem a { display: block; }
.try-grid { display: grid; gap: 1.6rem; align-items: start; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .try-grid { grid-template-columns: minmax(0, 1fr) 400px; gap: 2.5rem; } }
.problem { margin: 0; min-width: 0; }
/* The problem sheets are black on white paper in both themes. */
.problem img { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.problem figcaption { margin-top: .4rem; }
.try-calc { max-width: 400px; margin: 0 auto; width: 100%; }
.try-calc:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.try-lcd { min-height: 0; padding: 14px 10px; display: flex; justify-content: center; }
.try-lcd .screen, .try-lcd .screen-empty {
  margin: 0; font-family: var(--mono); white-space: pre; line-height: 1.3; letter-spacing: .06em;
  font-size: clamp(15px, 5.6vw, 25px);
}
.try-lcd .screen .n { display: none; }   /* the dev page's "lines a-b" label; not on the calculator */
.screen-empty { opacity: .7; }
.try-keys { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 16px; }
.try-count { font-family: var(--mono); font-size: .92rem; color: #c9d2d9; min-width: 4.5em; text-align: center; font-variant-numeric: tabular-nums; }
.try-src { margin: .8rem auto 0; max-width: 400px; }
.try-side #status { max-width: 400px; margin: 0 auto; }
.try-rules { max-width: 400px; margin: 1rem auto 0; padding-left: 1rem; border-left: 3px solid var(--lcd-dark); }
.try-how { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--line); max-width: 46rem; }

@media (max-width: 480px) {
  .calc { border-radius: 18px 18px 26px 26px; padding: 14px 12px 18px; }
  .lcd .big { font-size: 1.8rem; }
  .top nav { gap: .8rem; }
}
