@property --cx { syntax: '<length>'; inherits: true; initial-value: 0px; }
@property --cy { syntax: '<length>'; inherits: true; initial-value: 0px; }

/* Night (default): a dark room and a lamp. Colours that need transparency are RGB triplets. */
:root {
  color-scheme: dark;
  --bg: #06080c;
  --bg-1: #0c111b;            /* gradient stops around the light */
  --bg-2: #070a10;
  --bg-3: #040508;
  --fg: 220, 228, 245;        /* interface text */
  --fg2: 200, 212, 236;       /* secondary text */
  --frame: 160, 180, 220;     /* lines, borders, the rail */
  --tint: 255, 255, 255;      /* faint surface tints */
  --surface: 12, 16, 25;      /* panels */
  --surface-solid: #0c1019;
  --pop: 20, 26, 40;          /* toasts, tooltips */
  --overlay: 4, 5, 8;
  --warn: 255, 205, 150;
  --danger: 255, 150, 150;
  --blend: screen;            /* how the light mixes with the page */
  --ghost: #9fb0d0;           /* unlit letters of the intro */
  --strike: #fff;             /* the flash of a freshly typed letter */
  --ink: rgba(186, 200, 228, 0.46);   /* written text outside the light: quiet but readable (~3:1) */
  --lit: #e8efff;
  --dim: rgba(186, 200, 228, 0.66);   /* interface text: ≥4.5:1 */
  --ring: 200, 220, 255;              /* keyboard focus ring */
  --line: rgba(160, 180, 220, 0.1);
  --glow: 150, 186, 255;      /* lamp colour: set by the colour slider, warms to gold near your goal */
  --glow-hi: 200, 220, 255;
  --glow-lo: 110, 144, 224;
  --lamp-i: 1;                /* lamp intensity (intensity slider) */
  --font: 'Courier Prime', 'Courier New', ui-monospace, monospace;
  --scale: 1;
  --lamp: 1;
  --size: calc(clamp(18px, 0.7vw + 12px, 24px) * var(--scale));
  --lh: 1.9;
  --rail: 58vh;
  --x-dur: .14s;
}

/* Day: a muted, warm room in daylight. Dark ink; the lamp brightens the page in a soft warm cone. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #7a6f66;
  --bg-1: #857a70;            /* a little lighter around the lamp */
  --bg-2: #786d64;
  --bg-3: #675e57;
  --fg: 28, 24, 20;
  --fg2: 44, 38, 32;
  --frame: 34, 29, 24;
  --tint: 255, 248, 236;
  --surface: 232, 225, 214;
  --surface-solid: #e8e1d6;
  --pop: 238, 232, 222;
  --overlay: 58, 50, 44;
  --warn: 120, 64, 8;
  --danger: 150, 30, 30;
  --blend: screen;
  --ghost: #8d8279;
  --strike: #000;
  --ink: rgba(24, 20, 17, 0.8);
  --lit: #1c1814;
  --dim: rgba(22, 19, 16, 0.92);
  --ring: 24, 20, 16;
  --line: rgba(34, 29, 24, 0.16);
}
:root[data-theme="light"] .lit { text-shadow: none; }
:root[data-theme="light"] .top-btn, :root[data-theme="light"] .act-btn,
:root[data-theme="light"] .seg, :root[data-theme="light"] .clock {
  background: rgba(244, 239, 231, .94); border-color: transparent; color: #1c1814;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
:root[data-theme="light"] .seg .act-btn { background: none; box-shadow: none; }
:root[data-theme="light"] .top-btn:hover, :root[data-theme="light"] .act-btn:hover { background: #fffaf2; color: #000; }
:root[data-theme="light"] .status, :root[data-theme="light"] .streak, :root[data-theme="light"] .brand {
  background: rgba(244, 239, 231, .78); color: #1c1814; padding: 6px 12px; border-radius: 999px;
}
:root[data-theme="light"] .streak:empty { display: none; }
:root[data-theme="light"] .hint, :root[data-theme="light"] .prompt { color: #14110e; }
:root[data-theme="light"] #promptText { background: rgba(244, 239, 231, .6); padding: 2px 10px; border-radius: 8px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
:root[data-theme="light"] .prompt button { color: #14110e; background: rgba(244, 239, 231, .6); }
:root[data-theme="light"] .toast { background: rgba(244, 239, 231, .96); color: #1c1814; }
:root[data-theme="light"] .rail { background: linear-gradient(90deg, rgba(28, 24, 20, .5), rgba(28, 24, 20, .7) 50%, rgba(28, 24, 20, .5)); height: 2px; }
/* by day the lamp throws a wider, softer cone */
:root[data-theme="light"] .haze { left: -280px; width: 560px; height: 400px; opacity: .75; }
:root[data-theme="light"] .core { left: -150px; width: 300px; height: 260px; }
:root[data-theme="light"] .bloom { left: -320px; width: 640px; top: -130px; height: 150px; }
:root[data-theme="light"] .pill { box-shadow: 0 0 10px rgba(var(--glow), .5), 0 1px 2px rgba(0, 0, 0, .35); }
:root[data-theme="light"] .lit .caret::after { box-shadow: none; }
/* settings, panel and other surfaces are light cards on the muted room */
:root[data-theme="light"] .sheet-card,
:root[data-theme="light"] .panel { color: rgba(var(--fg), .9); }
:root[data-theme="light"] .panel { background: radial-gradient(120% 80% at 50% 0%, #ece6dc 0%, #e2dacd 60%, #d6cdbf 100%); }
:root[data-theme="light"] .pn-star.on { color: #a8661b; text-shadow: none; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); overflow: hidden; overscroll-behavior: none; }
body {
  color: var(--lit);
  font: var(--size)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  cursor: text;
}
[hidden] { display: none !important; }
/* text only for screen readers */
.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; }

.stage {
  position: fixed; left: 0; right: 0; top: 0; height: 100%;
  background: radial-gradient(120% 90% at 50% var(--rail), var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  overflow: hidden;
}

/* ---------- the paper ---------- */
.paper {
  position: absolute; left: 0; right: 0; top: 0; height: var(--rail);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 72%);
          mask-image: linear-gradient(to bottom, transparent 0%, #000 72%);
}
.page {
  position: absolute; top: 0; left: 0; right: 0; margin: 0 auto;
  width: min(38em, calc(100vw - 40px));
  will-change: transform;
}
.ink, .lit { white-space: pre-wrap; overflow-wrap: break-word; }
.ready .page {
  transition: transform .5s cubic-bezier(.3, .7, .2, 1),
              --cx var(--x-dur) cubic-bezier(.2, .8, .2, 1),
              --cy .5s cubic-bezier(.3, .7, .2, 1);
}
.ready.snap .page, .ready.snap .carriage { transition: none; }
.ink { color: var(--ink); }
.lit {
  position: absolute; inset: 0;
  color: var(--lit);
  text-shadow: 0 0 10px rgba(var(--glow), .35);
  -webkit-mask-image: radial-gradient(9em 3.4em at calc(var(--cx) - 1.2em) var(--cy), #000 0%, rgba(0,0,0,.7) 38%, transparent 100%);
          mask-image: radial-gradient(9em 3.4em at calc(var(--cx) - 1.2em) var(--cy), #000 0%, rgba(0,0,0,.7) 38%, transparent 100%);
  opacity: calc(.55 + .45 * var(--lamp-i));
  transition: opacity 1.5s ease;
}
.fresh { animation: strike 1s ease-out; }
/* selected text: lit up even outside the light, so you can see what you'll copy or replace */
.ink .sel { background: rgba(var(--glow), .24); color: rgba(var(--fg), .95); border-radius: 2px; }
.lit .sel { background: transparent; }
@keyframes strike { from { color: var(--strike); text-shadow: 0 0 14px rgba(var(--glow), 1), 0 0 2px var(--strike); } }

.caret { display: inline-block; position: relative; width: 0; height: 1.15em; vertical-align: -0.24em; }
.lit .caret::after {
  content: ''; position: absolute; left: 1px; top: 0; bottom: 0; width: 1.5px;
  background: var(--lit);
  box-shadow: 0 0 6px rgba(var(--glow), .9);
  animation: blink 1.2s ease-in-out .6s infinite;
}
@keyframes blink { 0%, 45% { opacity: 1; } 60%, 90% { opacity: .1; } }

/* ---------- rail, carriage and light ---------- */
.rail {
  position: absolute; left: 0; right: 0; top: var(--rail); height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--frame), .18) 18%, rgba(var(--frame), .18) 82%, transparent);
}
.carriage { position: absolute; left: 0; top: var(--rail); width: 0; height: 0; pointer-events: none; }
.ready .carriage { transition: transform var(--x-dur) cubic-bezier(.2, .8, .2, 1); }
.lamp {
  position: absolute; left: 0; top: 0;
  transform: scale(var(--lamp)); transform-origin: 0 0;
  transition: transform .4s ease, opacity 1.5s ease;
}
.beam { position: absolute; mix-blend-mode: var(--blend); animation: breathe 6s ease-in-out infinite; }
.beam .cone { position: absolute; inset: 0; clip-path: polygon(46% 100%, 54% 100%, 100% 0, 0 0); }
.haze { left: -140px; bottom: 0; width: 280px; height: 210px; filter: blur(24px) opacity(var(--lamp-i)); opacity: .5; animation-duration: 8s; animation-delay: -2s; }
.haze .cone {
  clip-path: polygon(44% 100%, 56% 100%, 100% 0, 0 0);
  background: radial-gradient(65% 100% at 50% 100%, rgba(var(--glow), .45) 0%, rgba(var(--glow), .12) 60%, transparent 95%);
}
.core { left: -85px; bottom: 4px; width: 170px; height: 160px; filter: blur(7px) opacity(var(--lamp-i)); }
.core .cone {
  background: radial-gradient(55% 100% at 50% 100%, rgba(var(--glow-hi), .55) 0%, rgba(var(--glow), .18) 50%, transparent 88%);
}
@keyframes breathe { 0%, 100% { opacity: .82; } 50% { opacity: 1; } }
.dust { position: absolute; left: -110px; bottom: 4px; width: 220px; height: 180px; mix-blend-mode: var(--blend); opacity: var(--lamp-i); }
.bloom {
  position: absolute; left: -170px; top: -78px; width: 340px; height: 84px;
  background: radial-gradient(50% 50% at 50% 60%, rgba(var(--glow), .09), transparent);
  mix-blend-mode: var(--blend);
  opacity: var(--lamp-i);
}
.spark {
  position: absolute; left: -110px; top: 0; width: 220px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--glow), .75), transparent);
  opacity: var(--lamp-i);
}
.pool {
  position: absolute; left: -90px; top: -18px; width: 180px; height: 36px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(var(--glow), .22), transparent);
  opacity: var(--lamp-i);
}
.pill {
  position: absolute; left: -11px; top: -5px; width: 22px; height: 10px; border-radius: 6px;
  background: linear-gradient(rgb(var(--glow-hi)), rgb(var(--glow-lo)));
  box-shadow: 0 0 10px rgba(var(--glow), .7), 0 0 28px rgba(var(--glow), .3);
}

/* end of a timed session: the light slowly goes down */
.dusk .lamp { opacity: .16; transition: transform .4s ease, opacity 6s ease; }
.dusk .lit { opacity: .4; transition: opacity 6s ease; }

/* ---------- quiet chrome ----------
 * Fades away while you type, comes back when you move the mouse, tap, pause for a few
 * seconds, or move through it with the keyboard. All controls are ≥40px and readable
 * (≥4.5:1) in both themes. */
.chrome {
  position: absolute; font-size: 13px; letter-spacing: .04em; color: var(--dim);
  transition: opacity 1.4s ease;
  user-select: none; -webkit-user-select: none;
}
.focus .chrome { opacity: 0; }
.focus .chrome:focus-within, .chrome:focus-within { opacity: 1; transition-duration: .2s; }
.brand {
  top: calc(20px + env(safe-area-inset-top)); left: 20px; max-width: 30vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 8px 0;
}
.status {
  bottom: calc(22px + env(safe-area-inset-bottom)); left: 20px;
  display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums;
}
.save-state { display: inline-flex; align-items: center; gap: 6px; opacity: .85; }
.save-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.save-state:empty { display: none; }
.save-state.saving::before { animation: pulse 1s ease-in-out infinite; }
.save-state.error { color: rgb(var(--danger)); opacity: 1; }
@keyframes pulse { 50% { opacity: .15; } }
.streak { bottom: calc(50px + env(safe-area-inset-bottom)); left: 20px; }
.actions { bottom: calc(14px + env(safe-area-inset-bottom)); right: 14px; display: flex; gap: 8px; align-items: center; }

/* pill buttons: top bar and bottom actions share one look */
.topbar { top: calc(12px + env(safe-area-inset-top)); right: 14px; display: flex; gap: 8px; align-items: center; }
.top-btn, .act-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; min-width: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgba(var(--frame), .3); background: rgba(var(--tint), .05);
  font-size: 13px; letter-spacing: .04em; color: rgba(var(--fg), .86);
}
.top-btn svg, .act-btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.top-btn.icon-only { padding: 0; width: 40px; }
.top-btn:hover, .act-btn:hover { color: var(--lit); border-color: rgba(var(--glow), .6); background: rgba(var(--glow), .1); }
.top-btn .ico-off, .top-btn.is-off .ico-on { display: none; }
.top-btn.is-off .ico-off { display: block; }
.seg { display: inline-flex; border-radius: 999px; border: 1px solid rgba(var(--frame), .3); background: rgba(var(--tint), .05); }
.seg .act-btn { border: 0; background: none; padding: 0 12px; }
.seg .act-btn + .act-btn { border-left: 1px solid rgba(var(--frame), .25); border-radius: 0 999px 999px 0; }
.seg .act-btn:first-child { border-radius: 999px 0 0 999px; }
.clock {
  position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  font-size: 14px; letter-spacing: .12em; font-variant-numeric: tabular-nums;
  color: rgba(var(--fg), .8); border: 1px solid rgba(var(--frame), .25); background: rgba(var(--tint), .04);
}
button {
  font: inherit; letter-spacing: inherit; color: inherit;
  background: none; border: 0; padding: 6px 8px; cursor: pointer;
  transition: color .3s ease, border-color .3s ease, background .3s ease, box-shadow .3s ease;
}
button:hover { color: var(--lit); }
button:disabled { opacity: .35; cursor: default; color: inherit; }
/* a clear focus ring for keyboard users, in every theme */
:focus-visible { outline: 2px solid rgb(var(--ring)); outline-offset: 2px; }
button:focus:not(:focus-visible), input:focus:not(:focus-visible) { outline: none; }
.zoom { position: absolute; bottom: 100%; left: 8px; margin-bottom: 6px; color: var(--lit); opacity: 0; transition: opacity .6s ease; }
.zoom.show { opacity: 1; }

.hint, .prompt {
  position: absolute; left: 50%; top: calc(var(--rail) + 34px); transform: translateX(-50%);
  width: min(38em, calc(100vw - 48px)); text-align: center;
  transition: opacity 1s ease;
}
.hint { font-size: 13px; letter-spacing: .24em; color: var(--dim); pointer-events: none; }
.prompt { font-size: .8em; font-style: italic; color: rgba(var(--fg2), .78); line-height: 1.6; }
.prompt button { display: inline-flex; margin: 10px auto 0; padding: 8px 14px; border-radius: 999px; font-style: normal; font-size: 12px; letter-spacing: .1em; color: var(--dim); }
.prompt button:hover { color: var(--lit); background: rgba(var(--tint), .05); }
.has-text .hint, .has-text .prompt { opacity: 0; pointer-events: none; }

.toast {
  position: absolute; left: 50%; bottom: calc(52px + env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px; background: rgba(var(--pop), .92); border: 1px solid var(--line);
  font-size: 13px; letter-spacing: .04em; color: rgba(var(--fg), .9);
  opacity: 0; pointer-events: none;
  transition: opacity .6s ease, transform .6s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--lit); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(var(--glow), .4); }

#input {
  position: fixed; left: 0; bottom: 0; width: 1px; height: 1px;
  opacity: 0; border: 0; resize: none; font-size: 16px;
  caret-color: transparent; color: transparent; background: transparent;
  white-space: pre; overflow: hidden; /* no wrapping: keeps long texts fast */
}

/* ---------- panels ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 16px;
  background: rgba(var(--overlay), .62);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .35s ease;
  cursor: default;
}
.sheet.open { opacity: 1; }
.sheet-card {
  position: relative; width: min(660px, 100%); max-height: min(88vh, 920px); overflow: auto;
  background: rgba(var(--surface), .96);
  border: 1px solid rgba(var(--frame), .12); border-radius: 14px;
  padding: 30px 26px 24px;
  font-size: 14px; line-height: 1.6; letter-spacing: normal; color: rgba(var(--fg), .86);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  transform: translateY(8px); transition: transform .35s ease;
}
.sheet.open .sheet-card { transform: none; }
.sheet h2 {
  font-size: 12px; font-weight: normal; letter-spacing: .3em; text-transform: lowercase;
  color: var(--dim); margin-bottom: 18px;
}
.sheet h3 { font-size: 15px; font-weight: normal; color: var(--lit); margin-bottom: 4px; }
.sheet-close {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; color: var(--dim);
}
.sheet-close:hover { background: rgba(var(--tint), .08); color: var(--lit); }
.sheet-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.row:first-of-type { border-top: 0; }
.row > span:first-child { color: rgba(var(--fg), .86); }
.group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pillbtn {
  border: 1px solid rgba(var(--frame), .2); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; letter-spacing: .06em; color: var(--lit);
}
.pillbtn:hover, .pillbtn:focus-visible { border-color: rgba(var(--glow), .55); }
.pillbtn[aria-pressed="true"] { background: rgba(var(--glow), .14); border-color: rgba(var(--glow), .45); }
.pillbtn.danger:hover { border-color: rgba(var(--danger), .6); }
select, .field {
  font: inherit; font-size: 13px; color: var(--lit);
  background: rgba(var(--tint), .04);
  border: 1px solid rgba(var(--frame), .2); border-radius: 8px; padding: 6px 10px;
}
select option { background: var(--surface-solid); }
/* settings as a drawer: no dimming, the page slides aside and stays visible */
.stage, .intro { transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.sheet.as-drawer {
  background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none;
  place-items: stretch end; padding: 0;
}
.sheet.as-drawer .sheet-card {
  width: min(420px, 100%); height: 100%; max-height: none; border-radius: 0;
  border-width: 0 0 0 1px; box-shadow: -24px 0 60px rgba(0, 0, 0, .28);
  transform: translateX(30px);
}
.sheet.as-drawer.open .sheet-card { transform: none; }
.drawer-open .stage, .drawer-open .intro.done { transform: translateX(-210px); }
.sheet.as-drawer .tab span { display: none; }                       /* narrow drawer: icons + open tab name */
.sheet.as-drawer .tab[aria-selected="true"] span { display: inline; }
.sheet.as-drawer .tab { padding: 10px 12px; }
@media (max-width: 900px) {                                        /* phones / small windows: from the bottom */
  .sheet.as-drawer { place-items: end stretch; }
  .sheet.as-drawer .sheet-card {
    width: 100%; height: auto; max-height: 54vh; border-radius: 18px 18px 0 0;
    border-width: 1px 0 0; box-shadow: 0 -20px 50px rgba(0, 0, 0, .25);
    transform: translateY(30px);
  }
  .drawer-open .stage { transform: translateY(-24vh); }
  .drawer-open .intro.done { transform: none; }
}

/* settings: big title, tabs by section, options with an explanation */
.sheet-card.settings { width: min(720px, 100%); padding: 30px 28px 0; font-size: 15px; }
.sheet h2.set-title { font-size: 30px; font-weight: normal; letter-spacing: -.01em; text-transform: none; color: var(--lit); margin: 0 0 20px; }
.sheet-card.settings .sheet-close { top: 22px; right: 16px; }
.tabs {
  display: flex; gap: 4px; padding: 5px; border-radius: 999px; margin-bottom: 18px;
  background: rgba(var(--tint), .05); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.tab {
  flex: 1 0 auto; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: 999px; font-size: 14px; letter-spacing: .02em; white-space: nowrap;
  color: rgba(var(--fg), .66);
}
.tab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-selected="true"] {
  color: var(--lit); background: rgba(var(--surface), 1);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(var(--glow), .3);
}
:root[data-theme="light"] .tab[aria-selected="true"] { background: #fff; box-shadow: 0 1px 6px rgba(60, 40, 10, .12); }
.opt-card { border-radius: 16px; padding: 4px 22px; background: rgba(var(--tint), .035); border: 1px solid var(--line); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 14px 24px; flex-wrap: wrap; padding: 20px 0; border-top: 1px solid var(--line); }
.opt:first-child { border-top: 0; }
.opt-text { flex: 1 1 220px; min-width: 0; }
.opt-title { font-size: 16px; color: var(--lit); }
.opt-desc { font-size: 13px; line-height: 1.5; margin-top: 4px; color: rgba(var(--fg2), .72); }
.opt-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sheet-card.settings .pillbtn { font-size: 13px; padding: 7px 14px; }
@media (max-width: 700px) {               /* narrow: icons, plus the name of the open tab */
  .tab span { display: none; }
  .tab[aria-selected="true"] span { display: inline; }
  .tab { padding: 10px 12px; }
}
.lock-setup { display: grid; gap: 8px; justify-items: start; }
.set-foot {
  position: sticky; bottom: 0; margin: 20px -28px 0; padding: 14px 28px;
  border-top: 1px solid var(--line); background: rgba(var(--surface), .98);
  font-size: 12px; color: var(--dim);
}
@media (max-width: 520px) {
  .sheet-card.settings { padding: 26px 16px 0; }
  .sheet h2.set-title { font-size: 26px; }
  .opt-card { padding: 2px 16px; }
  .set-foot { margin: 16px -16px 0; padding: 12px 16px; }
}

.slider { display: flex; align-items: center; gap: 10px; }
/* keyboard shortcuts list */
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; align-items: center; margin: 6px 0 4px; }
.shortcuts dt { white-space: nowrap; }
.shortcuts dd { color: rgba(var(--fg), .85); }
.keys { display: inline-flex; gap: 6px; flex-wrap: wrap; }
kbd {
  font: inherit; font-size: 12px; padding: 3px 8px; border-radius: 6px; min-width: 26px; text-align: center;
  background: rgba(var(--tint), .07); border: 1px solid rgba(var(--frame), .3); box-shadow: 0 1px 0 rgba(var(--frame), .3);
  color: var(--lit);
}
.set-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.slider input[type="range"] { width: min(180px, 40vw); accent-color: rgb(var(--glow-lo)); cursor: pointer; }
.field:focus, select:focus { outline: none; border-color: rgba(var(--glow), .55); }
textarea.field { width: 100%; resize: vertical; min-height: 84px; line-height: 1.6; }
.muted { color: var(--dim); font-size: 12px; letter-spacing: .02em; }
.warn { color: rgba(var(--warn), .9); font-size: 12px; }
.err { color: rgba(var(--danger), .9); font-size: 12px; min-height: 1.4em; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { padding: 12px 14px; border-radius: 10px; background: rgba(var(--tint), .03); }
.stat b { display: block; font-size: 20px; font-weight: normal; color: var(--lit); font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; letter-spacing: .08em; color: var(--dim); }
.heat-wrap { overflow-x: auto; margin-bottom: 6px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); grid-auto-columns: 11px; gap: 3px; width: max-content; margin-left: auto; }
.heat i { border-radius: 3px; background: rgba(var(--frame), .07); cursor: pointer; }
.heat i.empty { cursor: default; }
.heat i.future { visibility: hidden; }
.heat-legend { display: flex; justify-content: space-between; margin-bottom: 18px; }
.search { width: 100%; margin-bottom: 6px; }
.list .item {
  display: block; width: 100%; text-align: left; padding: 12px 2px;
  border-top: 1px solid var(--line); letter-spacing: normal; color: inherit;
}
.list .item:first-child { border-top: 0; }
.item .date { color: var(--lit); }
.item .meta { color: var(--dim); font-size: 12px; margin-left: 8px; }
.item .excerpt {
  display: block; margin-top: 2px; font-size: 13px; color: rgba(var(--fg2), .6);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
mark { background: rgba(var(--glow), .28); color: var(--lit); border-radius: 3px; padding: 0 1px; }
.reader-prompt { font-style: italic; color: var(--dim); margin: 6px 0 14px; }
.reader-text {
  white-space: pre-wrap; overflow-wrap: break-word;
  font-size: 15px; line-height: 1.9; color: rgba(var(--fg), .92);
  max-height: 50vh; overflow: auto; padding: 4px 0 12px;
}
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.share-preview {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 46vh; object-fit: contain;
  border-radius: 10px; background: #05070b; margin: 12px auto;
}

/* ---------- lock screen ---------- */
.lock {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 58%, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  cursor: default;
}
.lock form { display: grid; gap: 14px; justify-items: center; width: min(320px, 88vw); }
.lock .brandmark { font-size: 12px; letter-spacing: .4em; color: var(--dim); margin-bottom: 18px; }
.lock .field { width: 100%; text-align: center; font-size: 16px; letter-spacing: .25em; padding: 10px; }

/* ---------- intro: the name is typed, then rises and stays as the header ---------- */
.intro {
  position: fixed; inset: 0; z-index: 40; overflow: hidden; cursor: default;
  /* --rise and --wm-scale are measured by js/intro.js and set on <html> */
}
.intro::before {               /* the dark curtain that fades to reveal the writer */
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 62%, var(--bg-1) 0%, var(--bg) 50%, var(--bg-3) 100%);
  transition: opacity 1.2s ease .35s;
}
.intro.settled::before { opacity: 0; }
.intro.done { z-index: 5; pointer-events: none; }
.wm-wrap {
  position: absolute; left: 0; right: 0; top: 50%;
  display: flex; justify-content: center;
  transform: translateY(-58%);
  transition: transform 1.4s cubic-bezier(.7, 0, .2, 1), opacity 1.4s ease;
  perspective: 1600px;
}
.intro.settled .wm-wrap { transform: translateY(calc(-58% - var(--rise))) scale(var(--wm-scale)); }
.focus .intro.done .wm-wrap { opacity: .35; }      /* dims while you write, like the rest of the chrome */
.wordmark {
  position: relative; margin: 0;
  font: 700 clamp(96px, 25vw, 400px)/1 var(--font);
  letter-spacing: -.05em; color: var(--lit);
  white-space: nowrap; transform-style: preserve-3d; transform-origin: 30% 60%;
  padding-bottom: .12em;
}
.wm-letter {
  display: inline-block; position: relative; z-index: 1;
  opacity: .06; color: var(--ghost);
  transition: opacity .3s ease;
}
.wm-letter.on {
  opacity: 1; color: var(--lit);
  text-shadow: 0 0 .22em rgba(var(--glow), .28);
  animation: wmStrike 1s ease-out;
}
@keyframes wmStrike {
  0% { opacity: .2; transform: translateY(.05em); color: var(--strike); text-shadow: 0 0 .35em rgba(var(--glow), 1); }
  18% { opacity: 1; transform: none; }
  100% { opacity: 1; }
}
.wm-rail {
  position: absolute; left: -10%; right: -10%; bottom: .04em; height: max(1px, .006em);
  background: linear-gradient(90deg, transparent, rgba(var(--frame), .22) 15%, rgba(var(--frame), .22) 85%, transparent);
  transition: opacity .8s ease;
}
.wm-lamp {
  position: absolute; left: 0; bottom: .04em; width: 0; height: 0; z-index: 2;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .8s ease;
}
.wm-cone {
  position: absolute; left: -.55em; bottom: .02em; width: 1.1em; height: 1em;
  filter: blur(.05em); mix-blend-mode: var(--blend);
}
.wm-cone::before {
  content: ''; position: absolute; inset: 0;
  clip-path: polygon(45% 100%, 55% 100%, 100% 0, 0 0);
  background: radial-gradient(60% 100% at 50% 100%, rgba(var(--glow-hi), .6), rgba(var(--glow), .14) 55%, transparent 90%);
}
.wm-pill {
  position: absolute; left: -.08em; top: -.03em; width: .16em; height: .06em; border-radius: .04em;
  background: linear-gradient(rgb(var(--glow-hi)), rgb(var(--glow-lo)));
  box-shadow: 0 0 .1em rgba(var(--glow), .8), 0 0 .3em rgba(var(--glow), .35);
}
.intro.settled .wm-lamp, .intro.settled .wm-rail { opacity: 0; }

/* the writer fades in under the rising name */
.intro-open .stage .chrome, .intro-open .stage .hint, .intro-open .stage .prompt { opacity: 0; }

/* ---------- control panel ---------- */
.panel {
  position: fixed; inset: 0; z-index: 25;
  display: grid; grid-template-rows: auto 1fr;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-1) 0%, var(--bg) 60%, var(--bg-3) 100%);
  color: rgba(var(--fg), .88); font-size: 14px; line-height: 1.55; letter-spacing: normal;
  cursor: default; opacity: 0; transition: opacity .35s ease;
}
.panel.open { opacity: 1; }
.pn-head {
  display: flex; align-items: center; gap: 16px; padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}
.pn-brand { font-weight: 700; font-size: 18px; color: var(--lit); letter-spacing: -.02em; }
.pn-dim { color: var(--dim); font-weight: normal; font-size: 12px; letter-spacing: .04em; }
.pn-account { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.pn-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; object-fit: cover;
  display: grid; place-items: center; background: rgba(var(--glow), .2); color: var(--lit); font-size: 13px;
}
.pn-user { display: grid; line-height: 1.25; min-width: 0; }
.pn-name { color: var(--lit); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.pn-body { display: grid; grid-template-columns: 230px 1fr; min-height: 0; }
.pn-side { overflow-y: auto; padding: 18px 12px 40px; border-right: 1px solid var(--line); }
.pn-sec { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--dim); margin: 18px 10px 6px; }
.pn-sec:first-child { margin-top: 0; }
.pn-nav {
  display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left;
  padding: 9px 12px; min-height: 38px; align-items: center; border-radius: 8px; font-size: 14px; letter-spacing: normal; color: rgba(var(--fg), .78);
}
.pn-nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pn-nav .n { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.pn-nav:hover { background: rgba(var(--tint), .04); color: var(--lit); }
.pn-nav.on { background: rgba(var(--glow), .13); color: var(--lit); }
.pn-nav.add { color: var(--dim); }
.pn-folder-in { width: 100%; margin: 4px 0; }
.pn-main { overflow-y: auto; padding: 24px clamp(16px, 3vw, 40px) 80px; min-width: 0; }
.pn-title-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.pn-h1 { font-size: 26px; font-weight: normal; color: var(--lit); letter-spacing: -.01em; }
.pn-h1-in { font-size: 20px; }
.pn-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.pn-search { flex: 1 1 240px; min-width: 0; }
.pn-list { display: grid; }
.pn-row {
  display: grid; grid-template-columns: 36px 1fr; gap: 6px;
  padding: 14px 6px; border-top: 1px solid var(--line);
}
.pn-row:first-child { border-top: 0; }
.pn-row.archived { opacity: .7; }
.pn-star { padding: 0; width: 32px; height: 32px; font-size: 19px; line-height: 1; color: var(--dim); align-self: start; border-radius: 8px; }
.pn-star:hover { background: rgba(var(--tint), .06); }
.pn-star.on { color: rgb(var(--glow-hi)); text-shadow: 0 0 10px rgba(var(--glow), .6); }
.pn-row-body { min-width: 0; }
.pn-row-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pn-title { padding: 0; font-size: 16px; color: var(--lit); text-align: left; letter-spacing: normal; }
.pn-title:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(var(--glow), .5); }
.pn-title-in { font-size: 15px; width: min(420px, 100%); }
.pn-meta { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.pn-excerpt { color: rgba(var(--fg2), .62); font-size: 13px; margin: 4px 0 6px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pn-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pn-chip { padding: 1px 8px; border-radius: 999px; font-size: 12px; letter-spacing: normal; background: rgba(var(--tint), .05); color: rgba(var(--fg), .75); }
.pn-chip.folder { background: rgba(var(--glow), .12); }
.pn-tags-in { width: min(420px, 100%); margin-top: 8px; }
.pn-actions { display: flex; gap: 2px 4px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.pn-row:hover .pn-actions, .pn-row:focus-within .pn-actions { opacity: 1; }
.pn-link { padding: 7px 9px; min-height: 32px; border-radius: 8px; font-size: 13px; letter-spacing: .02em; color: var(--dim); }
.pn-link:hover { background: rgba(var(--tint), .06); }
.pn-link:hover, .pn-link:focus-visible { color: var(--lit); }
.pn-link.danger:hover { color: rgba(var(--danger), .95); }
.pn-folder-sel { font-size: 12px; padding: 2px 6px; }
.pn-empty { color: var(--dim); padding: 30px 0; }
.pn-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px);
  display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 999px;
  background: rgba(var(--pop), .96); border: 1px solid var(--line); font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .4s ease, transform .4s ease;
}
.pn-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.pn-toast button { color: var(--lit); text-decoration: underline; padding: 0 4px; }

/* statistics */
.pn-stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 20px; }
.pn-card { padding: 18px; border-radius: 12px; background: rgba(var(--tint), .025); border: 1px solid var(--line); margin-bottom: 16px; }
.pn-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.pn-card h2 { font-size: 13px; font-weight: normal; letter-spacing: .06em; color: rgba(var(--fg), .8); }
.pn-chart { position: relative; }
.pn-bars { height: 160px; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid rgba(var(--frame), .25); }
.pn-bar {
  flex: 1; min-width: 4px; height: max(calc(var(--v) * 100%), 3px);
  background: rgba(var(--glow), .85); border-radius: 4px 4px 0 0; outline: none;
  transition: background .2s ease;
}
.pn-bar.zero { height: 2px; background: rgba(var(--frame), .18); border-radius: 0; }
.pn-bar:hover, .pn-bar:focus-visible { background: rgb(var(--glow-hi)); }
.pn-axis, .pn-axis-top { display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.pn-axis { margin-top: 6px; }
.pn-axis-top { margin-bottom: 4px; }
.pn-chart .heat { margin-left: 0; }
.pn-chart .heat i:focus-visible { outline: 1px solid rgb(var(--glow-hi)); }
.pn-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 8px)); pointer-events: none;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap; font-size: 12px;
  background: rgba(var(--pop), .97); border: 1px solid var(--line); color: var(--lit);
  opacity: 0; transition: opacity .12s ease; z-index: 2;
}
.pn-tip.show { opacity: 1; }
.pn-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.pn-table th, .pn-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.pn-table th { color: var(--dim); font-weight: normal; }
.pn-taglist { display: grid; gap: 4px; }
.pn-tagrow { display: grid; grid-template-columns: minmax(80px, 160px) 1fr 40px; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 6px; text-align: left; letter-spacing: normal; color: rgba(var(--fg), .85); }
.pn-tagrow:hover { background: rgba(var(--tint), .04); }
.pn-tagbar { height: 6px; border-radius: 3px; background: rgba(var(--glow), .7); width: calc(var(--v) * 100%); }

@media (max-width: 760px) {
  .pn-head { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .pn-account { order: 3; width: 100%; margin-left: 0; }
  .pn-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .pn-side {
    display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; padding: 8px 12px;
    border-right: 0; border-bottom: 1px solid var(--line); white-space: nowrap;
  }
  .pn-sec { display: none; }
  .pn-nav { width: auto; flex: none; }
  .pn-folder-in { width: 160px; flex: none; }
  .pn-main { padding: 16px 16px 80px; }
  .pn-stats { grid-template-columns: repeat(2, 1fr); }
  .pn-actions { opacity: 1; }
}

/* ---------- print (PDF + yearly book) ---------- */
#print { display: none; }
@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  .stage, .sheet, .lock, .intro, .panel, #input { display: none !important; }
  #print { display: block; color: #111; font: 11.5pt/1.75 'Courier Prime', 'Courier New', monospace; }
  #print .cover { height: 92vh; display: flex; flex-direction: column; justify-content: center; align-items: center; page-break-after: always; }
  #print .cover h1 { font-size: 40pt; font-weight: normal; letter-spacing: .1em; }
  #print .cover p { color: #666; letter-spacing: .3em; margin-top: 12pt; }
  #print article { page-break-after: always; }
  #print article:last-child { page-break-after: auto; }
  #print h2 { font-size: 13pt; font-weight: normal; letter-spacing: .08em; border-bottom: 1px solid #ccc; padding-bottom: 6pt; margin-bottom: 14pt; }
  #print .p { font-style: italic; color: #555; margin-bottom: 12pt; }
  #print .t { white-space: pre-wrap; overflow-wrap: break-word; }
  @page { margin: 22mm 20mm; }
}

/* medium windows: top buttons become icons so they never touch the centred name */
@media (max-width: 900px) {
  #pagesLabel { display: none; }
  #pagesBtn { width: 40px; padding: 0; }
}

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  #sizeGroup { display: none; }
  #fullBtn { display: none; }
  .topbar { gap: 6px; right: 10px; }
  .top-btn.icon-only, .top-btn { width: 38px; min-width: 38px; min-height: 38px; padding: 0; }
  /* under the "typox" header, centred */
  .status { bottom: auto; left: 50%; transform: translateX(-50%); justify-content: center; white-space: nowrap; top: calc(58px + env(safe-area-inset-top)); }
  .streak { bottom: auto; left: 50%; transform: translateX(-50%); white-space: nowrap; top: calc(90px + env(safe-area-inset-top)); }
  #pagesLabel { display: none; }      /* icon only on phones, so it never touches the centred name */
  .clock { bottom: auto; top: calc(122px + env(safe-area-inset-top)); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .sheet { padding: 10px; }
  .sheet-card { padding: 28px 18px 20px; }
}
@media (prefers-contrast: more) {
  :root { --ink: rgba(186, 200, 228, .62); --dim: rgba(220, 228, 245, .9); }
  :root[data-theme="light"] { --ink: rgba(20, 17, 14, .8); }
  .top-btn, .act-btn, .seg { border-color: currentColor; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
  .dust { display: none; }
}
