:root {
  --st-bg0: #f3f0e8;
  --st-bg1: #e7eef2;
  --st-ink: #1c2430;
  --st-muted: #5c6675;
  --st-line: rgba(28, 36, 48, 0.14);
  --st-accent: #2f5d50;
  --st-accent-2: #b4532a;
  --st-panel: rgba(255, 255, 255, 0.72);
  --st-shadow: 0 18px 50px rgba(28, 36, 48, 0.08);
  --font-display: "Cormorant Garamond", "Noto Serif JP", serif;
  --font-body: "Outfit", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--st-ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 700px at 10% -10%, #dfe9e4 0%, transparent 55%),
    radial-gradient(900px 600px at 100% 0%, #f0e2d4 0%, transparent 50%),
    linear-gradient(160deg, var(--st-bg0), var(--st-bg1));
}

a { color: var(--st-accent); }

.st-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.st-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.st-brand {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
}
.st-sub {
  color: var(--st-muted);
  font-size: 0.95rem;
  margin: 4px 0 0;
}
.st-home {
  font-size: 0.9rem;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.st-home:hover { border-bottom-color: var(--st-accent); }

.st-panel {
  background: var(--st-panel);
  border: 1px solid var(--st-line);
  box-shadow: var(--st-shadow);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 22px;
}

.st-gate {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: left;
}
.st-gate h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin: 0 0 8px;
}
.st-gate p { color: var(--st-muted); margin: 0 0 18px; line-height: 1.6; }

.st-label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--st-muted);
  margin-bottom: 6px;
}
.st-input, .st-textarea {
  width: 100%;
  border: 1px solid var(--st-line);
  background: rgba(255,255,255,0.85);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  color: var(--st-ink);
}
.st-input:focus, .st-textarea:focus {
  outline: 2px solid rgba(47, 93, 80, 0.35);
  border-color: var(--st-accent);
}
.st-textarea { min-height: 120px; resize: vertical; }

.st-btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--st-accent);
  color: #fff;
}
.st-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.st-btn.secondary {
  background: transparent;
  color: var(--st-accent);
  border: 1px solid rgba(47, 93, 80, 0.35);
}
.st-btn.danger-soft {
  background: transparent;
  color: var(--st-accent-2);
  border: 1px solid rgba(180, 83, 42, 0.35);
}

.st-err {
  color: #9b2c2c;
  min-height: 1.2em;
  font-size: 0.9rem;
  margin-top: 10px;
}
.st-ok {
  color: var(--st-accent);
  font-size: 0.9rem;
  margin-top: 8px;
}

.st-hidden { display: none !important; }

.st-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}
.st-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.st-row .st-input { flex: 1 1 280px; }
.st-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--st-line);
  background: rgba(255,255,255,0.7);
  color: var(--st-muted);
}
.st-badge.fail {
  color: #8b2e2e;
  border-color: rgba(139, 46, 46, 0.35);
  background: rgba(139, 46, 46, 0.08);
}

.st-drive-panel {
  margin-bottom: 16px;
}
.st-drive-steps {
  margin: 10px 0 0;
  padding-left: 1.2rem;
  font-size: 0.88rem;
  color: var(--st-ink);
  display: grid;
  gap: 4px;
}
.st-drive-steps li.ok { color: var(--st-accent); }
.st-drive-steps li.fail { color: #8b2e2e; }
.st-drive-report {
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.4;
  border: 1px solid var(--st-line);
  border-radius: 8px;
  background: rgba(0,0,0,0.03);
  white-space: pre-wrap;
  word-break: break-word;
}
.st-status {
  font-size: 0.9rem;
  color: var(--st-muted);
  min-height: 1.4em;
}

.st-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 16px;
  min-height: 520px;
}
@media (max-width: 900px) {
  .st-layout { grid-template-columns: 1fr; }
}

.st-col h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 12px;
}

.st-section-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.st-section-list button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--st-line);
  background: rgba(255,255,255,0.55);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.st-section-list button.active {
  border-color: rgba(47, 93, 80, 0.45);
  background: rgba(47, 93, 80, 0.1);
}
.st-section-list .t {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
}
.st-section-list .s {
  display: block;
  font-size: 0.8rem;
  color: var(--st-muted);
  line-height: 1.4;
}

.st-tree {
  font-size: 0.92rem;
  line-height: 1.45;
}
.st-node {
  margin: 0 0 8px;
  padding-left: 14px;
  border-left: 2px solid rgba(47, 93, 80, 0.18);
}
.st-node-head {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}
.st-node-head:hover { background: rgba(28, 36, 48, 0.04); }
.st-layer {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--st-accent-2);
  background: rgba(180, 83, 42, 0.1);
  border-radius: 6px;
  padding: 2px 6px;
  margin-top: 2px;
}
.st-claim { font-weight: 600; }
.st-enrich {
  margin: 4px 0 0 42px;
  color: var(--st-muted);
  font-size: 0.85rem;
  white-space: pre-wrap;
}
.st-children { margin-top: 6px; }
.st-empty {
  color: var(--st-muted);
  font-size: 0.95rem;
  padding: 12px 0;
}

.st-detail {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--st-line);
}
.st-detail h4 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.st-meta {
  font-size: 0.8rem;
  color: var(--st-muted);
  margin-bottom: 8px;
}
.st-prose {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--st-line);
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 0.95rem;
}
.st-sources {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--st-muted);
}
.st-sources ul { padding-left: 18px; margin: 6px 0 0; }

.st-fallback {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--st-line);
}

.st-progress-panel { margin-bottom: 16px; }
.st-progress-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.st-progress-head h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0;
  flex: 1;
}
.st-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}
.st-stage {
  position: relative;
  min-width: 110px;
  flex: 1 1 110px;
  border: 1px solid var(--st-line);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.5);
  font-size: 0.82rem;
}
.st-stage .nm { font-weight: 700; display: block; margin-bottom: 4px; }
.st-stage .stt { color: var(--st-muted); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; }
.st-stage.running { border-color: rgba(47, 93, 80, 0.45); background: rgba(47, 93, 80, 0.08); }
.st-stage.done { border-color: rgba(47, 93, 80, 0.3); }
.st-stage.awaiting_user { border-color: rgba(180, 83, 42, 0.5); background: rgba(180, 83, 42, 0.08); }
.st-stage.failed { border-color: #c53030; background: rgba(197, 48, 48, 0.06); }
.st-stage.fork-mark {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  font-weight: 700;
  color: var(--st-muted);
  background: transparent;
  border-style: dashed;
}
.st-fork-note {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--st-muted);
}
.st-restart-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--st-line);
}
.st-stage .restart-mini {
  display: block;
  margin-top: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--st-accent-2);
  background: transparent;
  border: 1px solid rgba(180, 83, 42, 0.35);
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
  font-family: inherit;
}
.st-stage .restart-mini:hover {
  background: rgba(180, 83, 42, 0.1);
}
.st-stage .err-mini {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  color: #9b2c2c;
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
}
.st-event-log {
  margin-top: 12px;
  max-height: 140px;
  overflow: auto;
  font-size: 0.8rem;
  color: var(--st-muted);
  border-top: 1px solid var(--st-line);
  padding-top: 8px;
}
.st-event-log div { margin-bottom: 4px; }

.st-question-panel { margin-bottom: 16px; border-color: rgba(180, 83, 42, 0.35); }
.st-hint { color: var(--st-muted); font-size: 0.9rem; line-height: 1.55; margin: 0 0 14px; }
.st-q-card {
  border: 1px solid var(--st-line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.6);
}
.st-q-card .stage-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--st-accent-2);
  margin-bottom: 6px;
}
.st-q-card .prompt { font-weight: 600; margin-bottom: 10px; line-height: 1.5; }
.st-q-options { display: grid; gap: 8px; margin-bottom: 10px; }
.st-q-options label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.92rem;
  cursor: pointer;
}
.st-q-free { margin-top: 6px; }
.st-intervene-box {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--st-line);
}

.st-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 960px) {
  .st-zones { grid-template-columns: 1fr; }
}
.st-zone h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.st-liquid { display: grid; gap: 14px; }
.st-flow {
  border-left: 3px solid var(--st-accent);
  padding: 4px 0 4px 14px;
}
.st-flow-retained {
  border-left-color: var(--st-accent-2, #8a6a3d);
  background: linear-gradient(90deg, rgba(138, 106, 61, 0.06), transparent 60%);
}
.st-merge-meta {
  font-size: 0.72rem;
  color: var(--st-muted);
  margin-top: 4px;
}
.st-matrix {
  display: grid;
  grid-template-columns: repeat(var(--st-matrix-cols, 1), minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.st-matrix-col {
  border: 1px solid var(--st-line);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(47, 93, 80, 0.05), transparent 40%);
  min-width: 180px;
}
.st-matrix-col-head {
  font-weight: 700;
  margin-bottom: 8px;
  font-family: var(--font-display);
}
.st-matrix-layer {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.st-matrix-layer-lab {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--st-accent-2);
  padding-top: 6px;
}
.st-matrix-cells { display: grid; gap: 6px; }
.st-matrix-node { margin: 0; }
.st-matrix-empty {
  color: var(--st-muted);
  opacity: 0.45;
  font-size: 0.85rem;
  padding: 4px 0;
}
.st-relations {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.st-rel-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border: 1px solid var(--st-line);
  border-radius: 8px;
  font-size: 0.9rem;
}
.st-rel-row .kind {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--st-accent-2);
  text-transform: none;
  padding-top: 2px;
  white-space: nowrap;
}
.st-rel-row .from,
.st-rel-row .to { font-weight: 600; }
.st-nest {
  margin: 4px 0;
  padding-left: calc(var(--st-nest-depth, 0) * 12px);
}
.st-nest-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.st-nest-scale {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--st-accent);
  border: 1px solid var(--st-line);
  border-radius: 4px;
  padding: 1px 6px;
}
.st-nest-claim { font-weight: 700; }
.st-nest-contains {
  margin-top: 6px;
  border-left: 2px solid rgba(47, 93, 80, 0.25);
  padding-left: 10px;
}
.st-nest-for {
  font-size: 0.72rem;
  color: var(--st-muted);
  margin-bottom: 4px;
}
.st-flow-title {
  font-weight: 700;
  margin-bottom: 8px;
}
.st-flow-step {
  position: relative;
  padding: 8px 0 8px 12px;
  border-left: 2px solid rgba(47, 93, 80, 0.2);
  margin-left: 4px;
}
.st-flow-step .ord {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--st-accent-2);
}
.st-flow-step .role {
  font-size: 0.72rem;
  color: var(--st-muted);
  margin-left: 6px;
}
.st-flow-step .txt { margin-top: 2px; font-weight: 600; }
.st-flow-step .quote {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--st-muted);
  white-space: pre-wrap;
}
.st-nuance {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--st-accent-2);
}

.st-issue-box {
  border-top: 1px dashed var(--st-line);
  padding-top: 12px;
  font-size: 0.92rem;
}
.st-issue-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--st-accent);
  margin-bottom: 10px;
}
.st-issue-box code {
  font-size: 0.85em;
  background: rgba(28,36,48,0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.st-report-panel .st-progress-head h3 { flex: 1; }
.st-report-tabs {
  margin-top: 12px;
  border: 1px solid var(--st-line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  min-height: 420px;
}
.st-report-frame {
  width: 100%;
  height: 560px;
  border: 0;
  background: #fff;
}
.st-report-json {
  margin: 0;
  padding: 14px;
  max-height: 560px;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  background: #1c2430;
  color: #e8eef2;
}
