:root {
  color-scheme: light;
  --ink: #1c2330;
  --muted: #6a7280;
  --faint: #97a0ae;
  --paper: #f6f8fa;
  --panel: #ffffff;
  --line: #e1e7ee;
  --line-strong: #cdd6e0;
  --accent: #c07a2b;
  --accent-deep: #97601f;
  --accent-soft: #f8ecdc;
  --rail: #1f1a12;
  --blue: #3f74b0;
  --bad: #c0492f;
  --good: #2f8f63;
  --shadow: 0 22px 60px rgba(31, 26, 18, 0.14);
  --shadow-soft: 0 8px 22px rgba(31, 26, 18, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: rgba(192, 122, 43, 0.12);
  color: var(--accent-deep);
  padding: 0.05em 0.4em;
  border-radius: 6px;
}

button {
  cursor: pointer;
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* ----------------------------------------------------------- shell */
.bp-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-width: 0;
  min-height: 100vh;
}

/* ------------------------------------------------------------- rail */
.bp-rail {
  background: var(--rail);
  color: #e3ddd2;
  padding: 22px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
}

.bp-back {
  color: #b59a72;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.bp-back:hover {
  color: #ecd9b8;
}

.bp-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bp-brand strong {
  display: block;
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: -0.01em;
}
.bp-brand small {
  color: #a3998a;
  font-size: 0.74rem;
}
.bp-dot {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #e0a45c);
  box-shadow: 0 0 0 4px rgba(192, 122, 43, 0.2);
  flex: none;
}

.bp-chapters {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.bp-chapter {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 11px;
  color: #b6ad9f;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
}
.bp-chapter:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f0eade;
}
.bp-chapter.active {
  background: rgba(192, 122, 43, 0.18);
  border-color: rgba(192, 122, 43, 0.45);
  color: #fff;
}
.bp-chapter.done .bp-chapter-num {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.bp-chapter-num {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-size: 0.74rem;
  font-weight: 700;
  flex: none;
}
.bp-chapter.active .bp-chapter-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bp-chapter-label {
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.2;
}

.bp-rail-foot p {
  font-size: 0.74rem;
  color: #8a8174;
  line-height: 1.5;
  margin: 0;
}

/* ------------------------------------------------------------- main */
.bp-main {
  padding: 26px 30px 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1240px;
  min-width: 0;
  width: 100%;
}

.bp-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}
.bp-kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-deep);
  margin: 0 0 6px;
}
.bp-head h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}
#chapterLede {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 60ch;
  line-height: 1.5;
}

.bp-head-stats {
  display: flex;
  gap: 10px;
  flex: none;
}
.bp-stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  min-width: 68px;
  box-shadow: var(--shadow-soft);
}
.bp-stat span {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  font-weight: 700;
  white-space: nowrap;
}
.bp-stat strong {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bp-stat.warn strong {
  color: var(--bad);
}

/* ------------------------------------------------------------ stage */
.bp-stage {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: grid;
  grid-template-columns: 180px minmax(320px, 1fr) 240px;
  gap: 20px;
  min-height: 340px;
  overflow: hidden;
}

.bp-station {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.bp-station-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--faint);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.bp-station-sub {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--accent-deep);
}
.bp-badnum {
  color: var(--bad);
}

/* ------- producer ------- */
.bp-producer {
  justify-content: center;
}
.bp-card {
  background: linear-gradient(160deg, #ffffff, #faf4ec);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-soft);
}
.bp-card-glyph {
  align-self: center;
  border: 2px solid var(--accent);
  border-radius: 5px;
  color: var(--accent-deep);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 5px 8px 4px;
  position: relative;
}
.bp-card-glyph::before {
  background: var(--accent);
  content: "";
  height: 3px;
  left: 0;
  position: absolute;
  right: 0;
  top: 4px;
}
.bp-card strong {
  font-size: 0.9rem;
}
.bp-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.bp-prodstatus {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  min-height: 52px;
}
.bp-prod-line {
  font-size: 0.8rem;
  color: var(--muted);
}
.bp-prod-line b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.bp-prod-idle {
  color: var(--faint);
}
.bp-prod-blocked {
  color: var(--bad);
  font-weight: 700;
}
.bp-spike-pill {
  background: var(--bad);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-family: "JetBrains Mono", monospace;
  padding: 3px 10px;
  border-radius: 999px;
  animation: bpPulse 1s ease infinite;
}

/* ------- queue column ------- */
.bp-queuecol {
  justify-content: center;
}
.bp-chart {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 96px;
  background: linear-gradient(180deg, #fbf8f3, #f5f1ea);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px 0;
  overflow: hidden;
}
.bp-chart i {
  flex: 1 1 0;
  min-width: 2px;
  max-width: 8px;
  background: var(--accent);
  opacity: 0.75;
  border-radius: 2px 2px 0 0;
}
.bp-chart i.high {
  background: var(--bad);
  opacity: 0.8;
}
.bp-chart i.cap {
  background: var(--bad);
  opacity: 0.95;
}
.bp-chart-empty {
  align-self: center;
  margin: 0 auto;
  font-size: 0.72rem;
  color: var(--faint);
}
.bp-capline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--bad);
  pointer-events: none;
}
.bp-capline b {
  position: absolute;
  right: 6px;
  top: -16px;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  color: var(--bad);
}

.bp-queue-title {
  margin-top: 6px;
}
.bp-queue {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  background: repeating-linear-gradient(90deg, #f7f4ee, #f7f4ee 9px, #f1ece3 9px, #f1ece3 10px);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 46px;
  padding: 0 10px;
  overflow: hidden;
}
.bp-job {
  width: 9px;
  height: 26px;
  border-radius: 3px;
  flex: none;
  font-style: normal;
  background: var(--blue);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14);
  transition: background 0.4s;
}
.bp-job.warm {
  background: var(--accent);
}
.bp-job.hot {
  background: var(--bad);
}
.bp-job.fresh-in {
  animation: bpSlideIn 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.bp-q-more {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--bad);
  font-family: "JetBrains Mono", monospace;
  flex: none;
  margin-right: 4px;
}
.bp-q-empty {
  font-size: 0.72rem;
  color: var(--faint);
  margin: 0 auto;
}
.bp-queue-flow {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ------- workers column ------- */
.bp-workerscol {
  justify-content: center;
}
.bp-workers {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.bp-worker {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, #fff);
  border-radius: 10px;
  padding: 5px 9px;
  font-size: 0.72rem;
  min-height: 32px;
}
.bp-worker.idle {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--faint);
}
.bp-worker-name {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--muted);
  flex: none;
}
.bp-worker-state {
  margin-left: auto;
  font-size: 0.66rem;
}
.bp-worker .bp-job {
  height: 18px;
}
.bp-worker-bar {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.bp-worker-bar b {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s linear;
}

.bp-done-title {
  margin-top: 6px;
}
.bp-donelist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}
.bp-done {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 4px 8px;
  font-size: 0.7rem;
  color: var(--muted);
}
.bp-done b {
  margin-left: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--good);
  font-variant-numeric: tabular-nums;
}
.bp-done.warn b {
  color: var(--accent-deep);
}
.bp-done.bad {
  border-color: #ecc4b8;
  background: #fdf3ef;
}
.bp-done.bad b {
  color: var(--bad);
}
.bp-done-empty {
  font-size: 0.72rem;
  color: var(--faint);
  border: 1px dashed var(--line);
  border-radius: 9px;
  padding: 7px 9px;
}

/* ------------------------------------------------------------- deck */
.bp-deck {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}
.bp-controls-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bp-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bp-control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.bp-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.bp-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.bp-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.bp-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bp-btn.primary:hover:not(:disabled) {
  background: var(--accent-deep);
}
.bp-btn.on {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.bp-transport {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--rail);
  border-radius: 12px;
}
.bp-transport .bp-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #f0eade;
}
.bp-transport .bp-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--accent);
}
.bp-transport .bp-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bp-transport .bp-btn.on {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.bp-speeddial {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.bp-speed-btn {
  width: 32px;
  padding: 6px 0;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}
.bp-speed-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  line-height: 1.05;
}
.bp-speed-readout small {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a89e8d;
}
.bp-speed-readout b {
  color: #f0eade;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

.bp-keychips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.bp-keychip {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.74rem;
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bp-keychip:hover:not(:disabled) {
  border-color: var(--accent);
}
.bp-chiplabel {
  align-self: center;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin-right: 2px;
}
.bp-chipnote {
  font-size: 0.7rem;
  color: var(--faint);
}

.bp-sliders {
  gap: 22px;
}
.bp-slider {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  flex: 1;
  max-width: 260px;
}
.bp-slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}
.bp-slider-head b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.bp-slider input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.bp-control-note {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

/* ------- event narration ------- */
.bp-event {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--blue);
  background: linear-gradient(180deg, #f2f7fc, #fcfeff);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  animation: bpRise 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.bp-event-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bp-event-badge {
  background: var(--blue);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.bp-event-head strong {
  font-size: 0.86rem;
}
.bp-event-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink);
  line-height: 1.45;
}
.bp-event.warn {
  border-color: #ecd0a4;
  border-left-color: var(--accent);
  background: linear-gradient(180deg, #fdf6ea, #fffdf8);
}
.bp-event.warn .bp-event-badge {
  background: var(--accent);
}
.bp-event.bad {
  border-color: #ecc4b8;
  border-left-color: var(--bad);
  background: linear-gradient(180deg, #fdf1ed, #fffaf8);
}
.bp-event.bad .bp-event-badge {
  background: var(--bad);
}
.bp-event.good {
  border-color: #bcdfce;
  border-left-color: var(--good);
  background: linear-gradient(180deg, #effaf4, #fbfffd);
}
.bp-event.good .bp-event-badge {
  background: var(--good);
}

/* ------- explainer ------- */
.bp-explainer {
  background: linear-gradient(165deg, #ffffff, #faf4ec);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bp-explainer h3 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-deep);
}
.bp-explainer ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bp-explainer li {
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
}
.bp-keyidea {
  background: var(--rail);
  color: #f0eade;
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 0.82rem;
  line-height: 1.5;
}
.bp-keyidea b {
  color: #f2b366;
}
.bp-callout {
  font-size: 0.82rem;
  color: var(--ink);
  background: #fff6e8;
  border: 1px solid #ecd0a4;
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.5;
}
.bp-callout b {
  color: var(--accent-deep);
}
.bp-try {
  font-size: 0.82rem;
  color: var(--ink);
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: 11px;
  padding: 10px 12px;
  line-height: 1.5;
}
.bp-try b {
  color: var(--accent-deep);
}

/* ------------------------------------------------------------- foot */
.bp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bp-nav {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 11px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}
.bp-nav:hover:not(:disabled) {
  border-color: var(--accent);
}
.bp-nav-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bp-nav-primary:hover {
  background: var(--accent-deep);
}
.bp-progress {
  display: flex;
  gap: 7px;
}
.bp-pdot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.bp-pdot.active {
  background: var(--accent);
  transform: scale(1.3);
}
.bp-pdot.done {
  background: var(--accent-deep);
}

/* ----------------------------------------------------- animations */
@keyframes bpSlideIn {
  from {
    transform: translateX(-16px) scaleY(0.5);
    opacity: 0;
  }
  to {
    transform: translateX(0) scaleY(1);
    opacity: 1;
  }
}
@keyframes bpRise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes bpPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@media (max-width: 1080px) {
  .bp-shell {
    grid-template-columns: 1fr;
  }
  .bp-rail {
    position: static;
    height: auto;
  }
  .bp-chapters {
    flex-direction: row;
    overflow-x: auto;
  }
  .bp-chapter {
    flex: none;
  }
  .bp-deck {
    grid-template-columns: 1fr;
  }
  .bp-stage {
    grid-template-columns: 160px minmax(260px, 1fr) 220px;
    gap: 14px;
  }
}

@media (max-width: 900px) {
  .bp-rail {
    gap: 16px;
    padding: 16px 14px;
  }
  .bp-rail-foot {
    display: none;
  }
  .bp-main {
    gap: 14px;
    padding: 18px 14px 24px;
  }
  .bp-head {
    flex-direction: column;
    gap: 14px;
  }
  .bp-head h1 {
    font-size: 1.5rem;
  }
  .bp-head-stats {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    width: 100%;
  }
  .bp-stat {
    flex: 1 0 68px;
  }
  .bp-stage {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    padding: 16px;
  }
  .bp-producer,
  .bp-queuecol,
  .bp-workerscol {
    justify-content: flex-start;
  }
  .bp-prodstatus {
    min-height: 0;
  }
  .bp-controls-card,
  .bp-explainer {
    padding: 14px;
  }
  .bp-transport {
    align-items: stretch;
    flex-direction: column;
  }
  .bp-speeddial {
    margin-left: 0;
  }
  .bp-speed-readout {
    flex: 1;
  }
  .bp-foot {
    gap: 10px;
  }
  .bp-nav {
    padding: 9px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bp-job.fresh-in,
  .bp-spike-pill,
  .bp-worker-bar b,
  .bp-event {
    animation: none !important;
    transition: none !important;
  }
}
