/* Fruit family tree: lvrcz.com/fruits */
:root {
  --bg: #f6f4ec;
  --bg2: #efece1;
  --panel: #fffdf7;
  --card: #fffdf8;
  --line: #ddd8c8;
  --line2: #c9c2ad;
  --text: #1f241f;
  --muted: #6c7268;
  --accent: #3f8f3a;
  --accent-ink: #2d6f29;
  --accent-bg: #e3f1d8;
  --shadow: 0 1px 2px rgba(40, 40, 20, .06), 0 6px 18px rgba(40, 40, 20, .07);
  --r: 12px;

  /* group colours */
  --g-root: #7a7a6a;
  --g-early: #a26b3a;
  --g-magnoliid: #b0533c;
  --g-monocot: #c08a12;
  --g-ranunc: #8c6bb3;
  --g-saxi: #7b4fa6;
  --g-fabid: #2f8a4c;
  --g-malvid: #d0612a;
  --g-caryo: #c23d78;
  --g-asterid: #2c76b8;

  color-scheme: light;
}
/* dark theme: set by theme.js from the system setting or the toggle button */
:root[data-theme="dark"] {
    --bg: #0f1311;
    --bg2: #141a17;
    --panel: #151b18;
    --card: #171e1a;
    --line: #26302b;
    --line2: #34413a;
    --text: #e7ede8;
    --muted: #8f9b93;
    --accent: #8fd16a;
    --accent-ink: #a8e383;
    --accent-bg: rgba(143, 209, 106, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    --g-root: #9a9a8a;
    --g-early: #d39a63;
    --g-magnoliid: #e68369;
    --g-monocot: #e5b43c;
    --g-ranunc: #b59ae0;
    --g-saxi: #b38ae0;
    --g-fabid: #5fc27c;
    --g-malvid: #f0905a;
    --g-caryo: #ec6fa6;
    --g-asterid: #66a9ec;
    color-scheme: dark;
}

.g-root { --g: var(--g-root); }
.g-early { --g: var(--g-early); }
.g-magnoliid { --g: var(--g-magnoliid); }
.g-monocot { --g: var(--g-monocot); }
.g-ranunc { --g: var(--g-ranunc); }
.g-saxi { --g: var(--g-saxi); }
.g-fabid { --g: var(--g-fabid); }
.g-malvid { --g: var(--g-malvid); }
.g-caryo { --g: var(--g-caryo); }
.g-asterid { --g: var(--g-asterid); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 130px; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
body.panel-open { overflow: hidden; }
button { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--bg2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; user-select: all; }

/* ---------- header ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 28px;
  padding: 18px clamp(14px, 4vw, 40px) 12px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.home {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-decoration: none; color: var(--muted);
  font-size: 18px;
  transition: color .15s, border-color .15s;
}
.home:hover { color: var(--text); border-color: var(--line2); }
h1 { margin: 0; font-size: clamp(1.3rem, 2.6vw, 1.7rem); letter-spacing: -.02em; font-weight: 720; }
.sub { margin: 1px 0 0; color: var(--muted); font-size: .9rem; }

.stats { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; }
.stat { display: flex; align-items: baseline; gap: 4px; color: var(--muted); font-size: .88rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat strong { color: var(--accent-ink); font-size: 1.35rem; font-weight: 760; }
.stat.small strong { font-size: 1.05rem; }
.stat b { font-weight: 600; color: var(--text); }
.bar { width: clamp(80px, 12vw, 160px); height: 7px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6cbf4a, var(--accent)); border-radius: inherit; transition: width .6s cubic-bezier(.2, .9, .3, 1); }

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 10px clamp(14px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-block: 1px solid var(--line);
}
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button {
  border: 0; background: none; cursor: pointer;
  padding: 6px 12px; border-radius: 8px; font-size: .87rem; color: var(--muted); font-weight: 560;
}
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
#q {
  flex: 1 1 200px; max-width: 380px; min-width: 0;
  padding: 8px 14px; font: inherit; font-size: .92rem;
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
#q:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.acts { display: flex; gap: 6px; margin-left: auto; }
.view-radial .tree-only { display: none; }
.ghost {
  border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  border-radius: 9px; padding: 6px 11px; font-size: .84rem; color: var(--muted);
  transition: color .15s, border-color .15s;
}
.ghost:hover { color: var(--text); border-color: var(--line2); }

main { padding: 18px clamp(10px, 4vw, 40px) 30px; }
.empty { text-align: center; color: var(--muted); padding: 22px 12px; margin: 0; }
.warn { white-space: pre-line; background: #fff3cd; color: #6b4e00; border: 1px solid #f0d989; border-radius: 10px; padding: 10px 14px; font-size: .88rem; }
:root[data-theme="dark"] .warn { background: #3a3010; color: #f3dc8a; border-color: #5c4d18; }

/* ---------- rank chips ---------- */
.rk {
  display: inline-block;
  font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 5px;
  color: var(--muted); background: var(--bg2); border: 1px solid var(--line);
  vertical-align: 1px;
}
.r-order > .ch .rk, .rk.r-order, .lin.r-order .rk { color: #fff; background: var(--g, #777); border-color: transparent; }
.r-family > .ch .rk, .rk.r-family, .lin.r-family .rk { color: var(--g, #777); border-color: currentColor; background: transparent; }
.r-genus > .ch .rk, .rk.r-genus, .lin.r-genus .rk { font-style: italic; text-transform: none; letter-spacing: 0; font-size: .7rem; }
.rk.r-order { --g: #6b7a5c; }
.rk.r-family { --g: #6b7a5c; }

/* ---------- nested tree ---------- */
#tree-view { --ind: 20px; }
.clade { position: relative; }
.ch {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  min-height: 34px;
  padding: 2px 0;
}
.tog {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center;
  border: 0; background: none; cursor: pointer; border-radius: 6px; color: var(--muted);
}
.tog:hover { background: var(--bg2); color: var(--text); }
.tog svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transform: rotate(90deg); transition: transform .18s; }
.closed > .ch .tog svg { transform: rotate(0); }
.closed > .kids { display: none; }
.cl {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px;
  border: 0; background: none; cursor: pointer; text-align: left; padding: 3px 6px; border-radius: 7px; min-width: 0;
}
.cl:hover { background: var(--bg2); }
.cn { font-weight: 640; color: var(--text); }
.r-genus > .ch .cn, .r-subgenus > .ch .cn, .r-section > .ch .cn { font-style: italic; }
.r-order > .ch .cn { font-size: 1.04rem; }
.r-clade > .ch .cn { font-size: .98rem; letter-spacing: -.005em; }
.cc { color: var(--muted); font-size: .86rem; }
.cnt { margin-left: auto; flex: none; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-left: 8px; }
.cnt b { font-weight: 600; }
.cnt.some b { color: var(--accent-ink); }

/* connector lines */
.kids {
  position: relative;
  margin-left: 11px;
  padding-left: var(--ind);
  border-left: 2px solid color-mix(in srgb, var(--g) 34%, transparent);
}
.kids > .clade > .ch::before,
.kids > .leaves::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--ind) - 2px);
  top: 18px;
  width: calc(var(--ind) - 2px);
  border-top: 2px solid color-mix(in srgb, var(--g) 34%, transparent);
}
.kids > .leaves::before { top: 36px; }
.kids > .clade:last-child::after,
.kids > .leaves:last-child::after {
  /* hide the vertical line below the last child */
  content: "";
  position: absolute;
  left: calc(-1 * var(--ind) - 3px);
  top: 20px; bottom: -2px;
  width: 4px;
  background: var(--bg);
}
.kids > .leaves:last-child::after { top: 38px; }
.kids > .leaves { position: relative; }
.r-order > .ch .cn, .r-clade > .ch .cn { color: color-mix(in srgb, var(--g) 70%, var(--text)); }
.clade.flash > .ch { animation: flash 1.6s ease; border-radius: 8px; }
@keyframes flash { 0%, 40% { background: var(--accent-bg); } 100% { background: transparent; } }

/* fruit cards */
.leaves {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 8px;
  padding: 6px 0 12px;
}
.fruit {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px;
  text-align: left; cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid color-mix(in srgb, var(--g) 30%, var(--line));
  border-radius: var(--r);
  min-width: 0;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.fruit:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line2); }
.fruit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fruit.eaten { border-left-color: var(--accent); background: linear-gradient(90deg, var(--accent-bg), var(--card) 60%); }
.fruit.flash { animation: flash 1.6s ease; }
.ft {
  position: relative; flex: none;
  width: 52px; height: 52px; border-radius: 9px; overflow: hidden;
  background: var(--bg2);
  display: grid; place-items: center; font-size: 26px;
}
.ft img, .ct img, .vt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fruit:not(.eaten) .ft img { filter: saturate(.55) brightness(.97); transition: filter .2s; }
.fruit:not(.eaten):hover .ft img { filter: none; }
.tick {
  position: absolute; right: 3px; bottom: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font: 700 11px/1 system-ui; font-style: normal;
  box-shadow: 0 0 0 2px var(--card);
}
.fx { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.fn { font-weight: 620; font-size: .93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hx { font-style: normal; margin-left: 5px; color: var(--muted); font-weight: 500; }
.fs { font-style: italic; color: var(--muted); font-size: .79rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm { font-size: .74rem; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.nq { font-style: normal; color: var(--accent-ink); font-weight: 600; }

/* ---------- legend + footer ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; color: var(--muted); font-size: .82rem; margin-top: 20px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line2); background: var(--panel); }
.lg-dot.on { background: var(--accent); border-color: var(--accent); }
.lg-x { font-style: normal; font-weight: 700; }
.rank-legend { gap: 6px !important; }
footer { padding: 6px clamp(14px, 4vw, 40px) 40px; color: var(--muted); font-size: .8rem; max-width: 900px; }
footer p { margin: 4px 0; }
.built { opacity: .8; }

/* ---------- radial ---------- */
#radial-view { position: relative; }
.radial-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.radial-tools .hint { color: var(--muted); font-size: .8rem; margin-left: 6px; }
#radial-wrap {
  height: calc(100vh - 190px); min-height: 420px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
#radial { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
#radial:active { cursor: grabbing; }
#radial .lk { fill: none; stroke: var(--g); stroke-opacity: .55; stroke-width: 1.4; }
#radial .lk.ext { stroke-dasharray: 1 3; stroke-opacity: .35; }
#radial .cn { fill: var(--panel); stroke: var(--g); stroke-width: 1.6; cursor: pointer; }
#radial .cn.r-order, #radial .cn.r-clade { fill: var(--g); }
#radial .cn:hover, #radial .cn.hl { stroke-width: 3; fill: var(--g); }
#radial .leaf { cursor: pointer; outline: none; }
#radial .ld { fill: var(--panel); stroke: var(--g); stroke-width: 1.4; }
#radial .leaf.eaten .ld { fill: var(--accent); stroke: var(--accent); }
#radial .lt { font-size: 11px; fill: var(--text); paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; }
#radial .leaf:not(.eaten) .lt { fill: var(--muted); }
#radial .leaf.eaten .lt { font-weight: 650; }
#radial .leaf:hover .lt, #radial .leaf:focus .lt, #radial .leaf.hl .lt { fill: var(--text); font-weight: 700; }
#radial .leaf:focus .ld { stroke-width: 3; }
#radial.hovering .leaf:not(.hl) { opacity: .45; }
#radial.filtering .leaf:not(.match) { opacity: .16; }
#radial.filtering .leaf.match .ld { r: 6; }
#radial .ga { fill: none; stroke: var(--g); stroke-width: 6; stroke-linecap: round; opacity: .8; }
#radial .gt { font-size: 15px; font-weight: 750; letter-spacing: .12em; fill: var(--g); }
#radial .rootlab { font-size: 22px; font-weight: 750; fill: var(--text); }
#radial .rootsub { font-size: 13px; fill: var(--muted); }

#tip {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none;
  max-width: 240px; padding: 8px 10px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line2); box-shadow: var(--shadow);
  font-size: .82rem; display: flex; flex-direction: column; gap: 1px;
}
#tip img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; margin-bottom: 5px; }
#tip small { text-transform: uppercase; letter-spacing: .06em; font-size: .64rem; color: var(--muted); font-weight: 700; }
#tip i, #tip span { color: var(--muted); }
#tip em { font-style: normal; color: var(--accent-ink); font-size: .76rem; margin-top: 2px; }

/* ---------- panel ---------- */
#scrim { position: fixed; inset: 0; z-index: 40; background: rgba(15, 20, 15, .35); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
#panel {
  position: fixed; z-index: 50; top: 0; right: 0; bottom: 0;
  width: min(480px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(0, 0, 0, .16);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(105%); visibility: hidden;
  transition: transform .28s cubic-bezier(.2, .9, .3, 1), visibility 0s .28s;
  outline: none;
}
#panel.open { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2, .9, .3, 1); }
.close {
  position: sticky; top: 10px; float: right; margin: 10px 10px -46px 0; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer;
  background: color-mix(in srgb, var(--panel) 85%, transparent); backdrop-filter: blur(6px);
  font-size: 15px; color: var(--muted);
}
.close:hover { color: var(--text); }
#panel-body { padding: 0 0 30px; }
.hero { aspect-ratio: 4 / 3; max-height: 340px; width: 100%; background: var(--bg2); display: grid; place-items: center; overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero.emoji { font-size: 90px; aspect-ratio: 16 / 7; }
.credit { margin: 4px 18px 0; font-size: .7rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.credit a { color: inherit; }
.ph { padding: 12px 22px 4px; }
.ph h2 { margin: 6px 0 0; font-size: 1.65rem; line-height: 1.15; letter-spacing: -.02em; }
.clade-h { padding-top: 58px; border-bottom: 4px solid var(--g); padding-bottom: 14px; }
.rk.big { font-size: .72rem; }
.sci { margin: 2px 0 0; color: var(--muted); font-style: italic; }
.sci.plain { font-style: normal; }
.fr { margin: 6px 0 0; display: flex; gap: 7px; align-items: center; font-size: .92rem; }
.lang { font-size: .62rem; font-weight: 800; letter-spacing: .05em; padding: 1px 5px; border-radius: 4px; background: #2a5bd7; color: #fff; }
.cl-count { margin: 6px 0 0; color: var(--muted); }
.cl-count b { color: var(--accent-ink); font-size: 1.1rem; }
.badge {
  display: inline-block; font-size: .74rem; font-weight: 650; padding: 3px 9px; border-radius: 99px;
  background: var(--bg2); color: var(--muted); border: 1px solid var(--line);
}
.badge.on { background: var(--accent); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .badge.on { color: #0f1a0b; }
.badge.sm { font-size: .66rem; padding: 1px 7px; }
.ps { padding: 12px 22px 2px; }
.ps h3 { margin: 0 0 8px; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 720; }
.names { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.names li { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 2px 9px; font-size: .86rem; }
.mine .notes, .mine.sm {
  background: var(--accent-bg); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; padding: 10px 14px;
}
.mine h3 { color: var(--accent-ink); }
.notes p { margin: 0 0 4px; }
.notes p:last-child { margin: 0; }
.notes p.pending { font-style: italic; opacity: .6; }
.mine.sm { margin-top: 8px; padding: 8px 12px; font-size: .9rem; }
/* variant notes: one box only (the inner .notes must not draw a second one) */
.mine.sm .notes { background: none; border: 0; border-radius: 0; padding: 0; }
.mine.sm.empty { padding: 4px 10px; font-size: .82rem; }
.mine.sm.empty h4 { display: inline; margin: 0 6px 0 0; }
.mine.sm.empty .notes, .mine.sm.empty .notes p { display: inline; }
.mine.sm h4 { margin: 0 0 4px; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }

.vars { display: flex; flex-direction: column; gap: 8px; }
.var { display: flex; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); scroll-margin: 80px; }
.var.eaten { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.var.flash { animation: flash 2s ease; }
.vt { flex: none; width: 74px; height: 74px; border-radius: 9px; overflow: hidden; background: var(--bg2); display: grid; place-items: center; font-size: 30px; }
.var:not(.eaten) .vt img { filter: saturate(.6); }
.vx { min-width: 0; flex: 1; }
.vh { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vh strong { font-size: .96rem; }
.vx .sci { font-size: .8rem; }
.vt-d { margin: 3px 0 0; font-size: .87rem; }
.aka { margin: 3px 0 0; font-size: .78rem; color: var(--muted); }
.vid { margin: 5px 0 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .74rem; }
.vid a { color: var(--muted); }
.vid code { margin-left: auto; font-size: 11px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 3px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); cursor: pointer; font-size: .85rem;
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--line2); background: var(--bg2); }
.chip.eaten { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.chip.eaten::after { content: "✓"; color: var(--accent-ink); font-weight: 700; font-size: .8rem; }
.chip.plain { padding: 4px 10px; cursor: default; color: var(--muted); font-style: italic; }
.chip.plain:hover { background: var(--card); border-color: var(--line); }
.ct { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; background: var(--bg2); display: grid; place-items: center; font-size: 14px; flex: none; }
.times { font-weight: 700; color: var(--muted); }
.rel-l { margin: 8px 0 6px; font-size: .86rem; }
.rel-l:first-of-type { margin-top: 0; }
.lnk { border: 0; background: none; padding: 0; cursor: pointer; font-weight: 650; color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.muted { color: var(--muted); }

.lineage { display: flex; flex-wrap: wrap; gap: 4px 2px; align-items: center; }
.lin {
  display: inline-flex; gap: 5px; align-items: center;
  border: 0; background: none; cursor: pointer; padding: 2px 5px; border-radius: 6px; font-size: .83rem;
}
.lin:hover { background: var(--bg2); }
.lin .rk { font-size: .58rem; padding: 0 4px; }
.lin.r-genus > span:last-child, .lin.r-section > span:last-child, .lin.r-subgenus > span:last-child { font-style: italic; }
.sep { color: var(--line2); }

.wiki p { margin: 0; font-size: .9rem; color: color-mix(in srgb, var(--text) 85%, var(--muted)); }
.wiki .more { display: inline-block; margin-top: 4px; font-size: .78rem; color: var(--muted); }
.idline { padding: 14px 22px 0; margin: 0; font-size: .76rem; color: var(--muted); }

.branches { display: flex; flex-direction: column; gap: 6px; }
.branch {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "rk name cnt" "rk sub cnt";
  gap: 0 10px; align-items: center; text-align: left; cursor: pointer;
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); border-left: 4px solid var(--g); background: var(--card);
}
.branch:hover { background: var(--bg2); }
.branch .rk { grid-area: rk; }
.branch strong { grid-area: name; }
.branch .muted { grid-area: sub; font-size: .82rem; }
.branch .cnt { grid-area: cnt; margin: 0; }
.locate { margin: 16px 22px 0; }

.credits { list-style: none; margin: 0; padding: 10px 22px; font-size: .78rem; color: var(--muted); }
.credits li { padding: 3px 0; border-bottom: 1px solid var(--line); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .top { padding-top: 12px; }
  .sub { display: none; }
  .stats { gap: 4px 12px; }
  .stat strong { font-size: 1.15rem; }
  .bar { display: none; }
  .toolbar { gap: 6px; position: static; }
  #q { order: -1; flex-basis: 100%; max-width: none; }
  .acts { margin-left: 0; }
  .seg button { padding: 5px 9px; }
  #tree-view { --ind: 7px; }
  .kids { margin-left: 6px; }
  /* deep levels: stop indenting so cards keep a usable width */
  .kids .kids .kids .kids .kids .kids { margin-left: 2px; --ind: 4px; }
  .ch { min-height: 30px; }
  .ch .rk { display: none; }
  .r-order > .ch .rk, .r-family > .ch .rk { display: inline-block; }
  .cl { flex-wrap: nowrap; padding: 2px 4px; }
  .cn { white-space: nowrap; }
  .tog { width: 20px; }
  .leaves { grid-template-columns: 1fr; gap: 6px; }
  .fn, .fs { white-space: normal; }
  .cc { display: none; }
  .r-order > .ch .cc, .r-family > .ch .cc { display: inline; font-size: .78rem; }
  #panel { width: 100vw; border-left: 0; }
  .ph h2 { font-size: 1.4rem; }
  #radial-wrap { height: calc(100vh - 210px); }
  .radial-tools .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- progressive photos */
.lq { background-size: cover; background-position: center; }
.lq > img.pz { opacity: 0; transition: opacity .35s ease; }
.lq > img.pz.in { opacity: 1; }
.ft.lq, .ct.lq, .vt.lq, .hero.lq { filter: none; }
.zoomable { cursor: zoom-in; }
.hero.zoomable { position: relative; }
.hero.zoomable::after {
  content: '⤢'; position: absolute; right: 10px; bottom: 10px; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: 50%; font-size: 16px;
  background: rgba(0,0,0,.45); color: #fff; opacity: 0; transition: opacity .2s;
}
.hero.zoomable:hover::after { opacity: 1; }

/* ---------------------------------------------------------------- lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(8, 10, 8, .92); cursor: zoom-out;
  flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px;
}
.lightbox.open { display: flex; }
.lb-stage { position: relative; display: grid; max-width: 100%; max-height: calc(100% - 50px); }
.lb-stage img { grid-area: 1 / 1; width: min(1400px, 94vw); height: calc(100vh - 110px); height: calc(100dvh - 110px); object-fit: contain; position: relative; }
/* the blurred 560px preview sits BELOW the sharp image (filter would otherwise lift it on top) */
.lb-mid { filter: blur(3px); z-index: 0; }
.lb-full { opacity: 0; transition: opacity .3s; z-index: 1; }
.lb-full.in { opacity: 1; }
.lb-stage.done .lb-mid { display: none; }
.lb-cap { color: #ddd; font-size: .9rem; text-align: center; cursor: auto; }
.lb-cap span { color: #999; }
.lb-x { position: absolute; top: 12px; right: 16px; background: none; border: 0; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }

/* ---------------------------------------------------------------- culinary note */
.note {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0 clamp(14px, 4vw, 40px) 12px;
  padding: 10px 12px;
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 12px;
  font-size: .88rem; line-height: 1.45;
}
.note[hidden] { display: none; }
.note p { margin: 0; flex: 1; }
.note strong { color: var(--accent-ink); }
.note-i {
  flex: none; width: 20px; height: 20px; margin-top: 1px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: var(--bg);
  font: italic 700 13px/1 Georgia, serif;
}
.note-x { flex: none; background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.note-x:hover { color: var(--text); }
@media (max-width: 640px) {
  .note { font-size: .8rem; line-height: 1.4; padding: 8px 10px; margin-bottom: 8px; }
}

/* ---------- tier list page + tier badges ---------- */
:root {
  --t-S: #ff7f7f; --t-A: #ffbf7f; --t-B: #ffdf7f; --t-C: #bfff7f; --t-D: #7fbfff; --t-E: #9f9fe6; --t-F: #bf7fbf;
}
.tier-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-weight: 650; font-size: .9rem;
}
.tier-link:hover { border-color: var(--line2); }
.tl-main { padding: 4px clamp(14px, 4vw, 40px) 20px; max-width: 1100px; }
.tl-main .warn { margin: 0 0 12px; }
.tl-main .note { margin: 0 0 14px; max-width: 760px; }
.tierlist { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.tl-row { display: flex; min-height: 92px; }
.tl-row + .tl-row { border-top: 1px solid var(--line); }
.tl-label {
  flex: none; width: 76px; display: grid; place-items: center;
  font-size: 1.8rem; font-weight: 800; color: #1a1a1a;
  background: var(--t-C);
}
.tl-row[data-tier="S"] .tl-label { background: var(--t-S); }
.tl-row[data-tier="A"] .tl-label { background: var(--t-A); }
.tl-row[data-tier="B"] .tl-label { background: var(--t-B); }
.tl-row[data-tier="C"] .tl-label { background: var(--t-C); }
.tl-row[data-tier="D"] .tl-label { background: var(--t-D); }
.tl-row[data-tier="E"] .tl-label { background: var(--t-E); }
.tl-row[data-tier="F"] .tl-label { background: var(--t-F); }
.tl-items { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 8px; }
.tl-none { color: var(--muted); padding: 30px 8px; }
.tl-tile {
  width: 84px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-decoration: none; color: var(--text);
}
.tl-ph {
  width: 76px; height: 76px; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: var(--bg2) center / cover no-repeat; font-size: 36px;
  border: 1px solid var(--line); transition: transform .12s, border-color .12s;
}
.tl-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tl-tile:hover .tl-ph { transform: translateY(-2px); border-color: var(--line2); }
.tl-name { font-size: .74rem; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.unranked { margin-top: 28px; }
.unranked h2 { margin: 0 0 8px; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 720; }
.ur-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-tile.sm { width: 56px; opacity: .85; }
.tl-tile.sm .tl-ph { width: 48px; height: 48px; border-radius: 8px; font-size: 24px; }
.tl-tile.sm .tl-name { font-size: .66rem; color: var(--muted); }
.tiers-page footer { padding-top: 0; }
@media (max-width: 640px) {
  .tl-row { min-height: 72px; }
  .tl-label { width: 48px; font-size: 1.4rem; }
  .tl-items { gap: 6px; padding: 6px; }
  .tl-tile { width: 62px; }
  .tl-ph { width: 58px; height: 58px; }
  .tl-name { font-size: .66rem; }
  .tiers-page .sub { display: block; font-size: .8rem; }
}
.tier-badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 6px; font-weight: 800; font-size: .8rem; color: #1a1a1a; text-decoration: none;
  background: var(--t-C); vertical-align: middle;
}
.tier-badge.t-S { background: var(--t-S); } .tier-badge.t-A { background: var(--t-A); }
.tier-badge.t-B { background: var(--t-B); } .tier-badge.t-C { background: var(--t-C); }
.tier-badge.t-D { background: var(--t-D); } .tier-badge.t-E { background: var(--t-E); } .tier-badge.t-F { background: var(--t-F); }
.tier-badge.sm { min-width: 18px; height: 18px; font-size: .68rem; padding: 0 4px; border-radius: 5px; }
.ph .tier-badge { margin-left: 6px; }
.vh .tier-badge { margin-left: auto; margin-right: 6px; }

/* ---------- tier editor (private) ---------- */
.ed-actions { display: flex; align-items: center; gap: 8px; }
.ed-status { font-size: .85rem; color: var(--muted); }
.ed-status.ok { color: var(--accent-ink); }
.ed-status.err { color: #c0392b; }
.ed-save {
  padding: 8px 18px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700;
}
:root[data-theme="dark"] .ed-save { color: #0f1a0b; }
.ed-save:disabled { opacity: .4; cursor: default; }
.ed-drop { min-height: 76px; }
.ed-tile { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.ed-tile:active { cursor: grabbing; }
.ed-tile .tl-ph { pointer-events: none; }
.ed-tile .ed-of { font-size: .62rem; color: var(--muted); text-align: center; line-height: 1.1; margin-top: -2px; }
.ed-tile.is-var .tl-ph { border-style: dashed; }
.ed-ghost { opacity: .35; }
.ed-chosen .tl-ph { outline: 3px solid var(--accent); outline-offset: 1px; }
.ed-pool { margin-top: 24px; }
.ed-pool h2 { margin: 0 0 8px; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 720; }
.ed-hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ed-pool .tl-items { border: 1px dashed var(--line2); border-radius: 12px; background: var(--bg2); }
.ed-pool input[type=search] {
  width: 100%; max-width: 320px; margin: 0 0 8px; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit;
}
.editor-page .top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.ed-login { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 20px; width: min(340px, 90vw); }
.ed-login::backdrop { background: rgba(0, 0, 0, .4); }
.ed-login h2 { margin: 0 0 4px; font-size: 1.1rem; }
.ed-login p { margin: 0 0 10px; color: var(--muted); font-size: .88rem; }
.ed-login input[type=password] { width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.ed-remember { display: flex; gap: 6px; align-items: center; margin: 10px 0; font-size: .86rem; color: var(--muted); }
.ed-err { color: #c0392b !important; }
.ed-row { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 640px) {
  .editor-page .top { padding-bottom: 8px; }
  .ed-actions { width: 100%; justify-content: flex-end; }
}
.ed-sel .tl-ph { outline: 3px solid var(--accent); outline-offset: 2px; transform: scale(1.06); }
.ed-flash .tl-ph { animation: edflash .7s; }
@keyframes edflash { 0% { box-shadow: 0 0 0 6px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.ed-has-sel .tl-label { cursor: pointer; }
.ed-has-sel .tl-label:hover { filter: brightness(1.08); }
.ed-movebar {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: none; gap: 6px; align-items: center; padding: 8px; z-index: 20;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow);
}
.ed-has-sel .ed-movebar { display: flex; }
.ed-movebar .tier-badge { min-width: 38px; height: 38px; font-size: 1rem; border: 0; cursor: pointer; }
.ed-movebar .ghost { height: 38px; }

/* ---------- theme toggle + note reshow buttons ---------- */
.theme-toggle, .note-show {
  width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center;
  font-size: 17px; line-height: 1; border-radius: 10px;
}
.note-show { font: italic 700 15px/1 Georgia, "Times New Roman", serif; color: var(--accent-ink); }
.note-show[hidden] { display: none; }
.tiers-page .top { justify-content: flex-start; column-gap: 8px; flex-wrap: nowrap; align-items: flex-start; }
.tiers-page .top .brand { margin-right: auto; min-width: 0; }
.tiers-page .top > .ghost { flex: none; }
