/* ============================================================
 * Resonance Codex — design system
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Instrument+Serif&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --accent-h: 268;
  --bg:    oklch(0.135 0.014 270);
  --bg-1:  oklch(0.165 0.014 270);
  --bg-2:  oklch(0.195 0.015 270);
  --bg-3:  oklch(0.235 0.016 270);
  --border:        oklch(0.28 0.014 270 / 0.6);
  --border-strong: oklch(0.35 0.018 270 / 0.8);
  --fg:    oklch(0.97 0.005 270);
  --fg-2:  oklch(0.74 0.012 270);
  --fg-3:  oklch(0.55 0.014 270);
  --fg-4:  oklch(0.42 0.014 270);
  --accent:      oklch(0.74 0.17 var(--accent-h));
  --accent-2:    oklch(0.55 0.18 var(--accent-h));
  --accent-soft: oklch(0.32 0.09 var(--accent-h) / 0.4);
  --accent-glow: oklch(0.74 0.17 var(--accent-h) / 0.25);
  --warn: oklch(0.78 0.16 70);
  --good: oklch(0.74 0.16 150);
  --bad:  oklch(0.66 0.20 25);
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-2: 0 4px 16px oklch(0 0 0 / 0.4);
  --shadow-3: 0 12px 48px oklch(0 0 0 / 0.5);

  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-sans:  'Geist', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --nav-w: 220px;            /* expanded by default */
  --nav-w-collapsed: 72px;
  --picker-w: 320px;
  --pad: 32px;
}
.app.nav-collapsed { --nav-w: var(--nav-w-collapsed); }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16.8px;          /* 14 × 1.2 */
  line-height: 1.5;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}

/* ============ Page-level scrollbar (matches the picker's modern style) ============ */
html { scrollbar-gutter: stable; }
html, body {
  scrollbar-width: thin;
  scrollbar-color: oklch(0.45 0.04 270 / 0.55) transparent;
}
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
  background: transparent;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: oklch(0.40 0.04 270 / 0.5);
  border-radius: 100px;
  border: 3px solid transparent;
  background-clip: padding-box;
  transition: background-color .25s;
}
::-webkit-scrollbar-thumb:hover  { background-color: oklch(0.55 0.04 270 / 0.75); }
::-webkit-scrollbar-thumb:active { background-color: oklch(0.65 0.04 270 / 0.9); }
::-webkit-scrollbar-corner { background: transparent; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; color: inherit; background: none; border: none; outline: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.hidden { display: none !important; }

.b { font-weight: 600; color: var(--fg); }
.dim { color: var(--fg-3); }
.mono-tiny { font-family: var(--font-mono); font-size: 12.6px; text-transform: uppercase; letter-spacing: 0.08em; }

.kicker {
  font-family: var(--font-mono);
  font-size: 12.6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-3);
}
.kicker-dot { margin: 0 6px; color: var(--fg-4); }
.kicker-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--fg-2);
  font-size: 12px;
  letter-spacing: 0.06em;
}

/* ============ APP SHELL ============ */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) var(--picker-w) 1fr;
  min-height: 100vh;
}
.app.no-picker {
  grid-template-columns: var(--nav-w) 1fr;
}
.app.no-picker .picker { display: none; }

/* ============ LEFT NAV (icon rail) ============ */
.nav {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.nav-brand {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 0 12px;
  text-align: center; user-select: none;
}
.brand-full, .brand-mini {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.005em;
  color: var(--fg);
}
.brand-full { font-size: 18px; display: inline; }
.brand-mini { font-size: 16px; display: none; }
.app.nav-collapsed .brand-full { display: none; }
.app.nav-collapsed .brand-mini { display: inline; }

.nav-list {
  display: flex; flex-direction: column; gap: 4px;
  align-items: stretch; width: 100%;
  padding: 0 12px;
}
.nav-item {
  height: 44px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--fg-3);
  font-size: 14.4px;
  text-align: left;
  transition: background .15s, color .15s;
  position: relative;
  width: 100%;
}
.nav-item:hover { background: var(--bg-1); color: var(--fg); }
.nav-item.is-on {
  background: var(--bg-2);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.nav-item.is-on::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 22px;
  background: var(--accent);
  border-radius: 0 100px 100px 0;
  box-shadow: 0 0 8px var(--accent);
}
.nav-icon {
  line-height: 1;
  font-size: 18px;
  display: grid; place-items: center;
  width: 24px; height: 24px;
}
.nav-icon img {
  width: 24px; height: 24px;
  object-fit: contain;
  display: block;
  filter: brightness(0.92);
  transition: filter .15s;
}
.nav-item:hover .nav-icon img { filter: brightness(1.08); }
.nav-item.is-on .nav-icon img { filter: brightness(1.15) drop-shadow(0 0 4px var(--accent-glow)); }
.nav-label { font-weight: 500; font-size: 14.4px; }
.nav-count { font-family: var(--font-mono); font-size: 11px; color: var(--fg-4); }

/* Floating tooltip (only used when collapsed). */
.nav-item .nav-tip {
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  background: var(--bg-3);
  color: var(--fg);
  font-size: 14.4px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  transform: translate(-4px, -50%);
  z-index: 50;
  font-family: var(--font-sans);
  box-shadow: var(--shadow-2);
  display: flex; align-items: center; gap: 6px;
}
.app.nav-collapsed .nav-item:hover .nav-tip { opacity: 1; transform: translate(0, -50%); }

/* Collapsed mode: hide labels + counts, center the icon. */
.app.nav-collapsed .nav-item {
  grid-template-columns: 24px;
  justify-content: center;
  padding: 0;
  width: 44px;
  margin: 0 auto;
}
.app.nav-collapsed .nav-label,
.app.nav-collapsed .nav-count { display: none; }

.nav-foot { margin-top: auto; display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 100%; padding: 0 12px; }

.nav-toggle {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 44px;
  border-radius: 10px;
  color: var(--fg-3);
  font-size: 14.4px;
  text-align: left;
  width: 100%;
  transition: background .15s, color .15s;
}
.nav-toggle:hover { background: var(--bg-1); color: var(--fg); }
.nav-toggle-icon {
  display: block;
  flex-shrink: 0;
  transition: transform .18s ease;
}
.app.nav-collapsed .nav-toggle-icon { transform: rotate(180deg); }
.app.nav-collapsed .nav-toggle {
  grid-template-columns: 24px;
  justify-content: center;
  padding: 0;
  width: 44px;
  margin: 0 auto;
}
.app.nav-collapsed .nav-toggle-label { display: none; }

.nav-link {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 40px;
  border-radius: 10px;
  color: var(--fg-3);
  font-size: 14.4px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg-1); color: var(--fg); }
.nav-link-kofi:hover    { color: #ff5b76; }
.nav-link-discord:hover { color: #7c8df0; }
.nav-link-icon { display: grid; place-items: center; width: 24px; height: 24px; }
.nav-link-icon svg { display: block; }
.nav-link-kofi .nav-link-icon svg { margin-left: 4px; }
.app.nav-collapsed .nav-link {
  grid-template-columns: 24px;
  justify-content: center;
  padding: 0;
  width: 44px;
  margin: 0 auto;
}
.app.nav-collapsed .nav-link-label { display: none; }

/* ============ MAIN ============ */
.main {
  padding: 20px var(--pad) 60px;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.crumbs { font-size: 15px; color: var(--fg-3); display: flex; align-items: center; gap: 8px; }
.crumb-sep { color: var(--fg-4); }
.crumb-now { color: var(--fg); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.btn-ghost {
  padding: 7px 12px; border-radius: 8px; font-size: 15px;
  color: var(--fg-2); border: 1px solid transparent; transition: all .15s;
}
.btn-ghost:hover { background: var(--bg-2); color: var(--fg); border-color: var(--border); }
.btn-primary {
  padding: 8px 14px; border-radius: 8px; font-size: 15.6px; font-weight: 500;
  color: white; background: var(--accent-2);
  box-shadow: 0 0 0 1px oklch(0.5 0.18 var(--accent-h)),
              inset 0 1px 0 oklch(0.85 0.15 var(--accent-h) / 0.4),
              0 6px 18px var(--accent-glow);
  transition: all .15s;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(0); }

#char-content { max-width: 1700px; margin: 0 auto; }

/* ============ HERO ============ */
.hero {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-areas:
    "art body"
    "stats stats";
  gap: 28px;
  margin-bottom: 24px;
  position: relative;
}
.hero > .hero-art  { grid-area: art; }
.hero > .hero-body { grid-area: body; }
.hero > .stats-bar { grid-area: stats; margin-bottom: 0; }

/* Wide screens: stats becomes a third column alongside art + body, stacked vertically.
   Stats column scales with viewport width so it doesn't feel cramped on big monitors. */
@media (min-width: 1920px) {
  .hero {
    grid-template-columns: 280px 1fr clamp(300px, 22vw, 560px);
    grid-template-areas: "art body stats";
  }
  .hero > .stats-bar .stats-cards { grid-template-columns: 1fr; }
  .hero > .stats-bar .stats-bar-head { flex-direction: column; align-items: flex-start; gap: 12px; }
}
.hero::after {
  content: '';
  position: absolute;
  inset: -40px -20px;
  background: radial-gradient(800px 300px at 20% 30%, var(--accent-glow), transparent 60%);
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
}
.hero-art { display: flex; flex-direction: column; gap: 12px; }

/* Portrait — shows image when available, initials over a plain dark bg otherwise. */
.portrait {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  isolation: isolate;
  background: var(--bg-2);
}
.portrait-lg { aspect-ratio: 3 / 4; }
.portrait-sm { width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0; }
.portrait img.portrait-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
  z-index: 1;
}
.portrait-initials {
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 38.4px;
  color: var(--fg-3);
  letter-spacing: -0.02em;
}
.portrait-sm .portrait-initials { font-size: 16.8px; }

.variant-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}
.variant-tab {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  transition: all .15s;
  display: flex; flex-direction: column; gap: 2px;
  color: inherit;
}
.variant-tab:hover { background: var(--bg-2); border-color: var(--border-strong); }
.variant-tab.is-on {
  background: var(--bg-2);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.variant-label { font-size: 14.4px; font-weight: 500; }
.variant-sub   { font-family: var(--font-mono); font-size: 11.4px; color: var(--fg-3); letter-spacing: 0.05em; }

.hero-body { display: flex; flex-direction: column; gap: 18px; }
.hero-title-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.hero-name {
  font-family: var(--font-sans);
  font-size: 52.8px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.hero-meta {
  display: flex; gap: 28px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.meta-cell { display: flex; flex-direction: column; gap: 4px; }

/* Compact icon row replacing the old text meta cells. */
.hero-icon-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.hero-icon {
  height: 38px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px oklch(0 0 0 / 0.4));
}
.hero-identity {
  font-size: 16px;
  font-weight: 500;
  color: var(--fg-2);
  font-style: italic;
}

/* Tag chip row below the description (hero's classifyList content). */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: 100px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--fg-2);
}
.tag-chip-icon { height: 18px; width: 18px; object-fit: contain; }
.tag-chip-label { font-weight: 500; }
.hero-description {
  font-size: 16.8px;
  line-height: 1.65;
  color: var(--fg-2);
  max-width: 72ch;
  text-align: justify;
  hyphens: manual;          /* never split words automatically */
  overflow-wrap: normal;
}
.ability-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ability-quote {
  font-family: var(--font-mono);
  font-size: 14.4px;
  color: var(--fg);
  padding: 3px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ============ RARITY ICON (in-game image) ============ */
.rarity-img {
  display: inline-block;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
  flex-shrink: 0;
}
.rarity-img-xs { height: 16px; }
.rarity-img-sm { height: 22px; }
.rarity-img-md { height: 26px; }
.rarity-img-lg { height: 36px; }

/* Filter buttons in the picker — wrap the icon, dim it when not selected. */
.rarity-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: opacity .12s, border-color .12s, background .12s;
  opacity: 0.55;
}
.rarity-filter:hover { opacity: 0.9; }
.rarity-filter.is-on {
  opacity: 1;
  background: var(--bg-2);
  border-color: var(--border-strong);
}

/* ============ STATS BAR ============ */
.stats-bar {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 28px;
}
.stats-bar-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 14px; flex-wrap: wrap;
}
.level-selector { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.level-tabs {
  display: flex; gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.level-tab {
  display: flex; align-items: baseline; gap: 3px;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--fg-3);
  font-size: 14.4px;
  transition: all .15s;
}
.level-tab:hover { color: var(--fg); }
.level-tab.is-on {
  background: var(--bg-3);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.level-tab-key { font-family: var(--font-mono); font-size: 11.4px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-3); }
.level-tab.is-on .level-tab-key { color: var(--accent); }
.level-tab-num { font-family: var(--font-mono); font-size: 15.6px; font-weight: 600; font-feature-settings: 'tnum'; }

.rapport-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--fg-2);
  font-size: 14.4px;
  transition: all .15s;
}
.rapport-toggle:hover { color: var(--fg); border-color: var(--border-strong); }
.rapport-toggle.is-on {
  background: oklch(0.55 0.20 25 / 0.15);
  color: oklch(0.85 0.18 25);
  border-color: oklch(0.78 0.18 25 / 0.6);
  box-shadow: 0 0 0 3px oklch(0.55 0.20 25 / 0.1);
}
.rapport-icon { width: 16px; height: 16px; object-fit: contain; }

.stats-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}
.stat-card-key {
  font-family: var(--font-mono);
  font-size: 12.6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-3);
}
.stat-card-val {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--fg);
  font-feature-settings: 'tnum';
  letter-spacing: -0.01em;
  line-height: 1;
  display: flex; align-items: baseline; gap: 8px;
}
.stat-card-bonus { font-size: 15.6px; color: oklch(0.78 0.18 25); font-weight: 500; }
.stat-card-bar { height: 4px; background: var(--bg-3); border-radius: 100px; overflow: hidden; }
.stat-card-fill {
  height: 100%;
  background: linear-gradient(90deg, oklch(0.55 0.16 var(--h)), oklch(0.78 0.18 var(--h)));
  box-shadow: 0 0 8px oklch(0.78 0.18 var(--h) / 0.4);
  border-radius: 100px;
  transition: width .4s cubic-bezier(.2,.8,.2,1);
}

/* ============ PROFILE BLOCK ============ */
.profile-block {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 24px;
}
.profile-cell { display: flex; flex-direction: column; gap: 4px; }
.profile-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
}

/* ============ ARCHIVES ============ */
.archives-page { display: flex; flex-direction: column; gap: 32px; }
.archive-list { display: flex; flex-direction: column; gap: 8px; }
.archive {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color .15s;
}
.archive.is-open { border-color: var(--border-strong); }
.archive-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  width: 100%;
  text-align: left;
  color: var(--fg);
  transition: background .15s;
}
.archive-head:hover { background: var(--bg-2); }
.archive-caret { color: var(--fg-3); font-size: 13.2px; width: 12px; }
.archive.is-open .archive-caret { color: var(--accent); }
.archive-label { flex: 1; font-size: 18px; font-weight: 500; }
.archive-trust {
  font-family: var(--font-mono);
  font-size: 12.6px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  padding: 3px 8px;
  background: var(--accent-soft);
  border-radius: 100px;
}
.archive-body {
  padding: 0 42px 18px 42px;
  display: flex; flex-direction: column; gap: 10px;
}
.archive:not(.is-open) .archive-body { display: none; }
.archive-body p {
  font-size: 16.2px;
  line-height: 1.65;
  color: var(--fg-2);
  text-align: justify;
  hyphens: manual;          /* never split words automatically */
  overflow-wrap: normal;
  white-space: pre-wrap;
}

/* ============ VOICELINES ============ */
.voicelines-page { display: flex; flex-direction: column; gap: 16px; }
.voiceline-list { display: flex; flex-direction: column; gap: 8px; }
.voiceline {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s;
}
.voiceline:hover { border-color: var(--border-strong); }
.voiceline-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.voiceline-meta { min-width: 0; }
.voiceline-group { font-size: 14.4px; font-weight: 600; color: var(--fg); }
.voiceline-sub { margin-top: 2px; }
.voiceline-langs { display: flex; gap: 6px; flex-shrink: 0; }
.voiceline-lang-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 9px;
  border-radius: 7px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg-2);
  transition: all .15s;
  min-width: 56px;
  justify-content: center;
}
.voiceline-lang-btn:hover { color: var(--fg); border-color: var(--border-strong); background: var(--bg-3); }
.voiceline-lang-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.voiceline-lang-btn.is-playing {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.play-tri { font-size: 9.6px; line-height: 1; }
.voiceline-lang-label { font-family: var(--font-mono); font-weight: 700; font-size: 12px; letter-spacing: 0.06em; line-height: 1; }
.play-bars { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 11px; }
.play-bars i { display: block; width: 2.5px; background: var(--accent); border-radius: 100px; animation: play-bar 0.9s ease-in-out infinite; }
.play-bars i:nth-child(1) { animation-delay: 0s;    height: 30%; }
.play-bars i:nth-child(2) { animation-delay: 0.2s;  height: 70%; }
.play-bars i:nth-child(3) { animation-delay: 0.4s;  height: 50%; }
@keyframes play-bar { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1.2); } }

.voiceline-text-stack { display: flex; flex-direction: column; gap: 4px; }
.voiceline-text {
  font-size: 16.8px;
  line-height: 1.55;
  color: var(--fg-2);
  text-wrap: pretty;
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: all .25s ease;
  margin-left: -8px;
}
.voiceline-text.is-cn {
  font-family: var(--font-serif);
  font-size: 19.8px;
  letter-spacing: 0.01em;
  color: var(--fg);
  font-style: italic;
}
.voiceline-text.is-active {
  color: var(--fg);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.empty-block {
  padding: 40px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--fg-3);
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.tab {
  padding: 10px 14px;
  font-size: 15.6px;
  color: var(--fg-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  display: flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--fg); }
.tab.is-on { color: var(--fg); border-bottom-color: var(--accent); }

/* ============ INLINE LORE TAGS (with hover tooltip) ============ */
.lore-tag {
  cursor: help;
  font-weight: 500;
  transition: filter .12s;
}
.lore-tag:hover { filter: brightness(1.25); }

.lore-tip {
  position: fixed;
  z-index: 2000;
  max-width: 360px;
  background: oklch(0.18 0.012 270);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 12px 36px oklch(0 0 0 / 0.55);
  pointer-events: none;
  font-size: 13.5px;
  line-height: 1.55;
  /* Smooth fade-in */
  opacity: 1;
  transition: opacity .12s ease;
}
.lore-tip.hidden { display: none; }
.lore-tip-name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.lore-tip-detail { color: var(--fg-2); }

/* Little caret-style arrow pointing at the tag */
.lore-tip-arrow {
  position: absolute;
  width: 12px; height: 12px;
  background: oklch(0.18 0.012 270);
  border-left: 1px solid var(--border-strong);
  border-top:  1px solid var(--border-strong);
  transform: rotate(45deg);
  top: auto;
  bottom: -7px;
  margin-left: -6px;
}
.lore-tip[data-flipped="1"] .lore-tip-arrow {
  bottom: auto;
  top: -7px;
  border-left: 1px solid var(--border-strong);
  border-top:  1px solid var(--border-strong);
  border-right: none;
  border-bottom: none;
  transform: rotate(225deg);
}

/* ============ INLINE TAGS / RUNES (rich text) ============ */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: oklch(0.30 0.10 var(--h, 200) / 0.4);
  color: oklch(0.85 0.16 var(--h, 200));
  font-weight: 500;
  font-size: 0.92em;
  white-space: nowrap;
}
.rune {
  display: inline-block;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* ============ SKILLS ============ */
.skills-list { display: flex; flex-direction: column; gap: 12px; }
.skill-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  transition: border-color .15s;
}
.skill-card:hover { border-color: var(--border-strong); }

/* Derived child cards: indented and visually a bit smaller. The L-shape
   connector is built from two pseudo-elements:
   - ::before draws the horizontal arm into the card's badge area.
   - ::after  draws the vertical trunk that links the card to the chain
     above. By default it extends through the card (so consecutive
     derived siblings form one continuous line); the [data-last] sibling
     caps the trunk at the arm. */
.skill-card-derived {
  margin-left: 48px;
  position: relative;
  background: var(--bg);
}
.skill-card-derived::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 50%;
  margin-top: -1px;
  width: 22px;
  height: 1px;
  background: var(--border-strong);
}
.skill-card-derived::after {
  content: "";
  position: absolute;
  left: -28px;
  top: -12px;          /* up into the gap above this card */
  bottom: -12px;       /* down into the gap below */
  width: 1px;
  background: var(--border-strong);
}
.skill-card-derived[data-last]::after {
  bottom: auto;
  height: calc(50% + 12px);   /* stop at the arm */
}
.skill-card-derived .skill-badge {
  width: clamp(60px, 10vw, 110px);
  font-size: clamp(22px, 4vw, 40px);
}
.skill-card-derived .skill-name { font-size: 21px; }

/* Neutral / shared-pool tag for derived cards reused across characters. */
.neutral-pill {
  display: inline-flex;
  align-items: baseline;
  padding: 6px 14px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  line-height: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--bg-3);
  color: var(--fg-3);
  border: 1px solid var(--border-strong);
}
.skill-badge {
  width: clamp(80px, 14vw, 150px);
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(28px, 5vw, 56px);
  color: var(--fg);
  flex-shrink: 0;
  overflow: hidden;
}
.skill-badge img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.skill-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.skill-title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.skill-name { font-size: 26.4px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
/* Shared tag shape (Cost + Ultimate) — same size, font, padding, radius.
   Colors differ via the per-tag rules below. */
.skill-cost,
.ult-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  line-height: 1.1;
  border: 1px solid;
}
.skill-cost {
  background: #ffcf4a26;
  color: #ffcf4a;
  border-color: #ffcf4a66;
}
.skill-cost-num {
  font-weight: 700;
  font-feature-settings: 'tnum';
  font-size: 14px;
  line-height: 1;
}
.skill-cost-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.75;
}
.ult-pill {
  font-size: 12px;
  line-height: 14px;          /* match the cost number's effective height */
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: oklch(0.55 0.20 25 / 0.18);
  color: oklch(0.82 0.18 25);
  border-color: oklch(0.78 0.18 25 / 0.5);
}
.skill-des {
  font-size: 16.2px;
  color: var(--fg-2);
  line-height: 1.55;
  white-space: pre-wrap;
  margin: 0;
}
.skill-requirement {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: oklch(0.82 0.18 25);
  font-weight: 500;
}
.skill-requirement-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: oklch(0.78 0.18 25);
  background: oklch(0.55 0.20 25 / 0.18);
  border: 1px solid oklch(0.78 0.18 25 / 0.45);
  border-radius: 4px;
  padding: 2px 6px;
  margin-right: 8px;
  vertical-align: middle;
}
.skill-detail {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  white-space: pre-wrap;
}

/* Life skill block inside Resonance cards. */
.life-skill {
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.life-skill-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.life-skill-kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.life-skill-name { font-weight: 600; font-size: 14px; color: var(--fg); }
.life-skill-des  { margin: 0; font-size: 13.5px; color: var(--fg-2); line-height: 1.5; }

/* ============ RESONANCE ============ */
.resonance-page { display: flex; flex-direction: column; gap: 36px; }
.section { display: flex; flex-direction: column; gap: 16px; }
.section-head { display: flex; flex-direction: column; gap: 4px; }
.section-title { font-size: 19.2px; color: var(--fg-2); }
.res-chain { display: flex; flex-direction: column; }
.res-node { display: grid; grid-template-columns: 40px 1fr; gap: 16px; }
.res-rail { display: flex; flex-direction: column; align-items: center; }
.res-dot {
  width: 36px; height: 36px;
  border-radius: 100px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 13.2px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  box-shadow: 0 0 0 4px var(--bg);
  z-index: 1;
}
.res-line { flex: 1; width: 1px; background: var(--border-strong); margin: 2px 0; }
.res-content { padding: 0 0 28px 0; flex: 1; }
.res-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.res-head h4 { font-size: 20.4px; font-weight: 500; }
.awake { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--fg-3); }
.res-body { display: flex; flex-direction: column; gap: 6px; }
.res-body p { font-size: 16.2px; color: var(--fg-2); line-height: 1.55; white-space: pre-wrap; }

.awake-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.awake-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.awake-head { display: flex; align-items: center; gap: 10px; }
.awake-badge {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 13.2px;
  font-weight: 600;
  color: var(--fg-2);
}
.awake-card h4 { font-size: 18px; font-weight: 500; }
.awake-body { display: flex; flex-direction: column; gap: 4px; }
.awake-body p { font-size: 15px; color: var(--fg-2); line-height: 1.55; white-space: pre-wrap; }

/* ============ PICKER ============ */
.picker {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.picker-head {
  padding: 18px 18px 4px;
  display: flex; align-items: baseline; justify-content: space-between;
}
.picker-title {
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.picker-view-toggle {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg-3);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.picker-view-toggle:hover { background: var(--bg-3); color: var(--fg); border-color: var(--border-strong); }
.picker-view-toggle svg { fill: currentColor; }
.picker-row-sep { color: var(--fg-4); margin: 0 4px; }
.picker-search {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.search-icon { color: var(--fg-3); font-size: 16.8px; }
.picker-search input { flex: 1; font-size: 16.2px; padding: 2px 0; min-width: 0; }
.picker-search input::placeholder { color: var(--fg-3); }
.search-clear { width: 18px; height: 18px; border-radius: 4px; color: var(--fg-3); display: grid; place-items: center; font-size: 16.8px; }
.search-clear:hover { background: var(--bg-2); color: var(--fg); }

.picker-filters {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-row-rarity { gap: 4px; }
.filter-row-wrap .chip { font-size: 12.6px; }

.chip {
  padding: 4px 9px;
  font-size: 13.8px;
  font-weight: 500;
  border-radius: 6px;
  color: var(--fg-2);
  background: var(--bg-1);
  border: 1px solid var(--border);
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover { background: var(--bg-2); color: var(--fg); }
.chip.is-on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip.is-dim { color: var(--fg-3); font-family: var(--font-mono); font-size: 12.6px; letter-spacing: 0.02em; }

.picker-list {
  flex: 1;
  overflow-y: overlay;            /* WebKit: scrollbar floats over the content */
  overflow-y: auto;               /* fallback */
  padding: 8px 8px 24px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;          /* Firefox */
  scrollbar-color: transparent transparent;
  transition: scrollbar-color .25s;
}
.picker-list:hover { scrollbar-color: oklch(0.45 0.04 270 / 0.6) transparent; }

/* WebKit */
.picker-list::-webkit-scrollbar {
  width: 10px;
  background: transparent;
}
.picker-list::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px 0;
}
.picker-list::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 100px;
  border: 3px solid transparent;
  background-clip: padding-box;
  transition: background-color .25s;
}
.picker-list:hover::-webkit-scrollbar-thumb {
  background-color: oklch(0.45 0.04 270 / 0.55);
}
.picker-list::-webkit-scrollbar-thumb:hover {
  background-color: oklch(0.55 0.04 270 / 0.8);
}
.picker-list::-webkit-scrollbar-thumb:active {
  background-color: oklch(0.65 0.04 270 / 0.9);
}

.picker-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 10px;
  width: 100%;
  text-align: left;
  transition: background .12s;
  color: var(--fg);
}
.picker-row:hover { background: var(--bg-1); }
.picker-row.is-on { background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--border-strong); }
.picker-row.is-on.rarity-ssr { background: #ffcf4a1f; box-shadow: inset 0 0 0 1px #ffcf4a66; }
.picker-row.is-on.rarity-sr  { background: #b070ff1f; box-shadow: inset 0 0 0 1px #b070ff66; }
.picker-row.is-on.rarity-r   { background: #5a8ad61f; box-shadow: inset 0 0 0 1px #5a8ad666; }
.picker-row.is-on.rarity-n   { background: #8b95a31f; box-shadow: inset 0 0 0 1px #8b95a366; }
.picker-row-body { min-width: 0; }
.picker-row-name {
  font-size: 16.2px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Pin the rarity tag to the name's line instead of letting the grid center it. */
.picker-row > .rarity-img { align-self: start; margin-top: 3px; }
.picker-row-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  margin-top: 2px;
  display: flex; align-items: center; gap: 4px;
}
.dot { color: var(--fg-4); }
.picker-now { color: var(--accent); font-size: 12px; }
.picker-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--fg-3);
  font-size: 15.6px;
}

/* Grid view — fixed square tiles so the row count is stable and the tile
   size doesn't balloon when the filter narrows the list. */
.picker-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 90px);
  align-content: start;
  justify-content: center;
  gap: 6px;
  padding: 6px;
}
.picker-tile {
  position: relative;
  display: flex; flex-direction: column;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px;
  text-align: center;
  color: var(--fg);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  min-width: 0;
}
.picker-tile:hover { background: var(--bg-1); }
.picker-tile.is-on { background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--border-strong); }
.picker-tile.is-on.rarity-ssr { background: #ffcf4a1f; box-shadow: inset 0 0 0 1px #ffcf4a66; }
.picker-tile.is-on.rarity-sr  { background: #b070ff1f; box-shadow: inset 0 0 0 1px #b070ff66; }
.picker-tile.is-on.rarity-r   { background: #5a8ad61f; box-shadow: inset 0 0 0 1px #5a8ad666; }
.picker-tile.is-on.rarity-n   { background: #8b95a31f; box-shadow: inset 0 0 0 1px #8b95a366; }

.picker-tile-art {
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: 4px;
}
.picker-tile-art .portrait {
  width: 100%; height: 100%;
  border-radius: 8px;
}
.picker-tile-name {
  font-size: 11.5px;
  line-height: 1.2;
  font-weight: 500;
  color: var(--fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-tile.is-on .picker-tile-name { color: var(--fg); }

/* ============ ILLUSTRATIONS ============ */
.illustrations-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.illustrations-btn:hover { background: var(--accent); color: white; }
.illustrations-btn-icon { font-size: 16px; }
.illustrations-btn-count {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 100px;
  background: oklch(1 0 0 / 0.12);
  font-size: 11px;
  font-weight: 600;
}

/* Fullscreen modal variant (overrides the generic .modal-card sizing). */
.modal.modal-fullscreen { padding: 24px; }
.modal.modal-fullscreen .modal-card {
  width: 95vw;
  max-width: none;
  height: 95vh;
  max-height: none;
  padding: 24px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.illustrations-modal-head {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-right: 40px;       /* leave room for the × button */
}
.illustrations-modal-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}
.illustration-picks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  flex-basis: 100%;        /* push picks onto its own row so centering applies */
}

/* Overlay container in the top-right of the illustration/spine stage. */
.stage-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;     /* let stage be clickable, individual controls re-enable */
  max-height: calc(100% - 24px);
}
.stage-overlay > * { pointer-events: auto; }

/* Static vs Animation mode toggle (in the overlay). */
.outfit-mode-toggle {
  display: inline-flex;
  background: oklch(0.18 0.012 270 / 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  box-shadow: 0 4px 12px oklch(0 0 0 / 0.35);
}
.outfit-mode-toggle button {
  padding: 5px 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-3);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.outfit-mode-toggle button:hover { color: var(--fg); }
.outfit-mode-toggle button.is-on {
  background: var(--bg-3);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* Animation picker (only visible in spine mode, sits below the toggle). */
.anim-picker {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  max-height: calc(100% - 40px);
  overflow-y: auto;
  min-width: 140px;
  background: oklch(0.18 0.012 270 / 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 4px 12px oklch(0 0 0 / 0.35);
}
.anim-pick {
  padding: 5px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-3);
  font-size: 12.5px;
  font-family: var(--font-mono);
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.anim-pick:hover { background: var(--bg-2); color: var(--fg); }
.anim-pick.is-on {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Spine animation host. */
.spine-stage { display: flex; align-items: center; justify-content: center; }
.spine-player {
  width: 100%; height: 100%;
}
.spine-missing-msg {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 40px;
  text-align: center;
  color: var(--fg-3);
  font-size: 14px;
  line-height: 1.55;
}
.spine-missing-msg.is-shown { display: flex; }
.spine-missing-msg code {
  font-family: var(--font-mono);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--fg-2);
  display: inline-block;
  margin: 2px 0;
}
.illustration-pick {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg-2);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.illustration-pick:hover { background: var(--bg-3); color: var(--fg); border-color: var(--border-strong); }
.illustration-pick.is-on {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.illustration-stage {
  margin: 0;
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.illustration-stage img {
  position: absolute;
  top: 50%;
  left: 50%;
  --tx: 0px;
  --ty: 0px;
  --zs: 1;
  /* -50%/-50% centers the img on its midpoint; user pan adds tx/ty,
     scale(zs) zooms around the same midpoint. Order matters: scale first
     (so tx/ty stay in screen pixels), then translate by centering + pan. */
  transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(var(--zs));
  transform-origin: center center;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}
.illustration-missing-msg {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 13px;
}
.illustration-missing-msg.is-shown { display: flex; }

/* ============ LEGACY (team builder, cards, equipment) ============
 * These tabs aren't fully restyled yet; they reuse a minimal grid so they
 * remain usable inside the new shell. Polish later.
 * ============================================================ */
.legacy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.legacy-tile {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.legacy-tile:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.legacy-tile h4 { font-size: 16.8px; }
.legacy-tile p { font-size: 14.4px; color: var(--fg-3); }

/* Modal (used by legacy tabs) */
.modal {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.6);
  z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
}
.modal-card {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 28px 24px;
  width: min(640px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--fg-3);
  display: grid; place-items: center;
  font-size: 21.6px;
}
.modal-close:hover { background: var(--bg-3); color: var(--fg); }

/* ============================================================
 * TEAM BUILDER — board, gear, priority pool, pickers, card detail,
 * config modal, toast. Restored 2026-05-27 from the pre-redesign
 * backup; restyled with codex tokens.
 * ============================================================ */

/* Rarity tokens (used by gear quality borders, badges, picker cards). */
:root {
  --r6: #ff8c42;
  --r5: #ffd166;
  --r4: #c084fc;
  --r3: #60a5fa;
  --r2: #6ee7b7;
}

/* Generic badge (used by gear sub-text). */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10.8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 600;
}
.badge.q6 { background: rgba(255,140,66,0.15);  color: var(--r6); }
.badge.q5 { background: rgba(255,209,102,0.15); color: var(--r5); }
.badge.q4 { background: rgba(192,132,252,0.15); color: var(--r4); }
.badge.q3 { background: rgba(96,165,250,0.15);  color: var(--r3); }
.badge.q2 { background: rgba(110,231,183,0.15); color: var(--r2); }

/* Card-color dot (used by card detail; reserved for future use). */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--fg-4); vertical-align: middle; }

/* ---------- 5-slot team board ---------- */
.team-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-top: 8px;
}
.team-col { display: flex; flex-direction: column; gap: 10px; }

.team-char {
  position: relative;
  aspect-ratio: 1/1.35;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  outline: 0 solid transparent;
  transition: outline-color .15s, outline-width .15s, border-color .15s;
}
.team-char:hover { outline: 2px solid oklch(1 0 0 / 0.45); }
.team-char.dragging { opacity: 0.35; }
.team-char.drop-target {
  outline: 3px dashed var(--accent-2);
  outline-offset: -3px;
}
.team-char img.portrait-img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.team-char .empty-char {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--fg-4);
  font-size: 14.4px; text-align: center; padding: 16px;
}
.team-char .char-name {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 28px 10px 12px;
  background: linear-gradient(180deg, transparent 0%, oklch(0 0 0 / 0.85) 60%);
  color: white;
  font-weight: 600;
  font-size: 18px;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 2px oklch(0 0 0 / 0.9);
}
/* Top-corner buttons on filled slots */
.team-char .leader-btn,
.team-char .remove-btn {
  position: absolute;
  top: 6px;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid oklch(0 0 0 / 0.6);
  background: oklch(0 0 0 / 0.65);
  padding: 0;
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 2;
  transition: transform .12s, background .12s, opacity .12s, filter .12s;
  box-shadow: 0 2px 4px oklch(0 0 0 / 0.5);
  line-height: 1;
}
.team-char .leader-btn { left: 6px; }
.team-char .remove-btn { right: 6px; }
.team-char .leader-btn img { width: 22px; height: 22px; object-fit: contain; pointer-events: none; }
.team-char .leader-btn.inactive { opacity: 0.4; filter: grayscale(0.8); }
.team-char .leader-btn:hover { transform: scale(1.06); }
.team-char .leader-btn:not(.inactive) {
  background: linear-gradient(135deg, oklch(0.85 0.16 80 / 0.95) 0%, oklch(0.72 0.18 50 / 0.95) 100%);
  border-color: #000;
  box-shadow: 0 2px 8px oklch(0.72 0.18 50 / 0.5);
}
.team-char .remove-btn span {
  display: block;
  font-size: 28px;
  font-weight: 300;
  color: oklch(1 0 0 / 0.9);
  line-height: 1;
  transform: translateY(-2px);
  pointer-events: none;
}
.team-char .remove-btn:hover { background: var(--bad); transform: scale(1.06); }
.team-char .remove-btn:hover span { color: white; }

/* ---------- gear row (3 slots) ---------- */
.team-gear-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.gear-slot {
  aspect-ratio: 1/1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color .15s;
}
.gear-slot:hover { border-color: var(--accent); }
.gear-slot.q6 { border-color: var(--r6); box-shadow: inset 0 0 0 1px var(--r6); }
.gear-slot.q5 { border-color: var(--r5); box-shadow: inset 0 0 0 1px var(--r5); }
.gear-slot.q4 { border-color: var(--r4); }
.gear-slot.q3 { border-color: var(--r3); }
.gear-slot .empty-icon { color: var(--fg-4); font-size: 22px; opacity: 0.55; }
.gear-slot img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }

/* ---------- priority pool ---------- */
.priority-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.pri-wrap {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 6px;
  position: relative;
  cursor: grab;
  user-select: none;
  transition: opacity .15s;
}
.pri-wrap:active { cursor: grabbing; }
.pri-wrap.dragging { opacity: 0.35; }
.pri-wrap.drop-before::before,
.pri-wrap.drop-after::after {
  content: "";
  position: absolute;
  top: 4px; bottom: 22px;
  width: 4px;
  background: var(--accent-2);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-2);
  z-index: 5;
}
.pri-wrap.drop-before::before { left: -8px; }
.pri-wrap.drop-after::after   { right: -8px; }
.pri-card {
  position: relative;
  aspect-ratio: 100/145;
  border-radius: 6px;
  overflow: hidden;
  background: oklch(0.08 0.012 270);
  box-shadow: 0 3px 8px oklch(0 0 0 / 0.5);
  cursor: pointer;
  outline: 0 solid transparent;
  transition: outline-color .12s, outline-width .12s, box-shadow .12s;
}
.pri-card:hover { outline: 2px solid oklch(1 0 0 / 0.45); }
.pri-card.has-choice:not(.is-disabled)::after {
  content: "⚙";
  position: absolute; top: 4px; left: 4px;
  width: 32px; height: 32px;
  background: transparent;
  color: var(--r5);
  display: grid; place-items: center;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  z-index: 3;
  text-shadow:
    -2px -2px 0 #000,  2px -2px 0 #000,
    -2px  2px 0 #000,  2px  2px 0 #000,
     0 0 8px oklch(0 0 0 / 1),
     0 0 14px oklch(0 0 0 / 0.95);
}
.pri-card.has-choice:has(.leader-flag):not(.is-disabled)::after { top: 40px; }
.pri-card .leader-flag {
  position: absolute; top: 4px; left: 4px;
  width: 32px; height: 32px;
  z-index: 3;
  pointer-events: none;
  filter:
    drop-shadow(0 0 4px oklch(0 0 0 / 0.85))
    drop-shadow(0 2px 4px oklch(0 0 0 / 0.7));
}
.pri-card .disabled-tint {
  position: absolute; inset: 0;
  background: oklch(0.5 0.18 25 / 0.55);
  z-index: 3;
  pointer-events: none;
}
.pri-card .disabled-overlay {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: grid; place-items: center;
  pointer-events: none;
}
.pri-card .disabled-icon {
  width: 64px; height: 64px;
  background: oklch(0 0 0 / 0.6);
  border-radius: 50%;
  display: grid; place-items: center;
}
.pri-card .disabled-icon svg { width: 52px; height: 52px; }
.pri-card .owner-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: top center;
}
.pri-card .owner-bg.is-generic { background-position: center center; }
.pri-card .vignette {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, oklch(0 0 0 / 0.35) 100%);
}
.pri-card .diamond {
  position: absolute;
  top: 70%; left: 50%;
  width: 68%; aspect-ratio: 1/1;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 10px oklch(0 0 0 / 0.55));
}
.pri-card .diamond .diamond-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  background: var(--bg-3);
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 28px;
}
.pri-card .diamond .diamond-border {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.pri-card .diamond .stroke { fill: none; stroke: #000; stroke-width: 4; }
.pri-card .cost-circle {
  position: absolute; top: 6px; right: 6px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, oklch(0.45 0.02 270), oklch(0.2 0.02 270));
  border: 2px solid #000;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.18), 0 2px 4px oklch(0 0 0 / 0.6);
  display: grid; place-items: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
  text-shadow: 0 1px 2px oklch(0 0 0 / 0.8);
  z-index: 2;
}
.pri-card .cname {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 22px 8px 8px;
  font-size: 15.6px;
  font-weight: 600;
  line-height: 1.15;
  color: white;
  text-align: center;
  word-break: break-word;
  background: linear-gradient(180deg, transparent 0%, oklch(0 0 0 / 0.85) 70%);
  text-shadow: 0 1px 3px oklch(0 0 0 / 0.9);
  z-index: 2;
  pointer-events: none;
}

/* ---------- coming-soon placeholder (Equipment tab) ---------- */
.coming-soon {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg-3);
  text-transform: uppercase;
}

/* ---------- modal width variants ---------- */
.modal.modal-md   .modal-card { width: min(720px, 100%); }
.modal.modal-wide .modal-card { width: min(1040px, 100%); }

/* ---------- team-screen layout ---------- */
.screen[data-screen="team"] {
  max-width: 1920px;
  margin: 0 auto;
}
.picker-title { margin: 0 0 14px 0; font-size: 22px; }
.picker-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.picker-header input {
  flex: 0 0 240px;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  outline: none;
  font: inherit;
}
.picker-header input:focus { border-color: var(--accent); }
.picker-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: transparent;
  color: var(--fg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { color: var(--fg); border-color: var(--border-strong); }
.chip.on { background: var(--accent); color: white; border-color: var(--accent); }

/* Rarity-icon chip — match the codex `.rarity-filter` look (slight radius,
 * dim when off, brighten + subtle bg when on). */
.chip-rarity {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0.55;
  transition: opacity .12s, border-color .12s, background .12s;
}
.chip-rarity:hover { opacity: 0.9; }
.chip-rarity.on {
  opacity: 1;
  background: var(--bg-2);
  border-color: var(--border-strong);
  box-shadow: none;
}
.chip-rarity .rarity-img { display: block; }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
}
.picker-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  position: relative;
  outline: 0 solid transparent;
  transition: outline-color .15s, outline-width .15s, border-color .15s;
}
.picker-card:hover { outline: 2px solid oklch(1 0 0 / 0.5); }
.picker-card.disabled { opacity: 0.3; cursor: not-allowed; }
.picker-card.disabled:hover { outline: none; border-color: var(--border); }
.picker-card.q6 { border-color: var(--r6); box-shadow: 0 0 0 1px var(--r6) inset; }
.picker-card.q5 { border-color: var(--r5); }
.picker-card.q4 { border-color: var(--r4); }
.picker-card.q3 { border-color: var(--r3); }
.picker-card.q2 { border-color: var(--r2); }
/* Char/equip pickers keep a neutral background; the portrait carries the rarity feel. */
.picker-card.equip-card,
.picker-card.char-card { background: var(--bg-1); box-shadow: none; border-color: var(--border); }
.picker-card.char-card .pp-name,
.picker-card.equip-card .pp-name { color: var(--fg); font-weight: 600; }
.picker-card .pp-portrait {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 6px;
  margin-bottom: 4px;
  background: linear-gradient(135deg, oklch(0.22 0.05 270) 0%, oklch(0.15 0.03 270) 100%);
  display: grid; place-items: center; overflow: hidden;
  font-weight: 700;
}
.picker-card .pp-portrait img { width: 100%; height: 100%; object-fit: cover; }
.picker-card .pp-portrait-gear img { padding: 6px; object-fit: contain; }
.picker-card .pp-name {
  font-size: 12.6px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.picker-card .pp-sub {
  color: var(--fg-3);
  font-size: 10.8px;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  gap: 4px;
}
.picker-card .pp-sub .rarity-img { vertical-align: middle; }

/* ---------- card-detail modal ---------- */
.cd-head {
  display: flex; gap: 18px; align-items: center;
  padding-bottom: 16px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.cd-icon {
  position: relative;
  width: 120px; height: 120px;
  flex-shrink: 0;
}
.cd-icon img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  background: var(--bg-3);
}
.cd-icon svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cd-hd-right h2 { margin: 0 0 8px 0; font-size: 26px; }
.cd-cost { color: var(--fg-3); font-size: 14px; letter-spacing: 1px; }
.cd-cost b { color: var(--accent-2); font-size: 28px; margin-left: 8px; font-weight: 700; }
.cd-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}
@media (max-width: 760px) { .cd-body { grid-template-columns: 1fr; } }
.cd-desc {
  background: var(--bg-2);
  border-radius: 10px;
  padding: 16px 18px;
  color: var(--fg);
  font-size: 15px;
  line-height: 1.6;
}
.cd-actions h3 {
  margin: 0 0 12px 0;
  font-size: 12.6px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.opt-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 15px;
  transition: background .12s, border-color .12s;
}
.opt-row:hover { background: var(--bg-3); }
.opt-row.checked {
  background: linear-gradient(90deg, oklch(0.85 0.16 85 / 0.18) 0%, oklch(0.85 0.16 85 / 0.05) 100%);
  border-color: var(--r5);
}
.opt-row .opt-label { flex: 1; font-weight: 500; }
.opt-row.checked .opt-label { color: var(--r5); font-weight: 600; }
.opt-stepper {
  display: inline-flex; align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
}
.opt-step-btn {
  width: 28px; height: 30px;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background .12s, color .12s;
  display: grid; place-items: center;
}
.opt-step-btn:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--accent-2);
}
.opt-step-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.opt-num-display {
  min-width: 36px;
  padding: 4px 6px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.opt-row .opt-radio {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--fg-3);
  flex-shrink: 0;
  position: relative;
}
.opt-row.checked .opt-radio {
  border-color: var(--r5);
  background: var(--r5);
  box-shadow: inset 0 0 0 3px var(--bg-1);
}

/* ---------- config modal ---------- */
.cfg-list { display: flex; flex-direction: column; gap: 6px; }
.cfg-row {
  display: flex; align-items: center; gap: 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.cfg-row.cfg-row-stack { flex-direction: column; align-items: stretch; gap: 10px; }
.cfg-text { flex: 1; min-width: 0; }
.cfg-title { font-weight: 600; font-size: 15px; }
.cfg-sub { color: var(--fg-3); font-size: 12.6px; margin-top: 2px; }
.cfg-toggle {
  width: 56px; height: 28px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.cfg-toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  background: white;
  border-radius: 50%;
  transition: left .15s, background .15s;
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.5);
}
.cfg-toggle.on { background: var(--accent); border-color: var(--accent); }
.cfg-toggle.on::after { left: 30px; }
.cfg-radio-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cfg-radio {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.cfg-radio:hover { background: var(--bg-3); }
.cfg-radio.on {
  background: linear-gradient(90deg, oklch(0.85 0.16 85 / 0.18) 0%, oklch(0.85 0.16 85 / 0.05) 100%);
  border-color: var(--r5);
  color: var(--r5);
}
.cfg-radio-dot {
  width: 14px; height: 14px;
  background: transparent;
  border: 2px solid var(--fg-3);
  transform: rotate(45deg);
  flex-shrink: 0;
}
.cfg-radio.on .cfg-radio-dot {
  background: var(--r5);
  border-color: var(--r5);
  box-shadow: inset 0 0 0 2px var(--bg-1);
}

/* ---------- toast ----------
 * Default style: glassy slate card with a colored accent stripe on the left.
 * Anchored variant: positioned under a button via inline top/left, no transform. */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: oklch(0.18 0.014 270 / 0.96);
  color: var(--fg);
  padding: 9px 14px 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--good);
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: 0.1px;
  box-shadow: 0 12px 32px -10px oklch(0 0 0 / 0.65);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-left-color: var(--bad); }
.toast.anchored {
  bottom: auto;
  left: 0;
  transform: translateY(-4px);
}
.toast.anchored.show { transform: translateY(0); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1280px) {
  :root { --picker-w: 280px; --pad: 22px; }
}
@media (max-width: 1100px) {
  :root { --picker-w: 240px; }
  .hero { grid-template-columns: 240px 1fr; gap: 20px; }
  .hero-name { font-size: 72px; }
}
@media (max-width: 900px) {
  /* Stack the shell: nav bar on top, full-width content below. */
  .app, .app.no-picker {
    display: flex;
    flex-direction: column;
  }

  /* Nav becomes a horizontal top bar, always icon-only. */
  .nav {
    flex-direction: row;
    align-items: center;
    height: auto;
    width: 100%;
    gap: 8px;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .nav-brand { width: auto; padding: 0 6px 0 2px; flex: 0 0 auto; }
  /* Force the mini brand on mobile regardless of .nav-collapsed state. */
  .brand-full { display: none; }
  .brand-mini { display: inline; font-size: 13px; line-height: 1.0; }

  .nav-list {
    flex-direction: row;
    padding: 0;
    gap: 4px;
    flex: 1 1 auto;
    overflow-x: auto;
  }
  .nav-item {
    width: 44px;
    height: 44px;
    grid-template-columns: 24px;
    justify-content: center;
    padding: 0;
    flex: 0 0 auto;
  }
  .nav-item.is-on::before { display: none; }
  .nav-label, .nav-count { display: none; }
  .nav-item .nav-tip { display: none; }

  /* nav-foot: inline ko-fi + discord at the far right; hide the collapse toggle. */
  .nav-foot {
    flex-direction: row;
    width: auto;
    padding: 0;
    margin: 0 0 0 auto;
    gap: 4px;
    flex: 0 0 auto;
  }
  .nav-toggle { display: none; }
  .nav-link {
    grid-template-columns: 24px;
    width: 36px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }
  .nav-link-label { display: none; }

  /* Picker + main flow as plain full-width blocks. */
  .picker {
    display: flex;
    position: static;
    height: auto;
    width: 100%;
    border-right: none;
  }
  .picker-list { overflow: visible; }
  .main { width: 100%; }

  /* On the characters screen, show picker XOR detail based on selection. */
  .app:not(.no-picker):not(.char-selected) .main { display: none; }
  .app:not(.no-picker).char-selected .picker { display: none; }
}

@media (max-width: 530px) {
  .hero {
    grid-template-columns: 1fr;
    grid-template-areas:
      "art"
      "body"
      "stats";
  }
  .stats-cards { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .nav-link-discord { display: none; }
}
