/* ---------- Tokens ---------- */
:root {
  /* ===== Theme: Walnut (default) ===== */
  --board: #ddd0bb;
  --cork-1: #d9c9ae;
  --cork-2: #c9b493;
  --glow-focus: rgba(255, 196, 140, .55);
  --glow-break: rgba(190, 210, 140, .45);
  --ink: #1d1b16;
  --ink-soft: rgba(29, 27, 22, .6);
  --rule: rgba(29, 27, 22, .14);
  --paper: #fbfaf5;
  --surface: #ffffff;
  --red: #e2483d;
  --red-hi: #ef5a4f;
  --red-deep: #b8352c;
  --red-shadow: rgba(160, 40, 30, .55);
  --blue: #6f8a3c;
  --tile: #2a2724;
  --tile-top: #34302c;
  --tile-2: #1d1b19;
  --tile-ink: #f6f0e4;
  --peg: #6d6760;
  --ruler: #f1ead8;
  --btn-1: #ffffff;
  --btn-2: #efe9dc;
  --btn-edge: #cfc6b3;
  --paper-filter: none;
  --f-ui: "Inter", system-ui, sans-serif;
  --f-hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --ease: cubic-bezier(.34, 1.56, .64, 1);
  /* paper + felt grain (generated noise, no image files) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 -.17'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --cork-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='c'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .95 0 0 0 0 .85 0 0 0 1.4 -.78'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23c)'/%3E%3C/svg%3E");
  --felt: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .6 -.22'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
}
:root { --glow: var(--glow-focus); }
body[data-mode="short"] { --accent: var(--blue); --glow: var(--glow-break); }

/* ===== Theme: Matcha ===== */
:root[data-theme="matcha"] {
  --board: #a9b597;
  --cork-1: #b3bf9f;
  --cork-2: #93a281;
  --glow-focus: rgba(255, 250, 215, .55);
  --glow-break: rgba(240, 200, 170, .45);
  --ink: #1e2a1d;
  --ink-soft: rgba(30, 42, 29, .6);
  --rule: rgba(30, 42, 29, .15);
  --paper: #f7f7ef;
  --surface: #fdfdf8;
  --red: #4f8448;
  --red-hi: #63995b;
  --red-deep: #355f30;
  --red-shadow: rgba(40, 80, 35, .5);
  --blue: #b8734a;
  --tile: #2e3a2c;
  --tile-top: #3a4837;
  --tile-2: #222c21;
  --tile-ink: #eef3e2;
  --peg: #6f7a68;
  --ruler: #ecefe0;
  --btn-1: #fdfdf8;
  --btn-2: #e8ecdc;
  --btn-edge: #c3cbb2;
}

/* ===== Theme: Retro 70s ===== */
:root[data-theme="retro"] {
  color-scheme: dark;
  --board: #160e09;
  --cork-1: #22160e;
  --cork-2: #0c0805;
  --glow-focus: rgba(255, 170, 60, .45);
  --glow-break: rgba(240, 190, 70, .35);
  --ink: #3b2416;
  --ink-soft: rgba(59, 36, 22, .62);
  --rule: rgba(59, 36, 22, .16);
  --paper: #f5e7c8;
  --surface: #fbf2dc;
  --red: #d9622b;
  --red-hi: #ec7b40;
  --red-deep: #a5451a;
  --red-shadow: rgba(150, 60, 20, .55);
  --blue: #b07d12;
  --tile: #2a1a11;
  --tile-top: #3a2418;
  --tile-2: #1a100a;
  --tile-ink: #f7dfa6;
  --peg: #9a7650;
  --ruler: #efdbb2;
  --btn-1: #fbf2dc;
  --btn-2: #ecd9b2;
  --btn-edge: #c9ae80;
}

/* ===== Dark mode (works with every theme) ===== */
:root[data-dark="true"] {
  color-scheme: dark;
  --paper-filter: none;
  --paper: #2a2622;
  --surface: #36312c;
  --ink: #f2ece2;
  --ink-soft: rgba(242, 236, 226, .62);
  --rule: rgba(242, 236, 226, .14);
  --tile: #171513;
  --tile-top: #221f1c;
  --tile-2: #0f0e0c;
  --peg: #57514a;
  --ruler: #3a342e;
  --btn-1: #403a34;
  --btn-2: #322d28;
  --btn-edge: #1c1916;
  --board: #2a221b;
  --cork-1: #42352a;
  --cork-2: #261e18;
  --glow-focus: rgba(255, 160, 95, .5);
  --glow-break: rgba(170, 200, 110, .3);
}
:root[data-dark="true"][data-theme="matcha"] {
  --paper: #232a22;
  --surface: #2e372d;
  --ink: #e8efdf;
  --ink-soft: rgba(232, 239, 223, .62);
  --rule: rgba(232, 239, 223, .14);
  --tile: #141a13;
  --tile-top: #1d251c;
  --tile-2: #0d120c;
  --tile-ink: #e3edd2;
  --ruler: #323d30;
  --btn-1: #364034;
  --btn-2: #2a3329;
  --btn-edge: #151a14;
  --red: #6aa862;
  --red-hi: #7fbd76;
  --board: #1d241b;
  --cork-1: #2b3428;
  --cork-2: #161c14;
  --glow-focus: rgba(215, 240, 170, .3);
  --glow-break: rgba(220, 160, 120, .3);
}
:root[data-dark="true"][data-theme="retro"] {
  --paper: #18110c;
  --surface: #241912;
  --ink: #f6e2bc;
  --ink-soft: rgba(246, 226, 188, .6);
  --rule: rgba(246, 226, 188, .13);
  --tile: #0d0907;
  --tile-top: #17100b;
  --tile-2: #070504;
  --tile-ink: #f7d690;
  --peg: #6b4c30;
  --ruler: #2e2117;
  --btn-1: #2e2117;
  --btn-2: #21170f;
  --btn-edge: #0b0705;
  --board: #080504;
  --cork-1: #100a06;
  --cork-2: #040302;
  --glow-focus: rgba(255, 140, 40, .32);
  --glow-break: rgba(230, 180, 60, .28);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--board); color: var(--ink); font-family: var(--f-ui); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 3px; border-radius: 6px; }
.hand { font-family: var(--f-hand); }
.theme-anim, .theme-anim * { transition: background-color .5s ease, filter .5s ease !important; }

/* ---------- Paper surface ---------- */
.paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(172deg, rgba(255, 255, 255, .38) 0%, rgba(255, 255, 255, .06) 32%, rgba(255, 255, 255, 0) 55%, rgba(0, 0, 0, .05) 100%),
    var(--grain);
  box-shadow:
    inset 0 0 0 .5px rgba(0, 0, 0, .07),
    inset 0 1px 0 rgba(255, 255, 255, .6),
    0 1px 1.5px rgba(0, 0, 0, .2),
    0 10px 18px -6px rgba(0, 0, 0, .18);
  filter: var(--paper-filter);
}

:root[data-dark="true"] .paper {
  background-image: linear-gradient(172deg, rgba(255, 255, 255, .05) 0%, rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, .12) 100%), var(--grain);
  box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .06), inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 1.5px rgba(0, 0, 0, .5), 0 12px 22px -8px rgba(0, 0, 0, .6);
}
:root[data-dark="true"] .tabs { background: rgba(0, 0, 0, .25); }
:root[data-dark="true"] { --colon: color-mix(in srgb, var(--ink) 55%, transparent); }
:root[data-dark="true"] .clip { background: linear-gradient(180deg, #6b665f, #3d3a35); }

/* ---------- Layout: sidebar + board ---------- */
.layout {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0;
  height: 100dvh; overflow: hidden;
  background-color: var(--cork-1);
  background-image:
    var(--cork-light),
    var(--felt),
    radial-gradient(70% 60% at 30% 30%, var(--cork-1), var(--cork-2));
}

/* ---------- Sidebar (paper planner on a clip) ---------- */
.sidebar {
  position: sticky; top: 16px; align-self: start;
  margin: 16px 0 16px 16px; height: calc(100dvh - 32px); min-height: 600px;
  border-radius: 8px; padding: 30px 26px 20px;
  display: flex; flex-direction: column; gap: 4px; overflow: auto;
}
.clip {
  position: absolute; top: -6px; left: 50%; width: 92px; height: 22px; margin-left: -46px; border-radius: 6px 6px 10px 10px;
  background: linear-gradient(180deg, #8f8a83, #5f5b55); box-shadow: 0 3px 4px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.brand__pin { width: 24px; height: 24px; border-radius: 50%; flex: none; background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .9) 0 10%, rgba(255, 255, 255, 0) 24%), radial-gradient(circle at 50% 55%, var(--red) 0 55%, var(--red-deep) 100%); box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .25), 3px 4px 4px -1px rgba(0, 0, 0, .3); }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); margin: 6px 0 14px; }
.brand span { font-size: 32px; font-weight: 700; line-height: 1; }

.block { padding: 18px 0; border-top: 1.5px dashed var(--rule); }
.block__title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--ink); }
.step {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 800; color: var(--paper); background: var(--ink); box-shadow: none;
}

.task-input {
  width: 100%; border: 0; border-bottom: 2px solid var(--rule); background: transparent; outline: none;
  font-size: 28px; font-weight: 500; color: var(--ink); padding: 0 0 4px;
  transition: border-color .2s;
}
.task-input::placeholder { color: var(--ink-soft); opacity: .6; }
.task-input:focus { border-color: var(--red); }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  display: grid; place-items: center; gap: 0; height: 58px; border-radius: 12px;
  font-weight: 800; font-size: 20px; line-height: 1; color: var(--ink);
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--rule), 0 2px 0 rgba(0, 0, 0, .06);
  transition: transform .25s var(--ease), background-color .2s, color .2s, box-shadow .2s;
}
.chip small { font-size: 10px; font-weight: 600; letter-spacing: .06em; color: var(--ink-soft); }
.chip:hover { transform: translateY(-2px); }
.chip[aria-checked="true"] { background: var(--red); color: #fff; box-shadow: 0 3px 0 var(--red-deep), 0 8px 14px -8px var(--red-shadow); }
.chip[aria-checked="true"] small { color: rgba(255, 255, 255, .85); }

.block--today { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.goal { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 2px 0 12px; }
.goal span {
  position: relative; aspect-ratio: 1; border-radius: 50%;
  border: 1.5px dashed color-mix(in srgb, var(--ink) 25%, transparent);
}
.goal span.is-done {
  border: 0; background: radial-gradient(circle at 35% 30%, var(--red-hi), var(--red) 58%, var(--red-deep));
  box-shadow: 0 2px 3px rgba(0, 0, 0, .25), inset 0 -2px 3px rgba(0, 0, 0, .15);
  animation: pop .45s var(--ease);
}
.goal span.is-done::before { content: ""; position: absolute; left: 24%; top: 18%; width: 28%; height: 20%; border-radius: 50%; background: rgba(255, 255, 255, .8); rotate: -30deg; }
.today-sum { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.today-sum b { color: var(--red); }
.done-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; overflow: auto; min-height: 0; align-content: start; font-family: var(--f-hand); font-size: 22px; }
.done-list li { display: flex; gap: 8px; align-items: baseline; padding: 1px 0; border-bottom: 1px solid var(--rule); animation: pop .4s var(--ease); }
.done-list li::before { content: ""; width: 9px; height: 9px; border-radius: 50%; flex: none; align-self: center; background: radial-gradient(circle at 35% 30%, var(--red-hi), var(--red) 60%, var(--red-deep)); box-shadow: 1px 2px 2px rgba(0, 0, 0, .25); }
.done-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done-list .meta { font-size: 18px; color: var(--ink-soft); padding-right: 6px; }
.done-list .more { border: 0; color: var(--ink-soft); }
.done-list .more::before { content: none; }
.empty-hint { margin: 2px 0 0; font: 22px var(--f-hand); color: var(--ink-soft); }
@keyframes pop { from { opacity: 0; translate: 0 6px; } }

.sidebar__foot { border-top: 1.5px dashed var(--rule); padding-top: 14px; }
.themes { margin: 0 0 18px; }
.themes__label { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--ink); }
.themes__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.theme-btn {
  display: grid; justify-items: center; gap: 6px; padding: 10px 4px 9px; border-radius: 10px; font-size: 13px; font-weight: 700;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--rule); transition: transform .2s, box-shadow .2s;
}
.theme-btn:hover { transform: translateY(-1px); }
.theme-btn[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--red), 0 4px 10px -6px var(--red-shadow); color: var(--red); }
.swatch { display: flex; width: 56px; height: 20px; border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swatch i { flex: 1; }
.foot-btns { display: flex; gap: 8px; }
.foot-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border-radius: 10px;
  font-size: 13px; font-weight: 700; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--rule), 0 2px 0 rgba(0, 0, 0, .06);
  transition: transform .2s;
}
.foot-btn:hover { transform: translateY(-1px); }
.foot-btn svg { width: 17px; height: 17px; }
.keys { margin: 12px 0 0; font-size: 11.5px; color: var(--ink-soft); text-align: center; }
kbd { font: 700 10.5px var(--f-ui); padding: 1px 5px; border-radius: 4px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule), 0 1px 0 rgba(0, 0, 0, .12); }

/* ---------- Board + clock card ---------- */
.board {
  position: relative; display: flex; padding: 0; perspective: 1800px; min-width: 0; container-type: size;
  margin: 16px; border-radius: 8px; overflow: visible; isolation: isolate;
}
/* warm lamp light pooling behind the clock (tinted by mode) */
.board__light {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(50% 55% at 50% 48%, var(--glow), transparent 72%);
  transition: background .8s ease;
}
.is-running .board__light { animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .65; scale: 1.04; } }
/* a few old pinholes from previous notes */
.board__holes {
  position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .55;
  background:
    radial-gradient(circle at 12% 18%, rgba(0,0,0,.45) 0 1.6px, transparent 2.4px),
    radial-gradient(circle at 14.5% 19.2%, rgba(0,0,0,.35) 0 1.4px, transparent 2.2px),
    radial-gradient(circle at 86% 14%, rgba(0,0,0,.45) 0 1.6px, transparent 2.4px),
    radial-gradient(circle at 91% 72%, rgba(0,0,0,.4) 0 1.5px, transparent 2.3px),
    radial-gradient(circle at 9% 81%, rgba(0,0,0,.4) 0 1.5px, transparent 2.3px),
    radial-gradient(circle at 23% 88%, rgba(0,0,0,.35) 0 1.4px, transparent 2.2px),
    radial-gradient(circle at 74% 91%, rgba(0,0,0,.4) 0 1.6px, transparent 2.4px),
    radial-gradient(circle at 63% 7%, rgba(0,0,0,.35) 0 1.4px, transparent 2.2px);
}

.clock-card {
  /* digit height: as big as the board allows (height and width both checked) */
  --h: clamp(100px, min((100cqh - 300px) / 1.85, 25cqw), 400px);
  position: relative; z-index: 1; flex: 1; min-height: 0; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--h) * .14 + 34px) 32px calc(var(--h) * .08 + 22px);
  transform-origin: 50% 20px; will-change: transform;
  animation: drop .8s var(--ease) both .1s;
}
@keyframes drop { from { opacity: 0; translate: 0 -50px; scale: 1.06; } 60% { opacity: 1; } }

/* nothing inside the card may get squashed */
.clock-card > * { flex-shrink: 0; }

/* pins */
.pin {
  --pin: var(--red);
  position: absolute; top: 10px; left: 50%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; z-index: 3;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .9) 0 10%, rgba(255, 255, 255, 0) 24%),
    radial-gradient(circle at 50% 55%, var(--pin) 0 55%, color-mix(in srgb, var(--pin) 62%, #000) 100%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .28), inset 0 1px 1px rgba(255, 255, 255, .35), 4px 6px 5px -1px rgba(0, 0, 0, .32), 1px 2px 1px rgba(0, 0, 0, .2);
}
.clock-card > .pin { top: 14px; width: 26px; height: 26px; margin-left: -13px; }
.pin--l { left: 8%; }
.pin--r { left: 92%; }

/* mode tabs on the card */
.tabs { display: flex; justify-content: center; gap: 4px; padding: 4px; margin: 0 auto calc(var(--h) * .08 + 6px); width: fit-content; border-radius: 12px; background: rgba(29, 27, 22, .06); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08); }
.tab { padding: .6em 1.3em; border-radius: 9px; font-size: clamp(14px, calc(var(--h) * .085), 20px); font-weight: 700; color: var(--ink-soft); transition: background-color .2s, color .2s, box-shadow .2s; }
.tab:hover { color: var(--ink); }
.tab[aria-pressed="true"] { background: var(--surface); color: var(--red); box-shadow: 0 1px 0 rgba(0, 0, 0, .08), 0 4px 10px -4px rgba(0, 0, 0, .2); }

.status { padding: 0 .25em; margin: 0 0 calc(var(--h) * .1); max-width: 100%; text-align: center; font-size: clamp(24px, calc(var(--h) * .15), 46px); color: var(--ink-soft); min-height: 1.2em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status b { color: var(--ink); font-weight: 700; }

/* 3D split-flap digits */
.flipclock { display: flex; align-items: center; justify-content: center; gap: calc(var(--h) * .07); }
.flip {
  --w: calc(var(--h) * .72);
  position: relative; width: var(--w); height: var(--h); perspective: 420px;
  font: 800 calc(var(--h) * .78) / var(--h) var(--f-ui); color: var(--tile-ink); font-variant-numeric: tabular-nums;
  border-radius: calc(var(--h) * .09);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35), 0 14px 18px -10px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .25);
}
.flip__half, .flip__leaf { position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; backface-visibility: hidden; }
.flip__half span, .flip__leaf span { position: absolute; left: 0; right: 0; height: 200%; text-align: center; }
.flip__top, .flip__leaf--top { top: 0; border-radius: calc(var(--h) * .09) calc(var(--h) * .09) 0 0; background: linear-gradient(180deg, var(--tile-top), var(--tile)); }
.flip__bottom, .flip__leaf--bottom { bottom: 0; border-radius: 0 0 calc(var(--h) * .09) calc(var(--h) * .09); background: linear-gradient(180deg, var(--tile-2), #24211e); }
.flip__top span, .flip__leaf--top span { top: 0; }
.flip__bottom span, .flip__leaf--bottom span { top: -100%; }
.flip__leaf--top { transform-origin: 50% 100%; z-index: 2; }
.flip__leaf--bottom { transform-origin: 50% 0; transform: rotateX(90deg); z-index: 2; }
.flip.is-flipping .flip__leaf--top { animation: leaf-top .26s ease-in forwards; }
.flip.is-flipping .flip__leaf--bottom { animation: leaf-bottom .26s ease-out .26s forwards; }
@keyframes leaf-top { to { transform: rotateX(-90deg); filter: brightness(.6); } }
@keyframes leaf-bottom { from { transform: rotateX(90deg); filter: brightness(1.4); } to { transform: rotateX(0); } }
.flip::after { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 1px); height: 2px; background: rgba(0, 0, 0, .55); z-index: 4; }
.flip::before { content: ""; position: absolute; left: -3px; right: -3px; top: calc(50% - 5px); height: 10px; border-radius: 3px; z-index: 5;
  background: linear-gradient(90deg, var(--peg) 0 4px, transparent 4px calc(100% - 4px), var(--peg) calc(100% - 4px)); }
.colon { display: grid; gap: calc(var(--h) * .2); padding: 0 calc(var(--h) * .02); }
.colon i { width: calc(var(--h) * .085); height: calc(var(--h) * .085); border-radius: 50%; background: var(--colon, var(--tile)); box-shadow: 0 2px 3px rgba(0, 0, 0, .3); }
@keyframes colon { 50% { opacity: .25; } }

/* ruler progress */
.ruler {
  position: relative; width: calc(var(--h) * 3.3); max-width: 100%; height: clamp(16px, calc(var(--h) * .09), 26px); margin: calc(var(--h) * .17) 0 0; border-radius: 3px; overflow: hidden;
  background:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--ink) 45%, transparent) 0 1px, transparent 1px 10%),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--ink) 25%, transparent) 0 1px, transparent 1px 2%) 0 100% / 100% 45% no-repeat,
    var(--ruler);
  box-shadow: inset 0 0 0 1px var(--rule);
}
.ruler__fill { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, var(--accent, var(--red)) 55%, transparent); transition: width .3s linear; }

/* controls */
.controls { --b: clamp(56px, calc(var(--h) * .33), 84px); display: flex; align-items: center; justify-content: center; gap: calc(var(--b) * .3); margin-top: calc(var(--h) * .16); }
.start {
  display: inline-flex; align-items: center; gap: .55em; height: var(--b); min-width: calc(var(--b) * 3.4); justify-content: center; padding: 0 1.8em; border-radius: calc(var(--b) * .25);
  background: linear-gradient(180deg, var(--red-hi), var(--red)); color: #fff; font-weight: 700; font-size: calc(var(--b) * .32);
  box-shadow: 0 5px 0 var(--red-deep), 0 14px 20px -8px var(--red-shadow), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.start svg { width: 1.1em; height: 1.1em; }
.start:hover { transform: translateY(-1px); }
.start:active, .is-running .start { transform: translateY(4px); box-shadow: 0 1px 0 var(--red-deep), 0 6px 10px -6px rgba(160, 40, 30, .5), inset 0 2px 4px rgba(0, 0, 0, .15); }
.round {
  width: calc(var(--b) * .82); height: calc(var(--b) * .82); border-radius: 50%; display: grid; place-items: center; color: var(--ink);
  background: linear-gradient(180deg, var(--btn-1), var(--btn-2)); box-shadow: 0 3px 0 var(--btn-edge), 0 8px 12px -6px rgba(0, 0, 0, .3);
  transition: transform .12s ease, box-shadow .12s ease;
}
.round svg { width: 36%; height: 36%; }
.round:active { transform: translateY(3px); box-shadow: 0 0 0 var(--btn-edge); }

.rounds-label { margin: calc(var(--h) * .12) 0 0; text-align: center; font-size: clamp(12px, calc(var(--h) * .065), 16px); font-weight: 600; color: var(--ink-soft); }
.rounds { display: flex; justify-content: center; gap: 8px; }
.rounds span { width: clamp(14px, calc(var(--h) * .07), 20px); height: clamp(14px, calc(var(--h) * .07), 20px); border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(29, 27, 22, .3); }
.rounds span.is-done { background: radial-gradient(circle at 35% 30%, var(--red-hi), var(--red) 60%, var(--red-deep)); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }

/* "Done!" rubber stamp */
.print-veil {
  position: absolute; inset: 0; z-index: 5; border-radius: inherit; pointer-events: none; opacity: 0;
  background: radial-gradient(70% 70% at 50% 45%, rgba(20, 14, 8, .38), rgba(20, 14, 8, .55));
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  transition: opacity .45s ease;
}
.clock-card.is-veiled .print-veil { opacity: 1; }
.done-stamp {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; rotate: -12deg; pointer-events: none; z-index: 7;
  font: 800 calc(var(--h) * .45)/1 var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--red);
  border: 5px double var(--red); border-radius: 10px; padding: 6px 18px; opacity: 0;
  background: color-mix(in srgb, #fffdf6 92%, transparent); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5);
}
.clock-card.is-done .done-stamp { animation: stamp 1.8s ease-out; }
@keyframes stamp { 0% { opacity: 0; scale: 2.2; } 12% { opacity: .9; scale: 1; } 75% { opacity: .9; } 100% { opacity: 0; } }

/* ---------- Focus mode button ---------- */
.zen-btn {
  position: absolute; right: 18px; bottom: 16px; z-index: 4;
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 9px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--rule), 0 2px 0 rgba(0, 0, 0, .06);
  transition: color .2s, transform .2s, opacity .6s;
}
.zen-btn:hover { color: var(--ink); transform: translateY(-1px); }
.zen-btn svg { width: 15px; height: 15px; }
.zen-btn kbd { font-size: 10px; }

/* ---------- Focus mode ---------- */
body.is-zen .layout { grid-template-columns: minmax(0, 1fr); }
body.is-zen .sidebar { display: none; }
body.is-zen .clock-card { --h: clamp(100px, min((100cqh - 300px) / 1.85, 25cqw), 560px); animation: zen-in .6s var(--ease); }
@keyframes zen-in { from { scale: .96; opacity: .4; } }
/* candle: the card's edges darken as the time burns down */
.clock-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 3;
  background: radial-gradient(75% 70% at 50% 45%, transparent 45%, rgba(20, 10, 0, calc((1 - var(--left, 1)) * .5)) 100%);
  opacity: 0; transition: opacity 1s ease;
}
body.is-zen.is-running .clock-card::after { opacity: 1; }
body.is-zen .board__light { opacity: calc(.35 + var(--left, 1) * .65); }
/* controls fade away while you work, come back on mouse move */
.tabs, .controls, .rounds-label, .zen-btn { transition: opacity .6s ease; }
body.is-zen.is-idle { cursor: none; }
body.is-zen.is-idle .tabs, body.is-zen.is-idle .controls, body.is-zen.is-idle .rounds-label, body.is-zen.is-idle .zen-btn { opacity: 0; pointer-events: none; }

/* ---------- Session ticket (receipt printer) ---------- */
.printer { position: absolute; left: 50%; top: 50%; translate: -50% -58%; z-index: 8; display: none; width: 290px; }
.printer.is-on { display: block; }
.printer__slot {
  height: 12px; margin: 0 -14px; border-radius: 8px;
  background: linear-gradient(180deg, #0c0b0a, #2a2622); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .4);
  animation: slot-open .35s var(--ease);
  transition: opacity .4s, transform .4s;
}
.printer.is-done .printer__slot { opacity: 0; transform: scaleX(.6); }
@keyframes slot-open { from { transform: scaleX(.2); opacity: 0; } }
.printer__mouth { overflow: hidden; padding: 0 12px 24px; margin-top: -6px; }
.ticket { position: relative; cursor: grab; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .28)) drop-shadow(0 1px 1px rgba(0, 0, 0, .2)); touch-action: none; animation: print 1.7s cubic-bezier(.4, 0, .2, 1) both .3s; }
.ticket:active { cursor: grabbing; }
.ticket:focus-visible { outline: none; }
.ticket:focus-visible .ticket__paper { outline: 2.5px solid var(--blue); outline-offset: 3px; }
@keyframes print {
  0% { transform: translateY(-101%); }
  28% { transform: translateY(-64%); } 34% { transform: translateY(-64%); }
  62% { transform: translateY(-26%); } 68% { transform: translateY(-26%); }
  100% { transform: translateY(0); }
}
.ticket.is-torn { animation: none; }
.ticket__paper {
  --zz: 7px;
  padding: 18px 18px 26px; background: #fffdf6; color: #24211d;
  font: 500 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em;
  background-image: linear-gradient(180deg, rgba(0, 0, 0, .05), transparent 14%), var(--grain);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(var(--zz) * 2) 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(var(--zz) * 2) 100%;
}
/* once torn off, the top edge is ragged too */
.ticket.is-torn .ticket__paper {
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(var(--zz) * 2) 100%,
                conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(var(--zz) * 2) 100%;
  -webkit-mask-composite: source-in;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(var(--zz) * 2) 100%,
                conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(var(--zz) * 2) 100%;
          mask-composite: intersect;
  padding-top: 24px;
}
.ticket p { margin: 0; }
.t-brand { text-align: center; font-weight: 800; font-size: 16px; letter-spacing: .32em; }
.t-sub { text-align: center; font-size: 10px; color: rgba(36, 33, 29, .6); margin-top: 2px !important; }
.ticket hr { border: 0; border-top: 1.5px dashed rgba(36, 33, 29, .35); margin: 10px 0; }
.t-task { font: 700 26px/1.1 var(--f-hand); text-align: center; margin: 2px 0 10px !important; overflow-wrap: anywhere; }
.t-row { display: flex; justify-content: space-between; font-size: 11.5px; }
.t-row b { font-weight: 800; }
.t-note { text-align: center; font: 600 19px/1.1 var(--f-hand); color: var(--red); }
.t-barcode { height: 30px; margin: 12px 8px 4px; background: repeating-linear-gradient(90deg, #24211d 0 2px, transparent 2px 4px, #24211d 4px 5px, transparent 5px 8px, #24211d 8px 11px, transparent 11px 12px, #24211d 12px 13px, transparent 13px 16px); }
.t-hint { text-align: center; font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: rgba(36, 33, 29, .45); }

/* the Today entry flashes when a ticket lands on it */
.done-list li.is-new, .today-sum.is-new { animation: landed 1.2s ease-out; }
@keyframes landed { 0% { background: color-mix(in srgb, var(--red) 30%, transparent); scale: 1.04; } 100% { background: transparent; scale: 1; } }

/* ---------- Settings ---------- */
.sheet { border: 0; padding: 0; background: transparent; overflow: visible; width: min(400px, calc(100% - 32px)); }
.sheet::backdrop { background: rgba(20, 16, 10, .45); }
.sheet__inner { position: relative; padding: 40px 26px 24px; border-radius: 8px; color: var(--ink); }
.sheet h2 { margin: 0 0 14px; font-size: 38px; }
.fields { display: grid; gap: 10px; }
.num-field, .num { display: grid; grid-template-columns: 1fr 70px 52px; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.num input { height: 38px; border: 0; border-bottom: 2px solid var(--rule); background: transparent; color: var(--ink); text-align: center; font: 700 24px var(--f-hand); outline: none; }
.num input:focus { border-color: var(--red); }
.num em { font-style: normal; font-size: 12px; color: var(--ink-soft); }
.toggles { display: grid; gap: 10px; margin: 20px 0; font-size: 14px; font-weight: 600; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__ui { position: relative; width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 4px; flex: none; }
.switch input:checked + .switch__ui::after { content: "✓"; position: absolute; left: -1px; top: -15px; font: 700 34px/1 var(--f-hand); color: var(--red); }
.switch input:focus-visible + .switch__ui { outline: 2px solid var(--blue); outline-offset: 3px; }
.sheet__actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-ghost, .btn-red { height: 42px; padding: 0 20px; border-radius: 10px; font-weight: 700; font-size: 14px; }
.btn-ghost { color: var(--ink-soft); }
.btn-red { background: var(--red); color: #fff; box-shadow: 0 3px 0 var(--red-deep); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 80; padding: 10px 20px; border-radius: 6px;
  font: 700 24px var(--f-hand); color: var(--ink); translate: -50% 30px; opacity: 0; pointer-events: none;
  transition: opacity .3s, translate .45s var(--ease);
}
.toast.is-on { opacity: 1; translate: -50% 0; }

/* ---------- Medium screens: narrower sidebar, smaller digits ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); }

}

/* ---------- Phones: clock on top, planner below ---------- */
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); align-content: start; height: auto; min-height: 100dvh; overflow: visible; overflow-x: hidden; }
  .board { padding: 0; margin: 0 14px 24px; container-type: inline-size; }
  .keys { display: none; }
  .clock-card { --h: clamp(64px, 26cqw, 150px); min-width: 0; padding: 48px 14px 22px; }
  .clock-card .controls { --b: 52px; }
  .start { min-width: 0; padding: 0 1.4em; }
  .sidebar { position: relative; top: 0; height: auto; min-height: 0; margin: 24px 14px 18px; padding: 26px 20px 18px; overflow: visible; }
  .tab { padding: 8px 12px; font-size: 13px; }
  .status { font-size: 23px; }
  .done-list { max-height: 220px; }
  /* focus mode button sits under the clock on phones */
  .zen-row { margin-top: 16px; order: 10; justify-content: center; }
  .zen-btn { position: static; height: 38px; }
  .zen-btn kbd { display: none; }
  /* focus mode on a phone: the clock takes the whole screen */
  body.is-zen .layout { min-height: 0; }
  body.is-zen .board { position: fixed; inset: 0; margin: 0; z-index: 70; container-type: size; display: flex; }
  body.is-zen .clock-card { border-radius: 0; padding: 40px 14px 26px; --h: clamp(60px, min((100cqh - 330px) / 1.6, 26cqw), 220px); }
  body.is-zen .rotate-btn { display: inline-flex; }
  /* landscape: turn the card sideways so it fills the phone horizontally */
  body.is-zen.is-rotated .board {
    inset: auto; top: 0; left: 100vw; width: 100dvh; height: 100vw;
    transform: rotate(90deg); transform-origin: top left;
  }
  body.is-zen.is-rotated .clock-card { padding: 22px 30px 14px; --h: clamp(60px, min((100cqh - 170px) / 1.15, 22cqw), 280px); }
  body.is-zen.is-rotated .clock-card > .pin { display: none; }
  body.is-zen.is-rotated .status { margin-bottom: calc(var(--h) * .06); }
  body.is-zen.is-rotated .controls { margin-top: calc(var(--h) * .1); }
  body.is-zen.is-rotated .ruler { margin-top: calc(var(--h) * .1); }
  body.is-zen.is-rotated .rounds-label { display: none; }
  body.is-zen.is-rotated .zen-row { margin-top: 8px; }
}
.rotate-btn { display: none; }
.zen-row { display: flex; gap: 8px; }
.clock-card .zen-row { display: flex; gap: 8px; }

/* phone held sideways: clock fills the screen, planner is below it */
@media (orientation: landscape) and (max-height: 500px) {
  .layout { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100dvh; overflow: visible; }
  .sidebar { position: relative; top: 0; height: auto; min-height: 0; margin: 0 14px 18px; order: 2; }
  .board { height: 100dvh; margin: 0; padding: 10px 14px; container-type: size; }
  .clock-card { padding: 16px 24px 12px; --h: clamp(56px, min((100cqh - 190px) / 1.2, 19cqw), 240px); }
  .clock-card > .pin { display: none; }
  .status { margin-bottom: calc(var(--h) * .05); font-size: 20px; }
  .tabs { margin-bottom: 6px; }
  .tab { padding: 6px 14px; font-size: 13px; }
  .ruler { margin-top: calc(var(--h) * .1); }
  .controls { --b: 46px; margin-top: calc(var(--h) * .1); }
  .rounds-label { display: none; }
  .zen-btn { right: 12px; bottom: 10px; }
  .zen-btn kbd { display: none; }
  .keys { display: none; }
  body.is-zen .board { padding: 0; }
  body.is-zen .clock-card { border-radius: 0; }
}
@media (max-width: 360px) {
  .tab { padding: 7px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
