:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #10141a;
  --panel-2: #151a22;
  --panel-3: #1b222c;
  --line: rgba(236, 228, 209, 0.11);
  --line-strong: rgba(236, 228, 209, 0.2);
  --text: #eee9de;
  --muted: #999b9e;
  --soft: #c5c0b4;
  --gold: #c9a45e;
  --gold-bright: #e1bd70;
  --gold-dark: #786038;
  --silver: #bdc3c9;
  --purple: #8777ab;
  --green: #78a88e;
  --red: #b16d67;
  --blue: #718ca8;
  --radius: 18px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); overflow-x: hidden; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 68% -12%, rgba(135, 119, 171, 0.13), transparent 33rem),
    radial-gradient(circle at 10% 92%, rgba(201, 164, 94, 0.07), transparent 38rem),
    var(--bg);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: 252px;
  flex-direction: column;
  padding: 27px 18px 20px;
  border-right: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.9);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 3px 7px 24px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.brand-mark { width: 46px; height: 46px; flex: 0 0 46px; border: 1px solid rgba(225,189,112,.45); border-radius: 50%; object-fit: cover; box-shadow: 0 6px 18px rgba(0,0,0,.35); }

.main-nav { display: grid; gap: 5px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: 150ms ease;
}
.nav-item > span:first-child { width: 18px; color: #7e8084; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.035); color: var(--text); }
.nav-item.active { border-color: rgba(201,164,94,.17); background: linear-gradient(90deg, rgba(201,164,94,.13), rgba(201,164,94,.035)); color: var(--gold-bright); }
.nav-item.active > span:first-child { color: var(--gold-bright); }

.sidebar-footer { margin-top: auto; }
.shortcut-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  color: var(--soft);
  font-size: 12px;
  cursor: pointer;
}
kbd { padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: 5px; background: #0b0e13; color: var(--muted); font-size: 10px; }
.sidebar-footer p { margin: 13px 8px 0; color: #72767a; font-size: 11px; }
.sidebar-footer .sync-status { margin-top: 5px; color: #939aa3; }
.sidebar-footer .sync-status[data-status="saved"] { color: var(--green); }
.sidebar-footer .sync-status[data-status="saving"] { color: var(--gold); }
.sidebar-footer .sync-status[data-status="offline"] { color: #d78977; }
.privacy-dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 99px; background: var(--green); box-shadow: 0 0 9px rgba(120,168,142,.5); }

.main-content { min-height: 100vh; margin-left: 252px; padding: 0 4.5vw 64px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 104px;
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--bg) 72%, rgba(9,11,15,.88));
  backdrop-filter: blur(14px);
}
.eyebrow { margin: 0 0 5px; color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: .2em; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(25px, 3vw, 37px); font-weight: 500; line-height: 1; }
h2 { font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 500; }
h3 { font-size: 15px; font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.topbar-title { display: flex; align-items: center; gap: 10px; }
.mobile-brand-mark { display: none; width: 43px; height: 43px; border: 1px solid rgba(225,189,112,.4); border-radius: 50%; object-fit: cover; }
.button, .icon-button {
  min-height: 39px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: 150ms ease;
}
.button:hover, .icon-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button.primary { border-color: #c8a35b; background: var(--gold); color: #111218; font-weight: 700; }
.button.secondary, .icon-button { background: var(--panel-2); color: var(--soft); }
.button.ghost { min-height: 34px; padding: 0 11px; border-color: var(--line); background: transparent; color: var(--muted); font-size: 12px; }
.button.danger { border-color: rgba(177,109,103,.3); color: #d59690; }
.mobile-search { display: none; padding: 0; width: 39px; }

.view { max-width: 1440px; margin: 0 auto; padding-top: 28px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(300px, .72fr); gap: 18px; }
.stack { display: grid; align-content: start; gap: 18px; }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(20,25,33,.96), rgba(14,18,24,.96));
  box-shadow: 0 16px 42px rgba(0,0,0,.14);
  overflow: hidden;
}
.card-pad { padding: 21px; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.card-header h2, .card-header h3 { margin-bottom: 4px; }
.card-header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.section-label { color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }

.hero-card { position: relative; min-height: 235px; padding: 27px; background: linear-gradient(115deg, rgba(31,34,44,.98), rgba(17,21,28,.93)); }
.hero-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 86% 22%, rgba(201,164,94,.16), transparent 25%), linear-gradient(90deg, transparent 55%, rgba(135,119,171,.08)); }
.hero-content { position: relative; z-index: 1; max-width: 650px; }
.hero-title { margin: 8px 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(31px, 5vw, 50px); font-weight: 500; letter-spacing: -.02em; }
.hero-subtitle { margin-bottom: 20px; color: var(--soft); font-size: 14px; }
.hero-subtitle strong { color: var(--text); }
.quote { max-width: 520px; margin: 0; padding-left: 14px; border-left: 2px solid var(--gold-dark); color: #cfc8b8; font-family: Georgia, "Times New Roman", serif; font-size: 15px; font-style: italic; line-height: 1.55; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 20px; }
.chip, .tag { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-strong); border-radius: 99px; color: var(--soft); font-size: 10px; font-weight: 650; letter-spacing: .04em; }
.chip { padding: 6px 9px; background: rgba(10,12,17,.48); }
.tag { padding: 4px 7px; }
.tag.gold { border-color: rgba(201,164,94,.32); background: rgba(201,164,94,.08); color: #d9b979; }
.tag.green { border-color: rgba(120,168,142,.28); color: #95bda6; }
.tag.purple { border-color: rgba(135,119,171,.3); color: #a99bc8; }
.tag.red { border-color: rgba(177,109,103,.3); color: #d3948f; }
.tag.blue { border-color: rgba(113,140,168,.3); color: #9bb3c9; }

.resource-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.resource {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(8,11,15,.35);
}
.resource-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.resource-name { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.resource-value { margin: 9px 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; }
.stepper { display: grid; grid-template-columns: 30px 1fr 30px; gap: 4px; }
.stepper button { height: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); cursor: pointer; }
.stepper input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: #0d1015; color: var(--text); text-align: center; }
.hp-resource { display: flex; flex-direction: column; }
.hp-adjustments { display: grid; gap: 10px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.hp-adjustments label > span { display: block; color: var(--soft); font-size: 12px; font-weight: 700; }
.hp-adjustments label > small { display: block; margin: 2px 0 6px; color: var(--muted); font-size: 10px; }
.compact-stepper { grid-template-columns: 36px 1fr 36px; }
.compact-stepper button { font-size: 10px; }
.pips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.pip { width: 18px; height: 18px; padding: 0; border: 1px solid var(--gold-dark); border-radius: 50%; background: rgba(201,164,94,.16); cursor: pointer; }
.pip.empty { background: transparent; border-color: var(--line-strong); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle-row:first-of-type { border-top: 0; }
.toggle-row strong { display: block; margin-bottom: 2px; font-size: 13px; }
.toggle-row small { color: var(--muted); }
.intervention-callout { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 2px; border-top: 1px solid var(--line); }
.intervention-callout strong { display: block; margin-bottom: 3px; font-size: 13px; }
.intervention-callout small { display: block; color: var(--muted); line-height: 1.45; }
.switch { position: relative; flex: 0 0 42px; height: 24px; border: 1px solid var(--line-strong); border-radius: 99px; background: #0c0f14; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #6d7076; transition: 170ms ease; }
.switch.on { border-color: rgba(201,164,94,.45); background: rgba(201,164,94,.14); }
.switch.on::after { left: 21px; background: var(--gold-bright); }

.dashboard-main { grid-template-rows: auto auto minmax(240px,1fr); align-content: stretch; }
.todo-card { display: flex; min-height: 0; flex-direction: column; }
.objective-field { width: 100%; min-height: 190px; flex: 1; padding: 13px 14px; resize: vertical; border: 1px solid var(--line); border-radius: 11px; background: #0c0f14; color: var(--text); line-height: 1.5; }
.save-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 11px; }

.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.quick-card { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(9,12,17,.38); cursor: pointer; transition: 150ms ease; }
.quick-card:hover { border-color: rgba(201,164,94,.32); transform: translateY(-1px); }
.quick-card strong { display: block; margin-bottom: 5px; font-size: 13px; }
.quick-card small { color: var(--muted); line-height: 1.35; }

.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.filter-group { display: flex; flex-wrap: wrap; gap: 7px; }
.toolbar-actions, .card-header-actions, .record-card-head { display: flex; align-items: center; gap: 8px; }
.record-card-head { justify-content: space-between; }
.filter-button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.filter-button.active { border-color: rgba(201,164,94,.35); background: rgba(201,164,94,.11); color: var(--gold-bright); }
.inline-search { min-width: 240px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--text); }

.content-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; }
.content-card { min-height: 172px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, rgba(21,26,34,.92), rgba(13,17,22,.92)); }
.content-card.featured { grid-column: span 2; }
.content-card h3 { margin: 8px 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 500; }
.content-card p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.icon-action { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--gold-bright); font-size: 12px; cursor: pointer; }
.npc-card { display: flex; min-width: 0; flex-direction: column; }
.npc-card .card-meta { margin-top: auto; padding-top: 13px; }
.relationship-block { margin: 5px 0 12px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(6,9,12,.4); }
.relationship-block > div:first-child { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.relationship-block strong { color: var(--text); font-weight: 650; }
.relationship-slider { width: 100%; accent-color: var(--gold); cursor: ew-resize; }
.relationship-scale { display: flex; justify-content: space-between; color: var(--muted); }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.detail-list { display: grid; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.detail-list li { display: flex; gap: 9px; color: var(--soft); font-size: 12px; line-height: 1.45; }
.detail-list li::before { content: "◆"; color: var(--gold-dark); font-size: 7px; transform: translateY(5px); }

.profile-layout { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(0, 1.5fr); gap: 18px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.character-stats { padding: 19px; }
.character-stats .card-header { margin-bottom: 13px; }
.character-stats .card-header h2 { margin-bottom: 3px; font-size: 23px; }
.character-stats .card-header p { line-height: 1.35; }
.core-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.core-stat { padding: 10px 4px; border: 1px solid var(--line); border-radius: 9px; background: rgba(8,11,15,.38); text-align: center; }
.core-stat small { display: block; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.core-stat strong { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 24px; margin-top: 3px; font-family: Georgia, serif; font-size: 16px; }
.stat-section { margin-top: 14px; }
.stat-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; color: var(--gold); font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.ability-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ability { padding: 9px 5px; border: 1px solid var(--line); border-radius: 9px; background: rgba(8,11,15,.28); text-align: center; }
.ability small { display: block; color: var(--muted); font-size: 8px; font-weight: 700; }
.ability strong { display: block; margin: 3px 0 1px; font-family: Georgia, serif; font-size: 17px; }
.ability span { color: var(--soft); font-size: 10px; }
.stat-lines { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 5px 10px; }
.stat-line { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 25px; border-bottom: 1px solid rgba(236,228,209,.065); color: var(--muted); font-size: 10px; }
.stat-line strong { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-size: 11px; white-space: nowrap; }
.adv-badge { padding: 2px 4px; border: 1px solid rgba(120,168,142,.35); border-radius: 4px; background: rgba(120,168,142,.11); color: #a9d2b7; font-family: Inter, sans-serif; font-size: 7px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.unknown-stat { color: #6e7177 !important; font-weight: 500 !important; }
.stat-note { margin: 14px 0 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(201,164,94,.05); color: var(--muted); font-size: 9px; line-height: 1.45; }
.comparison-wrap { overflow-x: auto; }
.comparison-table { min-width: 720px; }
.comparison-row { display: grid; grid-template-columns: minmax(180px, 1.15fr) repeat(3, minmax(135px, 1fr)); align-items: stretch; border-bottom: 1px solid var(--line); }
.comparison-row > div { display: flex; align-items: center; min-height: 46px; padding: 8px 16px; border-left: 1px solid rgba(236,228,209,.07); }
.comparison-row > div:first-child { border-left: 0; }
.comparison-header { position: sticky; top: 0; z-index: 2; background: #171c24; color: var(--gold-bright); font-family: Georgia, serif; font-size: 17px; }
.comparison-header > div { min-height: 55px; }
.comparison-section { display: grid; grid-template-columns: 1fr; padding: 9px 16px; border-bottom: 1px solid rgba(201,164,94,.22); background: linear-gradient(90deg, rgba(201,164,94,.12), rgba(201,164,94,.025)); color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.comparison-label { color: var(--soft); font-size: 12px; font-weight: 620; }
.comparison-cell { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; }
.comparison-cell > strong { font-family: Georgia, serif; font-size: 17px; font-weight: 600; }
.comparison-sub { color: var(--muted); font-size: 10px; }
.comparison-note { padding: 2px 5px; border: 1px solid rgba(120,168,142,.32); border-radius: 4px; background: rgba(120,168,142,.1); color: #a9d2b7; font-size: 8px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.minimum-roll { display: block; flex-basis: 100%; color: #8c8f94; font-size: 9px; line-height: 1.1; }
.minimum-roll b { color: var(--gold); font-weight: 800; text-transform: uppercase; }
.comparison-footnotes { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; padding: 15px; background: rgba(8,11,15,.33); }
.comparison-footnotes p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.comparison-footnotes strong { color: var(--soft); }
.mode-picker { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 12px; background: #0d1015; }
.mode-picker label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.mode-picker select { min-width: 180px; padding: 9px 34px 9px 11px; border: 1px solid rgba(201,164,94,.32); border-radius: 8px; background: var(--panel-2); color: var(--gold-bright); cursor: pointer; }
.loadout-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding: 15px 17px; border: 1px solid rgba(201,164,94,.2); border-radius: 13px; background: linear-gradient(90deg, rgba(201,164,94,.09), rgba(135,119,171,.045)); }
.loadout-banner h3 { margin-bottom: 4px; font-family: Georgia, serif; font-size: 18px; }
.loadout-banner p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.prb-plan { margin: -2px 0 14px; border: 1px solid rgba(201,164,94,.28); border-radius: 13px; background: rgba(8,11,15,.42); overflow: hidden; }
.prb-plan summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 15px; cursor: pointer; list-style: none; }
.prb-plan summary::-webkit-details-marker { display: none; }
.prb-plan summary > span:first-child { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.prb-plan summary strong { color: var(--gold-bright); font-family: Georgia, serif; font-size: 17px; }
.prb-plan summary small { color: var(--muted); font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }
.prb-plan-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; border-top: 1px solid var(--line); background: var(--line); }
.prb-step { display: grid; grid-template-columns: 25px 1fr; gap: 8px; padding: 10px 12px; background: #11161d; }
.prb-step > b { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid rgba(201,164,94,.35); border-radius: 50%; color: var(--gold-bright); font: 700 11px Georgia,serif; }
.prb-step strong { display: block; color: var(--soft); font-size: 11px; }
.prb-step small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.prb-step-wide { grid-column: 1 / -1; }
.prb-questions { display: grid; gap: 3px; margin: 5px 0 0; padding-left: 15px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.spell-slot-strip { display: grid; grid-template-columns: repeat(6, minmax(86px,1fr)); gap: 7px; margin-bottom: 14px; }
.slot-summary { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(8,11,15,.35); color: var(--text); text-align: left; cursor: pointer; }
.slot-summary span { display: block; color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.slot-summary strong { display: block; margin-top: 4px; font-family: Georgia, serif; font-size: 17px; }
.slot-summary small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.slot-summary:hover, .slot-summary.active { border-color: rgba(201,164,94,.5); background: rgba(201,164,94,.1); }
.slot-summary.active span, .slot-summary.active small { color: var(--gold-bright); }
.spell-row { cursor: pointer; }
.spell-row.expanded { grid-template-columns: minmax(160px,.9fr) 80px 110px minmax(140px,1fr); border-color: rgba(201,164,94,.35); background: rgba(201,164,94,.055); }
.spell-distance { color: var(--soft) !important; }
.spell-expand { grid-column: 1 / -1; padding: 14px 4px 3px; border-top: 1px solid var(--line); cursor: default; }
.spell-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }
.spell-detail-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--line); overflow: hidden; }
.spell-detail-grid > div { min-width: 0; padding: 10px 11px; background: #11161d; }
.spell-detail-grid span, .spell-rules-copy > span { display: block; margin-bottom: 3px; color: var(--gold); font-size: 8px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.spell-detail-grid strong { display: block; color: var(--soft); font-size: 11px; overflow-wrap: anywhere; }
.spell-rules-copy { padding: 14px 0 2px; border-top: 2px solid rgba(135,119,171,.75); }
.spell-text { max-width: 920px; margin: 0 0 13px; color: var(--soft) !important; font-size: 12px !important; line-height: 1.65 !important; }
.spell-scaling { margin: 0 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(8,11,15,.38); }
.spell-scaling > span { display: block; margin-bottom: 8px; color: var(--gold); font-size: 8px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.spell-scaling-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(105px,1fr)); gap: 6px; }
.spell-scaling-grid > div { min-width: 0; padding: 8px; border-radius: 7px; background: #11161d; }
.spell-scaling-grid b { display: block; margin-bottom: 3px; color: var(--gold-bright); font-size: 10px; }
.spell-scaling-grid small { display: block; color: var(--soft); font-size: 9px; line-height: 1.35; overflow-wrap: anywhere; }
.spell-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.spell-actions small { color: var(--muted); }
.spell-source-link { margin-right: auto; color: var(--gold-bright) !important; text-decoration: none; }
.use-spell { min-width: 92px; }
.portrait-card { min-height: 390px; padding: 26px; background: radial-gradient(circle at 50% 15%, rgba(189,195,201,.11), transparent 38%), linear-gradient(160deg, #1b2029, #0f1319); }
.portrait-sigil { display: grid; place-items: center; width: 130px; height: 130px; margin: 12px auto 25px; border: 1px solid rgba(201,164,94,.28); border-radius: 50%; background: rgba(7,9,12,.55); color: var(--silver); font-family: Georgia, serif; font-size: 49px; box-shadow: inset 0 0 35px rgba(201,164,94,.06); }
.profile-name { margin-bottom: 5px; text-align: center; font-size: 29px; }
.profile-class { color: var(--muted); text-align: center; }
.stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-top: 21px; }
.stat-cell { padding: 12px 7px; border: 1px solid var(--line); border-radius: 10px; background: rgba(8,11,15,.36); text-align: center; }
.stat-cell small { display: block; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.stat-cell strong { display: block; margin-top: 5px; font-family: Georgia, serif; font-size: 17px; }
.tabs { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #0d1015; }
.tab { flex: 1; padding: 8px 9px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.tab.active { background: var(--panel-3); color: var(--gold-bright); }

.spell-list { display: grid; gap: 8px; }
.spell-row { display: grid; grid-template-columns: minmax(160px, .9fr) 80px 92px minmax(220px, 1.5fr); align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: rgba(12,15,20,.5); }
.spell-row strong { font-size: 13px; }
.spell-row small { color: var(--muted); line-height: 1.4; }
.spell-level { color: var(--gold); font-size: 11px; }
.upcast-note { display: block; margin-top: 4px; color: var(--soft) !important; font-size: 9px; font-weight: 650; line-height: 1.3; }

.journal-layout { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 16px; min-height: 610px; }
.journal-list { padding: 12px; }
.journal-list-header { display: flex; align-items: center; justify-content: space-between; padding: 5px 5px 13px; }
.session-item { width: 100%; padding: 12px; border: 1px solid transparent; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; }
.session-item:hover { background: rgba(255,255,255,.025); }
.session-item.active { border-color: rgba(201,164,94,.22); background: rgba(201,164,94,.08); }
.session-item strong { display: block; margin-bottom: 4px; font-size: 12px; }
.session-item small { color: var(--muted); font-size: 10px; }
.journal-editor { padding: 24px; }
.editor-fields { display: grid; grid-template-columns: 1fr 170px; gap: 10px; }
.text-input, .text-area, .select-input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: #0c0f14; color: var(--text); }
.text-input.title-input { font-family: Georgia, serif; font-size: 23px; }
.field-label { display: block; margin: 17px 0 7px; color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.text-area { min-height: 210px; resize: vertical; line-height: 1.55; }
.text-area.compact { min-height: 92px; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 13px; }

.check-list { display: grid; gap: 8px; }
.check-item { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(9,12,16,.4); }
.check-item input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--gold); }
.check-item.done .check-copy { color: #777; text-decoration: line-through; }
.check-copy { font-size: 12px; line-height: 1.45; }

.pantheon-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.deity { min-height: 135px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(12,15,20,.56); }
.deity-symbol { display: grid; place-items: center; width: 29px; height: 29px; margin-bottom: 11px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--gold); }
.deity h3 { margin-bottom: 4px; }
.deity p { color: var(--muted); font-size: 11px; line-height: 1.45; }

.bestiary-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding: 23px; background: linear-gradient(115deg, rgba(31,34,44,.98), rgba(17,21,28,.93)); }
.bestiary-hero h2 { margin: 5px 0 7px; font-size: 30px; }
.bestiary-hero p { max-width: 720px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.bestiary-totals { display: grid; grid-template-columns: repeat(3, minmax(90px,1fr)); gap: 8px; flex: 0 0 auto; }
.bestiary-totals div { min-width: 90px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(7,10,14,.42); text-align: center; }
.bestiary-totals strong { display: block; color: var(--gold-bright); font-family: Georgia, serif; font-size: 24px; }
.bestiary-totals span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.bestiary-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.bestiary-actions h2 { margin: 0 0 4px; }
.bestiary-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.creature-add-form { display: grid; grid-template-columns: minmax(180px,1.2fr) repeat(4,minmax(120px,.65fr)); gap: 10px; margin-bottom: 18px; padding: 15px; border: 1px solid rgba(201,164,94,.24); border-radius: 13px; background: rgba(201,164,94,.045); }
.creature-add-form label { display: grid; align-content: start; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.creature-add-notes { grid-column: 1 / -1; }
.creature-add-form .text-area { min-height: 78px; }
.creature-add-form > .button { justify-self: end; grid-column: 1 / -1; }
.bestiary-toolbar { display: grid; grid-template-columns: minmax(220px,1fr) repeat(3,minmax(165px,.52fr)); gap: 10px; margin-bottom: 13px; }
.bestiary-toolbar label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.bestiary-toolbar .inline-search { width: 100%; min-width: 0; }
.bestiary-result-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: var(--muted); font-size: 10px; }
.bestiary-result-line strong { color: var(--text); }
.bestiary-result-line a { color: var(--gold); text-decoration: none; }
.bestiary-result-line a:hover { color: var(--gold-bright); text-decoration: underline; }
.bestiary-table { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; }
.bestiary-entry { border-bottom: 1px solid var(--line); background: rgba(8,11,15,.24); }
.bestiary-entry:last-child { border-bottom: 0; }
.bestiary-entry.expanded { background: rgba(201,164,94,.045); box-shadow: inset 3px 0 0 rgba(201,164,94,.5); }
.bestiary-summary { display: grid; grid-template-columns: 68px minmax(240px,1.5fr) minmax(135px,.7fr) minmax(100px,.5fr) minmax(105px,.55fr) 36px; align-items: center; width: 100%; min-height: 70px; padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; }
button.bestiary-summary { cursor: pointer; transition: background 150ms ease; }
button.bestiary-summary:hover { background: rgba(201,164,94,.055); }
.bestiary-summary > div { min-width: 0; padding: 12px 13px; }
.bestiary-header { position: static; min-height: 43px; background: #171c24; color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.bestiary-cr strong { color: var(--gold-bright); font-family: Georgia, serif; font-size: 19px; }
.bestiary-name strong { display: block; margin-bottom: 4px; font-size: 15px; }
.bestiary-name small { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; }
.creature-tag { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.bestiary-reference { color: #85898f; font-size: 12px; }
.creature-expand-icon { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); font-size: 17px; transition: 150ms ease; }
.bestiary-entry.expanded .creature-expand-icon { transform: rotate(180deg); background: rgba(201,164,94,.12); }
.creature-statblock { padding: 22px 24px 26px; border-top: 1px solid rgba(201,164,94,.25); background: linear-gradient(145deg, rgba(23,28,36,.94), rgba(11,15,20,.94)); }
.creature-stat-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.creature-stat-heading h3, .creature-statblock-missing h3 { margin: 4px 0 3px; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.creature-stat-heading p, .creature-statblock-missing p { margin: 0; color: var(--muted); font-size: 13px; }
.creature-combat-stats { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; margin-bottom: 10px; }
.creature-combat-stats div { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(7,10,14,.38); }
.creature-combat-stats span, .creature-abilities span { display: block; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.creature-combat-stats strong { display: block; margin-top: 5px; color: var(--text); font-family: Georgia, serif; font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.creature-abilities { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 8px; margin-bottom: 14px; }
.creature-abilities div { padding: 11px 8px; border: 1px solid var(--line); border-radius: 10px; background: rgba(7,10,14,.26); text-align: center; }
.creature-abilities strong { display: block; margin: 4px 0 2px; font-family: Georgia, serif; font-size: 19px; }
.creature-abilities small { color: var(--muted); font-size: 10px; }
.creature-details { display: grid; gap: 7px; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.creature-details p { display: grid; grid-template-columns: 120px minmax(0,1fr); gap: 12px; margin: 0; color: var(--soft); font-size: 13px; line-height: 1.45; }
.creature-details strong { color: var(--gold); }
.creature-section { padding-top: 16px; }
.creature-section h4 { margin: 0 0 8px; color: var(--gold-bright); font-family: Georgia, serif; font-size: 19px; font-weight: 500; }
.creature-section p { margin: 0 0 9px; color: var(--soft); font-size: 13px; line-height: 1.6; }
.campaign-encounter-note, .missing-stat-note { display: grid; gap: 4px; margin-top: 17px; padding: 13px 14px; border: 1px solid rgba(201,164,94,.24); border-radius: 11px; background: rgba(201,164,94,.06); }
.campaign-encounter-note strong, .missing-stat-note strong { color: var(--gold-bright); font-size: 13px; }
.campaign-encounter-note span, .missing-stat-note span { color: var(--soft); font-size: 12px; line-height: 1.5; }
.creature-statblock-missing { display: grid; grid-template-columns: minmax(0,1fr) minmax(260px,.7fr); gap: 20px; align-items: center; }
.creature-statblock-missing .missing-stat-note { margin-top: 0; }
.creature-player-record { display: grid; grid-template-columns: minmax(220px,.7fr) minmax(300px,1.3fr); gap: 22px; align-items: start; }
.player-safe-heading h3 { margin: 4px 0 5px; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.player-safe-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.creature-notes-editor { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.creature-player-record .creature-notes-editor, .creature-statblock-missing .creature-notes-editor { margin-top: 0; padding-top: 0; border-top: 0; }
.creature-notes-editor label { display: block; margin-bottom: 7px; color: var(--gold); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.creature-notes-editor textarea { width: 100%; min-height: 112px; }
.creature-note-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.creature-entry-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.creature-edit-form { display: grid; grid-template-columns: minmax(170px,1.2fr) repeat(4,minmax(110px,.65fr)) auto; align-items: end; gap: 9px; margin-top: 13px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(7,10,14,.38); }
.creature-edit-form label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.mobile-cell-label { display: none; }

.empty-state { padding: 50px 20px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; padding: 11px 15px; border: 1px solid rgba(120,168,142,.3); border-radius: 9px; background: #15221b; color: #b7d5c1; font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(12px); transition: 180ms ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateY(0); }

dialog { color: var(--text); }
dialog::backdrop { background: rgba(3,5,8,.78); backdrop-filter: blur(6px); }
.command-dialog, .reference-dialog, .record-dialog { padding: 0; border: 1px solid var(--line-strong); border-radius: 18px; background: #11151b; box-shadow: var(--shadow); }
.command-dialog { width: min(680px, calc(100vw - 28px)); margin-top: 12vh; }
.dialog-shell { padding: 10px; }
.search-field { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 3px; padding: 5px 7px 5px 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: #0b0e12; color: var(--muted); }
.search-field input { height: 45px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; }
.close-button { padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--muted); font-size: 10px; }
.search-meta { display: flex; justify-content: space-between; padding: 10px 9px 7px; color: var(--muted); font-size: 10px; }
.search-results { max-height: 55vh; overflow-y: auto; }
.search-result { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 11px 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; cursor: pointer; }
.search-result:hover, .search-result.selected { background: rgba(201,164,94,.08); }
.result-icon { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; color: var(--gold); }
.search-result strong { display: block; margin-bottom: 3px; font-size: 12px; }
.search-result small { display: block; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.result-type { color: #7d8085; font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }

.reference-dialog { width: min(920px, calc(100vw - 28px)); }
.reference-shell { padding: 24px; }
.record-dialog { width: min(700px, calc(100vw - 28px)); }
.record-shell { padding: 24px; }
.record-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.record-fields label { display: grid; gap: 7px; color: var(--soft); font-size: 12px; }
.record-wide { grid-column: 1 / -1; }
.relationship-editor { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(7,10,14,.45); }
.record-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.dialog-heading h2 { margin: 0; }
.close-round { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: var(--panel-2); color: var(--muted); font-size: 20px; cursor: pointer; }
.reference-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.reference-item { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #0d1015; }
.reference-item h3 { margin-bottom: 6px; color: var(--gold-bright); }
.reference-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

@media (max-width: 1120px) {
  .content-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .pantheon-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .spell-row { grid-template-columns: minmax(150px,1fr) 70px 88px; }
  .spell-row small:last-child { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: 1fr; }
  .character-stats { display: grid; grid-template-columns: minmax(190px,.55fr) minmax(0,1.45fr); gap: 0 18px; }
  .character-stats .card-header, .character-stats .core-stats, .character-stats .stat-note { grid-column: 1; }
  .character-stats .stat-section { grid-column: 2; }
  .character-stats .stat-section:nth-of-type(2) { grid-row: 1 / span 2; margin-top: 0; }
}

@media (max-width: 860px) {
  .sidebar { inset: auto 0 0; width: 100%; height: calc(67px + env(safe-area-inset-bottom)); padding: 7px 10px env(safe-area-inset-bottom); border: 0; border-top: 1px solid var(--line); z-index: 50; }
  .brand, .sidebar-footer { display: none; }
  .main-nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .nav-item { justify-content: center; width: auto; min-width: 68px; height: 51px; padding: 0 9px; flex-direction: column; gap: 2px; font-size: 9px; }
  .nav-item > span:first-child { width: auto; font-size: 16px; }
  .main-content { margin-left: 0; padding: calc(82px + env(safe-area-inset-top)) 20px calc(98px + env(safe-area-inset-bottom)); }
  .dashboard-grid, .profile-layout { grid-template-columns: 1fr; }
  .dashboard-main { grid-template-rows: auto; }
  .topbar { position: fixed; inset: 0 0 auto; z-index: 40; min-height: calc(72px + env(safe-area-inset-top)); padding: calc(11px + env(safe-area-inset-top)) 20px 11px; background: rgba(9,11,15,.97); box-shadow: 0 8px 24px rgba(0,0,0,.28); }
  .topbar h1 { font-size: 27px; }
  .topbar .eyebrow { margin-bottom: 4px; }
  .mobile-brand-mark { display: block; }
  .view { width: 100%; min-width: 0; padding-top: 14px; }
  .card, .card-pad, .stack, .dashboard-grid { min-width: 0; }
  .button.secondary { display: none; }
  .mobile-search { display: inline-block; }
  .journal-layout { grid-template-columns: 1fr; }
  .journal-list { max-height: 230px; overflow-y: auto; }
  .reference-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .spell-slot-strip { grid-template-columns: repeat(3, 1fr); }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .bestiary-hero { align-items: stretch; flex-direction: column; }
  .bestiary-totals { width: 100%; }
  .bestiary-toolbar { grid-template-columns: 1fr 1fr; }
  .bestiary-search { grid-column: 1 / -1; }
  .creature-combat-stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .creature-abilities { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 620px) {
  .main-content { padding-right: 12px; padding-left: 12px; }
  .topbar { padding-right: 12px; padding-left: 12px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .primary { width: 39px; padding: 0; overflow: hidden; color: transparent; }
  .topbar-actions .primary::first-letter { color: #111218; }
  .resource-grid, .content-grid, .pantheon-grid, .reference-grid { grid-template-columns: 1fr; }
  .content-card.featured { grid-column: auto; }
  .quick-grid { grid-template-columns: 1fr; }
  .section-toolbar { align-items: stretch; flex-direction: column; }
  .inline-search { min-width: 0; width: 100%; }
  .card-pad { padding: 15px; }
  .card-header { flex-direction: column; align-items: stretch; gap: 11px; }
  .spell-list { gap: 7px; }
  .spell-row, .spell-row.expanded { grid-template-columns: minmax(0,1fr) auto; gap: 8px 10px; padding: 12px; overflow: hidden; }
  .spell-row > strong { grid-column: 1; grid-row: 1; min-width: 0; overflow-wrap: anywhere; }
  .spell-row > .spell-level { grid-column: 2; grid-row: 1; justify-self: end; white-space: nowrap; }
  .spell-row > .tag { grid-column: 1; grid-row: 2; justify-self: start; max-width: 100%; white-space: normal; }
  .spell-row > .spell-distance { grid-column: 2; grid-row: 2; justify-self: end; min-width: 0; max-width: 130px; text-align: right; overflow-wrap: anywhere; }
  .spell-row > .spell-expand { grid-column: 1 / -1; grid-row: 3; min-width: 0; padding: 12px 0 2px; }
  .spell-facts { display: grid; grid-template-columns: 1fr; }
  .spell-detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .spell-facts .tag { width: fit-content; max-width: 100%; white-space: normal; line-height: 1.35; }
  .spell-text { overflow-wrap: anywhere; }
  .spell-actions { align-items: stretch; flex-direction: column; }
  .spell-source-link { width: 100%; margin-right: 0; text-align: center; }
  .use-spell { width: 100%; }
  .editor-fields { grid-template-columns: 1fr; }
  .editor-footer { align-items: stretch; flex-direction: column; gap: 10px; }
  .editor-footer > div { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .nav-item { padding: 0 8px; }
  .character-stats { display: block; }
  .mode-picker { width: 100%; justify-content: space-between; }
  .mode-picker select { min-width: 0; flex: 1; }
  .loadout-banner { flex-direction: column; }
  .comparison-footnotes { grid-template-columns: 1fr; }
  .spell-slot-strip { grid-template-columns: repeat(2, 1fr); }
  .loadout-banner { padding: 13px; }
  .prb-plan-grid { grid-template-columns: 1fr; }
  .prb-step-wide { grid-column: auto; }
  .prb-plan summary > span:first-child { align-items: flex-start; flex-direction: column; gap: 2px; }
  .comparison-wrap { border-radius: 13px; }
  .comparison-table { min-width: 650px; }
  .comparison-row { grid-template-columns: 150px repeat(3, minmax(115px,1fr)); }
  .comparison-row > div { padding: 8px 10px; }
  .comparison-row > div:first-child { position: sticky; left: 0; z-index: 1; background: #12171e; box-shadow: 8px 0 14px rgba(0,0,0,.2); }
  .comparison-header > div:first-child { z-index: 3; background: #171c24; }
  .command-dialog, .reference-dialog, .record-dialog { max-height: calc(100dvh - 28px); overflow-y: auto; }
  .reference-shell { padding: 17px; }
  .record-shell { padding: 17px; }
  .record-fields { grid-template-columns: 1fr; }
  .record-wide { grid-column: auto; }
  .toolbar-actions { align-items: stretch; width: 100%; }
  .toolbar-actions .inline-search { flex: 1; }
  .bestiary-hero { padding: 17px; }
  .bestiary-hero h2 { font-size: 25px; }
  .bestiary-actions { align-items: stretch; flex-direction: column; }
  .bestiary-actions .button { width: 100%; }
  .creature-add-form { grid-template-columns: 1fr; }
  .creature-add-notes, .creature-add-form > .button { grid-column: auto; }
  .creature-add-form > .button { width: 100%; }
  .bestiary-totals { grid-template-columns: repeat(3,1fr); gap: 6px; }
  .bestiary-totals div { min-width: 0; padding: 9px 5px; }
  .bestiary-totals strong { font-size: 20px; }
  .bestiary-toolbar { grid-template-columns: 1fr; }
  .bestiary-search { grid-column: auto; }
  .bestiary-result-line { align-items: flex-start; flex-direction: column; }
  .bestiary-table { overflow: visible; border: 0; border-radius: 0; }
  .bestiary-header { display: none; }
  .bestiary-entry { margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(12,15,20,.55); }
  .bestiary-summary { grid-template-columns: 58px minmax(0,1fr) 32px; gap: 0; min-height: 0; }
  .bestiary-summary > div { padding: 11px; }
  .bestiary-summary .bestiary-cr { grid-column: 1; grid-row: 1; }
  .bestiary-summary .bestiary-name { grid-column: 2; grid-row: 1; }
  .bestiary-summary > div:nth-child(3) { grid-column: 1 / -1; grid-row: 2; border-top: 1px solid var(--line); }
  .bestiary-summary > div:nth-child(4) { grid-column: 1 / 2; grid-row: 3; border-top: 1px solid var(--line); }
  .bestiary-summary > div:nth-child(5) { grid-column: 2 / -1; grid-row: 3; border-top: 1px solid var(--line); }
  .creature-expand-icon { grid-column: 3; grid-row: 1; }
  .mobile-cell-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
  .creature-statblock { padding: 17px 15px 20px; }
  .creature-stat-heading { flex-direction: column; }
  .creature-stat-heading .button { width: 100%; text-align: center; }
  .creature-combat-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .creature-abilities { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .creature-details p { grid-template-columns: 1fr; gap: 3px; }
  .creature-statblock-missing, .creature-player-record { grid-template-columns: 1fr; }
  .creature-note-actions { align-items: stretch; flex-direction: column; }
  .creature-entry-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .creature-note-actions > .button { width: 100%; }
  .creature-edit-form { grid-template-columns: 1fr; }
  .creature-edit-form .button { width: 100%; }
}

@media (max-width: 390px) {
  .topbar h1 { font-size: 23px; }
  .topbar-actions .mobile-search { width: 36px; min-height: 36px; }
  .topbar-actions .primary { width: 36px; min-height: 36px; }
  .resource-grid { gap: 8px; }
  .resource { padding: 12px; }
  .spell-slot-strip { gap: 6px; }
  .slot-summary { padding: 9px; }
}
