@font-face {
  font-family: "Goldenhorst Headline";
  src: url("../fonts/GoldenhorstFace-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #090908;
  --panel: rgba(12, 13, 11, 0.88);
  --panel-strong: rgba(8, 9, 8, 0.96);
  --line: rgba(218, 184, 97, 0.28);
  --text: #f3ead6;
  --muted: #b8ad95;
  --gold: #d9ad48;
  --green: #77a779;
  --red: #b85d4e;
  --violet: #9b7ac0;
  --shadow: rgba(0, 0, 0, 0.55);
  --headline-font: "Goldenhorst Headline", Impact, Haettenschweiler, "Arial Black", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 292px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.82), rgba(0,0,0,0.22), rgba(0,0,0,0.86)),
    var(--scene-image),
    linear-gradient(145deg, #15110c, #0b1110 56%, #171016);
  background-size: cover;
  background-position: center;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 16px;
  background: rgba(5, 6, 5, 0.92);
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  color: var(--gold);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  line-height: 1;
}

.brand-mark {
  font-family: var(--headline-font);
  font-size: clamp(30px, 3.4vw, 46px);
  font-weight: 400;
  line-height: 0.92;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #1c1004, 0 0 18px rgba(217, 173, 72, 0.34);
}

.brand-subtitle {
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(14px, 1.4vw, 18px);
  font-weight: 900;
  text-transform: uppercase;
}

.top-actions,
.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.chrome-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.chrome-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.chrome-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  text-align: center;
}

.danger-button {
  border-color: rgba(184, 93, 78, 0.48);
  color: #f0b092;
}

.chrome-button:hover,
.chrome-link:hover,
.choice:hover,
.episode-button:hover {
  border-color: rgba(217,173,72,0.72);
  background: rgba(217,173,72,0.14);
}

.episodes {
  grid-column: 1;
  grid-row: 2 / 4;
  padding: 14px;
  background: rgba(7, 8, 7, 0.86);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.rail-title,
.panel-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.panel-help {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.episode-button {
  width: 100%;
  margin: 0 0 8px;
  padding: 10px;
  text-align: left;
  color: var(--text);
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(218,184,97,0.16);
  border-radius: 6px;
  cursor: pointer;
}

.episode-button.is-active {
  border-color: var(--gold);
  background: rgba(217,173,72,0.18);
}

.episode-button small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.stage {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(16px, 2vw, 28px);
}

.scene-frame {
  position: relative;
  margin: 0;
  min-height: 42vh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(217,173,72,0.2), transparent 54%),
    linear-gradient(145deg, #1f1a12, #091211 58%, #150f17),
    rgba(10, 12, 11, 0.42);
  box-shadow: 0 24px 70px var(--shadow);
}

.scene-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent, rgba(0,0,0,0.48)),
    var(--scene-image),
    linear-gradient(115deg, rgba(217,173,72,0.16), transparent 54%),
    linear-gradient(145deg, #1f1a12, #091211 58%, #150f17);
  background-size: cover;
  background-position: center;
  opacity: 0.28;
}

.scene-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 180ms ease;
}

.scene-frame[data-image-state="ready"] .scene-image {
  opacity: 1;
}

.scene-frame[data-image-state="locked"],
.scene-frame[data-image-state="rejected"],
.scene-frame[data-image-state="missing"] {
  display: grid;
  place-items: center;
}

.scene-placeholder {
  position: relative;
  z-index: 1;
  width: min(680px, calc(100% - 32px));
  padding: clamp(22px, 4vw, 42px);
  text-align: center;
}

.placeholder-kicker {
  margin: 0 0 8px;
  color: #f0b092;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.placeholder-title {
  margin: 0 auto 12px;
  max-width: 15ch;
  color: var(--gold);
  font-family: var(--headline-font);
  font-size: clamp(34px, 5vw, 64px);
  font-weight: 400;
  line-height: 0.9;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #1c1004, 0 0 20px rgba(217, 173, 72, 0.28);
}

.placeholder-copy {
  margin: 0 auto 18px;
  max-width: 58ch;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

.scene-packet-link {
  margin: 10px auto 0;
}

.scene-production {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.scene-production span {
  max-width: 100%;
  padding: 6px 8px;
  color: var(--text);
  background: rgba(5, 6, 5, 0.82);
  border: 1px solid rgba(218,184,97,0.28);
  border-radius: 6px;
}

.scene-frame[data-image-state="ready"] .scene-production {
  opacity: 0.18;
}

.scene-frame[data-image-state="ready"]:hover .scene-production,
.scene-frame:focus-within .scene-production {
  opacity: 1;
}

.reject-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
}

.reject-chip {
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid rgba(240, 176, 146, 0.46);
  border-radius: 6px;
  color: #f0b092;
  background: rgba(240, 176, 146, 0.08);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.reject-chip:hover,
.reject-chip:focus-visible {
  border-color: rgba(240, 176, 146, 0.82);
  background: rgba(240, 176, 146, 0.16);
}

.reject-reason {
  margin: 10px 0 0;
  color: #f0b092;
  font-size: 13px;
  line-height: 1.45;
}

.story-panel {
  margin-top: 12px;
  padding: clamp(18px, 2.3vw, 30px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px var(--shadow);
  backdrop-filter: blur(8px);
}

.scene-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.scene-meta span {
  padding: 4px 7px;
  border: 1px solid rgba(218,184,97,0.18);
  border-radius: 5px;
  background: rgba(255,255,255,0.035);
}

.story-title {
  margin: 0 0 14px;
  color: var(--gold);
  font-family: var(--headline-font);
  font-size: clamp(38px, 4.8vw, 68px);
  font-weight: 400;
  line-height: 0.92;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #1c1004, 0 0 18px rgba(217, 173, 72, 0.26);
}

.story-text {
  max-width: 76ch;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.56;
  white-space: pre-wrap;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.choice {
  min-height: 56px;
  padding: 13px 14px;
  color: var(--text);
  text-align: left;
  background: rgba(16, 17, 14, 0.86);
  border: 1px solid rgba(218,184,97,0.28);
  border-radius: 7px;
  cursor: pointer;
}

.choice strong {
  display: block;
  font-size: 16px;
}

.choice-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(218,184,97,0.18);
  border-radius: 7px;
  background: rgba(255,255,255,0.022);
}

.choice-group-title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.choice-group-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sidebar {
  grid-column: 3;
  grid-row: 2 / 4;
  padding: 14px;
  background: rgba(7, 8, 7, 0.88);
  border-left: 1px solid var(--line);
  overflow: auto;
}

.side-panel {
  margin-bottom: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.026);
  border: 1px solid rgba(218,184,97,0.16);
  border-radius: 8px;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(218,184,97,0.12);
  color: var(--muted);
}

.stat-row:last-child { border-bottom: 0; }
.stat-row strong { color: var(--text); font-variant-numeric: tabular-nums; }

.route-select {
  width: 100%;
  min-height: 38px;
  padding: 0 9px;
  color: var(--text);
  background: rgba(9, 10, 8, 0.95);
  border: 1px solid rgba(218,184,97,0.24);
  border-radius: 6px;
}

.route-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.route-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.route-status strong {
  display: inline-block;
  margin-right: 8px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.route-status p {
  margin: 7px 0 0;
}

.route-warning {
  color: #f0b092;
}

.beat-focus {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid rgba(218,184,97,0.16);
  border-radius: 7px;
  background: rgba(217,173,72,0.055);
}

.beat-focus strong {
  display: block;
  color: var(--gold);
  font-size: 13px;
  line-height: 1.25;
}

.beat-focus p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.beat-list {
  margin: 10px 0 0;
  padding-left: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  list-style: none;
}

.beat-list li + li {
  margin-top: 7px;
}

.beat-list label {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
}

.beat-list input {
  width: 14px;
  height: 14px;
  margin: 2px 0 0;
  accent-color: var(--gold);
}

.beat-list span {
  overflow-wrap: anywhere;
}

.image-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.direct-packet {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(240, 176, 146, 0.38);
  border-radius: 7px;
  background: rgba(240, 176, 146, 0.075);
}

.direct-packet strong,
.direct-packet span {
  display: block;
}

.direct-packet strong {
  color: var(--text);
  font-size: 13px;
}

.direct-packet span {
  margin-top: 3px;
  color: #f0b092;
  font-size: 12px;
  font-weight: 800;
}

.direct-packet p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.review-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.review-note-label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.review-note {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 9px;
  color: var(--text);
  background: rgba(9, 10, 8, 0.95);
  border: 1px solid rgba(218,184,97,0.24);
  border-radius: 6px;
  font: inherit;
  line-height: 1.45;
}

.download-link {
  display: block;
  margin-top: 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.import-link {
  display: block;
  margin-top: 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.import-link input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.download-link:hover {
  color: var(--text);
}

.tool-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.image-rules {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.item {
  padding: 5px 7px;
  border: 1px solid rgba(218,184,97,0.22);
  border-radius: 5px;
  color: var(--text);
  background: rgba(217,173,72,0.08);
  font-size: 12px;
}

.history {
  max-height: 220px;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
}

.footer {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px 18px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    overflow-x: hidden;
  }
  .episodes,
  .stage,
  .sidebar,
  .footer {
    grid-column: 1;
    grid-row: auto;
  }
  .episodes {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .episode-button {
    min-width: 220px;
  }
  .sidebar {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .choices {
    grid-template-columns: 1fr;
  }
  .choice-group-options {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }
  .top-actions {
    flex: 1 1 100%;
    min-width: 0;
  }
  .top-actions .chrome-button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 8px;
  }
  .brand {
    font-size: 28px;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .story-title {
    font-size: 34px;
  }
  .story-text {
    font-size: 18px;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }
  .brand {
    font-size: 26px;
  }
  .stage,
  .sidebar,
  .episodes {
    padding-left: 12px;
    padding-right: 12px;
  }
  .episode-button {
    min-width: min(220px, 78vw);
  }
  .scene-frame {
    min-height: 320px;
  }
  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-left: 12px;
    padding-right: 12px;
  }
}
