/* ==========================================================================
   SENT | Sharings — cinematic editorial theme
   Charcoal · forest · olive · stone · cream
   ========================================================================== */

:root {
  --ink: #202824;
  --ink-soft: #333d36;
  --forest: #39483b;
  --olive: #777c68;
  --stone: #d6ccba;
  --cream: #f1ede4;
  --surface: #faf7f0;
  --surface-2: #e8e2d5;
  --muted: #6d736a;

  --line: rgba(32, 40, 36, 0.13);
  --line-strong: rgba(32, 40, 36, 0.26);
  --line-dark: rgba(241, 237, 228, 0.16);

  --display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --text: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius: 3px;
  --shadow-sm: 0 1px 2px rgba(24, 30, 26, 0.06);
  --shadow: 0 24px 60px -32px rgba(20, 26, 22, 0.55);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --pad: max(28px, calc((100vw - 1120px) / 2 + 28px));

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-variation-settings: "SOFT" 0, "WONK" 1;
  line-height: 1.05;
  letter-spacing: -0.022em;
  color: var(--ink);
}
p { margin: 0 0 1em; }
a { color: var(--forest); text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; }
::selection { background: var(--stone); color: var(--ink); }

#app { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 28px 72px; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky; top: 0; z-index: 60;
  background: rgba(32, 40, 36, 0.94);
  backdrop-filter: saturate(120%) blur(12px);
  border-bottom: 1px solid rgba(241, 237, 228, 0.1);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 28px;
  height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: baseline; gap: 10px; color: var(--cream); }
.brand-sent {
  font-family: var(--text); font-weight: 500; font-size: 12px; letter-spacing: 0.42em;
  text-transform: uppercase; color: var(--cream);
}
.brand-divider { color: rgba(241, 237, 228, 0.34); font-size: 13px; }
.brand-em {
  font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--stone); letter-spacing: 0.01em;
}
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 8px 12px; font-size: 11px; font-weight: 500; letter-spacing: 0.16em;
  text-transform: uppercase; color: rgba(241, 237, 228, 0.62); border-radius: 2px;
  transition: color 0.2s var(--ease);
}
.nav a:hover { color: var(--cream); }
.nav a.is-active { color: var(--cream); box-shadow: inset 0 -1px 0 var(--stone); }

/* reading progress, sits on the topbar's lower edge */
.reading-progress {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%;
  background: var(--stone); transform-origin: 0 50%; transform: scaleX(0);
  transition: transform 0.1s linear; opacity: 0;
}
.reading-progress.is-live { opacity: 1; }

/* ------------------------------------------------------------- shared bits */

.eyebrow {
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--olive); font-weight: 600; margin-bottom: 12px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 2px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--cream);
  font-family: var(--text); font-size: 11.5px; font-weight: 500; letter-spacing: 0.12em;
  text-transform: uppercase; cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--forest); border-color: var(--forest); color: var(--cream); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); padding: 9px 10px; }
.btn-quiet:hover { background: transparent; color: var(--ink); }
.btn-danger { background: transparent; color: #8d3a2c; border-color: rgba(141, 58, 44, 0.4); }
.btn-danger:hover { background: #8d3a2c; border-color: #8d3a2c; color: var(--cream); }
.btn-sm { padding: 8px 14px; font-size: 10.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 2px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--muted);
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; cursor: pointer;
  transition: all 0.2s var(--ease);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--cream); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 600;
  padding: 4px 8px; border-radius: 2px; background: rgba(32, 40, 36, 0.07); color: var(--olive);
  border: 1px solid var(--line);
}
.badge-branch { background: transparent; color: var(--forest); border-color: var(--line-strong); }
.badge-draft { background: #f4e6cd; color: #7d5a14; border-color: #e2cfab; }

.admin-toolbar .status-filter {
  width: auto; margin-left: auto; padding: 9px 12px; border-radius: 2px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  font-size: 12px; font-family: var(--text);
}

.card-surface {
  background: var(--surface); border: 1px solid var(--line); border-radius: 2px;
}

.empty {
  text-align: center; padding: 68px 20px; color: var(--muted);
  border: 1px solid var(--line); background: rgba(250, 247, 240, 0.5);
}
.empty h3 { font-size: 28px; color: var(--ink); margin-bottom: 8px; }
.empty p { font-size: 13px; margin: 0; }

.loading {
  padding: 96px 0; text-align: center; color: var(--olive);
  letter-spacing: 0.26em; font-size: 10px; text-transform: uppercase;
}

/* -------------------------------------------------------------------- hero */

.hero {
  position: relative; overflow: hidden;
  margin: 0 calc(50% - 50vw); padding: 96px var(--pad) 44px;
  background: var(--ink); color: var(--cream);
  isolation: isolate;
}
.hero-media { position: absolute; inset: 0; z-index: -2; }
.hero-media img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 32%;
  filter: grayscale(0.22) contrast(1.04) brightness(0.92) saturate(0.92);
  transform: scale(1.02);
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(32, 40, 36, 0.28) 0%, rgba(32, 40, 36, 0.52) 42%, rgba(32, 40, 36, 0.95) 100%),
    var(--grain);
  background-size: auto, 180px 180px;
  opacity: 1; mix-blend-mode: normal;
}
.hero-inner { position: relative; max-width: 760px; }
.hero-kicker {
  font-size: 10px; letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--stone); margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(42px, 7.2vw, 92px); line-height: 0.98; color: var(--cream);
  letter-spacing: -0.03em; margin-bottom: 22px;
}
.hero h1 em { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--stone); }
.hero-sub {
  max-width: 52ch; color: rgba(241, 237, 228, 0.72); font-size: 14px; line-height: 1.7;
  margin-bottom: 30px;
}
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 10px 26px;
  padding-top: 20px; border-top: 1px solid var(--line-dark);
  color: rgba(241, 237, 228, 0.55); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
}
.hero-meta strong { color: var(--cream); font-weight: 500; margin-right: 5px; }

/* ----------------------------------------------------------------- toolbar */

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 26px 0 6px; border-bottom: 1px solid var(--line);
}
.search-field { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-field input {
  width: 100%; padding: 12px 14px 12px 38px; border-radius: 2px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13px; font-family: var(--text); outline: none;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.search-field input::placeholder { color: var(--olive); }
.search-field input:focus { border-color: var(--ink); background: #fffdf8; }
.search-field svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--olive); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented {
  display: inline-flex; border: 1px solid var(--line); border-radius: 2px;
  background: var(--surface); padding: 2px; gap: 2px;
}
.segmented button {
  border: 0; background: transparent; padding: 7px 13px; border-radius: 1px;
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); cursor: pointer; transition: all 0.2s var(--ease);
}
.segmented button:hover { color: var(--ink); }
.segmented button.is-active { background: var(--ink); color: var(--cream); }

/* ------------------------------------------------------------- topics list */

.browse-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  margin: 44px 0 4px;
}
.browse-head h2 { font-size: 13px; letter-spacing: 0.3em; text-transform: uppercase; font-family: var(--text); font-weight: 600; color: var(--olive); }
.sort-note {
  margin: 0; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--olive);
}

.topic-list { border-top: 1px solid var(--line); }

.topic { border-bottom: 1px solid var(--line); }

.topic-head {
  display: grid; grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 20px; align-items: center; width: 100%;
  padding: 22px 4px; background: none; border: 0; text-align: left;
  color: inherit; cursor: pointer; transition: background 0.25s var(--ease);
}
.topic-head:hover { background: rgba(250, 247, 240, 0.7); }
.topic-head:focus-visible { outline: 2px solid var(--forest); outline-offset: -2px; }

.topic-thumb {
  width: 74px; height: 92px; overflow: hidden; flex: none;
  background: linear-gradient(155deg, #39483b 0%, #202824 70%);
  display: grid; place-items: center;
}
.topic-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(0.25) contrast(1.06) brightness(0.92);
  transition: transform 0.6s var(--ease);
}
.topic-head:hover .topic-thumb img { transform: scale(1.05); }
.topic-thumb span {
  font-family: var(--display); font-size: 30px; color: rgba(241, 237, 228, 0.5);
}
.topic-thumb.is-empty { background: linear-gradient(155deg, rgba(57, 72, 59, 0.9), rgba(32, 40, 36, 0.95)), var(--grain); }

.topic-main { min-width: 0; display: block; }
.topic-meta {
  display: block; font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--olive); margin-bottom: 8px;
}
.topic-meta span + span::before { content: "·"; margin: 0 8px; color: var(--stone); }
.topic-title {
  display: block; font-family: var(--display); font-size: clamp(23px, 2.9vw, 33px);
  line-height: 1.06; letter-spacing: -0.025em; color: var(--ink);
}
.topic-excerpt {
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 12.5px; color: var(--muted); margin-top: 9px; line-height: 1.55;
}

.topic-side { display: flex; align-items: center; gap: 16px; }
.topic-count {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--olive);
  white-space: nowrap;
}
.topic-chevron {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 50%; color: var(--ink-soft);
  transition: transform 0.35s var(--ease), background 0.25s var(--ease), color 0.25s var(--ease);
}
.topic.is-open .topic-chevron { transform: rotate(180deg); background: var(--ink); border-color: var(--ink); color: var(--cream); }
.topic.is-empty-series .topic-chevron { display: none; }

/* accordion body */
.topic-body {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.42s var(--ease);
}
.topic.is-open .topic-body { grid-template-rows: 1fr; }
.topic-body-inner { overflow: hidden; }

.branch-list {
  list-style: none; margin: 0 0 0 96px; padding: 4px 0 26px;
  position: relative;
}
.branch-list::before {
  content: ""; position: absolute; left: 5px; top: 14px; bottom: 34px; width: 1px;
  background: var(--line-strong);
}
.branch-item {
  position: relative; display: flex; align-items: baseline; gap: 14px;
  padding: 11px 12px 11px 26px; color: var(--ink);
  border-radius: 1px; transition: background 0.2s var(--ease), padding-left 0.2s var(--ease);
}
.branch-item::before {
  content: ""; position: absolute; left: 0; top: 21px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--cream); border: 1px solid var(--line-strong);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.branch-item:hover { background: rgba(250, 247, 240, 0.9); }
.branch-item:hover::before { background: var(--forest); border-color: var(--forest); }
.branch-num {
  font-family: var(--text); font-size: 10px; letter-spacing: 0.12em; color: var(--olive);
  min-width: 16px;
}
.branch-title {
  font-family: var(--display); font-size: 19px; line-height: 1.25; letter-spacing: -0.015em;
  flex: 1; min-width: 0;
}
.branch-meta {
  font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--olive);
  white-space: nowrap;
}

.topic-foot {
  display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 0 0 28px 96px;
  padding-top: 4px;
}
.link-more {
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 500;
  color: var(--forest); border-bottom: 1px solid var(--line-strong); padding-bottom: 3px;
}
.link-more:hover { color: var(--ink); border-color: var(--ink); }

/* --------------------------------------------------------------- reader */

.reader { margin: 0 calc(50% - 50vw); }

.reader-hero {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: clamp(340px, 52vh, 520px); display: flex; align-items: flex-end;
  background: linear-gradient(160deg, #2b382f 0%, #202824 62%, #18201c 100%);
  padding: 34px var(--pad) 38px;
}
.reader-hero-img {
  position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%;
  object-fit: cover; object-position: center 30%;
  filter: grayscale(0.3) contrast(1.08) brightness(0.74) saturate(0.9);
}
.reader-hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(24, 32, 28, 0.5) 0%, rgba(24, 32, 28, 0.18) 32%, rgba(24, 32, 28, 0.9) 100%),
    var(--grain);
  background-size: auto, 180px 180px;
}
.reader-hero-inner { position: relative; width: 100%; max-width: 900px; }
.reader-back {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(241, 237, 228, 0.66); margin-bottom: 26px;
  transition: color 0.2s var(--ease), gap 0.2s var(--ease);
}
.reader-back:hover { color: var(--cream); gap: 12px; }
.reader-kicker {
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--stone); margin-bottom: 16px;
}
.reader-hero h1 {
  font-size: clamp(36px, 6vw, 74px); line-height: 1; letter-spacing: -0.03em;
  color: var(--cream); margin-bottom: 18px; max-width: 20ch;
}
.reader-byline {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(241, 237, 228, 0.6); margin: 0;
}
.reader-byline a { color: var(--stone); border-bottom: 1px solid rgba(214, 204, 186, 0.4); }
.reader-byline .badge-draft { background: #f4e6cd; color: #7d5a14; border: 0; }

.reader-body { max-width: 720px; margin: 0 auto; padding: 40px 0 0; }

.reader-tools {
  display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.series-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 26px 0 0; padding: 14px 16px;
  border: 1px solid var(--line); border-left: 2px solid var(--forest);
  background: rgba(250, 247, 240, 0.7);
}
.series-strip-label {
  font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase;
  font-weight: 600; color: var(--forest);
}
.series-strip-count { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--olive); }
.series-strip-link {
  margin-left: auto; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  font-weight: 500; color: var(--forest);
}
.series-strip-link:hover { color: var(--ink); }
.series-strip-series {
  font-family: var(--display); font-size: 19px; line-height: 1.25; letter-spacing: -0.015em;
  color: var(--ink); margin-right: auto; min-width: 0; overflow-wrap: anywhere;
  border-bottom: 1px solid var(--line-strong); padding-bottom: 1px;
}
.series-strip-series:hover { color: var(--forest); }

.prose {
  font-family: var(--display);
  font-size: 19.5px; line-height: 1.72; color: #2c352f;
  font-variation-settings: "SOFT" 30, "WONK" 0;
  overflow-wrap: break-word; margin-top: 34px;
}
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.1em; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--ink); margin: 1.7em 0 0.55em; letter-spacing: -0.02em; line-height: 1.15;
}
.prose h2 { font-size: 1.5em; }
.prose h3 { font-size: 1.24em; }
.prose strong { font-weight: 600; }
.prose blockquote {
  margin: 1.8em 0; padding: 6px 0 6px 22px; border-left: 2px solid var(--forest);
  font-family: var(--serif); font-style: italic; font-size: 1.28em; line-height: 1.5;
  color: var(--ink);
}
.prose ul, .prose ol { margin: 0 0 1.15em; padding-left: 1.3em; }
.prose li { margin-bottom: 0.4em; }
.prose li::marker { color: var(--olive); }
.prose a { color: var(--forest); text-decoration: underline; text-underline-offset: 2px; }
.prose img { margin: 1.6em 0; filter: grayscale(0.2) contrast(1.04); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.2em 0; }

/* heading written inside the sharing, styled as an editorial section label */
.prose h3:first-child, .prose h2:first-child { margin-top: 0; }

.branches-section {
  max-width: 720px; margin: 56px auto 0; padding-top: 34px; border-top: 1px solid var(--line);
}
.section-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin-bottom: 22px;
}
.section-head h2 { font-size: 30px; letter-spacing: -0.025em; }
.section-head p { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.branch-card {
  padding: 20px; background: var(--surface);
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}
.branch-card:hover { background: #fffdf8; }
.branch-card .entry-date {
  display: block; font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--olive); margin-bottom: 8px;
}
.branch-card h3 { font-size: 21px; line-height: 1.15; margin-bottom: 8px; letter-spacing: -0.02em; }
.branch-card h3 a { color: var(--ink); }
.branch-card h3 a:hover { color: var(--forest); }
.branch-card p {
  font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* reading sequence */
.reader-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  max-width: 720px; margin: 56px auto 0; padding-top: 30px; border-top: 1px solid var(--line);
  background: transparent;
}
.reader-nav-item {
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 20px 22px; border: 1px solid var(--line); background: var(--surface);
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.reader-nav-item:hover { background: #fffdf8; border-color: var(--line-strong); }
.reader-nav-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--olive); font-weight: 600; line-height: 1.3;
}
.reader-nav-title {
  font-family: var(--display); font-size: 22px; line-height: 1.15; color: var(--ink);
  letter-spacing: -0.02em; overflow-wrap: anywhere;
}
.reader-nav-next { text-align: right; align-items: flex-end; }
.reader-nav-next .reader-nav-label { justify-content: flex-end; text-align: right; }
.reader-nav-item.is-empty { visibility: hidden; border: 0; background: none; }

/* topic (series) page */
.reader-shell { padding-top: 0; }
.back-link {
  display: inline-flex; align-items: center; gap: 7px; font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--olive); margin: 18px 0 26px;
}
.back-link:hover { color: var(--ink); }
.reader-head { margin-bottom: 0; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.reader-head h1 { font-size: clamp(34px, 5vw, 56px); margin: 10px 0 16px; letter-spacing: -0.03em; }
.reader-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  color: var(--olive); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase;
}
.reader-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

/* ------------------------------------------------------------------ admin */

.login-wrap { max-width: 420px; margin: 84px auto; padding: 38px; background: var(--surface); border: 1px solid var(--line); }
.login-wrap h1 { font-size: 40px; }
.login-wrap p.sub { color: var(--muted); font-size: 13px; margin: 10px 0 28px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label {
  font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--olive); font-weight: 600;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border-radius: 2px; border: 1px solid var(--line-strong);
  background: #fffdf8; color: var(--ink); font-size: 14px; font-family: var(--text);
  outline: none; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--ink); box-shadow: 0 0 0 3px rgba(32, 40, 36, 0.08);
}
.field .hint { font-size: 11.5px; color: var(--old-muted, #6d736a); }
.form-error { color: #8d3a2c; font-size: 12.5px; margin: 0 0 12px; min-height: 17px; }

.admin-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 18px; padding: 56px 0 26px; border-bottom: 1px solid var(--line);
}
.admin-head h1 { font-size: clamp(34px, 5vw, 52px); }
.admin-head p { color: var(--muted); font-size: 13px; margin: 10px 0 0; max-width: 60ch; }
.admin-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stats { display: flex; flex-wrap: wrap; gap: 34px; padding: 24px 0 6px; border-bottom: 1px solid var(--line); }
.stat strong { font-family: var(--display); font-size: 30px; font-weight: 400; display: block; line-height: 1.1; }
.stat span { font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--olive); }

.admin-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 22px 0 16px; }
.table-wrap { border: 1px solid var(--line); background: var(--surface); }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table thead th {
  text-align: left; padding: 12px 16px; font-size: 9px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--olive); font-weight: 600;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.admin-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr { transition: background 0.18s var(--ease); }
.admin-table tbody tr:hover { background: #fffdf8; }
.cell-title { font-family: var(--display); font-size: 20px; color: var(--ink); letter-spacing: -0.015em; }
.cell-title a { color: var(--ink); }
.cell-title small { display: block; font-family: var(--text); font-size: 11px; color: var(--olive); letter-spacing: 0.02em; margin-top: 3px; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }
.cell-date { color: var(--olive); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }

.move-group { display: inline-flex; gap: 4px; }
.move-btn {
  width: 28px; height: 28px; border-radius: 2px; border: 1px solid var(--line-strong);
  background: #fffdf8; color: var(--ink-soft); cursor: pointer; font-size: 12px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.move-btn:hover:not(:disabled) { background: var(--ink); border-color: var(--ink); color: var(--cream); }
.move-btn:disabled { opacity: 0.24; cursor: default; }

/* ----------------------------------------------------------------- editor */

.editor-head {
  padding: 44px 0 24px; display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--line);
}
.editor-head h1 { font-size: clamp(30px, 4.4vw, 44px); }
.editor-head p { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.editor-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 26px;
  align-items: start; margin-top: 26px;
}
.panel { padding: 24px; background: var(--surface); border: 1px solid var(--line); }
.panel-title {
  font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--olive); font-weight: 600; margin-bottom: 16px;
}
.editor-side { display: grid; gap: 18px; position: sticky; top: 92px; }

.rte { border: 1px solid var(--line-strong); background: #fffdf8; }
.rte-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px; padding: 8px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.rte-toolbar .tb {
  min-width: 30px; height: 30px; padding: 0 7px; border-radius: 2px; border: 1px solid transparent;
  background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.rte-toolbar .tb:hover { background: #fffdf8; border-color: var(--line); }
.rte-toolbar .tb.is-on { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.rte-toolbar select {
  width: auto; height: 30px; padding: 0 6px; border-radius: 2px; border: 1px solid var(--line-strong);
  background: #fffdf8; color: var(--ink-soft); font-size: 11.5px; font-family: var(--text); flex: 0 0 auto;
}
.rte-toolbar .color-input {
  width: 30px; height: 30px; padding: 2px; border-radius: 2px;
  border: 1px solid var(--line-strong); background: #fffdf8; cursor: pointer; flex: 0 0 auto;
}
.rte-toolbar .swatches { display: inline-flex; align-items: center; gap: 4px; }
.rte-toolbar .swatch {
  width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18); cursor: pointer; transition: transform 0.15s var(--ease);
}
.rte-toolbar .swatch:hover { transform: scale(1.14); }
.tb-divider { width: 1px; height: 20px; background: var(--line-strong); margin: 0 5px; }
.rte-body {
  min-height: 360px; max-height: 64vh; overflow-y: auto; padding: 24px 26px;
  font-family: var(--display); font-size: 17px; line-height: 1.7; color: #2c352f;
  outline: none;
}
.rte-body:empty::before { content: attr(data-placeholder); color: var(--olive); }
.rte-body:focus { background: #fffefb; }
.rte-body h2 { font-size: 1.4em; margin: 1em 0 0.4em; }
.rte-body h3 { font-size: 1.2em; margin: 1em 0 0.4em; }
.rte-body p { margin: 0 0 0.9em; }
.rte-body blockquote { margin: 1em 0; padding-left: 16px; border-left: 2px solid var(--forest); font-style: italic; }
.rte-body ul, .rte-body ol { padding-left: 1.3em; margin: 0 0 0.9em; }

.image-drop {
  border: 1px dashed var(--line-strong); padding: 16px;
  display: grid; gap: 10px; justify-items: center; text-align: center; background: #fffdf8;
}
.image-preview {
  width: 100%; max-width: 132px; aspect-ratio: 9 / 16; overflow: hidden;
  background: linear-gradient(160deg, #39483b, #202824); display: grid; place-items: center;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview span { color: rgba(241, 237, 228, 0.6); font-family: var(--display); font-size: 26px; }
.image-drop p { font-size: 11px; color: var(--muted); margin: 0; }
.image-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.side-note { font-size: 11px; color: var(--muted); line-height: 1.55; }
.editor-actions { display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------------------- misc */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: var(--ink); color: var(--cream); padding: 12px 22px; border-radius: 2px;
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  opacity: 0; pointer-events: none; transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  z-index: 120; box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6); max-width: calc(100vw - 32px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #8d3a2c; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(24, 32, 28, 0.62); z-index: 130;
  display: grid; place-items: center; padding: 20px; backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--cream); border-radius: 2px; padding: 30px; max-width: 430px; width: 100%;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.6); border: 1px solid var(--line);
}
.modal h3 { font-size: 28px; margin-bottom: 10px; }
.modal p { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.site-footer { border-top: 1px solid var(--line); margin-top: 56px; background: var(--surface); }
.footer-inner {
  max-width: 1120px; margin: 0 auto; padding: 26px 28px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--olive);
}
.footer-mark { color: var(--ink-soft); font-weight: 600; }

/* --------------------------------------------------------------- invite */

.invite-shell { padding: 34px 0 10px; }
.invite-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.invite-card { padding: 34px 30px; text-align: center; background: var(--surface); border: 1px solid var(--line); }
.invite-card h1 { font-size: clamp(30px, 4.4vw, 46px); margin: 8px 0 12px; }
.invite-lede { color: var(--muted); font-size: 13px; max-width: 44ch; margin: 0 auto 26px; line-height: 1.6; }
.qr-box {
  width: max-content; margin: 0 auto; padding: 16px; background: #fff;
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.qr-box img, .qr-box canvas { display: block; width: 200px; height: 200px; }
.invite-url {
  font-size: 11px; color: var(--olive); margin: 18px auto 20px;
  word-break: break-all; max-width: 42ch; line-height: 1.6;
}
.invite-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.invite-side { display: grid; gap: 16px; }
.invite-side .panel { padding: 22px; }
.invite-side h2 { font-size: 22px; margin: 4px 0 12px; }
.steps { margin: 0; padding-left: 18px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.6; }
.steps li { margin-bottom: 7px; }
.steps li::marker { color: var(--olive); }
.steps li:last-child { margin-bottom: 0; }

/* --------------------------------------------------- save-to-home banner */

.install-banner {
  position: fixed; left: 12px; right: 12px; z-index: 100;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px;
  padding: 13px 15px; border-radius: 2px;
  background: var(--ink); color: var(--cream); border: 1px solid rgba(241, 237, 228, 0.16);
  box-shadow: 0 24px 50px -22px rgba(0, 0, 0, 0.7);
  animation: install-in 0.3s var(--ease) both;
}
.install-banner .install-icon { width: 44px; height: 44px; border-radius: 2px; flex: none; }
.install-text { flex: 1; min-width: 0; }
.install-text strong {
  display: block; font-family: var(--display); font-size: 18px; font-weight: 400; line-height: 1.2;
}
.install-text p { margin: 4px 0 0; font-size: 11.5px; color: rgba(241, 237, 228, 0.62); line-height: 1.45; }
.install-text b { color: var(--cream); font-weight: 500; }
.install-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
.install-banner .btn { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.install-banner .btn:hover { background: var(--stone); border-color: var(--stone); color: var(--ink); }
.install-banner .btn-quiet { background: transparent; border-color: transparent; color: rgba(241, 237, 228, 0.7); }
.install-banner .btn-quiet:hover { background: transparent; color: var(--cream); }
body.has-install-banner .toast { bottom: 112px; }

@keyframes install-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 940px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side { position: static; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .invite-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  /* admin becomes stacked cards so nothing is clipped on a phone */
  .table-wrap { border: 0; background: transparent; }
  .admin-table { display: block; width: 100%; }
  .admin-table thead { display: none; }
  .admin-table tbody { display: block; }
  .admin-table tr {
    display: block; width: 100%; margin-bottom: 10px; padding: 16px;
    border: 1px solid var(--line); background: var(--surface);
  }
  .admin-table tbody tr:hover { background: var(--surface); }
  .admin-table td { display: block; width: 100%; border: 0; padding: 0; }
  .admin-table td.cell-date { margin-bottom: 4px; }
  .admin-table td.cell-title { font-size: 22px; margin-bottom: 8px; }
  .admin-table td:nth-child(3), .admin-table td:nth-child(4) {
    display: inline-block; width: auto; margin: 0 8px 6px 0; vertical-align: middle;
  }
  .admin-table .row-actions {
    justify-content: flex-start; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  }
  .admin-table .row-actions .btn { flex: 1 1 auto; }
  .move-group { margin-bottom: 10px; gap: 6px; }
  .move-btn { width: 38px; height: 32px; font-size: 13px; }
  .admin-table .cell-date[style] { margin-top: 0 !important; }
}

@media (max-width: 700px) {
  .topic-head { grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; padding: 18px 2px; }
  .topic-thumb { width: 64px; height: 82px; }
  .topic-excerpt { display: none; }
  .topic-title { font-size: 22px; }
  .branch-list { margin-left: 76px; }
  .topic-foot { margin-left: 76px; }
  .branch-item { flex-wrap: wrap; gap: 2px 10px; padding: 10px 6px 10px 24px; }
  .branch-title { flex: 1 1 100%; font-size: 18px; }
  .branch-meta { display: none; }
  .reader-body, .branches-section, .reader-nav { padding-left: 0; padding-right: 0; }
}

@media (max-width: 640px) {
  :root { --pad: 16px; }
  #app { padding: 0 16px 56px; }
  .topbar-inner { padding: 0 16px; height: 58px; }
  .brand-sent { font-size: 10px; letter-spacing: 0.34em; }
  .brand-em { font-size: 19px; }
  .nav a { padding: 7px 9px; font-size: 9.5px; letter-spacing: 0.14em; }
  .hero { padding: 64px var(--pad) 32px; }
  .hero h1 { font-size: clamp(38px, 11vw, 54px); }
  .hero-sub { font-size: 13px; }
  .hero-meta { gap: 8px 18px; font-size: 9px; }
  .toolbar { padding-top: 20px; }
  .segmented button { padding: 7px 10px; font-size: 9.5px; }
  .browse-head { margin-top: 34px; }
  .reader-hero { padding: 26px var(--pad) 30px; min-height: 62vh; }
  .reader-hero h1 { font-size: clamp(32px, 9.6vw, 46px); }
  .reader-body { padding-top: 28px; padding-left: 16px; padding-right: 16px; }
  .branches-section, .reader-nav { margin-left: 16px; margin-right: 16px; }
  .prose { font-size: 18.5px; line-height: 1.7; }
  .reader-nav { grid-template-columns: 1fr; }
  .reader-nav-item.is-empty { display: none; }
  .reader-nav-next { text-align: left; align-items: flex-start; }
  .reader-nav-next .reader-nav-label { justify-content: flex-start; text-align: left; }
  .branch-grid { grid-template-columns: 1fr; }
  .section-head h2 { font-size: 26px; }
  .admin-head h1, .editor-head h1 { font-size: 32px; }
  .rte-body { padding: 18px; min-height: 280px; }
  .qr-box img, .qr-box canvas { width: 170px; height: 170px; }
  .invite-card { padding: 26px 20px; }
}

/* on phones the forward card comes first, then the way back */
@media (max-width: 640px) {
  .reader-nav { display: flex; flex-direction: column; }
  .reader-nav-next { order: -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* standalone numbered list (series page) */
.branch-list.standalone { margin: 0; padding: 0 0 12px; }
.branch-list.standalone .branch-item { padding-top: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.branch-list.standalone .branch-item::before { top: 26px; }
.branch-list.standalone::before { top: 30px; bottom: 30px; }

@media (max-width: 700px) {
  .branch-list.standalone { margin-left: 0; }
}

/* depth for image-less heroes */
.hero::before, .reader-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(70% 90% at 78% 4%, rgba(119, 124, 104, 0.3), transparent 68%);
  pointer-events: none;
}
.reader-hero.no-image { min-height: clamp(300px, 44vh, 430px); }
.reader-hero-ghost {
  position: absolute; right: -1vw; bottom: -5vw; z-index: -1;
  font-family: var(--display); font-size: min(50vw, 380px); line-height: 0.72;
  color: rgba(241, 237, 228, 0.055); pointer-events: none; user-select: none;
}

/* keep the topic meta on one line on small screens */
@media (max-width: 700px) {
  .topic-meta .meta-date { display: none; }
}

/* --------------------------------------------------- topic cover images */
.image-preview-wide {
  max-width: 100%;
  aspect-ratio: 16 / 9;
}

.topic.has-cover .topic-head {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 5px;
  padding: 30px 26px;
  margin: 10px 0 6px;
  color: var(--cream);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.topic.has-cover .topic-head:hover {
  background: none;
  transform: translateY(-1px);
  box-shadow: 0 18px 44px -26px rgba(16, 22, 19, 0.7);
}
.topic-cover {
  position: absolute;
  inset: 0;
  z-index: -2;
  display: block;
}
.topic-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.01);
  transition: transform 0.9s var(--ease);
}
.topic.has-cover .topic-head:hover .topic-cover img { transform: scale(1.04); }
.topic.has-cover .topic-head::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(18, 24, 21, 0.92) 0%, rgba(18, 24, 21, 0.72) 52%, rgba(18, 24, 21, 0.5) 100%),
    linear-gradient(180deg, rgba(18, 24, 21, 0.25), rgba(18, 24, 21, 0.55));
}
.topic.has-cover .topic-thumb { border: 1px solid rgba(241, 237, 228, 0.22); }
.topic.has-cover .topic-meta { color: rgba(214, 204, 186, 0.8); }
.topic.has-cover .topic-meta span + span::before { color: rgba(214, 204, 186, 0.5); }
.topic.has-cover .topic-title { color: var(--cream); }
.topic.has-cover .topic-excerpt { color: rgba(241, 237, 228, 0.7); }
.topic.has-cover .topic-count { color: rgba(214, 204, 186, 0.85); }
.topic.has-cover .topic-chevron { border-color: rgba(241, 237, 228, 0.34); color: var(--cream); }
.topic.has-cover.is-open .topic-chevron { background: var(--cream); color: var(--ink); border-color: var(--cream); }

@media (max-width: 640px) {
  .topic.has-cover .topic-head { padding: 22px 16px; gap: 14px; }
  .topic.has-cover .topic-head::after {
    background: linear-gradient(180deg, rgba(18, 24, 21, 0.55) 0%, rgba(18, 24, 21, 0.9) 100%);
  }
}

/* the series' opening sharing, first in the expanded list */
.branch-item.is-opening {
  background: rgba(214, 204, 186, 0.18);
  margin-bottom: 3px;
}
.branch-item.is-opening::before { background: var(--forest); border-color: var(--forest); }
.branch-item.is-opening .branch-num { color: var(--forest); }
.branch-item.is-opening:hover { background: rgba(214, 204, 186, 0.32); }
.branch-flag {
  display: inline-block;
  margin-left: 9px;
  padding: 2px 6px 1px;
  border: 1px solid rgba(57, 72, 59, 0.32);
  font-family: var(--text);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--forest);
  vertical-align: 3px;
}
@media (max-width: 640px) {
  .branch-item.is-opening { padding: 12px 10px 12px 24px; }
  .branch-flag { font-size: 8px; letter-spacing: 0.16em; padding: 2px 5px 1px; margin-left: 7px; }
}
