﻿:root {
  --bg: #0b1014;
  --surface: #11191f;
  --surface-alt: #162128;
  --text: #edf3f5;
  --muted: #a5b4bc;
  --border: #30434d;
  --accent: #8bc4d2;
  --focus: #f0c66c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Outfit", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.container {
  width: min(1220px, 94vw);
  margin: 0 auto;
}

.header { padding: 1.5rem 0 1rem; }

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

h1, h2, h3 { margin: 0; }

h1 {
  margin-top: 0.5rem;
  font-size: clamp(1.9rem, 3.8vw, 2.9rem);
}

.header p {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(0, 1fr);
  gap: 1rem;
  padding-bottom: 2rem;
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
}

.stack {
  padding: 0.85rem;
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.block {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  padding: 0.75rem;
  width: 100%;
  overflow: hidden;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.34rem;
  margin-top: 0.65rem;
  color: var(--muted);
}

select,
input,
button {
  font: inherit;
}

select,
input {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #18262e;
  color: var(--text);
  padding: 0.42rem;
}

button {
  margin-top: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #1b3039;
  color: var(--text);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: #0e1320;
  border-color: transparent;
  font-weight: 700;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
.network:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.status {
  min-height: 1.2rem;
  margin-top: 0.6rem;
  color: var(--muted);
}

.policy-note {
  margin: 0.35rem 0 0;
  color: var(--accent);
  font-size: 0.85rem;
}

.metrics {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.metrics article {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.45rem;
  background: #171e2d;
}

.metrics h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.metrics p {
  margin: 0.2rem 0 0;
  font-family: "JetBrains Mono", monospace;
}

.steps {
  margin: 0.6rem 0 0;
  padding-left: 1.2rem;
  max-height: 160px;
  overflow: auto;
}

.steps li {
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
  word-break: break-word;
}

.resilience-card {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #171e2d;
  padding: 0.55rem;
}

.resilience-card h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.resilience-card .helper-note {
  margin-top: 0.35rem;
}

.resilience-line {
  margin: 0.28rem 0 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.84rem;
  color: var(--text);
}

.line-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.line-editor label { margin-top: 0.5rem; }

.mode-row {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.mode-btn {
  margin-top: 0;
  padding: 0.38rem 0.45rem;
  font-size: 0.86rem;
}

.mode-btn.active {
  background: var(--accent);
  border-color: transparent;
  color: #0f1420;
  font-weight: 700;
}

.helper-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.selection-card {
  margin-top: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #171e2d;
  padding: 0.5rem;
}

.selection-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.selection-card p + p {
  margin-top: 0.28rem;
}

.selection-card label {
  margin-top: 0.5rem;
}

.selection-actions {
  margin-top: 0.48rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.selection-actions button {
  margin-top: 0;
  padding: 0.38rem 0.45rem;
  font-size: 0.83rem;
}

.terrain-actions {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.terrain-actions button {
  margin-top: 0;
}

.map-panel {
  padding: 0.95rem;
  min-width: 0;
}

.network {
  margin-top: 0.55rem;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #0f1420;
  touch-action: none;
}

.terrain-lake {
  fill: rgba(49, 130, 206, 0.32);
  stroke: rgba(49, 130, 206, 0.7);
  stroke-width: 2;
}

.terrain-obstacle {
  fill: rgba(185, 100, 68, 0.28);
  stroke: rgba(185, 100, 68, 0.7);
  stroke-width: 2;
}

.terrain-river {
  fill: none;
  stroke: rgba(58, 138, 219, 0.62);
  stroke-width: 18;
  stroke-linecap: round;
}

.edge {
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 0.8;
}

.edge.active {
  stroke-width: 11;
  opacity: 1;
}

.edge.selected {
  stroke-width: 12;
  opacity: 1;
}

.edge:focus-visible {
  stroke-width: 12;
  opacity: 1;
  outline: none;
}

.edge.blocked {
  stroke: rgba(148, 163, 184, 0.55) !important;
  stroke-dasharray: 9 8;
}

.station {
  fill: #f8fafc;
  stroke: #0f172a;
  stroke-width: 2;
  cursor: grab;
}

.station.active {
  fill: #dbeafe;
  stroke: #1d4ed8;
}

.station.selected {
  fill: #d7defe;
  stroke: #0f172a;
  stroke-width: 3;
}

.station:focus-visible {
  stroke: var(--focus);
  stroke-width: 4;
  outline: none;
}

.station.dragging {
  cursor: grabbing;
}

.station-label {
  font-size: 12px;
  fill: #d6deef;
  font-family: "JetBrains Mono", monospace;
  pointer-events: none;
}

.legend {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.legend span {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.24rem 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

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

  .line-editor {
    grid-template-columns: 1fr;
  }

  .mode-row,
  .selection-actions,
  .terrain-actions {
    grid-template-columns: 1fr;
  }
}
