:root {
  --bg: #f3efe6;
  --card: #fff;
  --ink: #1a1a1a;
  --muted: #666;
  --line: #d8d2c8;
  --orange: #e07020;
  --pink: #d63888;
  --pipe: #222;
  --water: #2a8fc9;
  --good: #1a8f4a;
  --spill: #c45a10;
  --panel: #faf8f4;
  --footer-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

/* Phones: page must scroll — desktop keeps the locked viewport shell */
@media (max-width: 900px) {
  html, body {
    height: auto;
    min-height: 100%;
    min-height: 100dvh;
  }
  body {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.55rem 1.1rem 0.7rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.bar-brand {
  min-width: 0;
}

h1 { margin: 0; font-size: 1.15rem; }
.sub { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.8rem; max-width: 48ch; line-height: 1.35; }

.bar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  justify-self: center;
  text-align: center;
}

.wip-banner {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a3a08;
  background: #ffe0c2;
  border: 2px solid #c45a10;
  border-radius: 10px;
  padding: 0.35rem 1.25rem;
  line-height: 1.2;
}

.wip-banner[hidden] { display: none; }

body.domain-electrical .wip-banner:not([hidden]) {
  display: block;
}

.mode-toggle {
  display: flex;
  border: 2px solid var(--pipe);
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.mode {
  font: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 0.7rem 1.85rem;
  border: none;
  background: var(--card);
  cursor: pointer;
  color: var(--muted);
  letter-spacing: 0.01em;
  min-width: 6.5rem;
}

.mode.on {
  background: var(--pipe);
  color: #fff;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.domain-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--orange);
  border-radius: 8px;
  background: #fff8f0;
  color: var(--ink);
  cursor: pointer;
}

.domain-btn:hover { background: #ffedd9; }
.domain-btn.elec {
  border-color: #4a6fa5;
  background: #eef3fb;
}

.tool.tool-delete {
  border-color: #c45a10;
  color: #8a3a08;
}
.tool.tool-delete.on {
  background: #c45a10;
  border-color: #c45a10;
  color: #fff;
}

@media (max-width: 900px) {
  .bar {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }
  .bar-center { order: -1; }
  .bar-brand .sub { display: none; }
  h1 { font-size: 1rem; }
  .mode {
    font-size: 1rem;
    padding: 0.55rem 1.25rem;
    min-width: 5rem;
  }
  .wip-banner {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
  }
  .header-actions { justify-content: flex-start; }
  .domain-btn { font-size: 0.75rem; padding: 0.4rem 0.65rem; }
  .tab-strip { padding: 0.35rem 0.75rem; }
  .guide { padding: 0.35rem 0.75rem; }
  .hint { padding: 0.35rem 0.75rem; }
  .tools { padding: 0.4rem 0.75rem; }
}

.tab-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1.1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.tab-strip-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 0.25rem;
}

.courses {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0;
  background: transparent;
  border: none;
  flex: 1 1 auto;
  align-items: flex-end;
  min-width: 0;
}

.course-tab-wrap {
  display: inline-flex;
  align-items: stretch;
  margin-bottom: -1px;
}

.course-tab {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #f0ebe3;
  cursor: pointer;
  color: var(--muted);
}

.course-tab-wrap.saved .course-tab {
  border-radius: 8px 0 0 0;
  padding-right: 0.5rem;
  font-style: italic;
}

.course-tab.on {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
  position: relative;
  z-index: 1;
}

.course-tab.saved {
  border-style: solid;
}

.tab-del {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  width: 1.55rem;
  padding: 0;
  border: 1px solid var(--line);
  border-left: none;
  border-bottom: none;
  border-radius: 0 8px 0 0;
  background: #f0ebe3;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.course-tab-wrap.saved:has(.course-tab.on) .tab-del {
  background: var(--bg);
  border-color: var(--line);
  z-index: 1;
  position: relative;
}
.tab-del:hover {
  background: #fde8e8;
  color: #b00020;
}

.tab-new {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  border: 1px dashed var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #fff;
  cursor: pointer;
  color: var(--ink);
  margin: 0 0 -1px 0.15rem;
  flex: 0 0 auto;
}

.tab-new:hover { border-color: var(--orange); color: var(--orange); }

.guide {
  margin: 0;
  padding: 0.4rem 1.1rem;
  background: #fffdf8;
  border-bottom: 1px solid var(--line);
}

.guide.compact .guide-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
}

.guide-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  flex-shrink: 0;
}

.guide-body {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--ink);
  flex: 1 1 20rem;
}

.guide-steps {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
  max-width: 72ch;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.25rem;
  list-style-position: inside;
}

.guide-steps[hidden] { display: none; }
.guide-steps li { margin: 0; }

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1.1rem;
  background: #eef6ff;
  border-bottom: 1px solid #c5d8ec;
}

.tools[hidden] { display: none; }

.tool {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}

.tool.on {
  background: var(--pipe);
  color: #fff;
  border-color: var(--pipe);
}

.tool-side { margin-left: auto; }

.save-status {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0 0.35rem;
}

.link {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  color: var(--ink);
}

.link:hover { border-color: var(--orange); }

.run-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1.1rem;
  background: #fff8e6;
  border-bottom: 1px solid #e8d090;
}

.run-editor[hidden] { display: none; }

.run-editor-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 0.25rem;
}

.run-editor button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.run-editor button.danger { color: #b00020; border-color: #e0a0a0; }
.run-editor button.quiet { color: var(--muted); background: transparent; border: none; }

.hint {
  margin: 0;
  padding: 0.35rem 1.1rem;
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.35;
}

.hint.ok { color: var(--good); }
.hint.warn { color: var(--spill); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  gap: 0.75rem;
  padding: 0.35rem 1.1rem 0.75rem;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    flex: none;
    overflow: visible;
    padding: 0.35rem 0.75rem 1.25rem;
    gap: 0.65rem;
  }
  .wall-box {
    height: auto;
    min-height: min(58vh, 420px);
    max-height: none;
  }
  .wall-scroll {
    min-height: min(58vh, 420px);
    max-height: 70vh;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: auto;
  }
  .panel {
    max-height: none;
    overflow: visible;
  }
}

.wall-box {
  position: relative;
  background: #ddd8ce;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.wall-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.75rem 0.75rem 3.5rem;
  /* Let SVG size drive scroll; don't force center when zoomed large */
  display: block;
}

.wall {
  display: block;
  /* Allow pan/scroll on touch; draw mode sets .drawing for none */
  touch-action: pan-x pan-y pinch-zoom;
  margin: 0 auto;
}
body.drawing .wall {
  touch-action: none;
}

.canvas-chrome {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}
.chrome-card {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.3rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chrome-btn {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.55rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
}

@media (max-width: 900px) {
  .canvas-chrome {
    left: 6px;
    bottom: 6px;
    gap: 0.3rem;
  }
  .chrome-btn {
    min-width: 2.4rem;
    height: 2.4rem;
    font-size: 0.85rem;
  }
  .chrome-card { padding: 0.25rem; }
}
.chrome-btn.primary {
  background: var(--water);
  color: #fff;
}
.chrome-btn.primary:hover { filter: brightness(1.06); }
.chrome-sep {
  width: 1px;
  height: 1.4rem;
  background: var(--line);
  margin: 0 0.15rem;
}
.zoom-label {
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 2.4rem;
  text-align: center;
  color: var(--muted);
}

.vis-goal.lit-load { fill: #f5d76e; stroke: #c9a227; }
.bulb-dot { fill: #666; pointer-events: none; }
.bulb-dot.on { fill: #fff6a8; stroke: #c9a227; stroke-width: 1; }
.spark {
  fill: none;
  stroke: #e6b800;
  stroke-width: 2;
  opacity: 0.7;
  animation: spark 0.8s ease infinite;
}
@keyframes spark { 50% { opacity: 0.25; r: 22; } }

.pipe-gap-empty.wire-black { stroke: #333; }
.pipe-gap-empty.wire-white { stroke: #888; }
.pipe-gap-empty.wire-green { stroke: #2a8f4a; }
.pipe-gap-empty.wire-red { stroke: #c0392b; }
.pipe-gap-filled.wire-black { stroke: #222; }
.pipe-gap-filled.wire-white { stroke: #bbb; }
.pipe-gap-filled.wire-green { stroke: #1a8f4a; }
.pipe-gap-filled.wire-red { stroke: #c0392b; }
.pipe-gap-filled.wire-black.flow,
.pipe-gap-filled.wire-red.flow { stroke: #e6b800; }
.pipe-conduit { stroke: #555; stroke-width: 9; stroke-linecap: round; }
.pipe-conduit.flow { stroke: #e6b800; }

.valve.switch .valve-body { fill: #fff8e0; stroke: #c9a227; }
/* Domain tool visibility: shared tools (both attrs) stay visible */
body.domain-plumbing .tools [data-elec]:not([data-plumb]) { display: none; }
body.domain-electrical .tools [data-plumb]:not([data-elec]) { display: none; }
body.domain-plumbing .run-editor [data-elec] { display: none; }
body.domain-electrical .run-editor [data-plumb] { display: none; }

.spill-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.75rem 0 0;
  font-size: 0.84rem;
  line-height: 1.35;
  cursor: pointer;
}

.spill-toggle input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.win {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  background: var(--good);
  color: #fff;
  font-weight: 700;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  overflow: auto;
  max-height: 100%;
}

.panel h2 {
  margin: 0;
  font-size: 0.95rem;
}

.panel-lead {
  margin: 0.3rem 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.goal-card {
  background: var(--panel);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.goal-card strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.goal-card p { margin: 0; }

.checks {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.checks li {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.84rem;
  line-height: 1.3;
}

.ck-mark {
  flex: 0 0 1.1rem;
  font-weight: 800;
  text-align: center;
}

.checks li.pass .ck-mark { color: var(--good); }
.checks li.fail .ck-mark { color: #b00020; }
.checks li.soft .ck-mark { color: var(--orange); }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.65rem;
  margin: 0 0 0.75rem;
}

.metrics div {
  background: var(--panel);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}

.metrics dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 0;
}

.metrics dd {
  margin: 0.1rem 0 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.live-status {
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.live-status p {
  margin: 0.25rem 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.live-status .ok { color: var(--good); }
.live-status .warn { color: var(--spill); }

.legend {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  background: #f7f4ee;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.legend-title {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.legend-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--ink);
}
.legend-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.swatch {
  width: 1.4rem;
  height: 0.35rem;
  border-radius: 2px;
  flex-shrink: 0;
}
.swatch-fixed { background: #3a3a3a; height: 0.4rem; }
.swatch-water { background: var(--water); height: 0.4rem; }
.swatch-gap {
  background: transparent;
  border-top: 3px dashed rgba(214, 56, 136, 0.45);
  height: 0;
  border-radius: 0;
}
.swatch-piece { background: #2f6f9f; height: 0.45rem; }
.swatch-spill { background: var(--spill); height: 0.4rem; border-radius: 50%; width: 0.55rem; height: 0.55rem; }
.legend-note {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
}

.panel-note {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

#play-panel[hidden],
#design-panel[hidden] {
  display: none;
}


/* SVG pipes */
.grid { stroke: rgba(0,0,0,0.05); stroke-width: 1; }
.wall-panel { fill: #ebe6dc; }
.wall-drywall { fill: #ebe6dc; }
.wall-stud { stroke: rgba(0,0,0,0.04); stroke-width: 1; }
.wall-plate { fill: #8b7355; }
.wall-floor { stroke: #8b7355; stroke-width: 3; }
.stud-bay-outline { fill: none; stroke: var(--orange); stroke-width: 2; opacity: 0.55; }
.wall-header-bg { fill: rgba(255,255,255,0.75); }
.wall-header-title { fill: var(--ink); font-weight: 700; font-size: 12px; font-family: system-ui, sans-serif; }
.wall-header-sub { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }

.pipe-fixed-run {
  stroke: #3a3a3a;
  stroke-width: 11;
  stroke-linecap: round;
  fill: none;
}
.pipe-fixed-run.flow { stroke: var(--water); }

/* Movable gap — empty dotted; filled = snap-in piece (not fixed PVC) */
.pipe-gap {
  stroke-width: 11;
  stroke-linecap: round;
  fill: none;
  pointer-events: none;
}
.pipe-gap-empty {
  stroke: var(--pink);
  stroke-dasharray: 10 8;
  opacity: 0.22;
}
.gap-group:not(.filled):hover .pipe-gap-empty {
  opacity: 0.75;
}
.pipe-gap-filled {
  stroke: #2f6f9f;
  stroke-width: 12;
  opacity: 1;
}
.pipe-gap-filled.flow { stroke: var(--water); stroke-width: 12; }
.pipe-gap-dash {
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 7 9;
  opacity: 0.85;
  pointer-events: none;
  fill: none;
}
.pipe-coupler {
  stroke: #1e4f72;
  stroke-width: 5;
  stroke-linecap: round;
  opacity: 0.95;
  pointer-events: none;
  fill: none;
}
.gap-group.filled:hover .pipe-gap-filled {
  stroke: #1a5a88;
  stroke-width: 13;
}
.gap-group.filled:hover .pipe-coupler { stroke: #143f5e; }
/* Capped gap: stay ghosted — never look like a solid pipe */
.pipe-gap.capped,
.pipe-gap-empty.capped {
  opacity: 0.18;
  stroke-dasharray: 6 10;
}
.gap-group:not(.filled):hover .pipe-gap.capped {
  opacity: 0.4;
}

.hit-gap {
  stroke: transparent;
  stroke-width: 22;
  stroke-linecap: round;
  cursor: pointer;
  fill: none;
}

/* End caps — faint pink until hover; on = plug mark, not a solid pipe */
.end-cap { cursor: pointer; }
.end-cap-hit {
  fill: rgba(214, 56, 136, 0.04);
  stroke: rgba(214, 56, 136, 0.2);
  stroke-width: 1.25;
  stroke-dasharray: 3 3;
  cursor: pointer;
  pointer-events: all;
}
.end-cap.off:hover .end-cap-hit {
  fill: rgba(214, 56, 136, 0.18);
  stroke: var(--pink);
  stroke-dasharray: none;
  stroke-width: 2;
}
.end-cap-bar {
  stroke: var(--pink);
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.28;
  pointer-events: none;
  fill: none;
}
.end-cap-label {
  fill: var(--pink);
  font-size: 11px;
  font-weight: 700;
  font-family: system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
}
.end-cap.off:hover .end-cap-bar {
  opacity: 0.95;
  stroke-width: 7;
}
.end-cap.off:hover .end-cap-label { opacity: 1; }

.end-cap.on .end-cap-hit {
  fill: rgba(214, 56, 136, 0.08);
  stroke: rgba(214, 56, 136, 0.45);
  stroke-dasharray: none;
}
.end-cap.on .end-cap-bar {
  stroke: var(--pink);
  opacity: 0.55;
  stroke-width: 6;
}
.end-cap.on .end-cap-label { opacity: 0.7; fill: var(--pink); }
.end-cap.on:hover .end-cap-bar { opacity: 0.95; stroke-width: 8; }
.end-cap.on:hover .end-cap-label { opacity: 1; }
.end-cap.on.flow .end-cap-hit { stroke: var(--water); fill: rgba(42, 143, 201, 0.12); }
.end-cap.on.flow .end-cap-bar { stroke: var(--water); opacity: 0.7; }
.end-cap.on.flow .end-cap-label { fill: var(--water); }

.preview {
  stroke: rgba(0,0,0,0.3);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 8 6;
  pointer-events: none;
  fill: none;
}
.sel {
  stroke: #ffc107;
  stroke-width: 14;
  stroke-linecap: round;
  opacity: 0.35;
  pointer-events: none;
  fill: none;
}

.hit-run { stroke: transparent; stroke-width: 22; cursor: pointer; fill: none; }
.hit-corner { fill: transparent; cursor: pointer; }
.vis { stroke: #fff; stroke-width: 2; pointer-events: none; }
.vis-supply { fill: #2a9d5c; }
.vis-goal { fill: var(--good); }
.vis-open_end { fill: var(--spill); }
.vis-open_end.spilling { fill: #e88a30; }
.vis-junction { fill: #555; }
.lbl { fill: var(--ink); font-size: 11px; font-weight: 700; font-family: system-ui, sans-serif; pointer-events: none; }

.valve-hit { fill: transparent; cursor: pointer; }
.valve-body { fill: #fff; stroke: #3a3a3a; stroke-width: 2; }
.valve-handle { stroke: #3a3a3a; stroke-width: 3; stroke-linecap: round; pointer-events: none; }
.valve-label { fill: var(--muted); font-size: 9px; font-weight: 700; font-family: system-ui, sans-serif; pointer-events: none; }
.valve.closed .valve-body { fill: #fde8e8; stroke: #b00020; }
.valve.closed .valve-handle { stroke: #b00020; }
.valve.open.flowing .valve-body { fill: #e8f4fc; stroke: var(--water); }

.spill-fx { pointer-events: none; }
.spill-halo {
  fill: rgba(42, 143, 201, 0.22);
  stroke: var(--water);
  stroke-width: 2;
}
.spill-stream {
  stroke: var(--water);
  stroke-width: 5;
  stroke-linecap: round;
  opacity: 0.6;
}
.spill-drop {
  fill: var(--water);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.spill-drop-1 { animation: drip 1.15s ease-in infinite; }
.spill-drop-2 { animation: drip 1.15s ease-in 0.38s infinite; }
.spill-drop-3 { animation: drip 1.15s ease-in 0.76s infinite; }
.spill-puddle {
  fill: var(--water);
  opacity: 0.45;
  animation: puddle 1.15s ease-in-out infinite;
}

@keyframes drip {
  0% { transform: translateY(0); opacity: 0.95; }
  70% { opacity: 0.7; }
  100% { transform: translateY(56px); opacity: 0; }
}
@keyframes puddle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.55; }
}

.vis-open_end.spilling {
  fill: #2a8fc9;
  stroke: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .spill-drop { animation: none; opacity: 0.7; }
  .spill-puddle { animation: none; }
}
