:root {
  --background: #fcfcfc;
  --panel: #ffffff;
  --text: #111111;
  --muted: #666666;
  --line: #111111;
  --border: #d9d9d9;
  --node: #d6d6d6;
  --active: #f0d64f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.intro {
  display: grid;
  gap: 10px;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.intro h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.15;
}

.description {
  max-width: 760px;
  margin: 0;
  line-height: 1.8;
  color: var(--muted);
}

.source-link {
  margin: 0;
  color: var(--muted);
}

.source-link a {
  color: inherit;
  text-underline-offset: 0.16em;
}

.status-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 16px;
  margin-top: 24px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
}

.label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.output-text,
.current-node {
  margin: 0;
  line-height: 1.2;
  word-break: break-all;
}

.output-text {
  display: flex;
  flex-wrap: wrap;
  gap: 0.18rem var(--output-gap, 0.18rem);
  height: 7.2rem;
  overflow: hidden;
  font-size: var(--output-font-size, 3rem);
  line-height: 1.08;
  align-content: flex-start;
}

.output-token {
  color: var(--text);
}

.output-token.is-match {
  color: #c62828;
}

.current-node {
  font-size: 2.2rem;
  font-weight: 700;
}

.transition-text,
.step-count {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.meta-line {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.meta-line strong {
  color: var(--text);
}

.graph-panel {
  margin-top: 16px;
  padding: 16px;
}

svg {
  display: block;
  width: 100%;
  height: auto;
}

marker path {
  fill: var(--line);
}

.edge-path {
  fill: none;
  stroke: var(--line);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edge-label {
  fill: var(--line);
  font-size: 22px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--panel);
  stroke-width: 8px;
}

.node circle {
  fill: var(--node);
  stroke: var(--line);
  stroke-width: 3;
  transition: fill 120ms ease;
}

.node text {
  fill: var(--text);
  font-size: 40px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}

.node-note {
  fill: var(--muted);
  font-size: 18px;
  font-weight: 700;
  text-anchor: middle;
}

.node.is-active circle {
  fill: var(--active);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-top: 20px;
}

.controls button {
  min-width: 132px;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.controls button.is-active {
  background: #c62828;
  border-color: #c62828;
  color: var(--panel);
}

.sync-status {
  margin: 0;
  min-height: 1.7em;
  color: var(--text);
  line-height: 1.7;
}

.sync-status.is-muted {
  color: var(--muted);
}

.sync-status.is-hidden {
  visibility: hidden;
}

@media (max-width: 720px) {
  .page {
    padding: 24px 14px 36px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .graph-panel {
    padding: 10px;
  }

  .controls button {
    flex: 1 1 140px;
  }

  .output-text {
    height: 6.4rem;
  }

  .node text {
    font-size: 34px;
  }

  .edge-label {
    font-size: 18px;
  }
}
