/* Quill. Two rooms to write in, picked in Account or with the sun/moon
   button (theme.js sets data-theme on <html> before the page draws):

   Light: a spring day on the balcony. Morning sky at the top of the page,
   new-leaf green, daffodil, apricot, blossom; sunlight on the greeting.
   Dark: a secluded library. Walnut and leather browns under a lamp's glow,
   cobalt bindings, gold leaf on the titles and the buttons. */

:root {
  color-scheme: light;
  --page: linear-gradient(180deg, #dcedf8 0, #eaf4f1 260px, #f7f8ef 560px) no-repeat, #f7f8ef;
  --bg: #f7f8ef;
  --top-bg: rgb(255 255 255 / .55);
  --surface: #ffffff;
  --surface-2: #eef4e6;
  --ink: #1f3128;
  --muted: #5f6f65;
  --line: #dde6d6;
  --edge: #dde6d6;
  --accent: #367f47;
  --accent-ink: #ffffff;
  --accent-soft: #dff0de;
  --title: #1d3b2a;
  --kicker: #3c77a6;
  --hero-bg: radial-gradient(circle at 90% 8%, #fff0b3 0, rgb(255 240 179 / 0) 40%), linear-gradient(135deg, #ffffff 0%, #f1f8ee 100%);
  --hero-ink: #1f3128;
  --hero-muted: #5f6f65;
  --hero-line: #dde6d6;
  --hero-track: #e8f0e1;
  --hero-ring: var(--accent);
  --hero-ring-met: var(--good);
  --tab-on: #ffffff;
  --tab-on-ink: #1f3128;
  --sprint-bg: #1f3d2c;
  --sprint-ink: #f6f8ee;
  --sprint-ring: #f5c242;
  --flame: #ec7a1c;
  --good: #2e8744;
  --ring-met: var(--good);
  --warn: #c2571a;
  --danger: #c0392b;
  --cell: #e5ecdf;
  --st-idea: #d5d2c5;
  --st-outlined: #efcd57;
  --st-drafting: #f2a25a;
  --st-drafted: #66a3db;
  --st-revised: #e38bb1;
  --st-done: #47a05a;
  --shadow: 0 1px 2px rgb(30 60 40 / .05), 0 8px 24px rgb(30 60 40 / .07);
  --radius: 16px;
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --cell-size: 12px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: radial-gradient(120% 70% at 50% -18%, #3b2a1a 0%, rgb(59 42 26 / 0) 62%) no-repeat, #15100c;
  --bg: #15100c;
  --top-bg: rgb(21 16 12 / .8);
  --surface: #211912;
  --surface-2: #2e2319;
  --ink: #f0e4cb;
  --muted: #b29f82;
  --line: #3a2c20;
  --edge: rgb(206 162 76 / .22);
  --accent: #d6a840;
  --accent-ink: #1b130b;
  --accent-soft: rgb(214 168 64 / .16);
  --title: #e8c56f;
  --kicker: #c9a55c;
  --hero-bg: linear-gradient(140deg, #24439a 0%, #182f72 55%, #112352 100%);
  --hero-ink: #f3e9d2;
  --hero-muted: #b6c1e2;
  --hero-line: rgb(214 168 64 / .4);
  --hero-track: rgb(255 255 255 / .13);
  --hero-ring: #d6a840;
  --hero-ring-met: #f0d27a;
  --tab-on: #2a4cb0;
  --tab-on-ink: #f3e9d2;
  --sprint-bg: #1c3478;
  --sprint-ink: #f3e9d2;
  --sprint-ring: #d6a840;
  --flame: #f0a04a;
  --good: #9cc98a;
  --ring-met: #e8c56f;
  --warn: #eba25c;
  --danger: #f08f80;
  --cell: #2b2119;
  --st-idea: #5f5347;
  --st-outlined: #937842;
  --st-drafting: #cf8e33;
  --st-drafted: #4468d0;
  --st-revised: #8d5aa9;
  --st-done: #4e905c;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 28px rgb(0 0 0 / .35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0 auto;
  max-width: 1200px;
  padding: 0 max(18px, env(safe-area-inset-left)) calc(80px + env(safe-area-inset-bottom));
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
h1, h2 { color: var(--title); }
p { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; }
small { font-size: .8em; color: var(--muted); font-weight: 400; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: .55em 1.1em;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); border-color: transparent; }
.btn-quiet { background: transparent; }
.btn-quiet:hover { background: var(--surface); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: var(--danger); }
.btn-sm { padding: .35em .85em; font-size: .88rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem;
  border: 0; border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem; line-height: 1;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }

.chip-btn {
  border: 1px dashed var(--line);
  background: transparent;
  border-radius: 999px;
  padding: .3em .8em;
  font-size: .85rem; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.chip-btn:hover { color: var(--ink); border-color: var(--muted); }

/* ---------- top bar ---------- */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: max(12px, env(safe-area-inset-top)) 0 12px;
  background: var(--top-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { border-radius: 9px; display: block; }
.brand-word { font: 600 1.45rem/1 var(--serif); letter-spacing: .01em; color: var(--title); }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tabs a {
  padding: .35em 1em; border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: .92rem; color: var(--muted);
}
.tabs a[aria-current="page"] { background: var(--tab-on); color: var(--tab-on-ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 999px; }

.avatar {
  --c: var(--accent);
  display: inline-grid; place-items: center; flex: none;
  width: 2.3rem; height: 2.3rem; border-radius: 999px;
  background: var(--c);
  color: #fff;
  font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.avatar.sm { width: 1.9rem; height: 1.9rem; font-size: .72rem; }
.avatar.xs { width: 1.3rem; height: 1.3rem; font-size: .55rem; vertical-align: -.25em; }
.avatar.lg { width: 4rem; height: 4rem; font-size: 1.4rem; }

/* ---------- the room ---------- */

.hello {
  display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center;
  margin: 18px 0 30px;
  padding: 28px 30px;
  background: var(--hero-bg);
  color: var(--hero-ink);
  border: 1px solid var(--hero-line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
}
.kicker { color: var(--kicker); font-size: .85rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.hello h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 6px 0 8px; }
.lede { font-size: 1.08rem; color: color-mix(in srgb, var(--hero-ink) 82%, var(--hero-muted)); max-width: 46ch; }
.hello .btn-quiet { color: var(--hero-ink); border-color: var(--hero-line); }
.hello .btn-quiet:hover { background: color-mix(in srgb, var(--hero-ink) 7%, transparent); }
.hello .ring-track { stroke: var(--hero-track); }
.hello .ring-fill { stroke: var(--hero-ring); }
.hello .ring.met .ring-fill { stroke: var(--hero-ring-met); }
.hello .ring-label span, .hello .today-stats dt { color: var(--hero-muted); }
.hello-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.today { display: flex; align-items: center; gap: 22px; }
.today-stats { display: grid; gap: 10px; margin: 0; }
.today-stats div { display: flex; flex-direction: column; }
.today-stats dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.today-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; display: block; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 9; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring.met .ring-fill { stroke: var(--ring-met); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label strong { font: 700 1.6rem/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.ring-label span { font-size: .75rem; color: var(--muted); max-width: 9ch; margin: 2px auto 0; line-height: 1.2; }

.room { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 30px; align-items: start; }
.sec-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-head h2 { font-size: 1.35rem; }
.sec-head .muted { font-size: .88rem; }
.sec-head .btn { margin-left: auto; }

.sprint-call {
  margin: -4px 0 14px; padding: 10px 14px;
  background: var(--accent-soft); border-radius: 12px; font-size: .92rem;
}

.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  --c: var(--accent);
  position: relative;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .12s, box-shadow .12s;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 10px 24px rgb(0 0 0 / .08); }
.card.is-sprinting { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); }
.card-link { display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 16px 22px; text-decoration: none; flex: 1; }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-who { min-width: 0; flex: 1; }
.card-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.you { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 1px 6px; border-radius: 999px; }
.card-sub { font-size: .82rem; color: var(--muted); }
.live { color: var(--c); font-weight: 700; }
.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 99px; background: currentColor; margin-right: 6px; vertical-align: 1px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.flame { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--flame); white-space: nowrap; }
.flame.cold { filter: grayscale(.85); opacity: .65; }
.card-book { display: grid; gap: 8px; }
.card-title { font: 600 1.25rem/1.2 var(--serif); }
.card-meta { font-size: .85rem; color: var(--muted); margin-top: -4px; }
.card-empty { color: var(--muted); font-style: italic; }
.card-foot { display: flex; align-items: flex-end; gap: 18px; margin-top: auto; padding-top: 4px; }
.card-foot > span { display: flex; flex-direction: column; line-height: 1.2; }
.card-foot small { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.card-foot b { font-variant-numeric: tabular-nums; }
.card-foot .spark { margin-left: auto; }
.join { display: flex; width: calc(100% - 40px); margin: -4px 18px 16px 22px; }

.spark rect.on { fill: var(--c, var(--accent)); }
.spark rect.off { fill: var(--cell); }

.progress { display: grid; gap: 6px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--c, var(--accent)); border-radius: inherit; min-width: 2px; transition: width .6s ease; }
.bar-label { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-label strong { color: var(--ink); }
.progress.big .bar { height: 14px; }
.progress.big .bar-label { font-size: 1rem; }
.progress.big .bar-label strong { font: 700 1.9rem/1 var(--serif); margin-right: 2px; }

.chmap { display: flex; gap: 2px; height: 8px; }
.chmap span { flex: 1; border-radius: 2px; min-width: 3px; }
.chmap.big { height: 14px; gap: 3px; margin-top: 4px; }
.st-idea { --s: var(--st-idea); }
.st-outlined { --s: var(--st-outlined); }
.st-drafting { --s: var(--st-drafting); }
.st-drafted { --s: var(--st-drafted); }
.st-revised { --s: var(--st-revised); }
.st-done { --s: var(--st-done); }
.chmap span, .dot { background: var(--s); }

/* ---------- feed ---------- */

.feed { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; padding-right: 4px; }
.feed h2 { font-size: 1.35rem; margin-bottom: 14px; }
.feed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ev { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 10px 8px; border-radius: 12px; }
.ev:hover { background: var(--surface); }
.ev-big { background: color-mix(in srgb, var(--c) 9%, transparent); }
.ev-big:hover { background: color-mix(in srgb, var(--c) 14%, transparent); }
.ev-text { font-size: .93rem; line-height: 1.4; }
.ev-name { font-weight: 700; text-decoration: none; }
.ev-name:hover { text-decoration: underline; }
.ev-meta { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.cheer {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 2px 9px; font-size: .85rem; cursor: pointer;
  filter: grayscale(1); opacity: .75;
  transition: filter .15s, opacity .15s, transform .1s;
}
.cheer:hover { filter: none; opacity: 1; }
.cheer.on { filter: none; opacity: 1; background: var(--accent-soft); border-color: transparent; font-weight: 700; }
.cheer:active { transform: scale(.92); }
.cheers-got { font-size: .85rem; padding: 2px 4px; font-variant-numeric: tabular-nums; }
.empty-feed { padding: 14px 4px; font-size: .92rem; }

/* ---------- a book ---------- */

.book-view { --c: var(--accent); }
.book-head { margin: 22px 0 22px; display: grid; gap: 8px; }
.book-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.book-tabs a {
  padding: .25em .85em; border-radius: 999px; border: 1px solid var(--line);
  text-decoration: none; font-size: .85rem; font-weight: 600; color: var(--muted);
}
.book-tabs a.on { color: var(--ink); background: var(--surface); border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.book-tabs a.archived { font-style: italic; opacity: .7; }
.book-title { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.01em; }
.book-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--muted); font-size: .92rem; }
.book-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-2); color: var(--ink); white-space: nowrap;
}
.pill[class*="st-"] { background: color-mix(in srgb, var(--s) 28%, transparent); }
.bs-planning { background: var(--surface-2); }
.bs-drafting { background: color-mix(in srgb, var(--st-drafting) 28%, transparent); }
.bs-revising { background: color-mix(in srgb, var(--st-revised) 28%, transparent); }
.bs-editing { background: color-mix(in srgb, var(--st-drafted) 28%, transparent); }
.bs-finished { background: color-mix(in srgb, var(--st-done) 30%, transparent); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.tile-wide { grid-column: span 3; justify-content: center; gap: 10px; }
.tile-ring { align-items: center; justify-content: center; }
.tile-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.tile-value { font: 700 1.6rem/1.15 var(--serif); font-variant-numeric: tabular-nums; }
.tile-sub { font-size: .82rem; color: var(--muted); }
.tone-good .tile-sub { color: var(--good); font-weight: 600; }
.tone-warn .tile-sub { color: var(--warn); font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--edge); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.book-cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.book-cols .panel { margin-bottom: 0; }
.empty-panel { display: grid; gap: 12px; justify-items: start; color: var(--muted); padding: 6px 0; }

/* heatmap */
.heat-wrap { overflow-x: auto; padding-bottom: 4px; }
.heat-grid { --sz: var(--cell-size); display: grid; grid-template-columns: auto max-content; grid-template-areas: ". months" "days heat"; gap: 4px 6px; width: max-content; }
.heat-months { grid-area: months; display: grid; gap: 3px; font-size: .7rem; color: var(--muted); height: 1em; }
.heat-months span { white-space: nowrap; }
.heat-days { grid-area: days; display: grid; grid-template-rows: repeat(7, var(--sz)); gap: 3px; font-size: .65rem; color: var(--muted); line-height: var(--sz); }
.heat { grid-area: heat; display: grid; grid-template-rows: repeat(7, var(--sz)); grid-auto-flow: column; grid-auto-columns: var(--sz); gap: 3px; }
.heat span, .heat-legend span { width: var(--cell-size); height: var(--cell-size); border-radius: 3px; background: var(--cell); }
.heat .l1, .heat-legend .l1 { background: color-mix(in srgb, var(--c) 30%, var(--cell)); }
.heat .l2, .heat-legend .l2 { background: color-mix(in srgb, var(--c) 55%, var(--cell)); }
.heat .l3, .heat-legend .l3 { background: color-mix(in srgb, var(--c) 80%, var(--cell)); }
.heat .l4, .heat-legend .l4 { background: var(--c); }
.heat .today { outline: 1.5px solid var(--ink); outline-offset: 1px; }
.heat-legend { display: flex; align-items: center; gap: 3px; font-size: .75rem; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.heat-legend span { display: inline-block; }

/* chapters */
.legend { list-style: none; margin: -4px 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 5px; }
.legend li.zero { opacity: .5; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.ch-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; }
.ch {
  display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto 6.5rem auto; gap: 10px; align-items: center;
  padding: 9px 4px 9px 0; border-top: 1px solid var(--line);
  position: relative;
}
.ch:first-child { border-top: 0; }
.ch::before { content: ""; position: absolute; left: -20px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--s); }
.ch[draggable="true"] { cursor: grab; }
.ch.dragging { opacity: .4; }
.ch.over { box-shadow: inset 0 2px 0 var(--accent); }
.ch-num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; text-align: right; }
.ch-main { min-width: 0; }
.ch-title { display: block; font-weight: 600; text-align: left; border: 0; background: none; padding: 0; cursor: default; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
button.ch-title { cursor: pointer; }
button.ch-title:hover { color: var(--accent); text-decoration: underline; }
.ch-title.untitled { color: var(--muted); font-weight: 500; }
.ch-note { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-note::before { content: "🔒 "; font-size: .75em; }
.ch-words { display: grid; gap: 4px; text-align: right; font-variant-numeric: tabular-nums; font-size: .88rem; }
.mini-bar { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--s); }
.ch-move { display: flex; }
.ch-move .icon-btn { width: 1.7rem; height: 1.7rem; font-size: .95rem; }

/* your log */
.log { list-style: none; margin: 0; padding: 0; display: grid; }
.log li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }
.log-day { font-size: .85rem; color: var(--muted); padding-top: 2px; }
.log-main b { font-variant-numeric: tabular-nums; color: var(--good); }
.log-main b.neg { color: var(--warn); }
.log-note { font-size: .85rem; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.log .icon-btn { opacity: .5; }
.log li:hover .icon-btn { opacity: 1; }

.empty-state { text-align: center; padding: 70px 20px; display: grid; gap: 14px; justify-items: center; }
.empty-state h1 { font-size: 2.2rem; }
.empty-state p { color: var(--muted); max-width: 44ch; }

/* ---------- dialogs and forms ---------- */

dialog {
  padding: 0; border-radius: 20px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--edge);
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  box-shadow: 0 20px 60px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(30 50 40 / .35); backdrop-filter: blur(2px); }
:root[data-theme="dark"] dialog::backdrop { background: rgb(8 6 4 / .62); }
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.dlg.narrow { max-width: 440px; }
dialog:has(.narrow) { width: min(440px, calc(100vw - 24px)); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px 24px; }
.dlg-head h2 { font-size: 1.4rem; }
.dlg-body { padding: 10px 24px 8px; overflow: auto; display: grid; gap: 14px; }
.dlg-body h3 { font-size: 1.05rem; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 18px 24px; border-top: 1px solid var(--line); margin-top: 6px; }
.spacer { flex: 1; }
.form-error { margin: 0 24px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: .9rem; }
.login .form-error { margin: 0; }

.field { display: grid; gap: 5px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span:first-child, .field > label, .field legend { font-size: .85rem; font-weight: 600; }
.field legend { padding: 0; margin-bottom: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg);
  padding: .55em .75em;
  min-height: 2.6rem;
}
textarea { resize: vertical; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; border-color: var(--accent); }
.big-number { font: 700 2rem/1.1 var(--serif) !important; padding: .35em .5em !important; font-variant-numeric: tabular-nums; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check input { margin-top: .25em; width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.check small { display: block; }
.privacy { font-size: .82rem; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.privacy::before { content: "🔒 "; }

.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 999px; margin-bottom: 6px; justify-self: start; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .3em .95em; border-radius: 999px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--tab-on); color: var(--tab-on-ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: block; padding: .35em .85em; border-radius: 999px; border: 1px solid var(--line); font-size: .88rem; font-weight: 600; color: var(--muted); }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { --c: #888; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch::before { content: ""; display: block; width: 2rem; height: 2rem; border-radius: 999px; background: var(--c); box-shadow: inset 0 0 0 2px rgb(255 255 255 / .2); }
.swatch:has(input:checked)::before { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatch:has(input:focus-visible)::before { outline: 2px solid var(--accent); outline-offset: 4px; }

.stack { display: grid; gap: 12px; }
.sep { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.inline-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.msg { margin-right: auto; font-size: .88rem; }
.msg.good { color: var(--good); }
.msg.bad { color: var(--danger); }
.account-links { display: flex; flex-wrap: wrap; gap: 8px; grid-template-columns: none; }

.people { list-style: none; margin: 0; padding: 0; display: grid; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.people-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-actions { display: flex; gap: 6px; }
.pw-gen { display: flex; gap: 6px; align-items: center; }
.pw-gen input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.share { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; justify-items: start; }
.share-title { font-weight: 600; font-size: .92rem; }
.share pre { margin: 0; white-space: pre-wrap; font-size: .85rem; overflow-wrap: anywhere; }

/* ---------- sign in ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px 0; }
.login-card {
  width: min(380px, 100%);
  display: grid; gap: 14px; justify-items: stretch; text-align: left;
  background: var(--surface); border: 1px solid var(--edge); border-radius: 22px;
  padding: 32px 28px; box-shadow: var(--shadow);
}
.login-card img { border-radius: 14px; justify-self: center; }
.login-card h1 { font-size: 2.2rem; text-align: center; }
.login-card > .muted, .login-card > .hint { text-align: center; }

/* ---------- sprint bar, toast, confetti ---------- */

.sprint-bar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 12px;
  background: var(--sprint-bg); color: var(--sprint-ink);
  padding: 8px 10px 8px 12px; border-radius: 999px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .3);
}
.sprint-ring { width: 36px; height: 36px; }
.sprint-ring circle { fill: none; stroke-width: 4; }
.sprint-ring .track { stroke: color-mix(in srgb, var(--sprint-ink) 22%, transparent); }
.sprint-ring .fill { stroke: var(--sprint-ring); stroke-linecap: round; transition: stroke-dasharray 1s linear; }
.sprint-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sprint-text strong { font: 700 1.2rem/1.1 var(--sans); font-variant-numeric: tabular-nums; }
.sprint-text span { font-size: .75rem; opacity: .75; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sprint-bar .icon-btn { color: inherit; opacity: .7; }
.sprint-bar .icon-btn:hover { background: color-mix(in srgb, var(--sprint-ink) 15%, transparent); color: inherit; opacity: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--edge);
  padding: 10px 18px; border-radius: 14px; box-shadow: var(--shadow);
  font-weight: 600; max-width: min(92vw, 520px); text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.party { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font: 700 1.15rem/1.3 var(--serif); padding: 14px 22px; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105vh; transform: rotate(720deg) translateX(40px); opacity: .8; } }

/* ---------- narrower screens ---------- */

@media (max-width: 980px) {
  .room { grid-template-columns: 1fr; }
  .feed { position: static; max-height: none; overflow: visible; }
  .book-cols { grid-template-columns: 1fr; }
  .book-cols .panel + .panel { margin-top: 0; }
}

@media (max-width: 720px) {
  body { padding-inline: max(12px, env(safe-area-inset-left)); }
  .top { gap: 8px; }
  .brand-word { display: none; }
  .tabs a { padding: .35em .75em; }
  .top-actions .label { display: none; }
  .top-actions .btn { width: 2.5rem; height: 2.5rem; padding: 0; font-size: 1.1rem; }
  .hello { grid-template-columns: 1fr; padding: 22px 20px; gap: 18px; }
  .today { justify-content: flex-start; }
  .ring { width: 112px; height: 112px; }
  .ring-label strong { font-size: 1.3rem; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-wide { grid-column: 1 / -1; }
  .ch { grid-template-columns: 1.6rem minmax(0, 1fr) auto; }
  .ch-words { grid-column: 2 / 3; text-align: left; grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
  .ch-move { grid-row: 1; grid-column: 3; }
  .ch .pill { grid-column: 3; grid-row: 2; justify-self: end; }
  .row2 { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .ch::before { left: -16px; }
  :root { --cell-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.more { margin-top: 10px; }
.dlg-body:last-child { padding-bottom: 24px; }
@media (max-width: 400px) {
  #sprint-open { display: none; }
}

/* ---------- the theme switch ---------- */

.theme-btn { width: 2.5rem; height: 2.5rem; color: var(--ink); }
.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .theme-btn .i-moon, :root:not([data-theme="dark"]) .theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn { color: var(--title); }
.login .theme-btn { position: fixed; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
.theme-seg span { padding-inline: 1.05em; }
