* { box-sizing: border-box; }
:root {
  --bg: #0f1420; --panel: #171d2b; --panel2: #1e2637; --line: #2a3550;
  --text: #dbe4f5; --muted: #8895b0; --accent: #7fb4ff; --accent2: #3d6fd6;
  --ground: #3f7d4e; --bridge: #b08655; --water: #10233a;
  --t1: #4d8cff; --t2: #ff5d5d; --err: #ff6b6b; --warn: #ffcf6b; --ok: #6bd88f;
}
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .3px; }
.brand span { color: var(--accent); font-weight: 500; }
.topnav a { color: var(--accent); text-decoration: none; margin-left: 16px; font-size: 13px; }
.topnav a:hover { text-decoration: underline; }

.workspace { display: flex; flex: 1; min-height: 0; }
.panel { width: 280px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 8px; }
.panel.right { border-right: none; border-left: 1px solid var(--line); }
.group { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.group h2 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.row:last-child { margin-bottom: 0; }
.grow { flex: 1; min-width: 0; }
label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
input, select, button { font: inherit; }
input[type=number] { width: 56px; }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; }
button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer;
}
button:hover { border-color: var(--accent2); }
button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; font-weight: 600; }
button.primary:hover { background: #4d80e8; }
button.danger { color: var(--err); }
button.danger:hover { border-color: var(--err); }
.hash { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-word; }
.hash.ok { color: var(--ok); }
.hash.err { color: var(--err); }
.hint { font-size: 11px; color: var(--muted); margin-top: 6px; }

.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool { text-align: left; font-size: 12px; }
.tool.active { border-color: var(--accent); background: #223154; color: #fff; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stage-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.coord { font-family: ui-monospace, Menlo, monospace; color: var(--muted); font-size: 13px; }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 10px; }
.sw.t1 { background: var(--t1); } .sw.t2 { background: var(--t2); }
.canvas-wrap { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 16px; }
canvas { background: var(--water); border: 1px solid var(--line); border-radius: 4px; cursor: crosshair; }

.validation .item { padding: 6px 8px; border-radius: 6px; margin-bottom: 6px; font-size: 12.5px; }
.validation .item.err { background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.4); color: #ffd0d0; }
.validation .item.warn { background: rgba(255,207,107,.12); border: 1px solid rgba(255,207,107,.35); color: #ffe6b8; }
.validation .ok { color: var(--ok); font-size: 12.5px; }
.validation .summary { font-weight: 600; margin-bottom: 8px; }

.versions .v { display: flex; justify-content: space-between; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.versions .v:last-child { border-bottom: none; }
.versions .v .h { font-family: ui-monospace, Menlo, monospace; color: var(--muted); }
.versions .v a { color: var(--accent); text-decoration: none; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; box-shadow: 0 8px 30px rgba(0,0,0,.4); font-size: 13px; z-index: 50;
}
.toast.err { border-color: var(--err); color: #ffd0d0; }
.toast.ok { border-color: var(--ok); color: #cbf6d8; }
