:root {
  color-scheme: dark;
  --bg: #0b0e0d;
  --surface: #111715;
  --surface-raised: #17211d;
  --surface-soft: #0f1412;
  --border: rgba(226, 244, 234, 0.13);
  --border-strong: rgba(226, 244, 234, 0.24);
  --text: #edf3ef;
  --muted: #96a69d;
  --muted-strong: #bdc9c1;
  --lime: #c6ed55;
  --cyan: #74d6e6;
  --amber: #f2c46b;
  --red: #ff8b86;
  --green: #5fd29a;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(116, 214, 230, 0.05), transparent 280px),
    var(--bg);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.loading-state, .fatal-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.identity { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(198, 237, 85, 0.65);
  border-radius: 50%;
  color: var(--lime);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--lime);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(24px, 4vw, 38px); line-height: 1.1; letter-spacing: 0; }
h2 { margin-bottom: 12px; font-size: 20px; line-height: 1.25; }
h3 { margin-bottom: 6px; font-size: 15px; line-height: 1.3; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.preview-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.sim-badge, .state-badge, .source-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 12px;
  white-space: nowrap;
}
.sim-badge { border-color: rgba(116, 214, 230, 0.45); color: var(--cyan); }
.verification-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--muted-strong); font-size: 12px; white-space: nowrap; }
.scenario-select {
  min-height: 30px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.status-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 0;
  padding: 16px 18px;
  border-left: 3px solid var(--cyan);
  background: rgba(116, 214, 230, 0.08);
}
.status-strip.warning { border-left-color: var(--amber); background: rgba(242, 196, 107, 0.08); }
.status-strip.danger { border-left-color: var(--red); background: rgba(255, 139, 134, 0.08); }
.status-title { margin-bottom: 5px; font-weight: 700; }
.status-copy { margin: 0; color: var(--muted-strong); font-size: 13px; line-height: 1.55; }
.status-meta { flex: 0 0 auto; color: var(--muted); font-size: 12px; text-align: right; }

.boundary {
  margin-top: 12px;
  padding: 12px 0 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.boundary strong { color: var(--muted-strong); font-weight: 600; }

.section { margin-top: 38px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; }

.mechanism {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.mechanism-step { position: relative; min-height: 150px; padding: 20px 18px 18px 0; }
.mechanism-step + .mechanism-step { padding-left: 18px; border-left: 1px solid var(--border); }
.step-index { margin-bottom: 18px; color: var(--lime); font-size: 12px; font-variant-numeric: tabular-nums; }
.mechanism-step p { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.circuit-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr); gap: 20px; align-items: start; }
.circuit-shell { min-width: 0; padding: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-soft); }
.circuit-svg { display: block; width: 100%; height: auto; min-height: 260px; }
.circuit-svg text { font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
.circuit-wire { fill: none; stroke: rgba(116, 214, 230, 0.42); stroke-width: 1.2; }
.circuit-wire.active { stroke: var(--lime); stroke-width: 1.8; }
.circuit-node { fill: rgba(116, 214, 230, 0.08); stroke: rgba(226, 244, 234, 0.22); stroke-width: 1; }
.circuit-node.active { fill: rgba(198, 237, 85, 0.2); stroke: var(--lime); }
.circuit-node.done { fill: rgba(95, 210, 154, 0.16); stroke: var(--green); }
.circuit-label { fill: var(--muted-strong); font-size: 12px; }
.circuit-label.muted { fill: var(--muted); font-size: 10px; }
.circuit-label.accent { fill: var(--lime); font-size: 11px; font-weight: 700; }
.circuit-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border: 1px solid var(--border-strong); border-radius: 2px; background: rgba(116, 214, 230, 0.08); }
.legend-swatch.active { border-color: var(--lime); background: rgba(198, 237, 85, 0.2); }
.legend-swatch.done { border-color: var(--green); background: rgba(95, 210, 154, 0.16); }
.circuit-aside { display: grid; gap: 12px; }
.circuit-aside h3 { margin-bottom: 4px; }
.circuit-stat { padding: 14px 0; border-top: 1px solid var(--border); }
.circuit-stat:first-child { padding-top: 0; border-top: 0; }
.circuit-stat-value { margin-bottom: 4px; color: var(--text); font-size: 21px; font-variant-numeric: tabular-nums; }
.circuit-stat-label { color: var(--muted); font-size: 12px; line-height: 1.45; }
.circuit-note { margin: 0; padding-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.circuit-brief { margin: 12px 0 18px; border: 1px solid rgba(242, 196, 107, 0.34); border-radius: var(--radius); overflow: hidden; background: linear-gradient(110deg, rgba(23, 31, 55, 0.96), rgba(15, 20, 32, 0.96)); }
.circuit-brief-head { display: flex; gap: 12px; padding: 18px 20px 16px; }
.circuit-brief-icon { color: var(--amber); font-size: 24px; line-height: 1; }
.circuit-brief h3 { margin: 0 0 6px; font-size: 16px; }
.circuit-brief-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px 12px; }
.circuit-brief-title-row h3 { margin-bottom: 0; }
.circuit-badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.circuit-badges .risk-badge, .circuit-badges .state-badge { min-height: 24px; padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 5px; font-size: 10px; line-height: 1; }
.circuit-badges .risk-badge { color: var(--lime); border-color: rgba(198, 237, 85, 0.38); }
.circuit-badges .state-badge { color: var(--cyan); }
.circuit-brief-head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.circuit-callouts { display: grid; gap: 8px; padding: 0 14px 14px; }
.circuit-callout { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 5px; background: rgba(0, 0, 0, 0.72); }
.circuit-callout.warning { background: rgba(18, 25, 45, 0.7); }
.circuit-callout span { flex: 0 0 auto; color: var(--cyan); font-size: 14px; line-height: 1.4; }
.circuit-callout.warning span { color: var(--amber); }
.circuit-callout p { margin: 0; color: var(--muted-strong); font-size: 11px; line-height: 1.5; }
.circuit-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.circuit-steps > div { min-height: 118px; padding: 14px 14px 13px; }
.circuit-steps > div + div { border-left: 1px solid var(--border); }
.circuit-steps span { display: block; margin-bottom: 11px; color: var(--amber); font-size: 10px; font-weight: 700; }
.circuit-steps strong { display: block; margin-bottom: 5px; color: var(--muted-strong); font-size: 12px; }
.circuit-steps p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.circuit-brief-foot { margin: 0; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10px; line-height: 1.5; }
.matrix-toggle { margin-top: 12px; }
.matrix-view { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.matrix-svg { display: block; width: 100%; height: auto; min-height: 250px; }
.matrix-label { fill: var(--muted-strong); font-size: 11px; }
.matrix-label.muted { fill: var(--muted); font-size: 10px; }
.matrix-cell { fill: rgba(116, 214, 230, 0.11); }
.matrix-cell.done { fill: rgba(95, 210, 154, 0.72); }
.matrix-cell.active { fill: var(--lime); }
.matrix-latch { fill: rgba(116, 214, 230, 0.11); }
.matrix-latch.done { fill: rgba(95, 210, 154, 0.72); }
.matrix-latch.active { fill: var(--lime); }

.staking-banner { display: flex; justify-content: space-between; gap: 24px; padding: 20px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: linear-gradient(105deg, rgba(19, 31, 27, 0.96), rgba(17, 23, 42, 0.92)); }
.staking-banner h2 { margin: 7px 0 6px; font-size: 19px; }
.staking-banner p { max-width: 680px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.staking-kicker, .panel-kicker { color: var(--lime); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.staking-split { display: grid; grid-template-columns: auto auto; align-content: center; gap: 2px 10px; min-width: 150px; padding-left: 20px; border-left: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.staking-split strong { color: var(--lime); font-size: 20px; font-variant-numeric: tabular-nums; }
.staking-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.staking-metrics .metric { min-height: 104px; }
.section-return { color: var(--muted-strong); font-size: 12px; text-decoration: none; }
.section-return:hover { color: var(--lime); }
.reward-rule { margin-top: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-soft); }
.reward-rule-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--cyan); font-size: 11px; }
.reward-rule-head strong { color: var(--lime); }
.reward-rule-bar { height: 8px; overflow: hidden; border-radius: 99px; background: var(--cyan); }
.reward-rule-bar span { display: block; height: 100%; background: var(--green); }
.reward-rule p { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.reward-schedule { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.reward-schedule > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.reward-schedule span { color: var(--muted); font-size: 10px; }
.reward-schedule strong { color: var(--muted-strong); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.staking-layout { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr); gap: 18px; margin-top: 18px; align-items: start; }
.staking-panel { min-width: 0; padding: 20px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.staking-panel .action-subtitle { margin: 10px 0 16px; }
.slot-rule { display: grid; gap: 4px; margin: 10px 0 16px; padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: rgba(116, 214, 230, 0.05); }
.slot-rule strong { color: var(--muted-strong); font-size: 13px; }
.slot-rule span, .slot-rule small, .field-hint { color: var(--muted); font-size: 11px; line-height: 1.45; }
.slot-rule small { color: var(--cyan); }
.field-hint { margin: -2px 0 13px; }
.stake-amount-label { margin-top: 14px; }
.stake-actions { margin-top: 12px; }
.component-panel { display: grid; gap: 0; }
.component-row { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.component-row strong { display: block; margin-bottom: 4px; color: var(--muted-strong); font-size: 13px; }
.component-row span { display: block; color: var(--muted); font-size: 11px; line-height: 1.45; }
.component-row .button-primary { flex: 0 0 auto; min-height: 36px; }
.component-claim { margin-top: 14px; }
.staking-footnote { margin: 14px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

.action-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr); gap: 28px; align-items: start; }
.action-panel { padding: 22px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.action-panel h2 { margin-bottom: 7px; }
.action-subtitle { margin-bottom: 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.field-label { display: block; margin-bottom: 7px; color: var(--muted-strong); font-size: 12px; }
.field-row { display: flex; gap: 8px; }
.field-row input { min-width: 0; flex: 1; }
input, .select-control {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
}
input::placeholder { color: #6f7d75; }
.button-primary, .button-secondary {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 6px;
  font-weight: 700;
  white-space: nowrap;
}
.button-primary { border: 1px solid var(--lime); background: var(--lime); color: #10150e; }
.button-secondary { border: 1px solid var(--border-strong); background: transparent; color: var(--text); }
.button-secondary:hover { border-color: var(--lime); color: var(--lime); }
.action-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.action-help { min-height: 21px; margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.action-help.error { color: var(--red); }
.action-help.success { color: var(--green); }

.account-summary { display: grid; gap: 13px; padding-top: 4px; }
.summary-line { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 13px; border-bottom: 1px solid var(--border); font-size: 13px; }
.summary-line span:first-child { color: var(--muted); }
.summary-line span:last-child { color: var(--muted-strong); font-variant-numeric: tabular-nums; text-align: right; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric { min-height: 114px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-soft); }
.metric-label { margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.metric-value { margin-bottom: 6px; font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.metric-context { color: var(--muted); font-size: 11px; line-height: 1.4; }

.progress-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(250px, 0.9fr); gap: 28px; }
.progress-track { height: 12px; overflow: hidden; border-radius: 99px; background: rgba(226, 244, 234, 0.1); }
.progress-bar { height: 100%; border-radius: inherit; background: var(--lime); transition: width 260ms ease; }
.progress-readout { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--muted-strong); font-size: 13px; font-variant-numeric: tabular-nums; }
.progress-caption { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.mini-list { display: grid; gap: 9px; }
.mini-list-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.mini-list-row span:first-child { color: var(--muted); }
.mini-list-row span:last-child { color: var(--muted-strong); text-align: right; }

.evidence-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.evidence-item { min-height: 126px; padding: 16px; border-top: 1px solid var(--border-strong); }
.evidence-item p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.evidence-value { margin-bottom: 7px; color: var(--muted-strong); font-size: 13px; word-break: break-word; }
.source-label { min-height: 22px; padding: 0 7px; border: 0; background: rgba(116, 214, 230, 0.1); color: var(--cyan); font-size: 11px; }

.log-list { display: grid; border-top: 1px solid var(--border); }
.log-row { display: grid; grid-template-columns: 118px minmax(0, 1fr) 110px; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.log-row span:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-row span:nth-child(2) { color: var(--muted-strong); }
.log-row span:last-child { color: var(--cyan); text-align: right; font-variant-numeric: tabular-nums; }

details { border-top: 1px solid var(--border); }
summary { padding: 15px 0; color: var(--muted-strong); cursor: pointer; font-size: 13px; }
.advanced-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 28px; padding: 0 0 18px; }
.raw-line { padding: 9px 0; border-bottom: 1px solid var(--border); }
.raw-line dt { margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.raw-line dd { margin: 0; color: var(--muted-strong); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }

.footer-note { margin-top: 42px; padding-top: 15px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1.6; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 4; max-width: min(360px, calc(100% - 36px)); padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-raised); color: var(--muted-strong); font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.28); }

@media (max-width: 860px) {
  .action-layout, .progress-layout, .circuit-layout { grid-template-columns: 1fr; }
  .staking-layout { grid-template-columns: 1fr; }
  .circuit-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .circuit-steps > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--border); }
  .circuit-steps > div:nth-child(4) { border-top: 1px solid var(--border); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .app-shell { width: min(100% - 24px, 540px); padding-top: 18px; }
  .topbar { flex-direction: column; }
  .preview-tools { justify-content: flex-start; }
  .status-strip { flex-direction: column; }
  .status-meta { text-align: left; }
  .mechanism { grid-template-columns: 1fr; }
  .mechanism-step, .mechanism-step + .mechanism-step { min-height: 0; padding: 17px 0; border-left: 0; border-bottom: 1px solid var(--border); }
  .mechanism-step:last-child { border-bottom: 0; }
  .step-index { margin-bottom: 8px; }
  .evidence-grid, .advanced-content { grid-template-columns: 1fr; }
  .staking-banner { flex-direction: column; }
  .staking-split { padding: 12px 0 0; border-top: 1px solid var(--border); border-left: 0; }
  .staking-metrics { grid-template-columns: 1fr; }
  .reward-schedule { grid-template-columns: 1fr; }
  .reward-schedule > div { justify-content: flex-start; }
  .circuit-steps { grid-template-columns: 1fr; }
  .circuit-steps > div, .circuit-steps > div:nth-child(3), .circuit-steps > div:nth-child(4) { border-left: 0; border-top: 1px solid var(--border); }
  .circuit-steps > div:first-child { border-top: 0; }
  .log-row { grid-template-columns: 90px minmax(0, 1fr); }
  .log-row span:last-child { grid-column: 2; text-align: left; }
  .field-row { flex-direction: column; }
  .button-primary, .button-secondary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar { transition: none; }
}
