:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #5d6975;
  --line: #d4d9de;
  --accent: #1452cc;
  --tree: #26323d;
  --cotree: #26323d;
  --support: #d7263d;
  --cycle: #ff8c42;
  --good: #1f8f55;
  --warn: #9c6d00;
  --danger: #b42318;
  --code: #eef2f7;
}

.slide-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  background: #fbfcfe;
  display: grid;
  gap: 0.45rem;
}

.slide-block code {
  display: inline-block;
  font-size: 0.97rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eff2f6 0%, #f7f8fa 100%);
  color: var(--text);
}

.course-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  border-bottom: 1px solid #d8dde5;
  background: #ffffff;
  font-size: 0.95rem;
}

.course-bar a {
  color: #173b75;
  text-decoration: none;
}

.course-bar a:hover,
.page-footer a:hover {
  text-decoration: underline;
}

.course-title {
  font-weight: 800;
}

.course-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem 1rem;
}

.page-header,
.page-footer {
  padding: 1.25rem 1.5rem;
}

.page-header {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(20, 82, 204, 0.07), rgba(255, 140, 66, 0.08)),
    #fcfcfd;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 2rem;
}

.kicker {
  margin: 0 0 0.35rem;
  color: #6b4f00;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  max-width: 60rem;
  color: var(--muted);
  line-height: 1.45;
}

.meta-box {
  min-width: 17rem;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  box-shadow: 0 10px 30px rgba(8, 15, 30, 0.04);
}

.layout {
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) minmax(28rem, 1.2fr) minmax(22rem, 30rem);
  gap: 1rem;
  padding: 1rem 1.5rem 1.5rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 10px 24px rgba(8, 15, 30, 0.04);
  min-height: 0;
}

.controls-panel,
.details-panel {
  overflow: auto;
}

.graph-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

h2, h3 {
  margin: 0 0 0.7rem;
}

textarea {
  width: 100%;
  min-height: 16rem;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0.8rem 0.9rem;
  font: 0.95rem/1.45 ui-monospace, "SFMono-Regular", Menlo, monospace;
  background: #fbfcfe;
}

.button-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.mode-notice {
  border: 1px solid rgba(20, 82, 204, 0.18);
  border-radius: 12px;
  background: rgba(20, 82, 204, 0.07);
  color: var(--muted);
  line-height: 1.4;
  margin: 0.7rem 0 0.9rem;
  padding: 0.7rem 0.8rem;
}

.mode-notice strong {
  color: var(--text);
}

.mode-notice[data-mode="horton"] {
  border-color: rgba(31, 143, 85, 0.22);
  background: rgba(31, 143, 85, 0.08);
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.6rem 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  border-color: #9fb2d7;
  background: #f7faff;
}

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

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

.hint,
.page-footer {
  color: var(--muted);
  line-height: 1.45;
}

.graph-hint {
  margin: -0.15rem 0 0.15rem;
}

.status-box,
.summary-box,
.details-box,
.legend-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  background: #fbfcfe;
}

.quick-object-list {
  max-height: 15rem;
  overflow: auto;
  margin-bottom: 1rem;
}

.quick-object-list:empty {
  display: none;
}

#graphContextBox {
  padding: 0.65rem 0.9rem;
}

.status-box[data-tone="ok"] {
  border-color: rgba(31, 143, 85, 0.35);
  background: rgba(31, 143, 85, 0.07);
}

.status-box[data-tone="warn"] {
  border-color: rgba(156, 109, 0, 0.35);
  background: rgba(156, 109, 0, 0.08);
}

.status-box[data-tone="error"] {
  border-color: rgba(180, 35, 24, 0.35);
  background: rgba(180, 35, 24, 0.08);
}

.summary-box dl,
.details-box dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 0.8rem;
}

.summary-box dt,
.details-box dt {
  font-weight: 700;
}

.summary-box dd,
.details-box dd {
  margin: 0;
}

#graphSvg {
  width: 100%;
  height: auto;
  background:
    radial-gradient(circle at top, rgba(20, 82, 204, 0.04), transparent 45%),
    linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.bottom-step-controls {
  justify-content: center;
  margin: 0.8rem 0 0.7rem;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(12rem, 1fr));
  gap: 0.35rem 0.8rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.legend-swatch {
  display: inline-block;
  width: 1.9rem;
  height: 0;
  margin-right: 0.45rem;
  vertical-align: middle;
  border-top-width: 4px;
  border-top-style: solid;
  border-top-color: transparent;
}

.graph-node {
  cursor: grab;
}

.graph-node.dragging {
  cursor: grabbing;
}

.tree-edge { border-top-color: var(--tree); }
.cotree-edge { border-top-color: var(--cotree); border-top-style: dashed; }
.support-edge { border-top-color: var(--support); }
.cycle-edge { border-top-color: var(--cycle); }

.legend-dot {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  margin-right: 0.45rem;
  vertical-align: middle;
  border: 2px solid transparent;
}

.root-dot {
  background: rgba(20, 82, 204, 0.12);
  border-color: var(--accent);
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  background: var(--code);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.subroutine-link {
  display: inline-block;
  border: 1px solid rgba(20, 82, 204, 0.28);
  border-radius: 999px;
  background: rgba(20, 82, 204, 0.08);
  color: #173b75;
  font-weight: 800;
  padding: 0.35rem 0.65rem;
  text-decoration: none;
}

.subroutine-link:hover {
  background: rgba(20, 82, 204, 0.13);
  text-decoration: underline;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
  margin-top: 0.4rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.4rem;
  vertical-align: top;
  text-align: left;
}

th {
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}

.small-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.inline-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin-left: 0.35rem;
}

.mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

.tag {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.tag-good {
  background: rgba(31, 143, 85, 0.12);
  color: var(--good);
}

.tag-bad {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.tag-neutral {
  background: rgba(20, 82, 204, 0.09);
  color: var(--accent);
}

.step-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#stepLabel,
#stepLabelBottom {
  min-width: 10rem;
  text-align: center;
  font-weight: 700;
}


.walkthrough-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.8rem;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.94rem;
}

.walkthrough-controls label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#updateLabel {
  min-width: 12rem;
  text-align: center;
  font-weight: 700;
  color: var(--text);
}

.candidate-list {
  display: grid;
  gap: 0.5rem;
}

.result-list {
  display: grid;
  gap: 0.5rem;
}

.candidate-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: #fbfcfe;
  cursor: pointer;
}

.candidate-item.good {
  border-color: rgba(31, 143, 85, 0.35);
}

.candidate-item.bad {
  border-color: rgba(180, 35, 24, 0.25);
  opacity: 0.9;
}

.candidate-item.chosen {
  box-shadow: inset 0 0 0 2px rgba(255, 140, 66, 0.35);
}

.candidate-item.selected {
  box-shadow: inset 0 0 0 2px rgba(20, 82, 204, 0.28);
}

.candidate-item-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.candidate-item-body {
  margin-top: 0.35rem;
  color: var(--muted);
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: #fbfcfe;
  cursor: pointer;
}

.result-item.current {
  box-shadow: inset 0 0 0 2px rgba(255, 140, 66, 0.28);
}

.result-item.selected {
  box-shadow: inset 0 0 0 2px rgba(20, 82, 204, 0.28);
}

.result-item-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.result-item-body {
  margin-top: 0.35rem;
  color: var(--muted);
}

.update-row-current {
  background: rgba(20, 82, 204, 0.06);
}

.update-row-done {
  background: rgba(31, 143, 85, 0.04);
}

.update-row-future {
  opacity: 0.7;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  background: #fcfcfd;
}

.page-footer a {
  color: #173b75;
}

@media (max-width: 1250px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .page-header,
  .page-footer,
  .course-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .course-links {
    justify-content: flex-start;
  }
}
