/* Dark values from docs/design/kit.css, light values from docs/design/landing.html. */
:root,
[data-theme="dark"] {
  --bg: #0e0d0b;
  --bg-glow: radial-gradient(
    1200px 700px at 50% -10%,
    rgba(227, 179, 106, 0.07),
    transparent 60%
  );
  --surface: #161411;
  --surface-2: #1e1b17;
  --surface-hover: #2b261e;
  --glass: rgba(22, 20, 17, 0.72);
  --border: rgba(239, 231, 214, 0.1);
  --border-strong: rgba(239, 231, 214, 0.18);
  --text: #efe7d6;
  --text-2: #c9bfab;
  --text-3: #8f8676;
  /* Dark theme: warm gold buttons instead of near-white ones that glare at night. */
  --primary-bg: #d6a45c;
  --primary-fg: #1b140b;
  --primary-hover: #e2b46e;
  --accent: #e3b36a;
  --accent-soft: rgba(227, 179, 106, 0.14);
  --accent-fg: #0e0d0b;
  --success: #86c59a;
  --danger: #e58a7b;
  --shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 24px 64px rgba(0, 0, 0, 0.5);
  --overlay: rgba(8, 8, 7, 0.62);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f4ef;
  --bg-glow: radial-gradient(
    1200px 700px at 50% -10%,
    rgba(154, 106, 44, 0.08),
    transparent 60%
  );
  --surface: #ffffff;
  --surface-2: #efebe3;
  --surface-hover: #efebe3;
  --glass: rgba(255, 255, 255, 0.72);
  --border: rgba(23, 20, 15, 0.1);
  --border-strong: rgba(23, 20, 15, 0.18);
  --text: #17140f;
  --text-2: #4f483d;
  --text-3: #7a7264;
  --primary-bg: #17140f;
  --primary-fg: #f6f1e6;
  --primary-hover: #000000;
  --accent: #9a6a2c;
  --accent-soft: rgba(154, 106, 44, 0.14);
  --accent-fg: #ffffff;
  --success: #2f8a52;
  --danger: #a33228;
  --shadow:
    0 1px 2px rgba(23, 20, 15, 0.04), 0 12px 32px rgba(23, 20, 15, 0.06);
  --shadow-pop: 0 24px 64px rgba(23, 20, 15, 0.16);
  --overlay: rgba(23, 20, 15, 0.38);
  color-scheme: light;
}
:root {
  --font:
    Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: Literata, Georgia, serif;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-pill: 999px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;
  --s12: 48px;
  --s16: 64px;
  --t-cap: 13px;
  --t-sm: 14px;
  --t-md: 15px;
  --t-base: 16px;
  --t-lg: 18px;
  --t-xl: 20px;
  --t-2xl: 24px;
  --t-3xl: 32px;
  --t-4xl: 40px;
  --t-hero: 56px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 180ms;
}

/* ---------- Buttons ---------- */
.btn {
  --btn-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-height);
  min-height: var(--btn-height);
  padding: 0 20px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font: 600 var(--t-md)/1 var(--font);
  cursor: pointer;
  transition:
    background var(--dur) var(--ease),
    transform 120ms var(--ease),
    border-color var(--dur) var(--ease);
  white-space: nowrap;
  text-decoration: none;
  text-align: center;
}
.btn svg {
  width: 18px;
  height: 18px;
}
.btn:active {
  transform: scale(0.98);
}
.btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px var(--accent-soft),
    0 0 0 1px var(--accent);
}
.btn-sm {
  --btn-height: 36px;
  padding: 0 14px;
  font-size: var(--t-sm);
}
.btn-lg {
  --btn-height: 52px;
  padding: 0 26px;
  font-size: var(--t-base);
}
.btn-primary {
  background: var(--primary-bg);
  color: var(--primary-fg);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--primary-fg);
}
.btn.button-with-arrow {
  gap: 12px;
  padding-inline-end: 5px;
}
.button-arrow {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-fg);
  color: var(--primary-bg);
  transition: transform var(--dur) var(--ease);
}
.btn-sm .button-arrow {
  width: 26px;
  height: 26px;
}
.btn-lg .button-arrow {
  width: 40px;
  height: 40px;
}
.button-with-arrow:not(:disabled):hover .button-arrow {
  transform: translateX(2px);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-accent {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.btn[hidden] {
  display: none;
}
.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}
.icon-btn {
  --icon-size: 40px;
  width: var(--icon-size);
  height: var(--icon-size);
  min-width: var(--icon-size);
  min-height: var(--icon-size);
  flex: none;
  padding: 0;
  border-radius: var(--r-pill);
  display: inline-grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ---------- Inputs ---------- */
.field {
  display: grid;
  gap: 8px;
}
.label {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--text);
}
.hint {
  font-size: var(--t-cap);
  color: var(--text-3);
}
:is(
  .input,
  :where(
    input:not(
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="file"],
      .own input
    ),
    select
  )
),
:is(.textarea, :where(textarea)) {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: 400 var(--t-base)/1.4 var(--font);
  transition:
    border-color var(--dur),
    box-shadow var(--dur);
}
:is(.textarea, :where(textarea)) {
  height: auto;
  min-height: 112px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.55;
}
:is(
  .input,
  :where(
    input:not(
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="file"],
      .own input
    ),
    select
  )
)::placeholder,
:is(.textarea, :where(textarea))::placeholder {
  color: var(--text-3);
}
:is(
  .input,
  :where(
    input:not(
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="file"],
      .own input
    ),
    select
  )
):focus,
:is(.textarea, :where(textarea)):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---------- Chips, segments, badges ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font: 500 var(--t-sm)/1 var(--font);
  cursor: pointer;
}
.chip:hover {
  background: var(--surface-2);
}
.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.chip.on::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.segmented button {
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  font: 600 var(--t-sm)/1 var(--font);
  cursor: pointer;
}
.segmented button:is(.on, .active) {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font: 600 12px/1 var(--font);
  letter-spacing: 0.01em;
  background: var(--glass);
  color: var(--text);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.badge.accent,
.badge.amber {
  background: var(--accent-soft);
  color: color-mix(in srgb, var(--accent) 60%, var(--text));
  border-color: transparent;
}

/* ---------- Surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}
/* ---------- App shell ---------- */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary-bg);
  color: var(--primary-fg);
  font: 700 18px/1 var(--font);
  margin-bottom: 12px;
}
.rail nav :is(a, button) {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--text-3);
}
.rail nav :is(a, button):hover {
  background: var(--surface-2);
  color: var(--text);
}
.rail nav :is(a, button).on {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}
.rail svg {
  width: 20px;
  height: 20px;
}
.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  height: 72px;
  padding: 0 32px;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: color-mix(in srgb, var(--accent) 60%, var(--text));
  font: 700 15px/1 var(--font);
  box-shadow: 0 0 0 2px var(--accent);
}

/* ---------- Story card ---------- */
.story-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.story {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.story img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Covers put the hero right of centre: crop toward it so faces are not cut off in portrait cards. */
  object-position: 68% 25%;
  transition: transform 400ms var(--ease);
}
.story:hover img {
  transform: scale(1.03);
}
.story::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 26%,
    rgba(0, 0, 0, 0.72) 52%,
    rgba(0, 0, 0, 0.78) 100%
  );
}
.story-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  z-index: 1;
}
.story-body {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1;
  color: #fff;
}
.story-body b {
  display: block;
  font-size: var(--t-lg);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.story-body span:not(.badge) {
  display: block;
  margin-top: 6px;
  font-size: var(--t-sm);
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.4;
}
.story .stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: 600 12px/1 var(--font);
  backdrop-filter: blur(8px);
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 0 8px 0 26px;
  border-radius: var(--r-pill);
  background: var(--cta-bg, var(--primary-bg));
  color: var(--cta-fg, var(--primary-fg));
  font: 600 16px/1.15 var(--font);
  text-decoration: none;
  transition:
    transform var(--dur),
    background var(--dur);
}
.cta b {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--cta-fg, var(--primary-fg));
  color: var(--cta-bg, var(--primary-bg));
  font-weight: 400;
  transition: transform var(--dur);
}
.cta:hover {
  background: var(--cta-hover, var(--primary-hover));
  color: var(--cta-fg, var(--primary-fg));
}
.cta:hover b {
  transform: translateX(3px);
}
.cta.sm {
  min-height: 44px;
  padding: 0 20px;
  font-size: 15px;
}
.chip:is([aria-pressed="true"], :has(:checked)) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
dialog.modal {
  color: var(--text);
  margin: auto;
}
dialog.modal::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(8px);
}
@media (max-width: 640px) {
  dialog.modal {
    max-width: calc(100% - 16px);
  }
}
html.has-modal,
html.has-modal body {
  overflow: hidden;
  overscroll-behavior: none;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--scrim);
  backdrop-filter: blur(8px);
}
.modal {
  --modal-inset: 28px;
  width: min(100%, 560px);
  max-height: calc(100dvh - 32px);
  min-width: 0;
  padding: var(--modal-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding: var(--modal-inset) 0 90px;
  animation: modalIn var(--motion);
  /* A slim themed scrollbar inside the rounded window instead of the system one with arrows. */
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 22%, transparent) transparent;
}
.modal::-webkit-scrollbar {
  width: 10px;
}
.modal::-webkit-scrollbar-track {
  margin-block: var(--r-xl);
  background: transparent;
}
.modal::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 22%, transparent) padding-box;
}
.modal:focus {
  outline: 0;
}
.modal.wide {
  width: min(100%, 840px);
}
.modal-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.modal-heading h2 {
  font-size: 24px;
  font-weight: 700;
}
.modal-heading p {
  font-size: var(--t-md);
  color: var(--text-2);
  margin: 6px 0 0;
}
.modal-heading > .icon-button {
  margin: 0;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 20px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.modal-actions > .small {
  margin-right: auto;
}
.modal-backdrop.fullscreen {
  padding: 0;
}
.modal-backdrop.modal-profile {
  place-items: start end;
  padding: 66px var(--gutter) 16px 16px;
  background: transparent;
  backdrop-filter: none;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 640px) {
  .modal-backdrop {
    padding: 8px;
  }
  .modal {
    --modal-inset: 16px;
    max-height: calc(100dvh - 16px);
  }
}
.pill-select {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: 600 var(--t-sm)/1 var(--font);
  display: inline-flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
}
.pill-select:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.pill-select svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

/* Popover select (replaces every native <select> in the app). */
.popover {
  width: min(240px, calc(100vw - 24px));
  padding: 6px;
  border-radius: 18px;
  box-shadow: var(--shadow-pop);
  background: var(--surface);
}
.popover .opt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 40px;
  gap: 8px;
  padding: 6px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: 500 var(--t-md)/1.25 var(--font);
  color: var(--text);
}
.popover .opt:hover {
  background: var(--surface-2);
}
.popover .opt:is(.on, :has(:checked), [aria-selected="true"]) {
  background: var(--accent-soft);
}
.popover .opt small {
  color: var(--text-3);
  font-size: 13px;
}
.popover .check {
  color: var(--accent);
}

.popover .opt:focus-visible {
  outline-offset: -2px;
}
.popover .opt:has(:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Reader cover: full-bleed art with title over it, then the prose column. */
.chapter-hero {
  position: relative;
  width: 100%;
  border-radius: var(--r-xl);
  overflow: hidden;
  aspect-ratio: 16/7;
  box-shadow: var(--shadow-pop);
}
.chapter-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
}
.chapter-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 25%,
    rgba(8, 8, 7, 0.72) 60%,
    rgba(8, 8, 7, 0.86)
  );
}
.chapter-hero .over {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 24px;
  z-index: 1;
  color: #fff;
}
.chapter-hero .over .eyebrow2 {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  gap: 8px;
  align-items: center;
}
.chapter-hero .over h1 {
  font-size: 44px;
  color: #fff;
  margin-top: 6px;
}
@media (max-width: 640px) {
  .chapter-hero {
    min-height: 170px;
  }
  .chapter-hero::after {
    background: linear-gradient(
      180deg,
      transparent 8%,
      rgba(8, 8, 7, 0.76) 42%,
      rgba(8, 8, 7, 0.86)
    );
  }
  .chapter-hero .over {
    inset: auto 16px 16px;
  }
  .chapter-hero .over h1 {
    font-size: clamp(24px, 8vw, 32px);
  }
}

/* Meta line: plain text with dots, no boxed pills. */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--text-2);
  font-size: var(--t-sm);
}
.meta b {
  color: var(--text);
  font-weight: 600;
}
.meta .dot::before {
  content: "·";
  margin-right: 14px;
  color: var(--text-3);
}

.prose {
  font-family: var(--font-read);
  font-size: 19px;
  line-height: 1.75;
  color: var(--text);
}
.prose p {
  margin: 0 0 1em;
}
.choices {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 12px 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font: 500 var(--t-base)/1.35 var(--font);
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--dur),
    background var(--dur),
    transform 120ms;
}
.choice:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.choice .num {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 13px/1 var(--font);
}
.choice .arrow {
  margin-left: auto;
  color: var(--text-3);
}
.pill {
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  font: 500 14px/1 var(--font);
  color: var(--text-2);
}
.pill.on {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(227, 179, 106, 0.1);
}
.step {
  padding: 30px 32px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px 18px;
}
.step .n {
  font: 400 44px/1 var(--font-read);
  font-style: italic;
  color: var(--accent);
}
.step h3 {
  margin: 4px 0 0;
  font: 500 23px/1.2 var(--font);
  letter-spacing: -0.02em;
}
.step p {
  grid-column: 2;
  margin: 0;
  color: var(--text-3);
  font-size: 16px;
  line-height: 1.55;
}
@media (max-width: 640px) {
  .step {
    padding: 20px;
    grid-template-columns: 40px 1fr;
    gap: 6px 12px;
  }
  .step .n {
    font-size: 34px;
  }
  .step h3 {
    font-size: 19px;
  }
  .step p {
    font-size: 15px;
  }
}

.tile {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 200px;
}
.tile.img {
  min-height: 420px;
}
.tile.img > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.tile.img:hover > img {
  transform: scale(1.04);
}
.tile.img::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    0deg,
    rgba(14, 13, 11, 0.92) 0%,
    rgba(14, 13, 11, 0.58) 45%,
    rgba(14, 13, 11, 0) 74%
  );
}
.tile > *:not(img) {
  position: relative;
  z-index: 1;
}
.tile:not(.img) {
  background:
    radial-gradient(
      420px 260px at 85% 0%,
      rgba(227, 179, 106, 0.12),
      transparent 70%
    ),
    var(--surface);
}
.tile h3 {
  margin: 10px 0 8px;
  font: 500 26px/1.15 var(--font);
  letter-spacing: -0.025em;
}
.tile p {
  margin: 0;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.5;
  max-width: 460px;
}
.plan {
  border-radius: 24px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.plan.hot {
  background:
    linear-gradient(
      180deg,
      rgba(227, 179, 106, 0.1),
      rgba(227, 179, 106, 0) 60%
    ),
    var(--surface);
  border-color: rgba(227, 179, 106, 0.45);
}
.plan .t {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: 500 18px/1 var(--font);
}
.plan .tag {
  font: 500 12px/1 var(--font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.plan .price {
  font: 500 52px/1 var(--font);
  letter-spacing: -0.04em;
}
.plan .price small {
  font-size: 17px;
  color: var(--text-3);
  letter-spacing: 0;
}
.plan ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
  color: var(--text-2);
  font-size: 16px;
}
.plan li {
  display: flex;
  gap: 10px;
}
.plan li::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: radial-gradient(circle, var(--accent) 0 3px, transparent 4px);
}
.plan .cta {
  margin-top: auto;
  justify-content: space-between;
}

html[data-theme="light"] :is(.tile, .step, .plan) {
  box-shadow:
    0 1px 2px rgba(23, 20, 15, 0.04),
    0 12px 32px rgba(23, 20, 15, 0.06);
}
html[data-theme="light"] .tile:not(.img) {
  background:
    radial-gradient(
      420px 260px at 85% 0%,
      rgba(154, 106, 44, 0.1),
      transparent 70%
    ),
    #fff;
}
html[data-theme="light"] .plan.hot {
  background:
    linear-gradient(180deg, rgba(154, 106, 44, 0.1), rgba(154, 106, 44, 0) 60%),
    #fff;
  border-color: rgba(154, 106, 44, 0.45);
}

.nav {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: min(1120px, calc(100% - 32px));
  height: 60px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 22px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.site-logo {
  font: 600 21px/1 var(--font);
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: 0;
}
.site-logo b {
  color: var(--accent);
  font-weight: 600;
}
.nav ul {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0 0 0 auto;
  padding: 0;
}
.nav li a {
  display: block;
  padding: 10px 14px;
  border-radius: 999px;
  font: 500 15px/1 var(--font);
  color: var(--text-2);
}
.nav li a:hover,
.nav li a[aria-current] {
  color: var(--text);
  background: var(--surface-2);
}

.nav .theme-picker {
  position: relative;
  flex: none;
  margin-inline-end: 6px;
}
.theme-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.theme-btn:hover {
  color: var(--text);
}
html:not([data-theme="light"]) .theme-icon-light,
html[data-theme="light"] .theme-icon-dark {
  display: none;
}
.theme-current {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.theme-options {
  position: absolute;
  inset: calc(100% + 8px) 0 auto auto;
  z-index: 1;
}
.theme-options .check {
  visibility: hidden;
}
.theme-options [aria-selected="true"] .check {
  visibility: visible;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 28px 44px 40px;
  color: var(--text-2);
  font-size: 14px;
}
.site-footer nav {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.app-footer {
  margin: auto var(--gutter) 0;
  padding: var(--s5) 0;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--t-cap);
}

.nav a,
.site-footer a {
  text-decoration: none;
}
.nav :is(.theme-picker, .cta, .mobile-menu) {
  flex: none;
}
.nav .cta {
  white-space: nowrap;
}
.mobile-menu {
  display: none;
}
.site-footer a:hover {
  color: var(--text);
}
.site-footer,
.app-footer {
  background: transparent;
}
@media (max-width: 960px) {
  .nav {
    padding-inline-start: 18px;
  }
  .nav > ul {
    display: none;
  }
  .nav .theme-picker {
    position: static;
    margin-inline-start: auto;
    margin-inline-end: 0;
  }
  .mobile-menu {
    display: grid;
  }
  /* The menu button now opens the bar on the left, as in the app: equal inner spacing on both ends. */
  .nav {
    padding-inline-start: 8px;
  }
  .nav .popover {
    position: absolute;
    inset: calc(100% + 8px) 8px auto auto;
  }
  .mobile-menu .popover {
    display: block;
  }
}
/* Phones: logo, two round buttons and «Начать» must fit inside the pill (they overflowed at 375–414 px). */
@media (max-width: 430px) {
  .nav {
    top: 10px;
    width: calc(100% - 20px);
    height: 56px;
    gap: 6px;
    padding: 0 6px;
  }
  .nav .site-logo {
    font-size: 19px;
  }
  .nav .site-logo svg {
    width: 28px;
    height: 28px;
  }
  .nav .theme-btn,
  .nav .mobile-menu > summary {
    width: 40px;
    height: 40px;
  }
  .nav .cta.sm {
    padding-inline: 16px;
    font-size: 15px;
  }
}
@media (max-width: 360px) {
  .nav {
    width: calc(100% - 16px);
    gap: 4px;
    padding-inline-start: 6px;
  }
  .nav .cta.sm {
    padding-inline: 8px;
    font-size: 14px;
  }
  .nav .site-logo {
    font-size: 18px;
  }
}
.waitlist-note {
  margin-block: 8px 0;
  color: var(--text-2);
}

details > summary:is(.chip, .theme-btn, .icon-btn) {
  list-style: none;
}
details > summary:is(.chip, .theme-btn, .icon-btn)::-webkit-details-marker {
  display: none;
}
@media (max-width: 640px) {
  .site-footer {
    padding-inline: 20px;
  }
  .site-footer nav {
    gap: 0 16px;
  }
  /* Thumb-sized rows for footer links on phones. */
  .site-footer nav a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }
}

/* Brand mark: book = «Ф», gold fork above the spine = choice. Adapts to the theme. */
:root,
[data-theme="dark"] {
  --brand-plate: #efe8da;
  --brand-ink: #17140f;
  --brand-gold: #b07a35;
}
[data-theme="light"] {
  --brand-plate: #17140f;
  --brand-ink: #f2ebdd;
  --brand-gold: #e3b36a;
}
.brand-mark {
  flex: none;
  display: block;
}
.brand-mark .plate {
  fill: var(--brand-plate);
}
.brand-mark .book {
  fill: none;
  stroke: var(--brand-ink);
  stroke-width: 3.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-mark .fork {
  fill: none;
  stroke: var(--brand-gold);
  stroke-width: 3.6;
  stroke-linecap: round;
}
.site-logo .brand-mark {
  margin-right: 10px;
}
/* Icon-size rules of the app rail must not shrink the brand mark. */
.rail .brand-mark,
.sidebar .brand-mark,
.brand .brand-mark {
  width: 40px;
  height: 40px;
}

/* Full-screen mobile menu (public pages). The header stays on top: its button turns into «×». */
.mnav {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  padding: 96px 24px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 60% at 80% 0%, var(--accent-soft), transparent 60%),
    var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: mnavIn 220ms var(--ease, ease-out);
}
.mnav[hidden] {
  display: none;
}
.mnav-links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mnav-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font: 600 30px/1.15 var(--font);
  letter-spacing: -0.025em;
  text-decoration: none;
}
.mnav-links a[aria-current] {
  color: var(--accent);
}
.mnav-arrow {
  color: var(--text-3);
  font-size: 24px;
  font-weight: 400;
  transition: transform 200ms var(--ease, ease-out);
}
.mnav-links a:active .mnav-arrow,
.mnav-links a:hover .mnav-arrow {
  transform: translateX(4px);
  color: var(--accent);
}
.mnav-bottom {
  margin-top: auto;
  padding-top: 32px;
  display: grid;
  gap: 12px;
}
.mnav-cta,
.mnav-login {
  justify-content: center;
  min-height: 56px;
  font-size: 18px;
  width: 100%;
}
.mnav-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin: 8px 0 0;
  font-size: 14px;
}
.mnav-legal a {
  color: var(--text-3);
}
html.mnav-open,
html.mnav-open body {
  overflow: hidden;
}
.mobile-menu .mnav-icon-close,
.mobile-menu[aria-expanded="true"] .mnav-icon-open {
  display: none;
}
.mobile-menu[aria-expanded="true"] .mnav-icon-close {
  display: grid;
}
.mobile-menu > span {
  display: grid;
  place-items: center;
}
@keyframes mnavIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .mnav {
    animation: none;
  }
}
@media (min-width: 961px) {
  .mnav {
    display: none !important;
  }
}
