:root {
  color-scheme: dark;
  --terminal: #111513;
  --terminal-2: #1b211e;
  --terminal-3: #262e2a;
  --paper: #f3f3ef;
  --paper-2: #e7e8e4;
  --ink: #242827;
  --muted: #777d7a;
  --line: #303533;
  --hazard: #eab900;
  --hazard-dark: #352c08;
  --danger: #d55c4d;
  --success: #8fbf87;
  --ui-text: #eef1ee;
  --ui-muted: #aab2ad;
  --control-width: 372px;
  font-family: Bahnschrift, "Arial Narrow", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ui-text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--terminal);
  background-size: 32px 32px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
}

button:active,
.button-link:active,
.text-link:active {
  transform: translateY(1px);
}

:focus-visible {
  outline: 3px solid var(--hazard);
  outline-offset: 3px;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #3a423e;
  padding: 8px clamp(14px, 2.4vw, 34px);
  background: rgba(17, 21, 19, 0.96);
  box-shadow: 0 10px 24px rgba(5, 7, 6, 0.34);
}

.app-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
}

.app-mark strong,
.app-mark small {
  display: block;
}

.app-mark strong {
  font-size: 0.92rem;
  letter-spacing: 0.06em;
}

.app-mark small {
  color: var(--ui-muted);
  font-size: 0.68rem;
}

.mark-glyph {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--hazard);
  color: var(--hazard);
  font: 900 1.35rem/1 Bahnschrift, sans-serif;
  transform: skew(-7deg);
}

.app-bar nav {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.4vw, 16px);
  white-space: nowrap;
}

.app-bar nav > a,
.bar-button {
  border: 1px solid #4a534e;
  border-radius: 0;
  padding: 9px 14px;
  background: #1a201d;
  color: var(--ui-text);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.bar-button-primary {
  border-color: var(--hazard);
  background: var(--hazard);
  color: #171a18;
}

.app-layout {
  display: grid;
  grid-template-columns: var(--control-width) minmax(0, 1fr);
  min-height: calc(100dvh - 64px);
}

.control-deck {
  position: relative;
  z-index: 4;
  border-right: 1px solid #3b4540;
  background: #161b18;
  box-shadow: 14px 0 34px rgba(4, 7, 5, 0.28);
}

.control-intro {
  border-bottom: 1px solid #3b4540;
  padding: 28px 24px 24px;
  background:
    linear-gradient(145deg, rgba(234, 185, 0, 0.12), transparent 50%),
    #1b211e;
}

.terminal-label {
  color: var(--hazard);
  font: 800 0.68rem/1.2 Consolas, monospace;
  letter-spacing: 0.14em;
}

.control-intro h1 {
  margin: 8px 0 10px;
  color: #f6f7f4;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  line-height: 1.02;
}

.control-intro p {
  margin: 0 0 14px;
  color: var(--ui-muted);
  font-size: 0.88rem;
  line-height: 1.65;
}

.text-link {
  display: inline-block;
  border-bottom: 1px solid var(--hazard);
  color: var(--hazard);
  font-size: 0.82rem;
  font-weight: 800;
}

.control-section {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  border-bottom: 1px solid #363e3a;
}

.section-index {
  display: grid;
  place-items: start center;
  border-right: 1px solid #363e3a;
  padding-top: 20px;
  color: var(--hazard);
  font: 900 0.78rem/1 Consolas, monospace;
}

.section-content {
  min-width: 0;
  padding: 18px 20px 20px;
}

.section-content h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading-row h2 {
  margin: 0;
}

.field-stack {
  display: grid;
  gap: 12px;
}

.field-pair,
.number-grid {
  display: grid;
  gap: 9px;
}

.field-pair,
.two-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.section-content label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #c7cdc9;
  font-size: 0.72rem;
  font-weight: 800;
}

.section-content input,
.section-content select,
.section-content textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #4a544f;
  border-radius: 0;
  padding: 8px 9px;
  background: #0f1311;
  color: #f1f3ef;
}

.section-content textarea {
  resize: vertical;
  line-height: 1.45;
}

.section-content input:hover,
.section-content select:hover,
.section-content textarea:hover {
  border-color: #7a847f;
}

.section-content input:focus,
.section-content select:focus,
.section-content textarea:focus {
  border-color: var(--hazard);
  outline: 1px solid var(--hazard);
  outline-offset: 0;
}

.number-grid input {
  padding-inline: 4px;
  text-align: center;
  font-family: Consolas, monospace;
  font-weight: 800;
}

.rule-line,
.autosave-note {
  margin: 0 0 12px;
  color: var(--ui-muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.field-hint {
  margin: -4px 0 0;
  color: var(--ui-muted);
  font-size: 0.66rem;
  line-height: 1.45;
}

.mini-action {
  flex: 0 0 auto;
  border: 1px solid #68716d;
  border-radius: 0;
  padding: 5px 8px;
  background: transparent;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
}

.mini-action:hover {
  border-color: var(--hazard);
  color: var(--hazard);
}

.class-readout {
  margin-top: 12px;
  border-left: 3px solid var(--hazard);
  padding: 9px 10px;
  background: #202722;
  color: #bfc6c1;
  font-size: 0.74rem;
  line-height: 1.55;
}

.roll-code {
  float: right;
  color: var(--hazard);
  font: 700 0.66rem/1 Consolas, monospace;
}

.validation-panel {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  margin: 18px 20px;
  border: 1px solid #4b5550;
  padding: 12px;
  background: #1d2420;
}

.validation-panel.is-valid {
  border-color: #6f956a;
}

.validation-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  background: var(--hazard);
  color: #161a18;
  font-weight: 900;
}

.validation-panel.is-valid .validation-icon {
  background: var(--success);
}

.validation-panel strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.82rem;
}

.validation-panel p {
  margin: 0;
  color: var(--ui-muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.control-actions {
  display: grid;
  gap: 8px;
  padding: 0 20px 10px;
}

.action-primary,
.action-secondary {
  min-height: 44px;
  border-radius: 0;
  font-weight: 900;
  cursor: pointer;
}

.action-primary {
  border: 1px solid var(--hazard);
  background: var(--hazard);
  color: #171a18;
}

.action-secondary {
  border: 1px solid #515b56;
  background: transparent;
  color: #d7dcd8;
}

.autosave-note {
  margin: 0;
  padding: 0 20px 28px;
  text-align: center;
}

.sheet-stage {
  min-width: 0;
  overflow-x: auto;
  padding: clamp(18px, 3vw, 46px);
  background:
    radial-gradient(circle at 50% 0%, #38403c, transparent 46rem),
    #242b27;
}

.sheet-toolbar {
  display: flex;
  width: 210mm;
  min-width: 210mm;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 12px;
  color: #cbd1cd;
  font-size: 0.76rem;
}

.sheet-toolbar strong {
  color: #f2f4f1;
}

.sheet-page {
  position: relative;
  width: 210mm;
  height: 297mm;
  min-width: 210mm;
  min-height: 297mm;
  margin: 0 auto 34px;
  overflow: hidden;
  border: 1px solid #9da29f;
  padding: 8mm;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 28px 70px rgba(4, 7, 5, 0.42);
}

.sheet-page::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 12px;
  height: 12px;
  border-right: 2px solid #b5b9b6;
  border-bottom: 2px solid #b5b9b6;
}

.sheet-header {
  display: grid;
  height: 17mm;
  grid-template-columns: minmax(0, 1fr) 150px 70px;
  align-items: end;
  gap: 10px;
  border: 3px solid var(--ink);
  border-top-width: 1px;
  border-radius: 18px 18px 0 0;
  padding: 9px 12px 7px;
}

.sheet-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.3rem;
  font-weight: 950;
  line-height: 0.92;
  letter-spacing: -0.04em;
}

.sheet-logo small {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
}

.sheet-logo-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 3px solid var(--ink);
  font-size: 1.7rem;
  transform: skew(-8deg);
}

.header-field {
  min-width: 0;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
}

.header-field span,
.back-identity span {
  display: block;
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 900;
  text-transform: uppercase;
}

.header-field strong,
.back-identity strong {
  display: block;
  min-height: 17px;
  overflow: hidden;
  font-size: 0.72rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.front-top-grid {
  display: grid;
  height: 56mm;
  grid-template-columns: 0.92fr 1.08fr;
  gap: 3mm;
  margin-top: 3mm;
}

.sheet-block {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--paper-2);
}

.sheet-block h2 {
  margin: 0;
  border-bottom: 2px solid var(--ink);
  padding: 5px 8px 4px;
  font-size: 0.76rem;
  line-height: 1.1;
  text-transform: uppercase;
}

.numbered-block h2 b,
.back-header h2 b {
  color: #747a77;
  font-size: 1.05rem;
}

.dark-block {
  border-radius: 16px 16px 0 0;
  padding: 7px;
  background: var(--ink);
  color: var(--paper);
}

.dark-block h2 {
  border: 0;
  padding: 0 4px 5px;
  text-align: center;
}

.sheet-field {
  margin-bottom: 6px;
}

.sheet-field:last-child {
  margin-bottom: 0;
}

.sheet-field span {
  display: block;
  margin: 0 3px 2px;
  font-size: 0.54rem;
  font-weight: 900;
}

.sheet-field strong,
.sheet-field p {
  display: block;
  min-height: 27px;
  margin: 0;
  overflow: hidden;
  padding: 5px 7px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.68rem;
  line-height: 1.35;
}

.personal-block .sheet-field strong {
  height: 19mm;
  padding: 7mm 8px 4px;
  font-size: 0.86rem;
}

.stat-stack {
  display: grid;
  height: 56mm;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.orb-row {
  display: grid;
  align-items: start;
  gap: 8px;
  padding: 10px;
}

.four-orbs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.three-orbs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-inline: 30px;
}

.orb-stat {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.orb-stat output {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  font: 900 1.05rem/1 Consolas, monospace;
}

.orb-stat span {
  font-size: 0.58rem;
  font-weight: 950;
}

.class-block,
.vitals-grid,
.trauma-block,
.loadout-block {
  margin-top: 3mm;
}

.class-block {
  height: 34mm;
}

.class-grid,
.class-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  padding: 8px;
}

.class-card,
.summary-card {
  min-width: 0;
  padding: 6px;
  background: var(--paper);
}

.class-card.is-active,
.summary-card.is-active {
  box-shadow: inset 0 0 0 3px var(--ink);
}

.class-card strong,
.summary-card strong {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  padding: 3px 5px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.59rem;
}

.class-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
}

.is-active .class-dot {
  background: currentColor;
  box-shadow: inset 0 0 0 2px var(--ink);
}

.class-card span,
.summary-card span {
  display: block;
  margin: 2px 0;
  color: #565c59;
  font-size: 0.5rem;
  font-weight: 800;
  line-height: 1.22;
}

.vitals-grid {
  display: grid;
  height: 34mm;
  grid-template-columns: minmax(0, 1fr) 0.34fr;
  gap: 9px;
}

.vital-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 12px 18px;
}

.single-vital {
  grid-template-columns: 1fr;
  padding-inline: 12px;
}

.vital-values > div {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.vital-values span {
  font-size: 0.58rem;
  font-weight: 950;
}

.vital-values strong {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--paper);
  text-align: center;
  font: 900 0.92rem/1 Consolas, monospace;
}

.vital-values strong i {
  font-style: normal;
  font-weight: 400;
}

.vital-values small {
  color: #6e7471;
  font-size: 0.47rem;
  font-weight: 800;
}

.trauma-list {
  display: grid;
  gap: 4px;
  padding: 7px 9px 8px;
}

.trauma-block {
  height: 36mm;
}

.trauma-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  min-height: 20px;
  padding: 3px 6px;
  background: #7d8380;
  color: var(--paper);
  font-size: 0.49rem;
  font-weight: 800;
}

.trauma-row strong {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fff;
}

.trauma-row.is-active {
  background: var(--ink);
}

.loadout-block {
  position: relative;
  height: 84mm;
  min-height: 84mm;
  background: var(--paper);
}

.loadout-fields {
  display: grid;
  gap: 7px;
  padding: 12px 12px 62px;
}

.equipment-copy {
  height: 28mm;
  min-height: 28mm;
  overflow: hidden;
  border-bottom: 1px solid #a1a6a3;
  padding: 4px;
  font-size: 0.7rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.small-line {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  border-bottom: 1px solid #a1a6a3;
  padding: 4px;
  font-size: 0.62rem;
}

.small-line strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.small-line span {
  color: #6e7471;
  font-weight: 900;
}

.loadout-footer {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.armor-chip span,
.credit-chip span {
  display: block;
  color: #636966;
  font-size: 0.5rem;
  font-weight: 900;
}

.armor-chip strong {
  display: grid;
  width: 78px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font: 900 0.95rem/1 Consolas, monospace;
}

.credit-chip {
  text-align: right;
}

.credit-chip strong {
  font: 900 1rem/1 Consolas, monospace;
}

.back-header {
  display: grid;
  height: 20mm;
  grid-template-columns: minmax(0, 1fr) 130px;
  gap: 20px;
  align-items: end;
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 10px 14px;
}

.back-header h2 {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
}

.back-header p {
  margin: 4px 0 0 20px;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
}

.back-identity {
  min-width: 0;
  border-bottom: 1px solid var(--ink);
}

.class-summary-grid {
  height: 31mm;
  border: 3px solid var(--ink);
  border-top: 0;
  background: var(--paper-2);
}

.summary-card {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.skill-tree {
  display: grid;
  height: 145mm;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 3mm;
  overflow: hidden;
  border: 3px solid var(--ink);
  padding: 12px;
  background: var(--paper);
}

.skill-column {
  min-width: 0;
}

.skill-column h3 {
  margin: 0 0 8px;
  padding: 8px;
  background: var(--paper-2);
  font-size: 0.82rem;
  line-height: 1.05;
}

.skill-column h3 small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.58rem;
}

.skill-list {
  display: grid;
  gap: 2px;
}

.skill-node {
  position: relative;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 5px;
  align-items: center;
  min-height: 27px;
  border: 1px solid transparent;
  padding: 3px 4px;
  color: #373c39;
  cursor: pointer;
}

.skill-node:hover {
  border-color: #8a908d;
  background: #ebede9;
}

.skill-node input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.skill-check {
  display: inline-grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}

.skill-node.is-selected .skill-check::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
}

.skill-node.is-required {
  background: #dfe2dd;
}

.skill-node.is-invalid {
  border-color: #8c332a;
}

.skill-copy {
  min-width: 0;
}

.skill-name {
  display: block;
  font-size: 0.55rem;
  font-weight: 950;
  line-height: 1.1;
}

.prereq {
  display: block;
  margin-top: 2px;
  color: #7a807d;
  font-size: 0.43rem;
  line-height: 1.1;
}

.back-fields {
  display: grid;
  height: 28mm;
  grid-template-columns: 1fr 1.4fr;
  gap: 3mm;
  margin-top: 3mm;
}

.training-block,
.condition-block {
  display: grid;
  gap: 5px;
  border: 3px solid var(--ink);
  padding: 8px;
  background: var(--paper-2);
  overflow: hidden;
}

.training-block {
  grid-template-columns: 1fr 1fr;
}

.training-block h3,
.condition-block h3 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.65rem;
}

.training-block div,
.condition-block p {
  min-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 5px;
  background: var(--paper);
  font-size: 0.58rem;
}

.training-block span {
  display: block;
  color: var(--muted);
  font-size: 0.48rem;
  font-weight: 800;
}

.training-block strong {
  display: block;
  margin-top: 3px;
}

.condition-block p {
  height: 15mm;
  white-space: pre-wrap;
}

.personal-notes-block {
  height: 38mm;
  margin-top: 3mm;
  overflow: hidden;
  border: 3px solid var(--ink);
  background: var(--paper-2);
}

.personal-notes-block h3 {
  height: 8mm;
  margin: 0;
  border-bottom: 2px solid var(--ink);
  padding: 6px 8px 4px;
  font-size: 0.67rem;
  line-height: 1;
  text-transform: uppercase;
}

.personal-notes-block p {
  height: 30mm;
  margin: 0;
  overflow: hidden;
  padding: 7px 9px;
  background:
    repeating-linear-gradient(to bottom, transparent 0, transparent 19px, #c3c7c3 20px),
    var(--paper);
  font-size: 0.61rem;
  line-height: 20px;
  white-space: pre-wrap;
}

.sheet-footer {
  position: absolute;
  right: 22px;
  bottom: 18px;
  left: 22px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid #a8adaa;
  padding-top: 4px;
  color: #757b78;
  font-size: 0.48rem;
  font-weight: 800;
}

.sheet-footer b {
  color: inherit;
  font: inherit;
}

.notes-page-header {
  display: flex;
  height: 18mm;
  align-items: center;
  justify-content: space-between;
  border: 3px solid var(--ink);
  border-radius: 18px 18px 0 0;
  padding: 7px 12px;
}

.notes-page-header h2 {
  margin: 3px 0 0;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  line-height: 1;
}

.notes-page-header .terminal-label {
  color: var(--muted);
}

.notes-page-header > strong {
  font: 900 0.84rem/1 Consolas, monospace;
}

.notes-identity-strip {
  display: grid;
  height: 20mm;
  grid-template-columns: 1.2fr 0.7fr 1fr 1fr;
  margin-top: 3mm;
  border: 3px solid var(--ink);
  background: var(--paper-2);
}

.notes-identity-strip > div {
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--ink);
  padding: 6px 8px;
}

.notes-identity-strip > div:last-child {
  border-right: 0;
}

.notes-identity-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.5rem;
  font-weight: 900;
}

.notes-identity-strip strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  font-size: 0.7rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.handwriting-panel {
  overflow: hidden;
  margin-top: 3mm;
  border: 3px solid var(--ink);
  background: var(--paper);
}

.handwriting-panel h3 {
  height: 8mm;
  margin: 0;
  border-bottom: 2px solid var(--ink);
  padding: 6px 8px 4px;
  background: var(--paper-2);
  font-size: 0.67rem;
  line-height: 1;
  text-transform: uppercase;
}

.writing-lines {
  height: calc(100% - 8mm);
  margin: 0 3mm;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 7mm, #bfc3bf calc(7mm + 1px));
}

.clues-panel {
  height: 94mm;
}

.status-log-panel {
  height: 54mm;
}

.free-notes-panel {
  height: 78mm;
}

.notes-footer {
  bottom: 6mm;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 44px));
  border: 1px solid var(--hazard);
  padding: 12px 15px;
  background: #171c19;
  color: #f4f4ef;
  font-size: 0.8rem;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Guide page */
.guide-page {
  min-height: 100dvh;
  background: #e8e9e5;
  color: var(--ink);
}

.guide-page .app-bar {
  color: var(--ui-text);
}

.guide-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 80px;
}

.guide-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
  gap: 34px;
  border-top: 12px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  padding: 30px 0 34px;
}

.guide-kicker {
  margin: 0 0 8px;
  font: 900 0.72rem/1 Consolas, monospace;
  letter-spacing: 0.13em;
}

.guide-hero h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 6.2rem);
  line-height: 0.88;
  letter-spacing: -0.06em;
}

.guide-hero-copy {
  align-self: end;
}

.guide-hero-copy p {
  margin: 0 0 18px;
  font-size: 0.95rem;
  line-height: 1.75;
}

.button-link {
  display: inline-block;
  border: 2px solid var(--ink);
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 900;
}

.formula-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 3px solid var(--ink);
}

.formula-strip div {
  min-width: 0;
  border-right: 1px solid var(--ink);
  padding: 15px 16px;
}

.formula-strip div:last-child {
  border-right: 0;
}

.formula-strip span,
.formula-strip strong {
  display: block;
}

.formula-strip span {
  font-size: 0.64rem;
  font-weight: 900;
}

.formula-strip strong {
  margin-top: 4px;
  font: 900 1.15rem/1 Consolas, monospace;
}

.guide-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 36px;
  margin-top: 38px;
}

.guide-toc {
  position: sticky;
  top: 90px;
  align-self: start;
  border-top: 4px solid var(--ink);
}

.guide-toc a {
  display: block;
  border-bottom: 1px solid #afb3b0;
  padding: 10px 4px;
  font-size: 0.78rem;
  font-weight: 800;
}

.guide-content {
  min-width: 0;
}

.guide-step {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  border-top: 2px solid var(--ink);
  padding: 23px 0 30px;
  scroll-margin-top: 84px;
}

.guide-step-number {
  font: 900 1.2rem/1 Consolas, monospace;
}

.guide-step h2 {
  margin: 0 0 9px;
  font-size: 1.45rem;
}

.guide-step p {
  max-width: 72ch;
  margin: 0 0 10px;
  color: #4a504d;
  font-size: 0.9rem;
  line-height: 1.75;
}

.guide-step ul {
  margin: 10px 0 0;
  padding-left: 1.2rem;
}

.guide-step li {
  margin: 5px 0;
  color: #3d423f;
  line-height: 1.6;
}

.class-table {
  width: 100%;
  margin-top: 18px;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.class-table th,
.class-table td {
  border-bottom: 1px solid #9ba09d;
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.class-table th {
  background: var(--ink);
  color: var(--paper);
}

.guide-callout {
  border-left: 6px solid var(--ink);
  margin-top: 14px;
  padding: 12px 15px;
  background: #d9dbd6;
  font-size: 0.82rem;
  line-height: 1.6;
}

.guide-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 8px solid var(--ink);
  margin-top: 30px;
  padding-top: 18px;
  color: #4f5552;
  font-size: 0.75rem;
}

@media (max-width: 1120px) {
  .app-layout {
    grid-template-columns: 330px minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .control-deck {
    border-right: 0;
    border-bottom: 1px solid #3b4540;
  }

  .sheet-stage {
    padding-inline: 10px;
  }

  .guide-hero,
  .guide-layout {
    grid-template-columns: 1fr;
  }

  .guide-hero-copy {
    max-width: 70ch;
  }

  .guide-toc {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .guide-toc a {
    padding-right: 10px;
  }
}

@media (max-width: 640px) {
  .app-bar {
    min-height: 58px;
    gap: 8px;
  }

  .app-mark small,
  .app-bar nav > a,
  #saveButton {
    display: none;
  }

  .bar-button {
    padding-inline: 11px;
  }

  .field-pair,
  .four-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 24px;
  }

  .guide-hero {
    gap: 20px;
  }

  .formula-strip {
    grid-template-columns: 1fr;
  }

  .formula-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .guide-toc {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-step {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .class-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .guide-footer {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  :root {
    color-scheme: light;
  }

  html,
  body {
    width: 210mm;
    margin: 0;
    background: #fff !important;
  }

  .no-print {
    display: none !important;
  }

  .app-layout,
  .sheet-stage {
    display: block;
    min-height: 0;
    overflow: visible;
    padding: 0;
    background: #fff !important;
  }

  .sheet-page {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    margin: 0;
    border: 0;
    padding: 8mm;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sheet-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .sheet-page::after {
    display: none;
  }

  .skill-node {
    min-height: 25px;
  }
}
