/* Commonplace — design tokens and components.
   Collected text is set in Literata (serif); the tool around it in system sans. */

:root {
  color-scheme: light dark;

  --paper: #f1f0eb;
  --sheet: #ffffff;
  --ink: #1b1f24;
  --ink-2: #5c636b;
  --rule: #d9d7cf;
  --danger: #a8402f;
  --danger-tint: #f6e6e2;

  --accent: #34558b;
  --tint: #e6ecf6;

  --serif: "Literata", "Charter", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --fs-1: 0.8rem;
  --fs-2: 0.875rem;
  --fs-3: 1rem;
  --fs-4: 1.25rem;
  --fs-5: 1.6rem;
  --fs-6: 2.25rem;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 40px;

  --r-control: 6px;
  --r-sheet: 14px;

  --shadow-sheet: 0 10px 30px rgba(27, 31, 36, 0.08);
  --tabbar-height: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16181c;
    --sheet: #1f2227;
    --ink: #e8e6e1;
    --ink-2: #9aa0a6;
    --rule: #2c3036;
    --danger: #e08a78;
    --danger-tint: #3a2622;
    --accent: #8fb1e3;
    --tint: #1e2735;
    --shadow-sheet: none;
  }
}

body[data-section="phrases"] {
  --accent: #3f7d5c;
  --tint: #e3efe7;
}
body[data-section="jokes"] {
  --accent: #b26a1b;
  --tint: #f6ebdc;
}
body[data-section="alcohol"] {
  --accent: #7a2f45;
  --tint: #f3e5e9;
}
@media (prefers-color-scheme: dark) {
  body[data-section="phrases"] {
    --accent: #7ec49b;
    --tint: #1e2e26;
  }
  body[data-section="jokes"] {
    --accent: #e3a455;
    --tint: #33281a;
  }
  body[data-section="alcohol"] {
    --accent: #d791a6;
    --tint: #33222a;
  }
}

/* --- base ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-3);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

kbd {
  font-family: var(--sans);
  font-size: 0.7em;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  border: 1px solid currentColor;
  opacity: 0.55;
  margin-left: var(--s2);
  vertical-align: 1px;
}

.muted {
  color: var(--ink-2);
}

/* --- shell --------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: var(--fs-4);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.tabs {
  display: flex;
  gap: var(--s1);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-control);
  color: var(--ink-2);
  font-size: var(--fs-2);
  font-weight: 500;
  text-decoration: none;
  transition: background 90ms ease, color 90ms ease;
}

.tab:hover {
  color: var(--ink);
  background: var(--tint);
}

.tab.is-active {
  color: var(--accent);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: var(--s3);
  right: var(--s3);
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.tab-icon {
  width: 18px;
  height: 18px;
}

.tab-badge {
  min-width: 1.4em;
  padding: 0 0.4em;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  font-size: var(--fs-1);
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--s5) var(--s5) calc(var(--s6) * 2);
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  margin: var(--s4) 0 var(--s5);
}

.page-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--fs-5);
  line-height: 1.2;
}

.page-meta {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-2);
  white-space: nowrap;
}

/* segmented control (links or buttons) */
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: calc(var(--r-control) + 3px);
  background: var(--tint);
  gap: 2px;
}

.segment {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-2);
  font-weight: 500;
  padding: var(--s1) var(--s3);
  border-radius: var(--r-control);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.6;
  transition: background 90ms ease, color 90ms ease;
}

.segment.is-active {
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.segment-count {
  color: var(--accent);
  font-weight: 600;
  margin-left: 2px;
}

.segmented-small .segment {
  padding: 2px var(--s3);
}

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

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  min-height: 40px;
  padding: 0 var(--s4);
  border: 1px solid transparent;
  border-radius: var(--r-control);
  font: inherit;
  font-size: var(--fs-2);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 90ms ease, color 90ms ease, border-color 90ms ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: var(--paper);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-quiet {
  background: var(--tint);
  color: var(--accent);
}
.btn-quiet:hover:not(:disabled) {
  filter: brightness(0.97);
}

.btn-danger {
  background: var(--danger-tint);
  color: var(--danger);
}

.btn-small {
  min-height: 32px;
  padding: 0 var(--s3);
  font-size: var(--fs-1);
}

.btn-wide {
  min-width: 220px;
}

.btn-row {
  display: flex;
  gap: var(--s3);
  justify-content: center;
}

.btn-row > .btn {
  flex: 1 1 0;
}

.btn-row-end {
  justify-content: flex-end;
}
.btn-row-end > .btn {
  flex: 0 0 auto;
}

.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 90ms ease, color 90ms ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover:not(:disabled) {
  background: var(--tint);
  color: var(--accent);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.link-btn {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.input {
  width: 100%;
  font: inherit;
  font-size: var(--fs-3);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  padding: var(--s2) var(--s3);
  min-height: 40px;
  resize: vertical;
}

.input::placeholder {
  color: var(--ink-2);
  opacity: 0.8;
}

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.input-serif {
  font-family: var(--serif);
}

input[type="search"].input {
  -webkit-appearance: none;
}

.field-hint {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-1);
}

/* --- quick add ------------------------------------------------------------- */

.quick-add {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  margin-bottom: var(--s5);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--r-sheet);
}

.quick-add-row {
  display: flex;
  gap: var(--s2);
  align-items: center;
}

.quick-add-row .input {
  flex: 1;
}

.quick-add-submit {
  justify-content: space-between;
}

.quick-add-extras {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms ease-out;
}

.quick-add-extras-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
  overflow: hidden;
}

.quick-add:focus-within .quick-add-extras,
.quick-add.is-open .quick-add-extras {
  grid-template-rows: 1fr;
}

.quick-add .quick-add-submit {
  display: none;
}
.quick-add:focus-within .quick-add-submit,
.quick-add.is-open .quick-add-submit {
  display: flex;
}

.quick-add:not(:focus-within):not(.is-open) .quick-add-extras-inner {
  padding: 0;
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.toolbar .input {
  flex: 1;
}

/* --- rows (lists) ----------------------------------------------------------- */

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.row {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--rule);
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--s2);
}

.row-title {
  font-family: var(--serif);
  font-size: var(--fs-4);
  font-weight: 500;
  line-height: 1.3;
}

.row-text {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--fs-4);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.row-notes {
  margin: var(--s1) 0 0;
  color: var(--ink-2);
  font-size: var(--fs-2);
  white-space: pre-wrap;
}

.row-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  margin-top: var(--s2);
  color: var(--ink-2);
  font-size: var(--fs-1);
}

.row-meta > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.row-meta > span:last-child {
  white-space: nowrap;
}

.row-meta .source-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: var(--ink-2);
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--fs-2);
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.row-meta .source-link:hover {
  color: var(--accent);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
  .row-actions .icon-btn {
    opacity: 0;
    transition: opacity 90ms ease;
  }
  .row:hover .row-actions .icon-btn,
  .row:focus-within .row-actions .icon-btn {
    opacity: 1;
  }
}

.row.is-retired .row-title {
  color: var(--ink-2);
}

.row.is-editing {
  display: block;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.confirm {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--fs-2);
  color: var(--danger);
  white-space: nowrap;
}

.row-details {
  margin-top: var(--s1);
  font-size: var(--fs-2);
}

.row-details summary {
  cursor: pointer;
  color: var(--ink-2);
  user-select: none;
}

.row-definition {
  margin: var(--s2) 0;
  font-family: var(--serif);
  font-size: var(--fs-3);
  line-height: 1.55;
  white-space: pre-line;
}

.streak {
  color: var(--accent);
  font-size: var(--fs-1);
  letter-spacing: 1px;
}

.phonetic {
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: var(--fs-2);
}

/* --- chips ------------------------------------------------------------------ */

.chip {
  display: inline-block;
  padding: 1px var(--s2);
  border-radius: var(--r-control);
  font-size: var(--fs-1);
  font-weight: 500;
  line-height: 1.6;
  background: var(--tint);
  color: var(--accent);
}

.chip--muted {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
}

.chip--warn {
  background: var(--danger-tint);
  color: var(--danger);
}

.chip--filter {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: var(--s1) var(--s3);
  font: inherit;
  font-size: var(--fs-2);
}

/* --- flashcard --------------------------------------------------------------- */

.review-root {
  display: flex;
  justify-content: center;
}

.flashcard {
  width: 100%;
  max-width: 560px;
  padding: var(--s6) var(--s5);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-sheet);
  cursor: pointer;
}

.flashcard.is-revealed {
  cursor: default;
}

.flashcard-word {
  font-family: var(--serif);
  font-size: var(--fs-6);
  font-weight: 500;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.reveal-region {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
}

.reveal-inner {
  overflow: hidden;
}

.flashcard.is-revealed .reveal-region {
  grid-template-rows: 1fr;
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .reveal-region {
    transition: grid-template-rows 220ms ease-out, opacity 220ms ease-out;
  }
}

.flashcard-notes {
  margin: var(--s4) 0 0;
  color: var(--ink-2);
  font-size: var(--fs-2);
  white-space: pre-wrap;
}

.flashcard-definition {
  margin-top: var(--s4);
  font-family: var(--serif);
  font-size: var(--fs-3);
  line-height: 1.55;
  white-space: pre-line;
}

.pronounce-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s4);
}

.youglish {
  margin-top: var(--s3);
}

.youglish:empty {
  display: none;
}

.flashcard-actions {
  margin-top: var(--s5);
}

.flashcard-actions .btn-wide {
  display: flex;
  margin: 0 auto;
}

.flashcard-prompt {
  margin: 0 0 var(--s3);
  text-align: center;
  color: var(--ink-2);
  font-size: var(--fs-2);
}

/* --- feature (random) card ------------------------------------------------------- */

.feature {
  padding: var(--s5);
  margin-bottom: var(--s5);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-sheet);
}

.feature-kicker {
  margin: 0 0 var(--s3);
  color: var(--ink-2);
  font-size: var(--fs-1);
  font-weight: 500;
}

.feature-text {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--fs-5);
  font-weight: 400;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.feature-source {
  margin: var(--s3) 0 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-2);
}

.feature-actions {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s4);
}

/* --- states -------------------------------------------------------------------- */

.empty {
  margin: var(--s5) 0;
  text-align: center;
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: var(--fs-4);
}

.empty .btn,
.empty .link-btn {
  margin-top: var(--s3);
  font-family: var(--sans);
}

.empty-text {
  margin: 0 0 var(--s3);
}

.loading {
  color: var(--ink-2);
  text-align: center;
}

.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--s5) + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-control);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--fs-2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
}

.toast-action {
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* --- mobile ------------------------------------------------------------------ */

@media (max-width: 640px) {
  .topbar {
    justify-content: center;
    padding: var(--s3) var(--s4);
  }

  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding: 0 var(--s2) env(safe-area-inset-bottom);
    background: var(--sheet);
    border-top: 1px solid var(--rule);
    gap: 0;
  }

  .tab {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: var(--s2) 0;
    border-radius: 0;
    font-size: 0.7rem;
  }

  .tab:hover {
    background: transparent;
  }

  .tab.is-active::after {
    display: none;
  }

  .tab-icon {
    width: 22px;
    height: 22px;
  }

  .tab-badge {
    position: absolute;
    top: 6px;
    left: calc(50% + 6px);
  }

  .page {
    padding: var(--s4) var(--s4) calc(var(--tabbar-height) + var(--s6) + env(safe-area-inset-bottom));
  }

  .page-head {
    margin-top: var(--s2);
    flex-wrap: wrap;
  }

  .flashcard {
    padding: var(--s5) var(--s4);
  }

  .flashcard-word {
    font-size: 1.85rem;
  }

  .quick-add-extras-inner {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toast-root {
    bottom: calc(var(--tabbar-height) + var(--s3) + env(safe-area-inset-bottom));
  }

  .btn-wide {
    width: 100%;
  }
}

/* =========================================================================
   Alcohol tab
   ========================================================================= */

.page--wide {
  max-width: 1140px;
}

.toolbar-wrap {
  flex-wrap: wrap;
  justify-content: space-between;
}

.segmented--scroll {
  max-width: 100%;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.segmented--scroll::-webkit-scrollbar {
  display: none;
}
.segmented--scroll .segment {
  white-space: nowrap;
}

/* 41 drinks do not need a 1500px search bar; keep it inline with the controls. */
.toolbar .input--search {
  flex: 1 1 220px;
  min-width: 160px;
  max-width: 320px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  margin: 0;
}

.chip--toggle {
  appearance: none;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  padding: 3px var(--s3);
  font: inherit;
  font-size: var(--fs-2);
  transition: background 90ms ease, color 90ms ease, border-color 90ms ease;
}
.chip--toggle.is-on {
  background: var(--tint);
  border-color: var(--tint);
  color: var(--accent);
}

.section-title {
  margin: var(--s6) 0 var(--s4);
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--fs-4);
}

/* Marks: the kind is carried by SHAPE first — ring, disc, half disc, diamond —
   so the four stay apart at 12px, in dark mode, and without relying on hue. */
.mark-inline {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  overflow: visible;
}
.mark .mark-body {
  stroke-width: 1.4;
}
.mark--fermented .mark-body {
  fill: var(--paper);
  stroke: var(--ink);
}
.mark--distilled .mark-body {
  fill: var(--accent);
  stroke: var(--accent);
}
.mark--fortified .mark-body {
  fill: var(--paper);
  stroke: var(--accent);
}
.mark-half {
  fill: var(--accent);
  pointer-events: none;
}
.mark--liqueurs .mark-body {
  fill: var(--tint);
  stroke: var(--accent);
  stroke-width: 1.6;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  list-style: none;
  margin: 0 0 var(--s4);
  padding: 0;
}
.legend-item {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 3px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-2);
  cursor: pointer;
}
.legend-item:hover {
  color: var(--accent);
  border-color: var(--tint);
  background: var(--tint);
}

.drinks-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: var(--s5);
  align-items: start;
}
/* The panel is hidden by attribute, so without this the 420px track is still
   reserved and the tree, lists and prose sit in the left 60% of the page. */
.drinks-layout:has(> .detail[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
.drinks-main {
  min-width: 0;
}

/* --- radial graph --- */
.radial-wrap {
  /* Width is no longer the binding constraint once the panel column collapses,
     height is: size the circle so the whole tree stays on screen. */
  max-width: clamp(560px, calc(100vh - 340px), 860px);
  margin: 0 auto;
}
.radial {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  font-family: var(--sans);
}
.radial .link {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
  transition: stroke 120ms ease, opacity 120ms ease;
}
.radial .link--family,
.radial .link--root {
  stroke: var(--ink-2);
  stroke-opacity: 0.45;
}
.radial .link.is-lit {
  stroke: var(--accent);
  stroke-opacity: 1;
  stroke-width: 1.6;
}
.radial .is-dim {
  opacity: 0.22;
}
.radial .root-disc {
  fill: var(--sheet);
  stroke: var(--rule);
}
.radial .node-label {
  fill: var(--ink-2);
  font-size: 11px;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 3px;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill 90ms ease, opacity 120ms ease;
}
.radial .node-label--root {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 20px;
  fill: var(--ink);
  stroke: none;
  cursor: default;
}
.radial .node-label--kind {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 14px;
  fill: var(--ink);
}
.radial .node-label--family {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 12.5px;
  fill: var(--ink);
}
.radial .node-label--leaf.is-lit,
.radial .node-label--leaf.is-selected {
  fill: var(--accent);
  font-weight: 600;
}
.radial .node-label--leaf.is-fav {
  fill: var(--accent);
}
/* A paper plate keeps the kind and family labels legible where they cross the
   link bundle; a text halo alone loses against a dozen overlapping strokes. */
.radial .label-plate {
  fill: var(--paper);
  stroke: none;
  pointer-events: none;
}
.radial .node-label-group {
  cursor: pointer;
}
/* Scaling an inner group keeps the fortified half-disc and the liqueur diamond
   in step, which a bare `r` on the circle never did. */
.radial .marks .mark {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 90ms ease, opacity 120ms ease;
}
.radial .marks .mark.is-selected,
.radial .marks .mark.is-lit {
  transform: scale(1.35);
}
.radial .marks .mark.is-selected .mark-body,
.radial .marks .mark.is-lit .mark-body {
  stroke: var(--accent);
  stroke-width: 2;
}
.radial .node-hit {
  fill: transparent;
  cursor: pointer;
}
.radial .hits .node-hit:hover,
.radial .hits .node-hit:focus-visible {
  fill: var(--tint);
  fill-opacity: 0.6;
  outline: none;
}
.radial .hits .node-hit:focus-visible {
  stroke: var(--accent);
  stroke-width: 1.5;
}

@media (prefers-reduced-motion: no-preference) {
  .radial .link {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
  }
  .radial.is-drawn .link {
    animation: draw 420ms ease-out forwards;
  }
  .radial.is-drawn .link--root {
    animation-delay: 0ms;
  }
  .radial.is-drawn .link--family {
    animation-delay: 140ms;
  }
  .radial.is-drawn .link:not(.link--root):not(.link--family) {
    animation-delay: 280ms;
  }
  @keyframes draw {
    to {
      stroke-dashoffset: 0;
    }
  }
}

/* --- ledger --- */
.ledger {
  /* Now that the panel column collapses, cap the measure so a description line
     doesn't run the full 1092px and the group count stays near its title. */
  max-width: 840px;
}
.ledger-group {
  border-top: 1px solid var(--rule);
}
.ledger-group:last-child {
  border-bottom: 1px solid var(--rule);
}
.ledger-group > summary {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  padding: var(--s3) 0;
  cursor: pointer;
  list-style: none;
}
.ledger-group > summary::-webkit-details-marker {
  display: none;
}
.ledger-group > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--ink-2);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  margin-right: var(--s1);
  transition: transform 120ms ease;
  align-self: center;
}
.ledger-group[open] > summary::before {
  transform: rotate(90deg);
}
.ledger-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--fs-4);
}
.ledger-group--sub {
  border-top: 0;
  margin-left: var(--s4);
}
.ledger-group--sub:last-child {
  border-bottom: 0;
}
.ledger-group--sub > summary {
  padding: var(--s2) 0;
}
.ledger-group--sub .ledger-title {
  font-size: var(--fs-3);
}
.ledger-meta {
  color: var(--ink-2);
  font-size: var(--fs-2);
}
.ledger-count {
  margin-left: auto;
  color: var(--ink-2);
  font-size: var(--fs-1);
}
.ledger-items {
  padding-bottom: var(--s2);
}
.ledger-item {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  width: 100%;
  min-height: 44px;
  padding: var(--s2) var(--s2);
  border: 0;
  border-radius: var(--r-control);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 90ms ease;
}
.ledger-item .mark-inline {
  margin-top: 6px;
}
.ledger-item:hover,
.ledger-item.is-selected {
  background: var(--tint);
}
.ledger-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ledger-name {
  font-family: var(--serif);
  font-size: var(--fs-3);
  font-weight: 500;
}
.zh {
  color: var(--ink-2);
  font-weight: 400;
  font-size: 0.9em;
  margin-left: 2px;
}
.ledger-say {
  color: var(--ink-2);
  font-size: var(--fs-2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.flag {
  margin-left: var(--s1);
  font-size: var(--fs-1);
  color: var(--accent);
  font-family: var(--sans);
}

/* --- serves strip --- */
.serves-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s3);
}
.serve {
  padding: var(--s4);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--r-sheet);
}
.serve-name {
  margin: 0 0 var(--s2);
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--fs-3);
}
.serve-say {
  margin: 0 0 var(--s2);
  color: var(--ink-2);
  font-size: var(--fs-2);
  line-height: 1.45;
}
.serve-links {
  margin: 0;
  font-size: var(--fs-2);
}

/* --- detail panel / sheet --- */
.detail {
  position: sticky;
  top: var(--s5);
  max-height: calc(100vh - var(--s5) * 2);
  overflow-y: auto;
  padding: var(--s5);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-sheet);
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.detail-kind {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--ink-2);
  font-size: var(--fs-1);
  font-weight: 500;
}
.detail-name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--fs-5);
  line-height: 1.15;
}
.detail-zh {
  margin: 2px 0 0;
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: var(--fs-2);
}
.say {
  margin: var(--s3) 0 var(--s4);
  font-family: var(--serif);
  font-size: var(--fs-4);
  line-height: 1.4;
}
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s1) var(--s3);
  margin: 0 0 var(--s4);
  font-size: var(--fs-2);
}
.facts dt {
  color: var(--ink-2);
}
.facts dd {
  margin: 0;
}
.detail-label {
  margin: var(--s3) 0 var(--s1);
  color: var(--ink-2);
  font-size: var(--fs-1);
  font-weight: 500;
  text-transform: none;
}
.detail .chips {
  margin: 0;
}
.styles {
  margin: 0;
  padding-left: 1.1em;
  font-size: var(--fs-2);
  color: var(--ink);
}
.styles li {
  margin-bottom: 2px;
}
.related {
  margin: 0;
  font-size: var(--fs-2);
  line-height: 1.7;
}
/* Stacked rather than tabular: four columns in a 420px panel wrapped "Made from"
   to eight lines and broke ABV ranges across the en-dash. */
.compare {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--fs-2);
}
.compare-row {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--rule);
}
.compare-row:first-child {
  padding-top: var(--s1);
}
.compare-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.compare-trait {
  margin: 2px 0 var(--s1);
  line-height: 1.45;
  color: var(--ink);
}
.compare-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--s3);
  margin: 0;
  color: var(--ink-2);
  line-height: 1.4;
}
.compare-made {
  flex: 1 1 12rem;
  min-width: 0;
}
.compare-abv {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.compare-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}
.compare-name:hover {
  text-decoration: underline;
}
.compare-name span:not(.zh) {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
}
.personal {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--rule);
}
.personal-row {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.btn.is-on {
  background: var(--accent);
  color: var(--paper);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgba(0, 0, 0, 0.35);
}

@media (max-width: 899px) {
  .drinks-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .detail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 15;
    max-height: 72vh;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    border-bottom: 0;
    padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom));
    transform: translateY(105%);
    transition: transform 220ms ease-out;
  }
  .detail.is-open {
    transform: none;
  }
  @media (prefers-reduced-motion: reduce) {
    .detail {
      transition: none;
    }
  }
}

@media (max-width: 640px) {
  .detail {
    bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    max-height: 66vh;
    padding-bottom: var(--s5);
  }
  .sheet-backdrop {
    bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  }
  .serves-grid {
    grid-template-columns: 1fr;
  }
  /* The tree is the point of the page, so the phone gets it too — scrolled
     sideways rather than shrunk until the rim labels are unreadable. */
  .radial-wrap {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }
  .radial {
    min-width: 560px;
  }
}

/* --- social prose --- */
.prose {
  max-width: 720px;
}
.prose h3 {
  margin: var(--s5) 0 var(--s2);
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--fs-4);
}
.prose h4 {
  margin: var(--s4) 0 var(--s1);
  font-size: var(--fs-2);
  font-weight: 600;
  color: var(--ink-2);
}
.prose p,
.prose li {
  font-family: var(--serif);
  font-size: var(--fs-3);
  line-height: 1.6;
}
.prose p {
  margin: 0 0 var(--s3);
}
.prose .aside {
  padding: var(--s3) var(--s4);
  border-left: 3px solid var(--accent);
  background: var(--tint);
  border-radius: 0 var(--r-control) var(--r-control) 0;
  font-size: var(--fs-2);
}
.glossary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s1) var(--s4);
  margin: 0 0 var(--s3);
}
.glossary dt {
  font-family: var(--serif);
  font-weight: 500;
}
.glossary dd {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.5;
}
.glossary--units dt {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.orders {
  padding-left: 1.4em;
  margin: 0 0 var(--s3);
}
.orders li {
  margin-bottom: var(--s1);
}
@media (max-width: 640px) {
  .glossary {
    grid-template-columns: 1fr;
    gap: 0 0;
  }
  .glossary dd {
    margin-bottom: var(--s2);
  }
}
