/* ==========================================================================
   The AI Patrika: the app around the paper.
   Calm, modern, made for a five-minute read with the morning chai. The paper
   itself (index.html, paper.css) stays vintage; everything else uses this.
   Light by day (cream), dark by night (espresso and amber), following the phone.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --surface: #f7f6f3;           /* cards: a whisper of grey so they read on white */
  --surface-2: #efe9dd;
  --ink: #1b1915;
  --ink-2: #57514a;
  --ink-3: #6e675d;   /* 5.6:1 on white, 5.2:1 on cards */
  --line: #e6ded0;
  --line-2: #d6ccba;
  --accent: #c2541c;          /* chai, brewed strong */
  --accent-ink: #a8461a;
  --accent-soft: #fbeadc;
  --ok: #2f7a4f;
  --ok-soft: #e1f0e5;
  --btn: #1b1915;
  --btn-ink: #fffdf8;
  --tab-on: #1b1915;
  --bar: rgba(255, 255, 255, 0.88);
  --head: rgba(255, 255, 255, 0.86);
  --shadow: 0 1px 2px rgba(48, 34, 16, 0.05), 0 10px 28px -14px rgba(48, 34, 16, 0.22);
  --paper: #e8dfc8;           /* the vintage paper, seen through the window */
  --paper-ink: #1d1a15;

  --sans: "Fredoka", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --v-name: "Old Standard TT", "Bodoni 72", "Didot", "Times New Roman", serif;
  --v-banner: "League Gothic", "Oswald", "Arial Narrow", sans-serif;
  --v-head: "Old Standard TT", "Bodoni 72", Georgia, serif;

  --r-lg: 20px;
  --r-md: 16px;
  --r-sm: 12px;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11100e; --surface: #1a1816; --surface-2: #23201c; --ink: #f3eee6; --ink-2: #b9b0a3; --ink-3: #9a9083;
    --line: #2b2723; --line-2: #3a352f; --accent: #e9a23b; --accent-ink: #f0b354; --accent-soft: rgba(233, 162, 59, 0.13);
    --ok: #7cc79a; --ok-soft: rgba(124, 199, 154, 0.13); --btn: #e9a23b; --btn-ink: #1a1206; --tab-on: #e9a23b;
    --bar: rgba(22, 20, 18, 0.9); --head: rgba(17, 16, 14, 0.86);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 30px -16px rgba(0, 0, 0, 0.7);
    --paper: #d3c8ab;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11100e; --surface: #1a1816; --surface-2: #23201c; --ink: #f3eee6; --ink-2: #b9b0a3; --ink-3: #9a9083;
  --line: #2b2723; --line-2: #3a352f; --accent: #e9a23b; --accent-ink: #f0b354; --accent-soft: rgba(233, 162, 59, 0.13);
  --ok: #7cc79a; --ok-soft: rgba(124, 199, 154, 0.13); --btn: #e9a23b; --btn-ink: #1a1206; --tab-on: #e9a23b;
  --bar: rgba(22, 20, 18, 0.9); --head: rgba(17, 16, 14, 0.86);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 30px -16px rgba(0, 0, 0, 0.7);
  --paper: #d3c8ab;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { text-wrap: balance; }

.wrap {
  max-width: 36rem;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.svg { width: 1em; height: 1em; flex: none; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--head);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 30; }
.top { top: env(safe-area-inset-top, 0px); }
.top.scrolled { border-bottom-color: var(--line); }
.top .wrap { display: flex; align-items: center; gap: .7rem; min-height: 60px; padding-block: .55rem; }
.top-actions { margin-left: auto; display: flex; gap: .5rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 19px;
  transition: transform .15s;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { color: var(--accent); }

/* ---------- views ---------- */
main.wrap { padding-bottom: calc(var(--tabs-h) + 2rem + env(safe-area-inset-bottom, 0px)); }
.view { animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }


.kicker { font-size: .7rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: var(--accent-ink); }


/* ---------- chai-break briefings ---------- */
.ico { width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 20px; }
.b-kicker { display: flex; align-items: center; gap: .4rem; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }
.b-kicker .read { color: var(--ok); letter-spacing: .04em; }
.b-title { margin: .2rem 0 .25rem; font-size: .98rem; line-height: 1.35; font-weight: 600; color: var(--ink); }
.b-why { margin: 0; font-size: .86rem; line-height: 1.45; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }



/* ---------- empty states ---------- */
.empty { margin: 3rem auto; max-width: 20rem; text-align: center; color: var(--ink-2); }
.empty .ico { margin: 0 auto 1rem; width: 56px; height: 56px; border-radius: 50%; font-size: 26px; }
.empty h3 { margin: 0 0 .35rem; font-size: 1.08rem; color: var(--ink); }
.empty p { margin: 0; font-size: .92rem; }


/* ---------- tab bar ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs .wrap { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: var(--tabs-h); }
.tab[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: .7rem; font-weight: 600; color: var(--ink-3);
  transition: color .15s;
}
.tab .svg { font-size: 22px; }
.tab[aria-current="page"] { color: var(--tab-on); }
.tab[aria-current="page"] .svg { stroke-width: 2.1; }

/* ---------- loading shimmer ---------- */
.skeleton { border-radius: var(--r-lg); background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface) 50%, var(--surface-2) 60%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   Reading: a single story, and the small print
   ========================================================================== */
.readbar { position: fixed; left: 0; top: 0; height: 2px; width: 0; background: var(--accent); z-index: 40; }
.top .title-mini { min-width: 0; flex: 1; font-size: .92rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .2s; }
.top.scrolled .title-mini { opacity: 1; }

.article { padding-bottom: 3rem; }
.article .kicker { display: inline-block; margin-top: 1.4rem; }
.article h1 { margin: .5rem 0 .7rem; font-family: var(--serif); font-weight: 700; font-size: clamp(1.9rem, 7.4vw, 2.5rem); line-height: 1.1; letter-spacing: -.012em; }
.article .decks p { margin: 0 0 .35rem; font-family: var(--serif); font-style: italic; font-size: 1.16rem; line-height: 1.4; color: var(--ink-2); }
.byline { margin: 1.1rem 0 1.4rem; padding: .75rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .82rem; color: var(--ink-3); }
.byline b { font-weight: 600; color: var(--ink-2); }
.body p { margin: 0 0 1.05em; font-family: var(--serif); font-size: 1.2rem; line-height: 1.66; color: var(--ink); hyphens: auto; -webkit-hyphens: auto; }
.why { margin: 1.6rem 0; padding: 16px 18px; border-radius: var(--r-md); background: var(--accent-soft); }
.why h2 { margin: 0 0 .4rem; font-size: .7rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: var(--accent-ink); }
.why p { margin: 0; font-size: 1rem; line-height: 1.55; color: var(--ink); }
.sources h2 { margin: 1.8rem 0 .5rem; font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.sources ol { margin: 0; padding-left: 1.2rem; display: grid; gap: .45rem; }
.sources li { font-size: .92rem; color: var(--ink-2); }
.sources li::marker { color: var(--ink-3); font-size: .85em; }
.sources a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; overflow-wrap: anywhere; }
.sources .host { color: var(--ink-3); font-size: .82rem; }

.in-paper {
  margin-top: 2rem;
  display: grid; grid-template-columns: 54px minmax(0, 1fr) 16px; gap: 14px; align-items: center;
  padding: 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.in-paper .swatch {
  width: 54px; height: 54px; border-radius: 10px; background: var(--paper); color: var(--paper-ink);
  display: grid; place-items: center; font-family: var(--v-name); font-weight: 700; font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.in-paper b { display: block; font-size: .95rem; font-weight: 600; }
.in-paper span { font-size: .82rem; color: var(--ink-3); }
.next { margin-top: 12px; display: block; padding: 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.next .b-title { font-size: 1.02rem; margin-bottom: 0; }

/* the small print */
.legal h1 { margin: 1.4rem 0 .3rem; font-size: 1.9rem; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; }
.legal .updated { margin: 0 0 1.4rem; font-size: .85rem; color: var(--ink-3); }
.legal h2 { margin: 2rem 0 .5rem; font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; }
.legal p, .legal li { font-size: .98rem; line-height: 1.65; color: var(--ink-2); }
.legal p { margin: .5rem 0; }
.legal ul { margin: .4rem 0 .8rem; padding-left: 1.2rem; }
.legal li { margin: .3rem 0; }
.legal li::marker { color: var(--accent); }
.legal strong { color: var(--ink); font-weight: 600; }
.legal a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.legal .summary { margin: 1rem 0; padding: 16px 18px; border-radius: var(--r-md); background: var(--accent-soft); }
.legal .summary p { margin: 0; color: var(--ink); }
.legal .table-wrap { overflow-x: auto; margin: .6rem 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
.legal table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 30rem; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: .6rem .75rem; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.legal th { background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: .8rem; }
.legal tr:last-child td { border-bottom: 0; }
.legal .contact { margin-top: 1rem; padding: 16px 18px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.in-app .web-only { display: none !important; }

/* the level meter: three bars, filled to the level */
.lvl {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .16rem .55rem .16rem .45rem; border-radius: 999px;
  font-size: .68rem; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-2); color: var(--ink-2);
}
.lvl-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.lvl-bars i { width: 3px; border-radius: 1px; background: var(--line-2); }
.lvl-bars i:nth-child(1) { height: 4px; }
.lvl-bars i:nth-child(2) { height: 7px; }
.lvl-bars i:nth-child(3) { height: 10px; }
.lvl[data-l="1"] { background: var(--ok-soft); color: var(--ok); }
.lvl[data-l="2"] { background: var(--accent-soft); color: var(--accent-ink); }
.lvl[data-l="3"] { background: var(--btn); color: var(--btn-ink); }
.lvl[data-l="1"] i:nth-child(-n+1),
.lvl[data-l="2"] i:nth-child(-n+2),
.lvl[data-l="3"] i { background: currentColor; }
.lvl[data-l="3"] .lvl-bars i { background: var(--btn-ink); }

/* ---------- a paper, explained (research.html) ---------- */
.rp-orig {
  margin: 0 0 .9rem; padding-left: .8rem; border-left: 2px solid var(--line-2);
  font-family: var(--serif); font-style: italic; font-size: 1rem; line-height: 1.45; color: var(--ink-2);
}
.rp-orig span {
  display: block; margin-bottom: .1rem;
  font-family: var(--sans); font-style: normal; font-size: .64rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3);
}
.rp-tags { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.rp-tags .lvl { font-size: .74rem; padding: .25rem .65rem .25rem .55rem; }
.rp-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .65rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: .74rem; font-weight: 600; color: var(--ink-2);
}
.rp-chip .svg { font-size: 13px; }
.rp-chip.ok { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.rp .byline { margin-top: 1rem; }

.rp-oneline {
  margin: 0 0 1.4rem;
  font-family: var(--serif); font-size: 1.32rem; line-height: 1.45; font-weight: 600; color: var(--ink);
  text-wrap: pretty;
}
.rp-oneline span {
  display: block; margin-bottom: .3rem;
  font-family: var(--sans); font-size: .68rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--accent-ink);
}

.rp-stat {
  margin: 0 0 1.8rem; padding: 20px 18px;
  display: grid; gap: .3rem; justify-items: start;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.rp-stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.rp-stat b { font-family: var(--serif); font-size: clamp(2.2rem, 11vw, 3rem); line-height: 1; font-weight: 700; letter-spacing: -.02em; color: var(--accent-ink); font-variant-numeric: lining-nums; }
.rp-stat figcaption { font-size: .9rem; line-height: 1.4; color: var(--ink-2); }

.rp-sec { margin: 0 0 1.6rem; }
.rp-sec h2 {
  margin: 0 0 .8rem; display: flex; align-items: center; gap: .55rem;
  font-size: .76rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
}
.rp-n {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--btn); color: var(--btn-ink);
  font-size: .7rem; letter-spacing: 0; font-variant-numeric: tabular-nums;
}
.rp .body p { font-size: 1.12rem; }
.rp-found { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.rp-found li {
  position: relative; padding: 12px 14px 12px 40px;
  border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line);
  font-size: 1rem; line-height: 1.5; color: var(--ink);
}
.rp-found li::before {
  content: ""; position: absolute; left: 14px; top: 1.05em;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-soft); box-shadow: inset 0 0 0 4px var(--accent);
}
.rp .why { margin-top: 0; }

.rp-words { margin: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.rp-words > div { padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); }
.rp-words dt { font-family: var(--serif); font-size: 1.02rem; font-weight: 700; color: var(--ink); }
.rp-words dd { margin: .2rem 0 0; font-size: .9rem; line-height: 1.45; color: var(--ink-2); }

.rp-try { position: relative; border-radius: var(--r-sm); background: #1b1915; color: #f3eee6; overflow: hidden; }
:root[data-theme="dark"] .rp-try { background: #0b0a09; border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rp-try { background: #0b0a09; border: 1px solid var(--line); } }
.rp-try pre { margin: 0; padding: 44px 14px 14px; overflow-x: auto; font: 500 .82rem/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre; }
.rp-copy {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .65rem; border-radius: 8px;
  background: rgba(255, 255, 255, .1); color: #f3eee6; font-size: .74rem; font-weight: 600;
}
.rp-copy .svg { font-size: 14px; }
.rp-try-text { margin: 0; padding: 12px 14px; border-radius: var(--r-sm); border: 1px dashed var(--line-2); font-size: .98rem; line-height: 1.55; color: var(--ink); }
.rp-note { margin: 0 0 1.4rem; padding: 10px 14px; border-radius: var(--r-sm); background: var(--surface-2); font-size: .88rem; line-height: 1.5; color: var(--ink-2); }
.rp-note::before { content: "Note · "; font-weight: 700; color: var(--ink); }

.rp-cta { margin: 1.8rem 0 0; display: grid; gap: 10px; }
.rp-cta .btn { margin-top: 0; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
.rp-fine { margin: .2rem 0 0; text-align: center; font-size: .78rem; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  .view, .skeleton { animation: none; }
  .icon-btn { transition: none; }
}

/* ==========================================================================
   Today (home.html): one cover, one button, then quiet lists.
   iOS manners: a large title that hands off to a compact bar, grouped inset
   lists with hairlines, one tint (the button), springy presses.
   ========================================================================== */
.home {
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --hair: color-mix(in srgb, var(--ink) 11%, transparent);
  --group: var(--surface);
}

/* compact bar: invisible at rest, a blurred material once scrolled */
.nav {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: transparent;
  transition: background-color .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.nav .wrap { position: relative; display: flex; align-items: center; justify-content: flex-end; height: 48px; }
.nav-title {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -30%); opacity: 0;
  font-size: 1.06rem; font-weight: 600; white-space: nowrap;
  transition: opacity .25s var(--ease-out), transform .35s var(--ease-out);
}
.nav.solid {
  background: var(--head);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
  backdrop-filter: saturate(1.8) blur(20px);
  box-shadow: 0 .5px 0 var(--hair);
}
.nav.solid .nav-title { opacity: 1; transform: translate(-50%, -50%); }
.nav-btn {
  width: 34px; height: 34px; border-radius: 50%; position: relative;
  display: grid; place-items: center; font-size: 18px;
  color: var(--ink-2); background: color-mix(in srgb, var(--ink) 6%, transparent);
  transition: transform .4s var(--spring);
}
.nav-btn:active { transform: scale(.88); transition-duration: .1s; }

/* the masthead: the name and what it is, centred over the centred cover */
.home .nav { position: fixed; left: 0; right: 0; }
.home .nav .wrap { height: 56px; }
.masthead { padding: calc(env(safe-area-inset-top, 0px) + 4px) 48px 0 2px; text-align: left; }
.masthead h1 { margin: 0; font-family: Tinos, "Times New Roman", Times, serif; font-size: clamp(1.75rem, 8.2vw, 2.35rem); line-height: 1.05; font-weight: 400; letter-spacing: -.01em; }
.masthead h1 span { color: var(--accent); }
/* the emblem (sun, newspaper, chip) sits beside the name */
.masthead .brand { display: flex; align-items: center; gap: .7rem; }
.masthead .emblem { flex: none; width: 76px; height: auto; margin-left: -4px; }
.masthead p { margin: .35rem 0 0; font-size: 1rem; font-weight: 400; color: var(--ink-2); }
.masthead[hidden] + #hero { padding-top: calc(env(safe-area-inset-top, 0px) + 40px); }


/* the large title */
.large { margin: 0 0 .6rem; }
/* large titles share a line with the floating moon button, centred on it, like Today's masthead */
[data-view] .large { padding: calc(env(safe-area-inset-top, 0px) + var(--title-top, 9px)) 48px 0 2px; }
.eyebrow { margin: 0; font-size: .8rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-3); }
.large h1 { margin: 0; font-size: 2.1rem; line-height: 1.1; font-weight: 600; letter-spacing: -.01em; }
.tagline { margin: .3rem 0 0; font-size: .98rem; color: var(--ink-2); }

/* entrances: everything rises in, a beat apart */
.home .view { animation: none; }
.enter { animation: enter .7s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }

/* ---------- the cover: today's front page, as an object ---------- */
.stage {
  display: block; position: relative;
  padding: 20px 0 24px; margin: 0 -16px;
  -webkit-tap-highlight-color: transparent;
}
.stage::before {           /* a soft pool of light under the paper */
  content: ""; position: absolute; left: 50%; top: 52%; width: 86%; height: 78%;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 16%, transparent), transparent);
  filter: blur(18px); pointer-events: none;
}
.cover {
  position: relative; margin: 0 auto;
  width: min(58vw, 228px); height: min(77vw, 304px); overflow: hidden;
  padding: 14px 14px 0;
  background: var(--paper); color: var(--paper-ink);
  background-image: radial-gradient(ellipse at 50% 35%, transparent 55%, rgba(150, 110, 60, .2));
  border-radius: 3px;
  box-shadow:
    0 0 0 .5px rgba(40, 28, 12, .18),
    0 2px 4px rgba(30, 20, 8, .1),
    0 14px 28px -8px rgba(30, 20, 8, .28),
    0 34px 60px -20px rgba(30, 20, 8, .38);
  transition: transform .55s var(--spring), box-shadow .55s var(--ease-out);
}
.stage > .cover, .stage .cover { animation: settle 1s var(--ease-out) both; animation-delay: 210ms; }
@keyframes settle { from { opacity: 0; transform: translateY(26px) scale(.94) rotate(-2.5deg); } }
.stage:active .cover { transform: scale(.965); transition-duration: .15s; }
@media (hover: hover) { .stage:hover .cover { transform: translateY(-4px) rotate(-.6deg); } }
.c-name { font-family: var(--v-name); font-weight: 700; letter-spacing: -.01em; font-size: clamp(19px, 6vw, 25px); line-height: 1; text-align: center; white-space: nowrap; }
.c-folio {
  margin-top: 7px; padding: 3px 0 2px;
  border-top: 2px solid currentColor; border-bottom: 1px solid currentColor;
  display: flex; justify-content: space-between; gap: 6px;
  font-family: var(--v-head); font-size: 7.5px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
.c-folio span:last-child { overflow: hidden; text-overflow: ellipsis; }
.c-banner {
  margin: 7px 0; font-family: var(--v-banner); font-size: clamp(19px, 6vw, 26px); line-height: .92;
  text-align: center; text-transform: uppercase; text-wrap: balance;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.c-photo { position: relative; height: 34%; overflow: hidden; }
.c-photo img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) sepia(.35) contrast(1.05); mix-blend-mode: multiply; }
.c-photo::after { content: ""; position: absolute; inset: 0; background: radial-gradient(rgba(0,0,0,.18) 1px, transparent 1.3px) 0 0 / 3px 3px; mix-blend-mode: multiply; }
.c-cols { margin-top: 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; height: 100%; }
.c-cols i { background: repeating-linear-gradient(to bottom, rgba(29, 26, 21, .32) 0 1.5px, transparent 1.5px 5px); }
/* set at 2x and scaled down: Android WebView refuses text under ~8px */
.c-cols.text { width: 200%; height: 200%; gap: 12px; align-items: start; transform: scale(.5); transform-origin: 0 0; }
.c-col { font-family: var(--v-head); font-size: 9.2px; line-height: 1.32; text-align: justify; hyphens: auto; -webkit-hyphens: auto; overflow: hidden; }
.c-col + .c-col { border-left: 1px solid rgba(29, 26, 21, .35); padding-left: 12px; margin-left: -6px; }
.c-col b { display: block; margin-bottom: 4px; font-size: 12.8px; line-height: 1.1; text-align: left; font-weight: 700; }
.c-col p { margin: 0; text-indent: 1em; }
.skeleton-cover { background: var(--surface-2); box-shadow: none; animation: breathe 1.6s ease-in-out infinite !important; }
@keyframes breathe { 50% { opacity: .55; } }

/* ---------- under the cover ---------- */
.hero-text { text-align: center; padding: 0 6px; }
.status { margin: 0; display: inline-flex; align-items: center; gap: .45rem; font-size: .8rem; font-weight: 600; color: var(--ink-3); }
.live { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 2.4s var(--ease-out) infinite; }
@keyframes ping { 0% { transform: scale(1); opacity: .6; } 70%, 100% { transform: scale(2.8); opacity: 0; } }
.hero-title {
  margin: .45rem auto 0; max-width: 22rem;
  font-size: 1.45rem; line-height: 1.22; font-weight: 600; letter-spacing: -.005em;
}
.hero-meta { margin: .55rem 0 0; font-size: .88rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bar { margin: 1rem auto 0; max-width: 12rem; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: var(--ink); animation: fill 1.1s var(--ease-out) .6s both; }
@keyframes fill { from { width: 0; } }
.cta {
  margin: 1.1rem auto 0; max-width: 22rem; min-height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--btn); color: var(--btn-ink);
  font-size: 1.06rem; font-weight: 500;
  box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--btn) 70%, transparent);
  transition: transform .45s var(--spring), opacity .2s;
}
.cta:active { transform: scale(.96); opacity: .9; transition-duration: .1s; }

/* ---------- section heads and grouped lists ---------- */
.sec-head { margin: 2.6rem 0 .6rem; padding: 0 2px; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.sec-head h2 { margin: 0; font-size: 1.3rem; font-weight: 600; letter-spacing: -.005em; }
.sec-head a { font-size: .95rem; color: var(--accent-ink); }
.sec-note { margin: -.2rem 0 .8rem; padding: 0 2px; font-size: .9rem; line-height: 1.45; color: var(--ink-2); }

.group { background: var(--group); border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 .5px var(--hair); }
.item {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 13px 14px 13px 16px;
  transition: background-color .25s;
}
.item + .item::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--hair); }
.item:active { background: color-mix(in srgb, var(--ink) 6%, transparent); transition-duration: 0s; }
.item-main { min-width: 0; display: block; }
.item-desk { display: block; font-size: .76rem; font-weight: 500; color: var(--ink-3); }
.item-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: .1rem; font-size: 1.02rem; line-height: 1.3; font-weight: 500; color: var(--ink);
}
.item-line { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: .2rem; font-size: .88rem; line-height: 1.4; color: var(--ink-2); }
.item-end { display: inline-flex; align-items: center; gap: 2px; font-size: .82rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.item-end .svg { font-size: 15px; opacity: .7; }
.item-note { display: inline-block; margin-top: .3rem; font-size: .76rem; font-weight: 600; color: var(--accent-ink); }
.item-note.done { color: var(--ink-3); }
.item.ed { grid-template-columns: 52px minmax(0, 1fr) auto; }
.item.ed + .item.ed::before { left: 80px; }
.ed-thumb { width: 52px; height: 64px; border-radius: 4px; overflow: hidden; background: var(--paper); box-shadow: 0 0 0 .5px rgba(0,0,0,.12), 0 4px 10px -6px rgba(0,0,0,.4); }
.ed-thumb img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) sepia(.3); mix-blend-mode: multiply; }
.month { margin: 1.8rem 0 .5rem; padding: 0 2px; font-size: .8rem; font-weight: 600; color: var(--ink-3); }
.month:first-child { margin-top: 0; }

/* ---------- earlier editions: a shelf of small covers ---------- */
.shelf {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 6px 16px 14px; scroll-padding: 0 16px;
  scrollbar-width: none;
}
.shelf::-webkit-scrollbar { display: none; }
.spine { flex: none; width: 112px; scroll-snap-align: start; }
.cover.sm { width: 112px; height: auto; aspect-ratio: 3 / 4; padding: 8px 8px 0; animation: none; transition: transform .45s var(--spring); }
.spine:active .cover.sm { transform: scale(.95); transition-duration: .12s; }
.cover.sm .c-name { font-size: 12.5px; }
.cover.sm .c-folio { margin-top: 4px; padding: 2px 0 1px; font-size: 5px; border-top-width: 1.5px; }
.cover.sm .c-photo { margin-top: 6px; height: 42%; }
.cover.sm .c-cols { margin-top: 5px; gap: 4px; }
.spine-date { display: block; margin-top: .6rem; font-size: .86rem; font-weight: 600; letter-spacing: -.01em; }
.spine-note { display: block; font-size: .78rem; color: var(--ink-3); }

/* ---------- the fine print ---------- */
.fine { margin: 3rem 0 0; text-align: center; font-size: .8rem; color: var(--ink-3); }
.fine p { margin: 0; }
.fine nav { margin-top: .45rem; display: flex; justify-content: center; gap: .5rem; }
.fine nav a { color: var(--ink-2); }

/* ---------- tab bar, iOS-thin ---------- */
.home .tabs { border-top: 0; box-shadow: 0 -.5px 0 var(--hair); -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); }
.home .tab { font-size: .68rem; font-weight: 500; transition: color .2s; }
.home .tab .svg { transition: transform .4s var(--spring); }
.home .tab:active .svg { transform: scale(.86); transition-duration: .1s; }
.home main.wrap { padding-bottom: calc(var(--tabs-h) + 2.4rem + env(safe-area-inset-bottom, 0px)); }

@media (prefers-reduced-motion: reduce) {
  .enter, .stage .cover, .live::after, .bar i, .skeleton-cover { animation: none !important; }
  .cover, .cta, .nav-btn, .nav-title, .home .tab .svg { transition: none; }
}

/* ---------- Reading Room tab ---------- */

.rr-feat {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 20px 18px 18px; border-radius: 20px;
  background: var(--surface); box-shadow: 0 0 0 .5px var(--hair), 0 12px 28px -20px rgba(40, 28, 12, .35);
  transition: transform .45s var(--spring);
}
.rr-feat:active { transform: scale(.98); transition-duration: .12s; }
.rr-k { font-size: .78rem; font-weight: 500; color: var(--ink-3); }
.rr-num { margin-top: .9rem; font-size: 2.2rem; line-height: 1; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.rr-lab { margin-top: .3rem; font-size: .84rem; color: var(--ink-3); }
.rr-t { margin-top: 1rem; font-size: 1.2rem; line-height: 1.28; font-weight: 600; }
.rr-l { margin-top: .4rem; font-size: .95rem; line-height: 1.45; color: var(--ink-2); }
.rr-go { margin-top: 1.1rem; padding: .6rem 1.05rem; border-radius: 999px; background: var(--btn); color: var(--btn-ink); font-size: .92rem; font-weight: 500; }
@media (prefers-reduced-motion: reduce) { .rr-feat { transition: none; } }


/* ---------- Profile tab ---------- */

.who { display: flex; align-items: center; gap: 14px; padding: 16px; }
.who-mark { width: 56px; height: 56px; border-radius: 14px; flex: none; box-shadow: 0 0 0 .5px var(--hair); }
.who-main { min-width: 0; display: grid; gap: 1px; }
.who-main b { font-size: 1.25rem; font-weight: 600; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.who-main span { font-size: .9rem; color: var(--ink-2); }
.who-main .faint { font-size: .82rem; color: var(--ink-3); }
.plan { margin-top: 12px; padding: 16px 18px; border-radius: 14px; background: var(--accent-soft); }
.plan-k { font-size: .78rem; font-weight: 500; color: var(--accent-ink); }
.plan b { display: block; margin-top: .15rem; font-size: 1.3rem; font-weight: 600; }
.plan p { margin: .35rem 0 0; font-size: .9rem; line-height: 1.45; color: var(--ink-2); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 11px; background: color-mix(in srgb, var(--ink) 7%, transparent); }
.seg a { padding: .55rem 0; border-radius: 9px; text-align: center; font-size: .92rem; font-weight: 500; color: var(--ink-2); transition: background-color .2s; }
.seg a[aria-checked="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px var(--hair); }
button.item { width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.item.pf { grid-template-columns: 30px minmax(0, 1fr) auto; padding-top: 11px; padding-bottom: 11px; }
.item.pf + .item.pf::before { left: 58px; }
.pf-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 17px; color: var(--ink-2); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.item.pf .item-title { -webkit-line-clamp: 1; margin: 0; }
.item.pf.danger .item-title, .item.pf.danger .pf-ico { color: #c4342b; }
.item.pf.danger .pf-ico { background: rgba(196, 52, 43, .1); }
[data-view="profile"] .fine { margin-top: 2rem; }

/* the action sheet: slides up from the bottom, iOS-style */
.sheet-scrim { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0); transition: background-color .26s; }
.sheet-scrim.open { background: rgba(0, 0, 0, .32); }
.action-sheet { width: min(100%, 36rem); padding: 0 10px calc(env(safe-area-inset-bottom, 0px) + 10px); transform: translateY(105%); transition: transform .34s cubic-bezier(.22, 1, .36, 1); }
.sheet-scrim.open .action-sheet { transform: none; }
.as-card, .as-cancel { border-radius: 14px; background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6); }
.as-card { text-align: center; overflow: hidden; }
.as-title { margin: 0; padding: 16px 18px 0; font-size: .95rem; font-weight: 600; color: var(--ink); }
.as-msg { margin: .3rem 0 0; padding: 0 20px 14px; font-size: .86rem; line-height: 1.4; color: var(--ink-3); }
.as-err { margin: 0; padding: 0 20px 12px; font-size: .84rem; color: #c4342b; }
.as-btn { display: block; padding: 15px; border-top: .5px solid var(--hair); font-size: 1.08rem; font-weight: 500; color: var(--accent-ink); }
.as-btn.danger { color: #c4342b; }
.as-cancel { margin-top: 8px; width: 100%; padding: 15px; border: 0; font: inherit; font-size: 1.08rem; font-weight: 600; color: var(--accent-ink); cursor: pointer; }
.as-btn:active, .as-cancel:active { background: color-mix(in srgb, var(--ink) 8%, var(--bg)); }
@media (prefers-reduced-motion: reduce) { .sheet-scrim, .action-sheet { transition: none; } }
[data-view="profile"] .month, [data-view="profile"] .month:first-child { margin-top: 1.8rem; }

.nav-btn::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; }   /* 44px hit area */

/* ---------- 5. iOS 26: scroll edge effect + floating glass tab bar ---------- */
/* the top bar fades content out beneath it instead of drawing a hairline */
.nav.solid { box-shadow: none; }
.nav::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 18px; pointer-events: none;
  background: linear-gradient(var(--head), transparent); opacity: 0; transition: opacity .3s;
}
.nav.solid::after { opacity: 1; }

/* the tab bar floats as a glass capsule above the content, which fades out beneath it */
.home .tabs {
  left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  max-width: 34rem; margin: 0 auto; padding: 0;
  border-radius: 999px; border: 0;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6);
  box-shadow: 0 0 0 .5px var(--hair), 0 10px 30px -12px rgba(0, 0, 0, .35);
}
.home .tabs .wrap { height: 62px; padding: 0 6px; }
.home .tab { border-radius: 999px; margin: 5px 0; gap: 3px; }
.home .tab[aria-current="page"] { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.home::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 24; pointer-events: none;
  height: calc(env(safe-area-inset-bottom, 0px) + 96px);
  background: linear-gradient(transparent, color-mix(in srgb, var(--bg) 85%, transparent) 70%);
}
.home main.wrap { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 7rem); }

/* ---------- 4. accessibility states for the glass ---------- */
@media (prefers-reduced-transparency: reduce) {
  .nav.solid, .home .tabs, .as-card, .as-cancel { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .home::after, .nav::after { display: none; }
}
@media (prefers-contrast: more) {
  :root { --ink-3: var(--ink-2); }
  .home .tabs, .group, .seg, .as-card, .as-cancel { box-shadow: 0 0 0 1px var(--ink-3); }
  .nav.solid { box-shadow: 0 1px 0 var(--ink-3); }
  .item + .item::before { background: var(--ink-3); }
}

/* ---------- Morning Reminder: iOS switch and time pill ---------- */
label.item.rem { cursor: pointer; }
.item.pf.rem { grid-template-columns: 30px minmax(0, 1fr) auto; }
.item.rem .item-desk { margin-top: .1rem; }
.switch {
  -webkit-appearance: none; appearance: none; margin: 0; flex: none;
  width: 51px; height: 31px; border-radius: 999px; position: relative; cursor: pointer;
  background: color-mix(in srgb, var(--ink) 16%, transparent); transition: background-color .25s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 0 0 .5px rgba(0, 0, 0, .06);
  transition: transform .3s cubic-bezier(.34, 1.3, .64, 1);
}
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }
.time-pill {
  -webkit-appearance: none; appearance: none; border: 0; margin: 0;
  padding: .4rem .7rem; border-radius: 8px; font: inherit; font-size: .98rem; font-weight: 500;
  color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); font-variant-numeric: tabular-nums;
}
.time-pill::-webkit-calendar-picker-indicator { display: none; }
#rem-time-row.off { opacity: .45; }
#rem-time-row.off .time-pill { pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }
