/* Plaster ground, eucalyptus ink, brass for tiers. Same palette as the blueprint. */
:root {
  --bg: #F3F4F1; --surface: #FFFFFF; --ink: #1E2420; --muted: #5B655F; --line: #D5DAD3;
  --accent: #3D5A44; --accent-ink: #FFFFFF; --accent-soft: #E1EADF;
  --brass: #8E6A22; --brass-soft: #F2E9D6; --warn: #9A3B2E; --warn-soft: #F6E3DF;
  --display: "Gloock", "Iowan Old Style", Georgia, serif;
  --body: "Figtree", -apple-system, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614; --surface: #1A201C; --ink: #E6EAE4; --muted: #9AA59E; --line: #2D3530;
    --accent: #95BA9C; --accent-ink: #121614; --accent-soft: #22302A;
    --brass: #D6B064; --brass-soft: #2E2817; --warn: #E59484; --warn-soft: #3A221E;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--body);
  padding: env(safe-area-inset-top, 0) max(16px, env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
main { max-width: 560px; margin: 0 auto; }
h1, .h2 { font-family: var(--display); font-weight: 400; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; }
.h2 { font-size: 1.35rem; margin-top: 28px; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.label { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.opt { text-transform: none; letter-spacing: 0; font-weight: 400; }

.top { max-width: 560px; margin: 0 auto; display: flex; align-items: baseline; gap: 8px; padding-block: 14px 10px; }
.mark { font-family: var(--display); font-size: 1.25rem; }
.beta { font-size: .7rem; color: var(--brass); background: var(--brass-soft); padding: 1px 7px; border-radius: 99px; }

.view { display: grid; gap: 18px; padding-block: 8px 24px; }
.view[hidden] { display: none; }
.stack { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; }
.banner { background: var(--brass-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: .875rem; margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 99px; padding: 8px 14px; font: inherit; font-size: .95rem; cursor: pointer; }
.chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Start screen: compact enough to fit one phone screen, buttons pinned to the bottom */
.view.compact { gap: 14px; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.intro { display: grid; gap: 6px; }
.compact h1 { font-size: 1.65rem; }
.compact .intro p { font-size: .95rem; }
.compact .stack { gap: 6px; }
.compact .chips { gap: 6px; }
.compact .chip { padding: 6px 12px; font-size: .9rem; }
.compact .level { padding: 8px 9px; }
.compact .level b { font-size: .9rem; }
.compact .level small { font-size: .75rem; }
.compact .switch small { display: inline; font-size: .85rem; }
.compact .switch .track { width: 42px; height: 26px; }
.compact .switch .knob { width: 20px; height: 20px; }
.compact .switch input:checked + .track .knob { transform: translateX(16px); }
#notes { width: 100%; font: inherit; font-size: .95rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.actionbar .btn { padding: 14px 18px; }
@media (min-width: 600px) { .actionbar { padding-left: calc(50% - 264px); padding-right: calc(50% - 264px); } }

.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.level { display: grid; gap: 2px; text-align: left; align-content: start; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 11px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.level b { font-size: .95rem; }
.level small { font-size: .78rem; color: var(--muted); line-height: 1.3; }
.level[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.level:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.direction { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 6px; }
.dir-name { font-family: var(--display); font-weight: 400; font-size: 1.5rem; line-height: 1.15; margin: 0; }
.dir-words { color: var(--muted); }
.swatches { display: grid; grid-template-columns: 6fr 3fr 1.6fr; gap: 0; border-radius: 10px; overflow: hidden; margin-top: 4px; border: 1px solid var(--line); }
.swatch { min-height: 56px; padding: 6px 8px; display: flex; flex-direction: column; justify-content: flex-end; font-size: .7rem; line-height: 1.25; min-width: 0; overflow: hidden; }
.swatch b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dir-materials { font-size: .9rem; }

.switch { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 46px; height: 28px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .knob { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch small { display: block; color: var(--muted); font-size: .85rem; }

textarea, input[type=password] {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical;
}
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.actions { display: grid; gap: 10px; margin-top: 4px; }
.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  font: inherit; font-weight: 600; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.small { padding: 9px 12px; font-size: .9rem; border-radius: 11px; }
.btn.wide { width: 100%; margin-top: 24px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .chip:focus-visible, .link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; cursor: pointer; justify-self: start; }

/* working */
.scan { position: relative; border-radius: 16px; overflow: hidden; background: var(--line); }
.scan img { display: block; width: 100%; max-height: 38vh; object-fit: cover; }
.scanline { position: absolute; left: 0; right: 0; height: 30%; background: linear-gradient(180deg, transparent, rgba(149,186,156,.45), transparent); animation: scan 2.2s ease-in-out infinite; }
@keyframes scan { 0% { top: -30%; } 100% { top: 100%; } }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.steps li::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--accent); border-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* compare */
.compare { position: relative; margin: 0; border-radius: 16px; overflow: hidden; background: var(--line); touch-action: pan-y; }
.compare img { display: block; width: 100%; height: 100%; object-fit: cover; }
#after-img { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos, 50%)); }
.divider { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 2px; margin-left: -1px; background: #fff; pointer-events: none; box-shadow: 0 0 6px rgba(0,0,0,.3); }
.divider span { position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.3); }
.divider span::before, .divider span::after { content: ""; position: absolute; top: 12px; border: 5px solid transparent; }
.divider span::before { left: 4px; border-right-color: #333; }
.divider span::after { right: 4px; border-left-color: #333; }
#compare-range { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: ew-resize; }
.tag { position: absolute; bottom: 10px; font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: rgba(20,24,22,.65); padding: 3px 8px; border-radius: 8px; pointer-events: none; }
.tag.left { left: 10px; } .tag.right { right: 10px; }
.rendering { position: absolute; inset: auto 10px 44px 10px; display: flex; gap: 10px; align-items: center; justify-content: center; background: rgba(20,24,22,.72); color: #fff; padding: 10px 12px; border-radius: 12px; font-size: .9rem; }
.rendering[hidden] { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .9s linear infinite; flex: none; }
.shown { font-size: .9rem; color: var(--muted); }
.shown b { color: var(--ink); font-weight: 600; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.read { color: var(--muted); font-size: .95rem; }
.verdict { display: grid; gap: 12px; }
.verdict > div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 4px; }
.verdict .flaw { border-color: var(--warn); background: var(--warn-soft); }
.verdict .flaw .label { color: var(--warn); }

.lenses { display: grid; gap: 10px; }
.lens { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; }
.lens .name { font-weight: 600; text-transform: capitalize; }
.lens .bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.lens .bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.lens .bar i.low { background: var(--brass); }
.lens .num { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); }
.lens .note { grid-column: 2 / -1; font-size: .85rem; color: var(--muted); margin-top: -6px; }

.ideas { display: grid; gap: 12px; }
.idea { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 8px; }
.idea.shown-in-after { border-color: var(--accent); }
.idea .head { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.idea h3 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.pill { font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--brass-soft); color: var(--brass); white-space: nowrap; }
.pill.green { background: var(--accent-soft); color: var(--accent); }
.idea ul { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
.idea .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .85rem; color: var(--muted); align-items: center; }

.toast { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); max-width: 528px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 12px; font-size: .95rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); }

@media (prefers-reduced-motion: reduce) { .scanline, .spinner, .steps li.active::before { animation: none; } }

/* Five By Nine references */
a.beta { text-decoration: none; }
.yt { display: inline-block; width: 18px; height: 13px; border-radius: 4px; background: #E62117; position: relative; vertical-align: -2px; margin-right: 7px; flex: none; }
.yt::after { content: ""; position: absolute; left: 7px; top: 3.5px; border-left: 5px solid #fff; border-top: 3px solid transparent; border-bottom: 3px solid transparent; }
.channel-link { display: inline-flex; align-items: center; font-size: .88rem; color: var(--ink); text-decoration: none; padding: 6px 10px 6px 8px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); justify-self: start; }
.channel-link b { font-weight: 600; }
.source { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 2px; }
.source img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--line); }
.source span { display: grid; gap: 1px; min-width: 0; }
.source small { font-size: .72rem; color: var(--muted); }
.source b { font-size: .88rem; font-weight: 600; line-height: 1.3; }
.deeper { display: grid; gap: 10px; }
.deeper .h2 { margin-top: 28px; }
.videos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.video { display: grid; gap: 4px; text-decoration: none; color: var(--ink); min-width: 0; }
.video img { width: 100%; aspect-ratio: 16 / 9; height: auto; object-fit: cover; border-radius: 10px; background: var(--line); }
.video b { font-size: .88rem; line-height: 1.3; }
.video small { font-size: .75rem; color: var(--muted); }
.yt-btn { margin-top: 6px; text-decoration: none; }
