:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #5f6b7a;
  --line: #d8e0eb;
  --accent: #0f6fff;
  --accent-soft: #e9f1ff;
  --success: #0a7d3d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #e8f0ff 0%, #f3f6fb 45%, #ecf8f1 100%);
}

.top-sentence {
  margin: 0;
  padding: 0.7rem 1rem;
  font-weight: 700;
  color: #14345c;
  background: #edf4ff;
  border-bottom: 1px solid #d9e4f5;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 1rem;
  min-height: calc(100vh - 44px);
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem;
  box-shadow: 0 6px 22px rgba(14, 35, 68, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 0;
  max-height: calc(100vh - 4rem);
  overflow: auto;
}

.panel-head {
  border-bottom: 1px solid #e6ecf4;
  padding-bottom: 0.7rem;
}

.panel-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #4e79c7;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0.35rem;
  line-height: 1.2;
}

.subtitle,
.muted {
  color: var(--muted);
}

.panel-head select {
  width: 100%;
  border: 1px solid #c5d2e2;
  border-radius: 8px;
  padding: 0.45rem;
  font-size: 0.95rem;
  background: #fff;
}

.step-list {
  display: grid;
  gap: 0.7rem;
}

.intent-stage {
  border-style: dashed;
  background: #f6fbff;
}

.step {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  background: #fbfdff;
}

.step label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.step input {
  width: 100%;
  border: 1px solid #c5d2e2;
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 0.95rem;
}

.step select {
  width: 100%;
  border: 1px solid #c5d2e2;
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 0.95rem;
  background: #fff;
  margin-bottom: 0.45rem;
}

.toggle-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-weight: 700;
}

.controls {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 9px;
  padding: 0.6rem 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

button.primary {
  color: #fff;
  background: var(--accent);
}

button.secondary {
  color: var(--ink);
  background: var(--accent-soft);
}

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

.prediction {
  margin-top: 1rem;
  border: 1px solid #d4e7d6;
  background: #f0fbf3;
  color: var(--success);
  border-radius: 10px;
  padding: 0.75rem;
  font-weight: 700;
}

.notice {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.funnel-list,
.tree-list {
  margin: 0;
  padding-left: 1rem;
}

.funnel-list li,
.tree-list li {
  margin-bottom: 0.35rem;
}

.reveal {
  margin-top: 0.85rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.85rem;
}

.trick-sections {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.6rem;
}

#reveal-explanation-panel {
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  padding: 0.35rem;
}

#reveal-explanation-toggle {
  width: 100%;
  text-align: left;
  background: #f2f7ff;
  color: #16365f;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
}

#reveal-explanation-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 220ms ease, opacity 220ms ease;
  padding: 0 0.25rem;
}

#reveal-explanation-panel.open #reveal-explanation-content {
  max-height: 2000px;
  opacity: 1;
  padding: 0.55rem 0.25rem 0.2rem;
}

.collapsible {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
}

.collapse-toggle {
  width: 100%;
  text-align: left;
  background: #f2f7ff;
  color: #16365f;
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
}

.collapse-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 220ms ease, opacity 220ms ease;
  padding: 0 0.6rem;
}

.collapsible.open .collapse-content {
  max-height: 1200px;
  opacity: 1;
  padding: 0.4rem 0.6rem 0.6rem;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f5f7fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem;
}

.meter-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  border: 1px solid #cfd9e7;
  background: #f5f8fd;
  overflow: hidden;
  margin: 0.5rem 0 0.75rem;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f6fff 0%, #47b6ff 100%);
  transition: width 180ms ease-in-out;
}

.meter-stages {
  margin: 0;
  padding-left: 1rem;
}

.meter-stage {
  color: #6a7687;
  margin-bottom: 0.25rem;
}

.meter-stage.active {
  color: #0c2040;
  font-weight: 700;
}

.meter-bars {
  margin: 0.55rem 0 0;
  padding: 0.45rem;
  border: 1px solid #d4deee;
  border-radius: 8px;
  background: #f7faff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.3;
  white-space: pre;
}

.phase-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.phase-item {
  border: 1px solid #d7e0ee;
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  background: #fbfdff;
  color: #64778f;
  font-weight: 600;
  font-size: 0.9rem;
}

.phase-item.active {
  border-color: #87b4ff;
  background: #eef5ff;
  color: #16365f;
}

.cloud-grid {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  gap: 0.2rem;
}

.cloud-dot {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: block;
}

.cloud-dot.on {
  background: #0f6fff;
  opacity: 0.9;
}

.cloud-dot.off {
  background: #d9e2ef;
  opacity: 0.45;
}

.branch-diagram {
  margin-top: 0.25rem;
}

.branch-stage {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.branch-node {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: #fbfdff;
}

.branch-node.active {
  border-color: #84b2ff;
  background: #eef5ff;
}

.branch-title {
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.branch-note {
  color: #617083;
  font-size: 0.88rem;
}

.branch-link {
  color: #9dadc2;
  font-size: 1.05rem;
  line-height: 1.1;
  margin: 0.15rem 0 0.15rem 0.4rem;
}

.branch-link.active {
  color: #3f7de5;
  font-weight: 700;
}

.probability-card {
  margin-top: 0.65rem;
  border: 1px solid #d6e1f0;
  border-radius: 10px;
  padding: 0.65rem;
  background: #f8fbff;
}

.prob-options {
  margin-top: 0.3rem;
  color: #63758c;
  font-size: 0.86rem;
}

.warning-text {
  color: #8e2f00;
  background: #fff1e8;
  border: 1px solid #ffd5bf;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-weight: 700;
}

.session-replay {
  margin-top: 0.8rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.8rem;
}

.replay-controls {
  margin-top: 0.5rem;
}

.replay-live {
  margin-top: 0.55rem;
  background: #f6fbff;
}

.replay-list {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.45rem;
}

.replay-row {
  border: 1px solid #d8e2ef;
  border-radius: 9px;
  padding: 0.55rem 0.65rem;
  background: #fbfdff;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.replay-row p {
  margin: 0.1rem 0;
}

.replay-row.seen {
  border-color: #bad0f7;
  background: #f3f8ff;
}

.replay-row.active {
  border-color: #6a9ef3;
  background: #eaf3ff;
  transform: translateX(4px);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .panel {
    padding: 1rem;
    max-height: none;
    overflow: visible;
  }
}
