/* ============================================================
   The Big Questions · 大哉問 — design system
   A dark "codex at candlelight" aesthetic: ink-indigo fields,
   a warm amber flame (reason), dusk-violet (the unknown / 形上),
   and terracotta (value, flesh, feeling). Serif narrative,
   generous reading measure. Sibling to the physics codex, not
   a twin: where that one glowed cold cyan, this one glows warm.
   ============================================================ */

:root {
  /* Palette — indigo dusk with a candle burning in it */
  --ink: #07060e; /* page void            */
  --ink-2: #0d0c18; /* raised surface       */
  --ink-3: #161526; /* card / inset         */
  --line: #2a2740; /* hairlines            */
  --line-soft: #1c1a2c;
  --text: #ece8f2; /* primary prose        */
  --text-dim: #a6a2b8; /* secondary            */
  --text-faint: #847f98; /* captions, meta — ≥4.5:1 on every surface */

  --accent: #eab65c; /* candlelight amber — "reason / the flame"   */
  --accent-2: #8f8ae0; /* dusk indigo-violet — "the unknown / 形上" */
  --accent-3: #d98a6a; /* terracotta — "value / flesh / feeling"    */
  --glow: rgba(234, 182, 92, 0.33);

  /* Type */
  --serif:
    "Iowan Old Style", "Palatino Linotype", "Palatino", "Georgia",
    "Noto Serif TC", "Songti TC", serif;
  --sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Noto Sans TC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;

  --measure: 42rem; /* reading width */
  --gutter: clamp(1rem, 4vw, 1.25rem); /* side gutter: 16px on phones */
  --tap: 2.5rem; /* minimum touch target (40px) */
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- reset-ish ---------- */
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--serif);
  /* ~17px on a 390px phone, 18.9px from ~1000px up */
  font-size: clamp(1.02rem, 0.96rem + 0.45vw, 1.18rem);
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  /* the page never scrolls sideways; wide content scrolls inside its own box */
  overflow-x: hidden;
  overflow-x: clip;
}

/* candlelit wash behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(
      1200px 700px at 78% -8%,
      rgba(234, 182, 92, 0.1),
      transparent 60%
    ),
    radial-gradient(
      900px 600px at 10% 108%,
      rgba(143, 138, 224, 0.1),
      transparent 60%
    ),
    var(--ink);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
a:hover {
  color: #f4ca7e;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}
pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  max-width: 100%;
  border-collapse: collapse;
}
/* wrap anything wider than the measure (tables, diagrams) in .scroll-x */
.scroll-x,
.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* ---------- keyboard focus ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
:focus:not(:focus-visible) {
  outline: none;
}
.card:focus-visible,
.btn:focus-visible,
.chip:focus-visible,
.ch-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

/* ---------- layout ---------- */
.wrap {
  width: min(100% - 2 * var(--gutter), 68rem);
  margin-inline: auto;
}
.prose {
  width: min(100% - 2 * var(--gutter), var(--measure));
  margin-inline: auto;
}

section {
  padding-block: clamp(2.5rem, 6vw, 5rem);
}

/* ---------- top nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.5rem clamp(1rem, 4vw, 2.2rem);
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--sans);
}
.nav__brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-shrink: 0;
  min-height: var(--tap);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.nav__brand b {
  font-weight: 700;
}
.nav__brand .zh {
  color: var(--text);
}
.nav__brand .la {
  color: var(--text-faint);
  font-style: italic;
  font-size: 0.82em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.nav__links {
  display: flex;
  gap: clamp(0.7rem, 2.5vw, 1.4rem);
  font-size: 0.9rem;
  /* a sideways-scrolling strip on narrow screens — never traps the page */
  min-width: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav__links::-webkit-scrollbar {
  display: none;
}
.nav__links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.15rem;
  color: var(--text-dim);
}
.nav__links a:hover {
  color: var(--text);
}
@media (max-width: 400px) {
  .nav__brand .la {
    display: none;
  }
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  padding-block: clamp(4rem, 12vw, 8rem) clamp(2rem, 6vw, 4rem);
  text-align: center;
}
.hero__eyebrow {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.4rem;
}
.hero h1 {
  font-size: clamp(2.1rem, 1.2rem + 5vw, 5rem);
  line-height: 1.08;
  text-wrap: balance;
  margin: 0 0 1.2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.hero h1 .glow {
  color: #fff;
  text-shadow: 0 0 36px var(--glow);
}
.hero__lede {
  width: min(100% - 2.5rem, 36rem);
  margin: 0 auto;
  color: var(--text-dim);
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  line-height: 1.6;
}
.hero__sub {
  margin-top: 1.5rem;
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 0.9rem;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  min-height: var(--tap);
  padding: 0.6rem 1.3rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--ink-3);
  transition: all 0.25s var(--ease);
  touch-action: manipulation;
}
.btn:hover {
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(234, 182, 92, 0.08);
  transform: translateY(-1px);
}
.btn--ghost {
  background: transparent;
}
.btn-row {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* ---------- the "map" of chapters ---------- */
.map {
  display: grid;
  /* 1 column on phones, 2 on tablets, 3–4 on wide screens */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: clamp(0.75rem, 2vw, 1rem);
}
.card {
  position: relative;
  display: block;
  padding: clamp(1.1rem, 3vw, 1.4rem) clamp(1.1rem, 3vw, 1.4rem) 1.5rem;
  min-width: 0;
  background: linear-gradient(160deg, var(--ink-2), var(--ink));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  transition: all 0.3s var(--ease);
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    400px 200px at var(--mx, 50%) var(--my, 0%),
    rgba(234, 182, 92, 0.1),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
}
.card:hover {
  border-color: var(--line);
  transform: translateY(-3px);
}
.card:hover::after {
  opacity: 1;
}
.card__no {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  letter-spacing: 0.1em;
}
.card__title {
  font-size: 1.3rem;
  margin: 0.5rem 0 0.4rem;
  color: var(--text);
  font-weight: 500;
}
.card__title .la {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-top: 0.25rem;
}
.card__desc {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0;
}
.card__tag {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid var(--line-soft);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}
.card--ready .card__tag {
  color: var(--accent-3);
  border-color: color-mix(in srgb, var(--accent-3) 40%, transparent);
}
/* chapters not yet written: a dimmed, non-interactive door */
.card--soon {
  cursor: default;
  opacity: 0.62;
}
.card--soon:hover {
  transform: none;
  border-color: var(--line-soft);
}
.card--soon:hover::after {
  opacity: 0;
}

/* ---------- section headings ---------- */
.kicker {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
}
.section-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 500;
  margin: 0.6rem 0 1rem;
  letter-spacing: -0.01em;
}

/* ---------- chapter / prose ---------- */
.chapter-head {
  padding-block: clamp(3rem, 8vw, 6rem) 1rem;
  text-align: center;
}
.chapter-head .no {
  font-family: var(--mono);
  color: var(--accent-3);
  letter-spacing: 0.2em;
  font-size: 0.9rem;
}
.chapter-head h1 {
  font-size: clamp(2rem, 1.1rem + 4.5vw, 4rem);
  font-weight: 500;
  margin: 0.8rem 0 0.4rem;
  line-height: 1.1;
  text-wrap: balance;
}
.chapter-head .la {
  font-family: var(--sans);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-size: 0.85rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.35rem;
}
.prose h2 {
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2rem);
  font-weight: 500;
  margin: clamp(2.2rem, 5vw, 3rem) 0 1rem;
  letter-spacing: -0.01em;
}
.prose h2 .n {
  font-family: var(--mono);
  font-size: 0.6em;
  color: var(--accent);
  margin-right: 0.6rem;
  vertical-align: 0.15em;
}
.prose h3 {
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.3rem);
  font-weight: 600;
  color: var(--text);
  margin: 2rem 0 0.8rem;
  font-family: var(--sans);
}
.prose strong {
  color: #fff;
  font-weight: 600;
}
.prose em {
  color: var(--accent);
  font-style: italic;
}
.lead {
  font-size: clamp(1.14rem, 1.02rem + 0.55vw, 1.32rem);
  color: var(--text-dim);
  line-height: 1.7;
}
.prose blockquote {
  margin: 2rem 0;
  padding: 0.4rem 0 0.4rem clamp(1rem, 3vw, 1.4rem);
  border-left: 2px solid var(--accent-2);
  color: var(--text-dim);
  font-style: italic;
}
.prose blockquote cite {
  display: block;
  font-style: normal;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  letter-spacing: 0.04em;
}

/* drop-cap on the opening paragraph */
.prose .opening::first-letter {
  font-size: 3.4em;
  float: left;
  line-height: 0.8;
  padding: 0.05em 0.12em 0 0;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- callouts: worldview, core-debate & aside ---------- */
.callout {
  margin: 2.2rem 0;
  padding: clamp(1rem, 3vw, 1.3rem) clamp(1rem, 3.5vw, 1.4rem);
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  background: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.98rem;
  line-height: 1.65;
}
.callout__label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
  font-weight: 600;
}
.callout p:last-child {
  margin-bottom: 0;
}
.callout--world {
  border-left: 3px solid var(--accent);
}
.callout--world .callout__label {
  color: var(--accent);
}
.callout--philo {
  border-left: 3px solid var(--accent-2);
}
.callout--philo .callout__label {
  color: var(--accent-2);
}
.callout--aside {
  border-left: 3px solid var(--text-faint);
  background: transparent;
}
.callout--aside .callout__label {
  color: var(--text-faint);
}

/* a two-column "position vs position" battlefield grid inside prose */
.versus {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin: 2rem 0;
}
.versus > * {
  min-width: 0;
}
@media (max-width: 560px) {
  .versus {
    grid-template-columns: 1fr;
  }
}
.stance {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--ink-2);
  padding: clamp(0.9rem, 3vw, 1.2rem);
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.6;
}
.stance h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--text);
}
.stance .for,
.stance .against {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-dim);
}
.stance .for b {
  color: var(--accent);
  font-weight: 600;
}
.stance .against b {
  color: var(--accent-3);
  font-weight: 600;
}

/* ---------- interactive figure frame ---------- */
.figure {
  margin: 2.6rem 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-2);
  overflow: hidden;
}
.figure__stage {
  position: relative;
  background: radial-gradient(120% 140% at 50% 0%, #110e1c, #07060e);
}
.figure__stage > * {
  min-width: 0; /* grid/flex children may not push the stage wider than the page */
}
/* Two panels side by side. Set the ratio per figure with the --split custom
   property (e.g. style="--split: 1.6fr 1fr"); a phone stacks them. */
.figure__stage--split {
  display: grid;
  grid-template-columns: var(--split, 1.5fr 1fr);
  gap: 0;
}
@media (max-width: 640px) {
  .figure__stage--split {
    grid-template-columns: 1fr;
  }
  .figure__stage--split > * {
    border-left: 0 !important; /* inline divider from the side-by-side layout */
    grid-column: 1 / -1;
  }
  .figure__stage--split > * + * {
    border-top: 1px solid var(--line-soft);
  }
}
.figure canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  /* a finger on a canvas still scrolls the page; drag interactives opt out */
  touch-action: pan-y pinch-zoom;
}
.figure canvas[data-pointer="drag"] {
  touch-action: none;
}
.figure__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.5rem;
  align-items: center;
  padding: clamp(0.8rem, 2.5vw, 1rem) clamp(0.9rem, 3vw, 1.2rem);
  border-top: 1px solid var(--line-soft);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-dim);
}
.figure__caption {
  padding: 0.9rem clamp(0.9rem, 3vw, 1.2rem);
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--text-faint);
  border-top: 1px solid var(--line-soft);
  line-height: 1.5;
}
.ctrl {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1 1 9rem;
  min-width: 9rem;
  max-width: 100%;
}
.ctrl label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ctrl output {
  font-family: var(--mono);
  color: var(--accent);
}
/* sliders: a 3px track drawn inside a 40px-tall hit area */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 100%;
  height: var(--tap);
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y; /* horizontal drags move the thumb, vertical ones scroll */
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7.5px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px var(--glow);
}
input[type="range"]::-moz-range-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px var(--glow);
}
input[type="range"]:focus-visible {
  outline: none;
}
input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow:
    0 0 0 3px var(--ink-2),
    0 0 0 5px var(--accent);
}
input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow:
    0 0 0 3px var(--ink-2),
    0 0 0 5px var(--accent);
}
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.2;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: pointer;
  background: transparent;
  transition: all 0.2s;
  touch-action: manipulation;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}
.chip--on {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent);
}
.readout {
  max-width: 100%;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.readout b {
  color: var(--accent-3);
}

/* KaTeX sizing inside prose */
.katex-display {
  margin: 1.6rem 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3rem 0.1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.katex {
  font-size: 1.04em;
}

/* ---------- chapter footer nav ---------- */
.ch-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 4rem 0 0;
  font-family: var(--sans);
}
.ch-nav a {
  flex: 1;
  min-width: 0;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--ink-2);
  transition: all 0.25s var(--ease);
}
.ch-nav a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.ch-nav .dir {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ch-nav .t {
  display: block;
  color: var(--text);
  margin-top: 0.25rem;
}
.ch-nav .next {
  text-align: right;
}
@media (max-width: 640px) {
  .ch-nav {
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 3rem;
  }
}

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--line-soft);
  padding: 3rem 0;
  text-align: center;
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 0.85rem;
}
.footer a {
  color: var(--text-dim);
}

/* ---------- "under construction" chapter stub ---------- */
.stub {
  text-align: center;
  padding-block: clamp(3rem, 10vw, 7rem);
}
.stub .glyph {
  font-size: 3rem;
  opacity: 0.5;
}
.stub p {
  color: var(--text-dim);
  font-family: var(--sans);
}

/* reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.7s var(--ease),
    transform 0.7s var(--ease);
}
.reveal.in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .card:hover,
  .btn:hover,
  .ch-nav a:hover {
    transform: none;
  }
}
/* hover lifts are pointless (and sticky) on touch screens */
@media (hover: none) {
  .card:hover,
  .btn:hover,
  .ch-nav a:hover {
    transform: none;
  }
}

/* ============================================================
   Reader notes (js/notes.js) — highlights, selection bar, popover,
   answer boxes, dock, and the /notes/ review page.
   ============================================================ */
/* note colours are the same on every sibling site: gold = key point,
   violet = open question, blue = answered */
:root {
  --nt-key: #ffd479;
  --nt-ask: #b69bff;
  --nt-done: #7cc5ff;
}
::highlight(nt-key) {
  background-color: rgba(255, 212, 121, 0.3);
  color: #fff;
}
::highlight(nt-ask) {
  background-color: rgba(182, 155, 255, 0.34);
  color: #fff;
}
::highlight(nt-done) {
  background-color: rgba(124, 197, 255, 0.2);
}
::highlight(nt-flash) {
  background-color: rgba(255, 255, 255, 0.85);
  color: #05060a;
}
.prose.nt-over {
  cursor: pointer;
}
/* 只看畫線: keep section headings and the blocks that carry a note */
.nt-focus article.prose > :not(.nt-has):not(.nt-answer):not(h2) {
  display: none;
}

.nt-bar {
  position: fixed;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--ink-3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  font-family: var(--sans);
}
.nt-bar[hidden] {
  display: none;
}
.nt-bar--bottom {
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
}
.nt-bar__btn {
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  touch-action: manipulation;
}
.nt-bar__btn::before {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.45em;
  border-radius: 50%;
  background: currentColor;
}
.nt-bar__btn--key {
  color: var(--nt-key);
}
.nt-bar__btn--ask {
  color: var(--nt-ask);
}
.nt-bar__btn:hover {
  border-color: currentColor;
}
.nt-bar__msg {
  padding: 0 0.8rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: var(--tap);
}

.nt-pop {
  position: absolute;
  z-index: 70;
  width: min(22rem, calc(100vw - 16px));
  padding: 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--ink-3);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
  font-family: var(--sans);
}
.nt-pop__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nt-pop__row--end {
  justify-content: space-between;
}
.nt-pop__text {
  display: block;
  width: 100%;
  margin: 0.7rem 0;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.55;
  resize: vertical;
}
.nt-pop__del {
  min-height: var(--tap);
  padding: 0 0.4rem;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.nt-pop__del:hover,
.nt-pop__del[data-armed] {
  color: #ff8f8f;
}

.nt-answer {
  margin: 1.4rem 0 2rem;
  padding: clamp(0.9rem, 3vw, 1.2rem) clamp(1rem, 3.5vw, 1.4rem);
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--nt-done);
  background: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.96rem;
  line-height: 1.7;
}
.nt-answer__label {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  font-weight: 600;
  color: var(--nt-done);
  margin-bottom: 0.5rem;
}
.nt-answer__q {
  color: var(--text-dim);
  font-size: 0.88rem;
}
.nt-answer p {
  margin: 0 0 0.7rem;
}
.nt-answer p:last-child {
  margin-bottom: 0;
}

.nt-dock {
  position: fixed;
  z-index: 60;
  right: max(0.8rem, env(safe-area-inset-right, 0px));
  bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--sans);
}
.nt-dock__btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink-3) 92%, transparent);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  touch-action: manipulation;
}
.nt-dock__btn:hover,
.nt-dock__btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--text);
}
.nt-dock__btn:disabled {
  opacity: 0.45;
  cursor: default;
  border-color: var(--line);
  color: var(--text-dim);
}
.nt-dock__warn {
  font-size: 0.8rem;
  color: #ff8f8f;
}

.nt-badge {
  display: inline-block;
  margin-top: 0.7rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--nt-key);
}

/* /notes/ review page */
.nt-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1.5rem 0 0.6rem;
}
.nt-status {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--text-faint);
}
.nt-item {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--nt-key);
  background: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.65;
}
.nt-item--ask {
  border-left-color: var(--nt-ask);
}
.nt-item--done {
  border-left-color: var(--nt-done);
}
.nt-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.nt-item__quote {
  margin: 0.5rem 0;
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--text);
  white-space: pre-line;
}
.nt-item__note {
  margin: 0.4rem 0;
  color: var(--nt-ask);
}
.nt-item__answer {
  margin: 0.6rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line-soft);
  color: var(--text-dim);
}
.nt-item__answer p {
  margin: 0 0 0.6rem;
}
.nt-item__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
}
