:root {
  --bg: #0d1420;
  --bg-2: #131d2d;
  --card: #18243a;
  --card-edge: #2a3b58;
  --ink: #e7ecf3;
  --ink-dim: #9aa8bd;
  --storm: #6fd3ff;
  --order: var(--storm);
  --gold: #d9b45a;
  --danger: #e0604f;
  --physical: #e08a4f;
  --cognitive: #6fa8ff;
  --spiritual: #b98bff;
  --health: #e05a5a;
  --focus: #5ab4e0;
  --investiture: #f2e6a0;
  --radius: 10px;
  --serif: "Crimson Pro", Georgia, serif;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, color-mix(in srgb, var(--order) 18%, transparent), transparent 70%),
    radial-gradient(900px 500px at -10% 110%, rgba(111, 211, 255, 0.08), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  padding-bottom: 260px;
}

/* Key art backdrop: fixed, desaturated, and darkened toward the bottom where the sheet is densest. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(13, 20, 32, 0.4) 0%, rgba(13, 20, 32, 0.62) 50%, rgba(13, 20, 32, 0.86) 100%),
    url("assets/key-art.webp") center 30% / cover no-repeat;
  filter: saturate(0.9);
}

h2, h3 {
  font-family: var(--display);
  letter-spacing: 0.06em;
  margin: 0 0 0.6rem;
  color: var(--gold);
}
h2 { font-size: 1rem; border-bottom: 1px solid var(--card-edge); padding-bottom: 0.4rem; }
h2 small { font-family: var(--serif); font-size: 0.75rem; color: var(--ink-dim); letter-spacing: 0; text-transform: none; font-weight: 400; margin-left: 0.4rem; }
h3 { font-size: 0.8rem; margin-top: 0.9rem; color: var(--ink-dim); }

input, select, textarea, button, .btn {
  font: inherit;
  color: var(--ink);
}
input, select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--order) 70%, transparent); outline-offset: 0; }
textarea { width: 100%; resize: vertical; }
input[type="number"] { width: 4.2rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--order); }

button, .btn {
  background: #22324d;
  border: 1px solid var(--card-edge);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { background: #2c4166; border-color: var(--order); }
button.danger:hover, button.danger.armed { border-color: var(--danger); background: #4a2525; }
button.ghost { background: transparent; }
button.icon { background: transparent; border: none; padding: 0.2rem 0.4rem; color: var(--ink-dim); }
button.icon:hover { color: var(--ink); }
button.add { margin-top: 0.5rem; background: transparent; border-style: dashed; color: var(--ink-dim); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.6rem;
  padding: 0.6rem 1.2rem;
  background: rgba(13, 20, 32, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--card-edge);
}
.brand { font-family: var(--display); font-size: 1.1rem; letter-spacing: 0.08em; display: flex; gap: 0.5rem; align-items: center; }
.glyph { color: var(--order); width: 2rem; height: 2rem; filter: drop-shadow(0 0 6px var(--order)); }
.toolbar { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
#charSelect { max-width: 14rem; }

/* Layout */
.sheet { max-width: 1280px; margin: 0 auto; padding: 1rem 1.2rem; }
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 40%), rgba(24, 36, 58, 0.78);
  backdrop-filter: blur(10px) saturate(1.1);
  border: 1px solid rgba(111, 160, 220, 0.22);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
/* The blur makes each card its own stacking context, so lift the one with an open dropdown
   above the cards after it. */
.card:has(.tag-field.open, .menu-wrap.open) { position: relative; z-index: 5; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.span-2 { grid-column: span 2; }
.core-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "attributes resources"
    "skills skills"
    "conditions expertises";
}
.attributes { grid-area: attributes; }
.resources { grid-area: resources; }
.skills { grid-area: skills; }
.conditions { grid-area: conditions; }
.expertises { grid-area: expertises; }

/* Identity */
.identity { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.6rem 0.8rem; border-top: 3px solid var(--order); }
.identity .wide { grid-column: span 2; }
.identity .small output { font-family: var(--display); font-size: 1.3rem; padding: 0.2rem 0; display: block; }
body:not(.is-singer) .singer-only { display: none; }

.field { display: flex; flex-direction: column; gap: 0.2rem; }
.field label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); }
.field input:not([type="checkbox"]), .field select { width: 100%; }
.field.inline { margin-top: 0.6rem; flex-direction: row; align-items: center; gap: 0.5rem; }
.field.inline label { font-size: 0.85rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.field.inline input[type="number"] { width: 4.2rem; }
.tiny { font-size: 0.72rem; color: var(--ink-dim); display: inline-flex; align-items: center; gap: 0.3rem; }
.tiny input { width: 3.4rem; padding: 0.1rem 0.3rem; font-size: 0.85rem; }
.hint { color: var(--ink-dim); font-size: 0.85rem; margin: 0.4rem 0; }

/* Tabs */
.tabs { display: flex; gap: 0.3rem; margin: 1rem 0 0.8rem; border-bottom: 1px solid var(--card-edge); }
.tab {
  background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  font-family: var(--display); letter-spacing: 0.06em; color: var(--ink-dim); padding: 0.5rem 0.9rem;
}
.tab:hover { background: transparent; color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--order); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Attributes */
.attr-groups { display: flex; flex-direction: column; gap: 0.7rem; }
.attr-group {
  display: grid; grid-template-columns: 1fr auto; gap: 0.8rem; align-items: center;
  padding: 0.6rem; border-radius: 8px; background: var(--bg-2);
  border-left: 3px solid var(--grp);
}
.attr-group.physical, .skill-col.physical { --grp: var(--physical); }
.attr-group.cognitive, .skill-col.cognitive { --grp: var(--cognitive); }
.attr-group.spiritual, .skill-col.spiritual { --grp: var(--spiritual); }
/* Fixed columns (wide enough for "Willpower") so scores line up across groups */
.attr-pair { display: grid; grid-template-columns: repeat(2, 5rem); gap: 0.8rem; }
.attr { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.attr-score {
  width: 3.6rem !important; padding-inline: 0; text-align: center;
  font-family: var(--display); font-size: 1.4rem;
  appearance: textfield; -moz-appearance: textfield;
}
/* The spinner takes up width and would push the digit off center */
.attr-score::-webkit-inner-spin-button, .attr-score::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.defense { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; min-width: 7.5rem; }
.defense-value {
  font-family: var(--display); font-size: 1.8rem; line-height: 1;
  width: 3.4rem; height: 3.4rem; display: grid; place-items: center;
  border: 2px solid var(--grp); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: 0 0 12px color-mix(in srgb, var(--grp) 35%, transparent) inset;
}
.defense-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }

.roll-link { background: none; border: none; padding: 0; text-align: left; cursor: pointer; }
.roll-link:hover { background: none; color: var(--order); text-decoration: underline dotted; }
.attr-name { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }

/* Resources */
.tracker { margin-bottom: 0.8rem; }
.tracker.muted { opacity: 0.5; }
.tracker-head { display: flex; justify-content: space-between; align-items: baseline; }
.tracker-name { font-family: var(--display); letter-spacing: 0.05em; }
.tracker-nums { font-family: var(--display); font-size: 1.1rem; }
.tracker-current { width: 4rem !important; text-align: right; font-family: var(--display); font-size: 1.1rem; padding: 0.1rem 0.3rem; }
.bar { height: 10px; background: var(--bg-2); border-radius: 6px; overflow: hidden; margin: 0.35rem 0; border: 1px solid var(--card-edge); }
.bar-fill { height: 100%; width: 0; transition: width 0.25s ease; }
.health .bar-fill { background: linear-gradient(90deg, #8f2b2b, var(--health)); }
.focus .bar-fill { background: linear-gradient(90deg, #2b5f8f, var(--focus)); }
.investiture .bar-fill { background: linear-gradient(90deg, #b9d9f0, var(--investiture)); box-shadow: 0 0 10px #fff8; }
.tracker-controls { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.tracker-amount { width: 3.4rem !important; }
.tracker-controls button { padding: 0.15rem 0.6rem; }

.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.4rem; margin-top: 0.6rem; }
.stat { background: var(--bg-2); border-radius: 8px; padding: 0.45rem; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 0.2rem; }
.stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }
.stat-value { font-family: var(--display); font-size: 1rem; }
.stat-value.clickable { cursor: pointer; color: var(--order); }

/* Skills */
.skill-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.skill-col { padding: 0 1.6rem; }
.skill-col:first-child { padding-left: 0; }
.skill-col:last-child { padding-right: 0; }
.skill-col + .skill-col { border-left: 1px solid rgba(111, 160, 220, 0.18); }
.skill-col h3 { margin-top: 0; color: var(--grp); }
/* Cells are placed explicitly so rows stay aligned whether or not they have an
   Erudition toggle (hidden for non-Scholars, absent on surges). */
.skill-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto 2.4rem; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0; border-bottom: 1px dotted rgba(255, 255, 255, 0.07);
}
.skill-row .skill-name { grid-column: 1; }
.skill-row .boost-toggle { grid-column: 2; }
.skill-row .skill-attr { grid-column: 3; }
.skill-row .pips { grid-column: 4; }
.skill-row .skill-mod { grid-column: 5; }
/* Names may shrink and truncate so long ones can't push their row's pips/modifier out of line. */
.skill-name { font-size: 0.98rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skill-attr { font-size: 0.65rem; color: var(--ink-dim); letter-spacing: 0.06em; }
.skill-mod { font-family: var(--display); text-align: right; }
.pips { display: inline-flex; gap: 3px; }
.pip {
  width: 13px; height: 13px; padding: 0; border-radius: 2px; transform: rotate(45deg);
  background: transparent; border: 1px solid var(--ink-dim);
}
.pip:hover { border-color: var(--order); background: transparent; }
.pip.on { background: var(--order); border-color: var(--order); box-shadow: 0 0 6px var(--order); }

/* Erudition: bonus ranks from the Scholar key talent */
.erudition-ctl {
  display: none; float: right; align-items: center; gap: 0.3rem;
  font-family: var(--serif); font-size: 0.8rem; letter-spacing: 0; color: var(--gold);
}
.erudition-ctl input { width: 3rem; padding: 0.05rem 0.3rem; font-size: 0.8rem; }
.erudition-ctl.over { color: var(--danger); }
body.show-erudition .erudition-ctl { display: inline-flex; }
.boost-toggle { display: none; background: none; border: none; padding: 0 0.15rem; font-size: 0.8rem; color: var(--ink-dim); opacity: 0.35; }
.boost-toggle:hover { background: none; opacity: 1; color: var(--gold); }
body.show-erudition .boost-toggle { display: inline-block; }
.skill-row.boosted .boost-toggle, .boost-toggle.on { opacity: 1; color: var(--gold); text-shadow: 0 0 6px var(--gold); }
.skill-row.boosted .skill-mod { color: var(--gold); }
.pip.bonus { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 6px var(--gold); }

/* Conditions */
.condition-grid { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip { border-radius: 999px; padding: 0.2rem 0.7rem; font-size: 0.85rem; color: var(--ink-dim); background: transparent; }
.chip.on { background: color-mix(in srgb, var(--danger) 30%, transparent); border-color: var(--danger); color: var(--ink); }
.chip[data-condition="determined"].on, .chip[data-condition="empowered"].on,
.chip[data-condition="enhanced"].on, .chip[data-condition="focused"].on {
  background: color-mix(in srgb, var(--storm) 25%, transparent); border-color: var(--storm);
}

/* Lists */
.list { display: flex; flex-direction: column; gap: 0.4rem; }
.list-item { display: flex; gap: 0.4rem; align-items: center; }
.list-item > .weapon, .list-item > .talent, .list-item > .goal, .list-item > .connection, .list-item > .armor-item { flex: 1; min-width: 0; }
/* Armor: equipped, name, deflect on one line; traits underneath, lined up with the name */
.armor-item { display: grid; grid-template-columns: auto 1fr auto; gap: 0.4rem; align-items: center; }
.armor-item > .tag-field { grid-column: 2 / -1; }
.armor-item > .check { grid-row: span 2; }
.grow { flex: 1; min-width: 0; }
.short { width: 4.6rem !important; }
.check { display: flex; align-items: center; }

/* Drag to reorder */
.drag-handle {
  align-self: center; padding: 0.35rem 0.2rem; font-size: 1rem; line-height: 1;
  cursor: grab; touch-action: none; opacity: 0.45;
}
.list-item:hover .drag-handle, .drag-handle:focus-visible { opacity: 1; }
.list-item.dragging {
  position: relative; z-index: 5; border-radius: 8px;
  outline: 1px solid var(--order); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  background: color-mix(in srgb, var(--order) 10%, var(--card));
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

/* Per-item side controls: ⋮ menu + remove */
.item-side { display: flex; align-items: center; gap: 0.1rem; align-self: center; }
.menu-wrap { position: relative; }
.kebab { font-size: 1.1rem; line-height: 1; padding: 0.2rem 0.45rem; border-radius: 6px; }
.menu-wrap.open .kebab { color: var(--ink); background: var(--bg-2); }
.menu {
  display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 15; min-width: 13rem;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 8px; padding: 0.3rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.menu-wrap.open .menu { display: flex; flex-direction: column; }
.menu button { background: transparent; border: none; text-align: left; padding: 0.4rem 0.6rem; border-radius: 5px; white-space: nowrap; }
.menu button:hover { background: #2c4166; }
.menu hr { border: none; border-top: 1px solid var(--card-edge); margin: 0.25rem 0; width: 100%; }
.menu .menu-item { cursor: pointer; padding: 0.4rem 0.6rem; border-radius: 5px; white-space: nowrap; font-size: 0.9rem; }
.menu .menu-item:hover { background: #2c4166; }
.menu button.danger:hover, .menu button.danger.armed { background: #4a2525; }
.empty { font-style: italic; }

/* Tag fields (weapon and armor traits): chips plus a text box, styled as one input */
.tag-field {
  position: relative; flex: 1.6; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem;
  background: var(--bg-2); border: 1px solid var(--card-edge); border-radius: 6px;
  padding: 0.2rem 0.3rem; cursor: text;
}
.tag-field:focus-within { outline: 2px solid color-mix(in srgb, var(--order) 70%, transparent); }
.tag-input { flex: 1; min-width: 4rem; border: none; background: transparent; padding: 0.1rem 0.2rem; }
.tag-input:focus { outline: none; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 0.15rem;
  padding: 0 0.15rem 0 0.55rem; border-radius: 999px; font-size: 0.95rem; line-height: 1.4;
  background: color-mix(in srgb, var(--order) 18%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--order) 45%, var(--card-edge));
}
.tag-remove { background: none; border: none; padding: 0 0.25rem; font-size: 0.7rem; color: var(--ink-dim); cursor: pointer; }
.tag-remove:hover { background: none; color: var(--ink); }
.tag-suggest {
  display: none; position: absolute; left: 0; top: calc(100% + 4px); z-index: 15; min-width: 13rem;
  max-height: 14rem; overflow-y: auto; scrollbar-color: var(--card-edge) transparent;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 8px; padding: 0.3rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.tag-field.open .tag-suggest { display: block; }
.tag-option { padding: 0.3rem 0.6rem; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.tag-option small { color: var(--ink-dim); }
.tag-option:hover, .tag-option.active { background: #2c4166; }
.tag-option.custom { color: var(--gold); }

.weapon {
  display: grid; grid-template-columns: 2fr 1.3fr auto 1fr auto; gap: 0.4rem;
  padding: 0.5rem; background: var(--bg-2); border-radius: 8px;
}
.weapon .name { font-weight: 600; }
.weapon > .tag-field { grid-column: 1 / 3; }
.weapon-actions { grid-column: 3 / 6; display: flex; gap: 0.4rem; justify-content: flex-end; align-items: center; }
.weapon-actions .mod { color: var(--order); font-family: var(--display); }
.weapon-actions button { padding: 0.25rem 0.55rem; font-size: 0.82rem; }
.attack-btn { font-weight: 600; border-color: color-mix(in srgb, var(--order) 60%, var(--card-edge)); }
.segmented { display: inline-flex; }
.segmented button { border-radius: 0; margin-left: -1px; color: var(--ink-dim); background: transparent; }
.segmented button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 6px 6px 0; }
.segmented button.on { color: var(--ink); background: #2c4166; border-color: var(--order); position: relative; }
.stakes-toggle { color: var(--ink-dim); background: transparent; }
.stakes-toggle.on { color: var(--gold); border-color: var(--gold); background: color-mix(in srgb, var(--gold) 15%, transparent); }

/* Stormlight charges (fabrials, infused weapons) */
.weapon-charges { grid-column: 1 / -1; display: none; align-items: center; font-size: 0.85rem; }
.weapon.has-charges .weapon-charges { display: flex; }
.charge-counter { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.charge-label { color: var(--ink-dim); margin-right: 0.3rem; }

.weapon-details { grid-column: 1 / -1; display: none; flex-direction: column; gap: 0.2rem; }
.weapon.has-details .weapon-details { display: flex; }
.weapon-details label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); }
.charge-counter input.short { width: 3.4rem !important; text-align: center; }
.charge-counter button { padding: 0.1rem 0.55rem; }
.charge-dots { display: inline-flex; gap: 4px; margin-right: 0.2rem; }
.sphere { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--ink-dim); }
.sphere.lit { background: radial-gradient(circle at 35% 35%, #fff, var(--storm)); border-color: var(--storm); box-shadow: 0 0 6px var(--storm); }
.charge-counter.depleted input { border-color: var(--danger); color: var(--danger); }

.talent { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.5rem; background: var(--bg-2); border-radius: 8px; }
.talent-head { display: flex; gap: 0.4rem; }
.talent .name { font-weight: 600; }
.goal, .connection { display: flex; gap: 0.5rem; align-items: center; }
.connection input:first-child { width: 9rem; }

.currency { display: flex; flex-direction: column; gap: 0.5rem; }
.radiant { border-top: 3px solid var(--order); }
.radiant .field { margin-bottom: 0.5rem; }

/* Dice tray */
.dice-tray {
  position: fixed; right: 1rem; bottom: 1rem; width: min(420px, calc(100vw - 2rem)); z-index: 20;
  background: rgba(19, 29, 45, 0.97); border: 1px solid var(--card-edge); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.tray-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--card-edge); }
.tray-head strong { font-family: var(--display); color: var(--gold); }
.tray-toggles { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; flex: 1; }
.tray-toggles button { padding: 0.2rem 0.55rem; font-size: 0.82rem; }
.dice-tray.collapsed .tray-body { display: none; }
.dice-tray.collapsed #trayToggle { transform: rotate(180deg); }
.tray-body { padding: 0.6rem 0.7rem; }
.custom-roll { display: flex; gap: 0.3rem; }
.custom-roll input { flex: 1; }
.roll-log { list-style: none; margin: 0.6rem 0 0; padding: 0; max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.3rem; }
.roll-log li {
  display: grid; grid-template-columns: 1fr auto; gap: 0 0.5rem; align-items: center;
  padding: 0.35rem 0.5rem; background: var(--bg-2); border-radius: 6px;
}
.roll-log li:first-child { border: 1px solid color-mix(in srgb, var(--order) 60%, transparent); animation: glow 0.6s ease; }
.roll-label { font-weight: 600; }
.roll-total { font-family: var(--display); font-size: 1.4rem; grid-row: span 2; color: var(--order); }
.roll-detail { font-size: 0.8rem; color: var(--ink-dim); }
.roll-totals { grid-row: span 2; display: flex; gap: 0.6rem; align-items: flex-end; }
.roll-part { display: flex; flex-direction: column; align-items: center; font-family: var(--display); font-size: 1.3rem; line-height: 1.1; }
.roll-part small { font-family: var(--serif); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }
.roll-part.hit { color: var(--order); }
.roll-part.dmg { color: var(--health); }
.roll-part.graze { color: var(--ink-dim); font-size: 1rem; }
.tag { font-size: 0.72rem; padding: 0.05rem 0.45rem; border-radius: 999px; justify-self: start; margin-top: 0.15rem; }
.tag.opportunity { background: #1f5b3e; color: #b9f5d4; }
.tag.complication { background: #5b1f1f; color: #f5b9b9; }
.tag.blank { background: #2a3448; color: var(--ink-dim); }
@keyframes glow { from { box-shadow: 0 0 18px var(--order); } to { box-shadow: none; } }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform 0.25s, opacity 0.25s, visibility 0s 0.25s;
  background: #22324d; border: 1px solid var(--card-edge); padding: 0.5rem 1rem; border-radius: 8px; z-index: 30;
}
.toast.show {
  transform: translate(-50%, 0); opacity: 1; visibility: visible;
  transition: transform 0.25s, opacity 0.25s, visibility 0s;
}

.confirm { background: #1b2740; color: var(--ink); border: 1px solid var(--card-edge); border-radius: 10px; padding: 1.1rem 1.3rem; max-width: 26rem; }
.confirm::backdrop { background: rgba(0, 0, 0, 0.55); }
.confirm p { margin: 0 0 1rem; line-height: 1.4; }
.confirm.history { max-width: 38rem; width: 90vw; max-height: 80vh; }
.confirm.history h3 { margin: 0 0 0.4rem; }
.confirm.history .hint { color: var(--ink-dim); font-size: 0.9rem; margin-bottom: 0.6rem; }
.history-list { list-style: none; margin: 0 0 1rem; padding: 0; max-height: 40vh; overflow-y: auto; }
.history-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.3rem 0; border-bottom: 1px solid var(--card-edge); font-size: 0.92rem; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* Responsive */
/* Reference tab */
.reference p { margin: 0 0 0.6rem; }
.ref-action { display: grid; grid-template-columns: 2.2rem minmax(0, 1fr); gap: 0.4rem; padding: 0.25rem 0; line-height: 1.35; }
.ref-item { padding: 0.2rem 0; line-height: 1.35; }
.ref-action b, .ref-item b { color: var(--order); font-weight: 600; }
.cost { font-size: 0.75rem; color: var(--gold); letter-spacing: -0.1em; padding-top: 0.2rem; white-space: nowrap; }
.cost-0 { color: var(--ink-dim); }
.cost-R { color: var(--spiritual); font-size: 0.95rem; padding-top: 0; letter-spacing: 0; }
.cost-key { display: block; margin-top: 0.2rem; }
.cost-key .cost { margin-left: 0.6rem; }
.cost-key .cost:first-child { margin-left: 0; }
.ref-item.active { background: color-mix(in srgb, var(--order) 14%, transparent); border-left: 3px solid var(--order); padding-left: 0.5rem; border-radius: 4px; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin: 0.3rem 0 0.6rem; }
.ref-table th { text-align: left; font-family: var(--display); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--ink-dim); font-weight: 400; border-bottom: 1px solid var(--card-edge); padding: 0.3rem 0.4rem; }
.ref-table thead tr:first-child th[colspan] { color: var(--gold); border-bottom: none; padding-bottom: 0; }
.ref-table td { padding: 0.3rem 0.4rem; vertical-align: top; border-bottom: 1px solid rgba(111, 160, 220, 0.1); line-height: 1.3; }
.ref-table td:first-child { white-space: nowrap; }
.ref-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.025); }
/* Full-width cards split their content into two columns. */
.ref-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2rem; }
.ref-cols h3:first-child { margin-top: 0; }
.ref-flow { columns: 2; column-gap: 2rem; }
.ref-flow > div > *, .ref-flow > .ref-item { break-inside: avoid; }
.ref-flow h3 { break-after: avoid; }
.twists td { width: 50%; }
.twists td:first-child { white-space: normal; }
.injury-roll { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.injury-roll strong { font-family: var(--display); font-size: 1.2rem; margin-left: 0.3rem; }
.injury-roll + .hint { margin-top: 0.2rem; }
.ref-credit { text-align: center; margin-top: 1rem; }

@media (max-width: 900px) {
  .identity { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid, .core-grid { grid-template-columns: 1fr; grid-template-areas: "attributes" "resources" "skills" "conditions" "expertises"; }
  .span-2 { grid-column: auto; }
  .ref-cols { grid-template-columns: 1fr; }
  .ref-flow { columns: 1; }
  .skill-columns { grid-template-columns: 1fr; gap: 1rem; }
  .skill-col { padding: 0; }
  .skill-col + .skill-col { border-left: none; border-top: 1px solid rgba(111, 160, 220, 0.18); padding-top: 0.8rem; }
  .stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .weapon { grid-template-columns: 1fr 1fr; }
  .weapon > .tag-field, .weapon-actions { grid-column: 1 / -1; }
}

/* Print: show every tab on light paper, hide controls */
@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 12px; }
  body::before { display: none; }
  .card { backdrop-filter: none; }
  .topbar, .tabs, .dice-tray, .toast, button.add, button.remove, .menu-wrap, .drag-handle, .charge-counter button, .tracker-controls button, .tracker-amount { display: none !important; }
  .tab-panel { display: block !important; margin-top: 0.8rem; break-inside: avoid-page; }
  .tab-panel.reference { display: none !important; }
  .card { background: #fff; border-color: #999; box-shadow: none; break-inside: avoid; }
  input, select, textarea { background: #fff; color: #000; border-color: #bbb; }
  h2, h3, .skill-col h3 { color: #000; }
  .attr-group, .stat, .weapon, .talent { background: #f4f4f4; }
  .pip.on { background: #000; border-color: #000; box-shadow: none; }
  .pip { border-color: #000; }
  .pip.bonus { background: #999; border-color: #000; box-shadow: none; }
  :root { --ink-dim: #444; }
}
