*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
/* Layered backdrop: three light pools (amber top-right, fire bottom-left, gold centre) + a faded fan of decay curves
   with a tick ruler (images/bg-curves.svg), masked so it fades out from the bottom-left. */
body {
  margin: 0; color: var(--ink); font: 400 17px/1.6 var(--font-body); -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(46vw 40vw at 94% 2%, var(--pool-a), transparent 70%) fixed,
    radial-gradient(40vw 36vw at 2% 98%, var(--pool-b), transparent 70%) fixed,
    radial-gradient(32vw 28vw at 56% 52%, var(--pool-c), transparent 72%) fixed,
    var(--paper);
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--ink); opacity: var(--pattern-o);
  -webkit-mask: url(/images/bg-curves.svg) left bottom / max(1200px, 92vw) auto no-repeat, radial-gradient(130% 120% at 0% 100%, #000 25%, transparent 72%);
  -webkit-mask-composite: source-in;
  mask: url(/images/bg-curves.svg) left bottom / max(1200px, 92vw) auto no-repeat, radial-gradient(130% 120% at 0% 100%, #000 25%, transparent 72%);
  mask-composite: intersect;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-color: var(--amber); text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.08; letter-spacing: -.03em; margin: 0; font-weight: 700; }
p { margin: 0 0 1em; }
mark { background: var(--amber); color: #17120d; border-radius: 3px; padding: 0 2px; }
::selection { background: var(--amber); color: #17120d; }
:focus-visible { outline: 3px solid var(--fire); outline-offset: 2px; }
#main:focus:not(:focus-visible), h1[tabindex='-1']:focus:not(:focus-visible) { outline: none; }
h1[tabindex='-1']:focus-visible, #main:focus-visible { outline: 2px dashed var(--fire); outline-offset: 6px; }
.skip { position: fixed; left: -999px; top: 10px; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; z-index: 100; font-weight: 600; text-decoration: none; }
.skip:focus { left: calc(var(--rail) + 12px); }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.mute { color: var(--mute); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Left rail: rotated text labels on a heat-ramp time ruler (right edge = minutes at the top, years at the bottom);
   the current page gets a fire needle pointing into the ruler instead of a filled pill. */
#rail { position: fixed; inset: 0 auto 0 0; width: var(--rail); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 22px 0; background: color-mix(in srgb, var(--paper) 78%, transparent); backdrop-filter: blur(10px); z-index: 40; }
#rail::before { content: ''; position: absolute; top: 0; bottom: 0; right: 0; width: 3px; background: linear-gradient(var(--hz-minutes), var(--hz-hours), var(--hz-days), var(--hz-weeks), var(--hz-months), var(--hz-years)); }
#rail::after { content: ''; position: absolute; top: 0; bottom: 0; right: 3px; width: 9px; background: repeating-linear-gradient(to bottom, var(--rule) 0 1px, transparent 1px 14px), repeating-linear-gradient(to bottom, var(--rule) 0 1px, transparent 1px 70px); background-size: 5px 100%, 9px 100%; background-repeat: no-repeat; background-position: right top; pointer-events: none; }
.logo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: #17120d; text-decoration: none; }
.logo svg { width: 28px; height: 28px; }
:root[data-theme='dark'] .logo { box-shadow: 0 0 0 1px var(--rule); }
.rail-nav { display: flex; flex-direction: column; gap: 4px; align-self: stretch; }
.rail-nav a { position: relative; display: flex; justify-content: center; text-decoration: none; color: var(--mute); padding: 14px 0; transition: color .2s; }
.rail-nav a span { writing-mode: vertical-rl; transform: rotate(180deg); font: 13px/1 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; }
.rail-nav a:hover { color: var(--ink); }
.rail-nav a[aria-current='page'] { color: var(--ink); font-weight: 700; }
.rail-nav a[aria-current='page']::after { content: ''; position: absolute; right: 3px; top: 50%; width: 22px; height: 2px; background: var(--fire); transform: translateY(-50%); }
.rail-nav a[aria-current='page']::before { content: ''; position: absolute; right: 22px; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--fire); transform: translateY(-50%); }
.rail-tools { display: flex; flex-direction: column; gap: 10px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--rule); background: transparent; font-size: 22px; line-height: 1; }
.icon-btn:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .ti { display: grid; place-items: center; }
.stage { margin-left: var(--rail); min-height: 100vh; display: flex; flex-direction: column; }
#main { flex: 1; }
.wrap { width: min(1180px, 100% - 64px); margin-inline: auto; }
.enter > * { animation: rise .5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Buttons and fields */
.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 999px; padding: 14px 26px; font: 600 15px/1 var(--font-body); text-decoration: none; background: var(--ink); color: var(--paper); transition: transform .2s var(--ease); }
.btn svg { width: 18px; height: 18px; }
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-amber { background: var(--amber); color: #17120d; }
.btn-ink { background: #17120d; color: #fff3dc; }
.btn-line { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; }
.btn-sm { padding: 9px 16px; font-size: 13px; }
.field, select.field, textarea.field { width: 100%; background: var(--card); color: var(--ink); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; font: inherit; }
.field:focus { border-color: var(--ink); }
.field:focus-visible { outline: 3px solid color-mix(in srgb, var(--fire) 70%, transparent); outline-offset: 1px; }
.field[aria-invalid='true'] { border-color: var(--fire); box-shadow: inset 0 0 0 1px var(--fire); }
.lbl { display: block; font: 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin: 18px 0 6px; }
.alert { background: var(--fire); color: #17120d; padding: 10px 14px; border-radius: 10px; margin: 12px 0; font-weight: 600; }
.err-msg { color: var(--fire-text); font-size: 14px; font-weight: 600; margin: 6px 0 0; }

/* Toast */
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 90; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-weight: 600; animation: rise .3s var(--ease); }

/* Footer */
#foot { border-top: 1px solid var(--rule); margin-top: 96px; }
body[data-page='home'] #foot { margin-top: 0; }
.foot-top { display: grid; grid-template-columns: 1.3fr 1fr; gap: 56px; padding: 56px 0 36px; }
.foot-top h2 { font-size: clamp(28px, 3.4vw, 46px); max-width: 18ch; }
.sub-form { margin-top: 22px; max-width: 560px; }
.sub-row { display: flex; gap: 8px; }
.sub-form .field { border-radius: 999px; padding-inline: 20px; flex: 1; }
.sub-msg { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; }
.sub-msg[data-kind='err'] { color: var(--fire-text); font-weight: 600; }
.sub-msg[data-kind='ok'] { color: var(--ink); }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 26px; align-content: start; font: 13px var(--font-mono); text-transform: uppercase; letter-spacing: .08em; }
.foot-links a { text-decoration: none; }
.foot-links a:hover { color: var(--fire-text); }
.foot-theme { display: none; align-items: center; gap: 8px; background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 14px 6px 8px; font: inherit; text-transform: inherit; letter-spacing: inherit; }
.foot-theme svg { width: 18px; height: 18px; }
.foot-bot { padding: 22px 0 34px; border-top: 1px solid var(--rule); color: var(--mute); font-size: 14px; display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* Search modal */
.sheet { position: fixed; inset: 0; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); z-index: 80; display: none; padding: 11vh 20px 20px; overflow-y: auto; }
.sheet.open { display: block; }
body.modal-open { overflow: hidden; }
.sheet-box { width: min(720px, 100%); margin: 0 auto; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-top h2 { font-size: 12px; letter-spacing: .1em; color: var(--fire-text); }
.sheet input { width: 100%; background: transparent; border: 0; border-bottom: 2px solid var(--ink); font: 700 clamp(26px, 5vw, 46px)/1.2 var(--font-display); letter-spacing: -.03em; color: var(--ink); padding: 8px 4px 14px; border-radius: 6px 6px 0 0; }
.sheet input:focus-visible { outline: 3px solid color-mix(in srgb, var(--fire) 70%, transparent); outline-offset: 4px; }
.sheet-count { margin: 12px 0 0; min-height: 1.4em; }
.sheet-list { margin-top: 8px; display: grid; }
.sheet-list a { display: flex; justify-content: space-between; gap: 16px; padding: 14px 10px; border-bottom: 1px solid var(--rule); text-decoration: none; font-weight: 600; border-radius: 8px; }
.sheet-list a:hover, .sheet-list a[aria-selected='true'] { background: var(--card); color: var(--fire-text); box-shadow: inset 3px 0 0 var(--fire); }
.sheet-hint { margin-top: 18px; }

@media (max-width: 860px) {
  :root { --rail: 0px; }
  #rail { inset: auto 0 0 0; width: 100%; height: 64px; flex-direction: row; padding: 0 8px 0 4px; }
  #rail::before { top: 0; bottom: auto; left: 0; right: 0; width: auto; height: 3px; background: linear-gradient(90deg, var(--hz-minutes), var(--hz-hours), var(--hz-days), var(--hz-weeks), var(--hz-months), var(--hz-years)); }
  #rail::after { display: none; }
  .logo { width: 40px; height: 40px; margin-left: 4px; }
  .logo svg { width: 24px; height: 24px; }
  .rail-nav { flex-direction: row; gap: 0; flex: 1; justify-content: space-around; align-self: stretch; }
  .rail-nav a { align-items: center; padding: 0 8px; min-width: 44px; }
  .rail-nav a span { writing-mode: horizontal-tb; transform: none; font-size: 11px; letter-spacing: .1em; }
  .rail-nav a[aria-current='page']::after { right: auto; left: 50%; top: 3px; width: 2px; height: 14px; transform: translateX(-50%); }
  .rail-nav a[aria-current='page']::before { right: auto; left: 50%; top: 15px; transform: translateX(-50%); width: 6px; height: 6px; }
  .rail-theme { display: none !important; }
  .foot-theme { display: inline-flex; }
  .stage { padding-bottom: 64px; }
  .wrap { width: min(1180px, 100% - 32px); }
  .skip:focus { left: 8px; }
  .foot-top { grid-template-columns: 1fr; gap: 32px; padding-top: 44px; }
  #toasts { bottom: 78px; }
}
@media (max-width: 420px) { .sub-row { flex-direction: column; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
