/* Leaf - global styles, components and screens.
 * Paper, not app: warm paper with a faint grain, warm ink, hairline rules, set type.
 * No shadows on text surfaces, no gradients, no motion: a page changes in one frame, like e-ink. */

*, *::before, *::after { box-sizing: border-box; }

/* Still: nothing ever animates. Page turns replace the page in one frame. */
*, *::before, *::after {
  transition: none !important;
  animation: none !important;
  scroll-behavior: auto !important;
}

:root {
  --ui-size: 16.5px;
  --read-size: var(--body-size);
  --read-leading: var(--leading-normal);
  --read-font: var(--font-reading);
  --margin-factor: 1;
  --feed-head: 56px;
  --r-ctl: 10px;      /* buttons, fields */
  --r-sheet: 18px;    /* sheet top corners */
  --r-cover: 3px;     /* books are nearly square-cornered */
  /* Paper grain: a tiled noise tile, darker specks on light paper. */
  --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='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1  0 0 0 0 .08  0 0 0 0 .05  0 0 0 .075 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
  color: var(--ink);
}
/* On dark paper the grain is a faint lighter speck instead. */
:root[data-theme="night"] {
  --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='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 .96  0 0 0 0 .9  0 0 0 .045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

html { background: var(--grain), var(--paper); }
html.snap-feed {
  scroll-snap-type: y proximity;
  scroll-padding-top: calc(var(--feed-head) + env(safe-area-inset-top));
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--grain), var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  line-height: 1.45;
  font-kerning: normal;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

::selection { background: var(--mark); color: var(--ink); }

a { color: inherit; text-decoration-line: underline; text-decoration-color: var(--ink-3); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
cite { font-style: italic; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }

:focus { outline: none; }
:focus-visible { outline: var(--focus) solid var(--ink); outline-offset: 2px; }
.view:focus, .reader:focus { outline: none; }

[hidden] { display: none !important; }

.icon { display: inline-flex; line-height: 0; }
.icon svg { display: block; }

.meta { font-size: 0.8em; color: var(--ink-2); line-height: 1.4; letter-spacing: 0.005em; }
/* Numbers in Literata: Atkinson's slashed zero looks like a terminal, not a book. */
.num, .count, .tab-count, .foot-progress, .chrome-pct, .feed-count, .preview-page {
  font-family: var(--font-reading);
  font-variant-numeric: lining-nums tabular-nums;
}

/* ------------------------------------------------------------------ screen frame */

.screen {
  max-width: 38rem;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 8px)
    calc(var(--side) + env(safe-area-inset-right))
    calc(env(safe-area-inset-bottom) + 56px)
    calc(var(--side) + env(safe-area-inset-left));
}

.screen-head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 64px;
  margin: 0 0 6px;
}
.screen-head .back { margin-left: -12px; }
.screen-title {
  margin: 0;
  font-family: var(--font-reading);
  font-weight: 400;
  font-style: italic;
  font-size: 1.75em;
  line-height: 1.15;
  letter-spacing: -0.012em;
  min-width: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--target);
  min-height: var(--target);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  flex: none;
}
.icon-btn:active { background: var(--paper-2); }

/* Section label: letterspaced small capitals, quiet. */
.label {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 34px 0 12px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.7em;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.label::after { content: ''; flex: 1; border-top: var(--hairline) solid var(--rule); transform: translateY(-0.3em); }
.label-link { margin-left: auto; order: 2; padding: 0; border: 0; background: none; color: var(--ink-2); font: inherit; letter-spacing: inherit; text-transform: inherit; min-height: 28px; }

.lede { font-size: 1em; line-height: 1.55; margin: 8px 0 16px; color: var(--ink); }
.empty, .empty-state { color: var(--ink-2); padding: 24px 0; }
.empty-state p { margin: 0 0 8px; }
.empty-state .btn { margin-top: 12px; }

hr.rule { border: 0; border-top: var(--hairline) solid var(--rule); margin: 18px 0 0; }

/* A centred fleuron between sections. */
.orn {
  display: block;
  margin: 26px 0 0;
  text-align: center;
  font-family: var(--font-reading);
  color: var(--ink-3);
  font-size: 1.05em;
  line-height: 1;
}

/* progress: hairline track, ink fill */
.progress { display: block; height: 2px; background: var(--rule); overflow: hidden; border-radius: 2px; }
.progress > i { display: block; height: 100%; background: var(--ink); }

/* ------------------------------------------------------------------ rows & buttons */

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: var(--row);
  padding: 10px 2px;
  border: 0;
  border-bottom: var(--hairline) solid var(--rule);
  background: none;
  text-align: left;
  color: var(--ink);
}
.row:active { background: var(--paper-2); }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-hint { font-size: 0.8em; color: var(--ink-2); }
.row-trail { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-3); flex: none; }
.row-trail .count { color: var(--ink-2); font-size: 1.02em; }
.rows { margin-top: 28px; border-top: var(--hairline) solid var(--rule); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border: var(--hairline) solid var(--ink-3);
  border-radius: var(--r-ctl);
  background: none;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.01em;
}
.btn:active { background: var(--paper-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 600; }
.btn.primary:active { background: var(--ink-2); border-color: var(--ink-2); }
.btn.quiet { border-color: transparent; color: var(--ink-2); }
.btn[aria-pressed="true"] { border-color: var(--ink); }
.btn[aria-busy="true"] { color: var(--ink-2); }

.link { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; text-decoration-color: var(--ink-3); text-underline-offset: 0.18em; min-height: 32px; }

.actions { display: grid; gap: 10px; margin: 22px 0 0; }
.actions .btn { width: 100%; }
.actions.pair { grid-template-columns: 1fr 1fr; }

/* ------------------------------------------------------------------ settings controls */

.field { margin: 20px 0 0; }
.field-name { font-size: 0.85em; color: var(--ink-2); margin: 0 0 8px; }
.field-hint { font-size: 0.8em; color: var(--ink-2); margin: 8px 0 0; line-height: 1.45; }

.seg {
  display: flex;
  padding: 3px;
  gap: 3px;
  border-radius: calc(var(--r-ctl) + 3px);
  background: var(--paper-2);
  border: var(--hairline) solid var(--rule);
}
.seg > button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-ctl);
  background: none;
  color: var(--ink-2);
  font-size: 0.92em;
  line-height: 1.2;
}
.seg > button[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 var(--hairline) var(--rule); }
:root[data-theme="night"] .seg > button[aria-pressed="true"] { background: var(--ink); color: var(--paper); box-shadow: none; }
.seg > button:focus-visible { position: relative; z-index: 1; }

.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink);
  min-height: var(--target);
}
.swatch-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 56px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  border: var(--hairline) solid var(--rule);
  background: var(--sw-paper);
  color: var(--sw-ink);
  font-family: var(--font-reading);
  font-size: 1.15em;
}
[data-theme="night"] .swatch-chip { border-color: var(--ink-3); }
.swatch-auto {
  background: linear-gradient(135deg, var(--theme-paper-paper) 0 50%, var(--theme-night-paper) 50% 100%);
  color: var(--theme-paper-ink);
}
.swatch-name { font-size: 0.78em; color: var(--ink-2); }
.swatch[aria-pressed="true"] .swatch-chip { outline: 2px solid var(--ink); outline-offset: 3px; }
.swatch[aria-pressed="true"] .swatch-name { color: var(--ink); font-weight: 600; }
.swatch:focus-visible { outline-offset: 4px; }

.stepper {
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  align-items: center;
  padding: 3px;
  border-radius: calc(var(--r-ctl) + 3px);
  background: var(--paper-2);
  border: var(--hairline) solid var(--rule);
}
.stepper-btn {
  min-height: 40px;
  border: 0;
  border-radius: var(--r-ctl);
  background: none;
  color: var(--ink);
  font-size: 1em;
}
.stepper-btn:active { background: var(--paper); }
.stepper-value {
  text-align: center;
  font-family: var(--font-reading);
  font-size: 1.2em;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 40px;
}
.aa-small, .aa-large { font-family: var(--font-reading); }
.aa-small { font-size: 0.85em; }
.aa-large { font-size: 1.25em; }

.select, .time {
  min-height: var(--target);
  width: 100%;
  padding: 0 12px;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--r-ctl);
  background: var(--paper-2);
  color: var(--ink);
}
.times { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.time-field { display: grid; gap: 6px; font-size: 0.85em; color: var(--ink-2); }
.time-field .time { font-size: 1.1rem; color: var(--ink); }

/* ------------------------------------------------------------------ sheets */

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgb(20 16 10 / 0.22); }
:root[data-theme="night"] .sheet-backdrop { background: rgb(0 0 0 / 0.5); }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-height: 88svh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--grain), var(--paper);
  border-top: var(--hairline) solid var(--rule);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  padding: 0 calc(var(--side) + env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 28px) calc(var(--side) + env(safe-area-inset-left));
}
.sheet > * { max-width: 38rem; margin-left: auto; margin-right: auto; }
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding-top: 10px;
  background: var(--grain), var(--paper);
  border-bottom: var(--hairline) solid var(--rule);
}
.sheet-head::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 4px;
  background: var(--rule);
}
.sheet-head .icon-btn { margin-right: -10px; }
.sheet-title {
  margin: 0;
  font-family: var(--font-reading);
  font-style: italic;
  font-weight: 400;
  font-size: 1.25em;
  color: var(--ink);
}
.sheet-body { padding-top: 4px; }
.sheet .field:first-child { margin-top: 14px; }

/* ------------------------------------------------------------------ covers */

.cover {
  --w: 100%;
  position: relative;
  display: block;
  width: var(--w);
  aspect-ratio: 2 / 3;
  container-type: inline-size;
  border-radius: var(--r-cover) calc(var(--r-cover) + 2px) calc(var(--r-cover) + 2px) var(--r-cover);
  background: var(--cloth);
  color: #F2ECDF;
  overflow: hidden;
  flex: none;
  /* The only shadow in Leaf: a book lifts off the paper a little. */
  box-shadow: 0 1px 1px rgb(30 20 10 / 0.18), 0 6px 14px -8px rgb(30 20 10 / 0.45);
  font-family: var(--font-reading);
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
}
:root[data-theme="night"] .cover { box-shadow: 0 0 0 1px rgb(255 255 255 / 0.06); filter: brightness(0.92); }
/* Spine: a fold line near the left edge. */
.cover::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5.5%;
  width: 1px;
  background: rgb(0 0 0 / 0.22);
  box-shadow: 1px 0 0 rgb(255 255 255 / 0.08);
}
.cover-frame {
  position: absolute;
  inset: 7% 8% 7% 12%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5cqw;
  padding: 8cqw 5cqw;
  border: 1px solid rgb(242 236 223 / 0.42);
  outline: 1px solid rgb(242 236 223 / 0.18);
  outline-offset: -4cqw;
}
.cover-title {
  display: block;
  font-weight: 450;
  line-height: 1.12;
  letter-spacing: -0.005em;
  text-wrap: balance;
  hyphens: manual;
  overflow-wrap: normal;
  word-break: normal;
}
.cover-title.fit-s { font-size: 15cqw; font-style: italic; }
.cover-title.fit-m { font-size: 12cqw; }
.cover-title.fit-l { font-size: 10cqw; }
.cover-title.fit-xl { font-size: 8.4cqw; }
.cover-orn { font-size: 9cqw; line-height: 1; opacity: 0.7; }
.cover-author {
  display: block;
  font-family: var(--font-ui);
  font-size: 5.8cqw;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.3;
  opacity: 0.85;
}
/* Paper-label variant: a printed label pasted on the cloth. */
.cover-label .cover-frame {
  inset: 22% 14% 24% 18%;
  background: #EFE8D8;
  color: #2A241C;
  border-color: rgb(42 36 28 / 0.35);
  outline-color: rgb(42 36 28 / 0.18);
  border-radius: 1px;
}
.cover-label .cover-title.fit-s { font-size: 13cqw; }
.cover-label .cover-title.fit-m { font-size: 10.5cqw; }
.cover-label .cover-title.fit-l { font-size: 9cqw; }
.cover-label .cover-title.fit-xl { font-size: 7.6cqw; }
.cover-label .cover-orn { color: var(--cloth); opacity: 1; }
.cover-s .cover-orn, .cover-s .cover-author { display: none; }
.cover-s .cover-frame { gap: 0; }
.cover-s.cover-label .cover-frame { inset: 18% 10% 20% 16%; }

/* ------------------------------------------------------------------ home */

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 26px;
}
.wordmark {
  margin: 0;
  font-family: var(--font-reading);
  font-style: italic;
  font-weight: 400;
  font-size: 1.65em;
  line-height: 1;
  letter-spacing: -0.015em;
}
.wordmark { font-size: 1em; line-height: 0; }
.logo { display: inline-block; line-height: 0; color: var(--ink); }
.logo svg { display: block; height: 28px; width: auto; overflow: visible; }
.logo .logo-letters, .logo .logo-pixels { fill: currentColor; }
.logo .logo-leaf { fill: var(--accent); }
/* The far side of the folded leaf: the accent, softened into the paper. */
.logo .logo-leaf-far { fill: var(--accent); opacity: 0.62; }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .logo .logo-leaf-far { fill: color-mix(in srgb, var(--accent) 62%, var(--paper)); opacity: 1; }
}
.logo.large svg { height: 64px; }
.home-date {
  margin: 0;
  text-align: right;
  color: var(--ink-2);
  font-size: 0.68em;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1.5;
}
.update-line { margin: 12px 0 0; font-size: 0.85em; color: var(--ink-2); }

.continue {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 18px;
  align-items: center;
  width: 100%;
  padding: 2px 0 4px;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
}
.continue:active .continue-title { text-decoration: underline; text-decoration-color: var(--ink-3); }
.continue-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.continue-title { font-family: var(--font-reading); font-size: 1.3em; line-height: 1.2; letter-spacing: -0.005em; }
.continue-author { color: var(--ink-2); font-size: 0.9em; }
.continue .meta { margin-top: 8px; }
.continue .progress { margin-top: 8px; width: 100%; }
.continue-cta { margin-top: 12px; font-size: 0.85em; font-weight: 600; letter-spacing: 0.02em; color: var(--ink); display: inline-flex; align-items: center; gap: 2px; }

.daily {
  position: relative;
  display: block;
  width: 100%;
  padding: 6px 0 4px 34px;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
}
.daily::before {
  content: '“';
  position: absolute;
  left: -2px;
  top: -10px;
  font-family: var(--font-reading);
  font-size: 3.6em;
  line-height: 1;
  color: var(--accent);
}
.daily[lang="pl"]::before { content: '„'; top: -34px; }
.daily:active .teaser { text-decoration: underline; text-decoration-color: var(--ink-3); }
.teaser {
  display: block;
  font-family: var(--font-reading);
  font-size: calc(var(--scale-key-line) * 1em);
  line-height: 1.45;
}
.daily .teaser { font-size: 1.22em; font-style: italic; line-height: 1.42; letter-spacing: -0.003em; }
.daily .meta { display: block; margin-top: 10px; }

.shelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 92px;
  gap: 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--side));
  padding: 4px var(--side) 14px;
  scroll-snap-type: x proximity;
}
.shelf::-webkit-scrollbar { display: none; }
.shelf-item { display: block; padding: 0; border: 0; background: none; scroll-snap-align: start; scroll-margin-left: var(--side); }
.shelf-item .progress { margin-top: 8px; }

.menu { margin-top: 30px; border-top: var(--hairline) solid var(--rule); }
.menu-row .row-main { flex-direction: row; align-items: center; gap: 14px; font-family: var(--font-reading); font-size: 1.12em; }
.menu-row .row-main .icon { color: var(--ink-2); }

/* ------------------------------------------------------------------ library */

.tabs { display: flex; gap: 24px; margin: 0 0 6px; border-bottom: var(--hairline) solid var(--rule); }
.tab {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: var(--target);
  padding: 0;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-2);
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.tab-count { font-size: 0.8em; color: var(--ink-3); font-weight: 400; }

.add-notes { margin: 0; padding-left: 1.1em; color: var(--ink-2); font-size: 0.92em; line-height: 1.5; }
.add-notes li { margin: 6px 0; }
.add-notes li::marker { color: var(--ink-3); }
.lib-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 16px 0 4px; }
.lib-tools .meta { margin: 0; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.88em; }

.book-grid {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px 16px;
}
@media (min-width: 560px) { .book-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.grid-book {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
}
.grid-book:active .cover { filter: brightness(0.9); }
.grid-book .meta { font-size: 0.72em; display: flex; justify-content: space-between; gap: 6px; }
.grid-book .progress { margin-top: -2px; }
.grid-book .tag { color: var(--accent); font-weight: 600; }

.book-list, .saved-list, .rights-list { list-style: none; margin: 0; padding: 0; }
.book-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 16px 0 16px;
  border: 0;
  border-bottom: var(--hairline) solid var(--rule);
  background: none;
  color: var(--ink);
  text-align: left;
}
.book-row:active { background: var(--paper-2); }
.book-row-title { font-family: var(--font-reading); font-size: 1.1em; line-height: 1.3; }
.book-row-author { color: var(--ink-2); font-size: 0.94em; }
.book-row .meta { margin-top: 2px; }
.book-row .progress { margin-top: 10px; }

/* ------------------------------------------------------------------ book detail */

.book-detail .screen-head { min-height: 56px; }
.book-hero { display: flex; flex-direction: column; align-items: center; text-align: center; margin-top: 2px; }
.book-hero .cover { --w: 148px; margin-bottom: 24px; }
.book-head { margin-top: 0; }
.book-title {
  margin: 0;
  font-family: var(--font-reading);
  font-weight: 400;
  font-size: 1.95em;
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.book-subtitle { margin: 6px 0 0; font-family: var(--font-reading); font-style: italic; color: var(--ink-2); font-size: 1.05em; }
.book-author { margin: 12px 0 2px; font-size: 0.72em; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.book-head .meta { margin: 6px 0 0; }
.book-progress { margin: 18px auto 0; width: 60%; }
.blurb { font-family: var(--font-reading); font-size: 1.04em; line-height: 1.6; margin: 22px 0 0; text-align: left; }

.toc { list-style: none; margin: 0; padding: 0; }
.toc-btn {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 12px 0;
  border: 0;
  border-bottom: var(--hairline) solid var(--rule);
  background: none;
  color: var(--ink);
  text-align: left;
  line-height: 1.35;
}
.toc-btn:active { background: var(--paper-2); }
.toc-item.level-1 .toc-btn { font-weight: 600; font-size: 0.7em; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); padding-top: 22px; min-height: 44px; }
.toc-item.level-2 .toc-btn { font-family: var(--font-reading); }
.toc-item.level-3 .toc-btn { font-family: var(--font-reading); padding-left: 1.25em; color: var(--ink-2); }
.toc-btn[aria-current="true"] { box-shadow: inset 2px 0 0 var(--accent); padding-left: 14px; font-style: italic; }
.toc-item.level-3 .toc-btn[aria-current="true"] { padding-left: calc(1.25em + 14px); }

.rights { margin-top: 36px; padding-top: 12px; border-top: var(--hairline) solid var(--rule); font-size: 0.85em; color: var(--ink-2); }
.rights p { margin: 6px 0; }
.rights .meta { font-size: 0.94em; }

/* ------------------------------------------------------------------ saved */

.saved-item { display: flex; align-items: flex-start; gap: 8px; border-bottom: var(--hairline) solid var(--rule); }
.saved-open {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 18px 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
}
.saved-open:active { background: var(--paper-2); }
.saved-open .teaser { font-size: 1.08em; font-style: italic; }
.saved-item .remove { margin-top: 12px; margin-right: -10px; color: var(--ink-2); }

/* ------------------------------------------------------------------ settings / comfort / about */

.settings .actions.stacked { margin-top: 14px; }
.storage-status { margin: 0 0 4px; line-height: 1.5; }

.recipe { margin: 4px 0 0; padding: 0; list-style: none; counter-reset: step; }
.recipe li {
  position: relative;
  counter-increment: step;
  padding: 0 0 14px 2.1em;
  line-height: 1.55;
}
.recipe li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.4em;
  text-align: right;
  font-family: var(--font-reading);
  font-style: italic;
  color: var(--accent);
  font-variant-numeric: lining-nums;
}

.about .wordmark-inline { font-family: var(--font-reading); font-style: italic; font-size: 1.1em; }
.md h2, .md h3, .md h4 { font-family: var(--font-reading); font-weight: 500; font-size: 1.08em; margin: 20px 0 6px; line-height: 1.3; }
.md h2 { font-size: 1.15em; }
.md p, .md li { line-height: 1.5; }
.md p { margin: 8px 0; }
.md ul { margin: 6px 0 12px; padding-left: 1.1em; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--ink-3); }
.md code { font-size: 0.9em; }
.rights-item { display: grid; gap: 2px; padding: 12px 0; border-bottom: var(--hairline) solid var(--rule); }
.rights-title { font-family: var(--font-reading); }
.licence { border-bottom: var(--hairline) solid var(--rule); }
.licence summary { min-height: 52px; display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; padding: 10px 0; cursor: pointer; list-style: none; }
.licence summary::-webkit-details-marker { display: none; }
.licence summary::before { content: '+'; width: 1.2em; color: var(--ink-2); font-family: var(--font-reading); }
.licence[open] summary::before { content: '–'; }
.licence-name { font-family: var(--font-reading); }
.licence-text { white-space: pre-wrap; font-size: 0.72em; line-height: 1.5; color: var(--ink-2); margin: 0 0 16px; font-family: var(--font-ui); }

/* ------------------------------------------------------------------ text fields */

.input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--r-ctl);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 1.02em;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--ink); background: var(--paper); }

/* ------------------------------------------------------------------ the door (sign in) */

.door {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 32px) calc(var(--side) + env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 32px) calc(var(--side) + env(safe-area-inset-left));
}
.door-inner { width: 100%; max-width: 22rem; display: flex; flex-direction: column; align-items: center; text-align: center; }
.door .logo svg { height: 56px; }
.door-kicker {
  margin: 18px 0 0;
  font-size: 0.68em;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.door-box { width: 100%; margin-top: 30px; padding-top: 26px; border-top: var(--hairline) solid var(--rule); text-align: left; }
.door-title { margin: 0; font-family: var(--font-reading); font-style: italic; font-weight: 400; font-size: 1.7em; line-height: 1.15; letter-spacing: -0.01em; }
.door-lede { margin: 8px 0 0; color: var(--ink-2); line-height: 1.5; overflow-wrap: anywhere; }
.door-tick { color: var(--accent); font-weight: 600; }
.door-form { display: grid; gap: 10px; margin-top: 22px; }
.door-form .btn { width: 100%; }
.door-msg { margin: 2px 0; min-height: 1.2em; font-size: 0.88em; color: #A2412F; line-height: 1.4; }
:root[data-theme="night"] .door-msg { color: #E59A80; }
.door-msg.good { color: var(--ink-2); }
.door-msg:empty { display: none; }
.door-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 36px;
  margin: -6px 0 10px -4px;
  padding: 0 6px 0 2px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 0.85em;
  overflow-wrap: anywhere;
}
.door-foot { margin: 36px 0 0; font-family: var(--font-reading); font-style: italic; color: var(--ink-3); font-size: 0.92em; }

/* ------------------------------------------------------------------ account */

.account-email { margin: 0; font-family: var(--font-reading); font-size: 1.12em; overflow-wrap: anywhere; }
.account .field { margin-top: 14px; }
.sync-line { margin: 16px 0 0; font-size: 0.88em; color: var(--ink-2); }
.sync-line.bad { color: #A2412F; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  z-index: 60;
  transform: translateX(-50%);
  max-width: min(92vw, 30rem);
  padding: 12px 18px;
  border-radius: var(--r-ctl);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9em;
  line-height: 1.4;
}
.toast.has-action { display: flex; align-items: center; gap: 14px; padding-right: 8px; width: max-content; }
.toast-action {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--paper);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ------------------------------------------------------------------ device preview controls */

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.profile-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 56px;
  padding: 8px 12px;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--r-ctl);
  background: var(--paper-2);
  color: var(--ink);
  text-align: left;
}
.profile-btn[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--paper); }
.profile-name { font-size: 0.94em; }
.approx { font-size: 0.85em; color: var(--ink-2); margin: 18px 0 0; line-height: 1.5; }
.preview-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.preview-nav .btn { padding: 0 14px; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------------------------ desktop nicety */
@media (min-width: 900px) {
  :root { --ui-size: 17px; }
  .screen { padding-top: 32px; }
}
