:root {
  --paper: #f6f3ec;
  --card: #fffdf8;
  --card-alt: #fbf8f1;
  --ink: #211f1b;
  --ink-soft: #555046;
  --ink-mute: #8a8377;
  --line: #e3dbcb;
  --line-strong: #d3c9b5;
  --steel: #2f5d7c;
  --steel-soft: #e7eef3;
  --clay: #b4552f;
  --danger: #9c2f2f;
  --radius-l: 16px;
  --radius-m: 12px;
  --radius-s: 8px;
  --shadow: 0 1px 2px rgba(33, 31, 27, .04), 0 8px 24px -18px rgba(33, 31, 27, .18);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 20px;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-feature-settings: "tnum" 1;
}

.page { max-width: 1040px; margin: 0 auto; }

/* ---------- masthead ---------- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; }

.mark { width: 26px; height: 26px; color: var(--steel); flex: none; }
.mark-needle { stroke: var(--clay); }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; letter-spacing: .02em; }
.brand-text em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
}

.node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-alt);
  font-size: 12.5px;
  color: var(--ink-soft);
  max-width: 100%;
}
.node-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-mute); flex: none;
}
.node[data-state="ok"] .node-dot { background: var(--steel); }
.node[data-state="loading"] .node-dot { animation: pulse 1.4s ease-in-out infinite; }
.node[data-state="error"] .node-dot { background: var(--danger); }

@keyframes pulse { 50% { opacity: .25; } }

/* ---------- panels ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 22px;
  box-shadow: var(--shadow);
}

main > section + section { margin-top: 18px; }

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 4px;
}

h2 { font-size: 16px; margin: 0 0 2px; letter-spacing: .01em; }
.panel-sub { margin: 0 0 16px; font-size: 12.5px; color: var(--ink-mute); }

/* ---------- stage / gauge ---------- */
.stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  font-size: 13px;
  color: var(--clay);
  letter-spacing: .04em;
}

.switch { display: flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.switch button {
  border: 0; background: transparent; color: var(--ink-soft);
  font: inherit; font-size: 12.5px; padding: 5px 14px; cursor: pointer;
}
.switch button + button { border-left: 1px solid var(--line-strong); }
.switch button.is-on { background: var(--steel); color: #fff; }

.gauge-wrap {
  position: relative;
  margin: 6px auto 0;
  width: 100%;
  max-width: 560px;
}
#gauge { display: block; width: 100%; height: auto; }

.readout {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  max-width: 70%;
}
.readout strong {
  font-family: var(--mono);
  font-size: clamp(34px, 8vw, 52px);
  font-weight: 600;
  letter-spacing: -.02em;
  display: inline-block;
  min-width: 3.6ch;
}
.readout span { font-size: 14px; color: var(--ink-soft); margin-left: 4px; }
.readout small {
  display: block; margin-top: 2px;
  font-size: 11.5px; color: var(--ink-mute); letter-spacing: .06em;
}

.stage-foot { margin-top: 18px; }
.progress {
  height: 3px; width: 100%;
  background: var(--line);
  border-radius: 2px; overflow: hidden;
}
.progress i {
  display: block; height: 100%; width: 0%;
  background: var(--steel);
  transition: width .12s linear;
}

.actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 14px;
  padding: 10px 26px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fdfbf6;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.quiet {
  background: transparent; color: var(--ink-soft);
  border-color: var(--line-strong);
  padding: 7px 16px; font-size: 12.5px;
}
.btn.quiet:hover { color: var(--steel); border-color: var(--steel); transform: none; }

/* ---------- metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 16px 18px;
}
.metric h3 {
  margin: 0; font-size: 12px; font-weight: 600;
  letter-spacing: .1em; color: var(--ink-mute);
}
.metric-value {
  margin: 6px 0 2px;
  font-family: var(--mono);
  font-size: 30px; font-weight: 600; line-height: 1.1;
  letter-spacing: -.02em;
}
.metric-value em {
  font-style: normal; font-size: 13px; font-weight: 400;
  color: var(--ink-soft); margin-left: 5px;
}
.metric-note { margin: 0; font-size: 12px; color: var(--ink-mute); }
.metric.is-hero .metric-value { color: var(--steel); }
.metric.is-done { border-color: var(--line-strong); }

/* ---------- exit grid ---------- */
.exit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 26px;
  margin: 0;
}
.exit-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.exit-row:last-child { border-bottom: 0; }
.exit-row dt { font-size: 12.5px; color: var(--ink-mute); flex: none; letter-spacing: .02em; }
.exit-row dd {
  margin: 0; text-align: right;
  font-family: var(--mono); font-size: 13px;
  color: var(--ink); word-break: break-word;
}
.exit-row dd .muted { color: var(--ink-mute); }
.exit-row dd .sub {
  display: block; font-family: inherit;
  font-size: 11.5px; color: var(--ink-mute); margin-top: 2px;
}

.badge {
  display: inline-block;
  font-family: -apple-system, "Segoe UI", "PingFang SC", sans-serif;
  font-size: 11.5px; line-height: 1.5;
  padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft); background: var(--card-alt);
  margin-left: 6px;
}
.badge.ok { color: var(--steel); border-color: #b9d0dd; background: var(--steel-soft); }
.badge.warn { color: var(--clay); border-color: #e2c3ae; background: #f8ecdf; }
.badge.bad { color: var(--danger); border-color: #e0bdbd; background: #f7eaea; }
.badge.wait { color: var(--ink-mute); }

.detail {
  grid-column: 1 / -1;
  margin: 2px 0 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--card-alt);
  font-size: 12.5px;
  color: var(--ink-soft);
}
.detail ul { margin: 6px 0 0; padding-left: 18px; }
.detail li { margin: 2px 0; font-family: var(--mono); font-size: 12px; }
.detail p { margin: 4px 0 0; }
.detail strong { font-size: 12.5px; color: var(--ink); }
.muted { color: var(--ink-mute); }
.detail .muted { color: var(--ink-mute); }

/* ---------- history ---------- */
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list .empty { color: var(--ink-mute); font-size: 13px; }
.history-item {
  display: grid;
  grid-template-columns: 132px repeat(4, minmax(0, 1fr));
  gap: 10px; align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.history-item:last-child { border-bottom: 0; }
.history-item .h-time { color: var(--ink-mute); font-size: 12px; }
.history-item .h-num { font-family: var(--mono); }
.history-item .h-num em { font-style: normal; font-size: 11px; color: var(--ink-mute); margin-left: 3px; }
.history-item .h-hero { color: var(--steel); }

/* ---------- notes ---------- */
.note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 26px;
  margin-top: 14px;
}
.note-grid h3 {
  margin: 0 0 6px; font-size: 13px; color: var(--steel); letter-spacing: .02em;
}
.note-grid p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.note-grid code {
  font-family: var(--mono); font-size: 12px;
  background: var(--card-alt); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 4px;
}

/* ---------- footer ---------- */
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 22px 4px 6px;
  font-size: 11.5px; color: var(--ink-mute);
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exit-grid, .note-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .masthead { border-radius: var(--radius-l); padding: 12px 14px; }
  .panel { padding: 18px; }
  .metric-value { font-size: 26px; }
  .history-item { grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 12px 0; }
  .history-item .h-time { grid-column: 1 / -1; }
  .actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
