:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-border: #2a2f3a;
  --text: #e7e9ee;
  --text-dim: #9aa3b2;
  --accent: #5aa9ff;
  --accent-dim: #2b4a73;
  --node-fill: #1e2430;
  --node-stroke: #5aa9ff;
  --arrow: #e7e9ee;
  --placeholder: #ff9d5c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

header .desc {
  color: var(--text-dim);
  font-size: 13px;
  flex: 1 1 300px;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

select, button, input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
}

button {
  cursor: pointer;
  background: var(--accent-dim);
  border-color: var(--accent);
}

button:hover { filter: brightness(1.15); }

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

main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

svg#canvas {
  width: 100%;
  height: 100%;
  max-width: 1100px;
}

.node-box {
  fill: var(--node-fill);
  stroke: var(--node-stroke);
  stroke-width: 1.5;
}

.node-label {
  fill: var(--text);
  font-size: 13px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.node-sub {
  fill: var(--text-dim);
  font-size: 10px;
  text-anchor: middle;
  font-style: italic;
}

.arrow-line {
  stroke: var(--arrow);
  stroke-width: 2;
  fill: none;
  marker-end: url(#arrowhead);
}

.arrow-line.loop {
  stroke: var(--placeholder);
  stroke-dasharray: 6 4;
}

.arrow-label {
  fill: var(--text-dim);
  font-size: 10px;
  text-anchor: middle;
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

#side-panel {
  width: 340px;
  border-left: 1px solid var(--panel-border);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#step-status {
  font-size: 13px;
  color: var(--text-dim);
}

#current-caption {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.4;
  min-height: 70px;
}

#current-caption .placeholder-tag {
  color: var(--placeholder);
  font-size: 11px;
  display: block;
  margin-top: 6px;
}

#hint {
  font-size: 12px;
  color: var(--text-dim);
}

#log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.log-item {
  border-left: 2px solid var(--accent-dim);
  padding-left: 8px;
  color: var(--text-dim);
}

.log-item b { color: var(--text); }
