/* Water Droplet Journey: the Watershed Tracer Desk (coast cross-section map, tracer log, process chart pop-up).
   Scene by art.js; panel colors from the --wd-* properties below (light and dark). The map keeps its daytime colors. */
html {
  --wd-ink: #10283a; --wd-panel-bg1: #f3f8fb; --wd-panel-bg2: #e1edf4; --wd-accent: #1d5f86; --wd-ok: #13704a; --wd-bad: #b3261e;
  --wd-chip: #ffffff; --wd-chip-on: #d7eaf6; --wd-line: #0c2f5a; --wd-muted: #3d5566;
}
html[data-theme="dark"] {
  --wd-ink: #e6f0f6; --wd-panel-bg1: #172630; --wd-panel-bg2: #111d25; --wd-accent: #8cc8ec; --wd-ok: #4fd08c; --wd-bad: #ff8a80;
  --wd-chip: #0f1a21; --wd-chip-on: #1f3a4d; --wd-line: #000000; --wd-muted: #a9bfcd;
}
.wd { position: absolute; inset: 0; display: grid; grid-template-columns: 410px minmax(0, 1fr); gap: 12px; padding: 10px; color: var(--tlg-text); font-size: 16px; }
.wd input, .wd button { font: inherit; }
.wd-controls { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto; padding: 8px 12px;
  background: linear-gradient(var(--wd-panel-bg1), var(--wd-panel-bg2)); color: var(--wd-ink); border: 3px solid var(--wd-accent); border-radius: 14px; box-shadow: 0 3px 8px rgba(0,0,0,.16); }
.wd-right { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; overflow: auto; }
.wd-step { display: grid; gap: 4px; }
.wd-step-b { display: grid; gap: 4px; }
.wd-step-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; line-height: 1.2; }
.wd-n { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--wd-accent); color: #fff; font-size: 16px; font-weight: 800; }
html[data-theme="dark"] .wd-n { color: #0b1a24; }
.wd-step.is-done .wd-n { background: var(--wd-ok); }
.wd-mark { margin-left: auto; font-weight: 800; white-space: nowrap; }
.wd-mark.is-ok, .wd-fmark.is-ok { color: var(--wd-ok); }
.wd-mark.is-bad, .wd-fmark.is-bad { color: var(--wd-bad); }
.wd-fmark { font-weight: 800; }

/* legs */
.wd-leg { display: grid; grid-template-columns: 24px minmax(0, 1fr) 200px; grid-template-areas: "n r b"; align-items: center; column-gap: 6px; }
.wd-leg-n { grid-area: n; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #ffffff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); color: #ffffff; font-weight: 800; font-size: 16px; }
.wd-leg-r { grid-area: r; font-weight: 700; line-height: 1.15; }
.wd-leg-a { color: var(--wd-muted); }
.wd-leg-btn { grid-area: b; display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 40px; padding: 4px 8px; border: 2px dashed #8aa3b4; border-radius: 10px;
  background: var(--wd-chip); color: var(--wd-ink); font-size: 16px; line-height: 1.1; text-align: left; cursor: pointer; }
.wd-leg-btn.is-set { border-style: solid; border-color: var(--wd-accent); background: var(--wd-chip-on); font-weight: 700; }
.wd-leg-btn[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--wd-accent); }
.wd-leg-c { flex: none; opacity: .75; }
.wd-leg-btn:disabled { cursor: default; opacity: 1; }
.wd-leg .wd-fmark { display: block; font-size: 16px; }
.wd-leg .wd-fmark[hidden] { display: none; }
.wd-leg-c.is-ok { color: var(--wd-ok); opacity: 1; font-weight: 800; } .wd-leg-c.is-bad { color: var(--wd-bad); opacity: 1; font-weight: 800; }

/* chips */
.wd-chips { display: grid; gap: 4px; }
.wd-chips--2 { grid-template-columns: 1fr 1fr; }
.wd-chips--row { grid-template-columns: 1fr 1fr; }
.wd-chip { position: relative; display: flex; align-items: center; min-height: 40px; padding: 3px 22px 3px 8px; border: 2px solid #9fb0bc; border-radius: 10px;
  background: var(--wd-chip); color: var(--wd-ink); font-size: 16px; line-height: 1.15; text-align: left; cursor: pointer; }
html[data-theme="dark"] .wd-chip, html[data-theme="dark"] .wd-leg-btn { border-color: #4d606d; }
html[data-theme="dark"] .wd-leg-btn.is-set { border-color: var(--wd-accent); }
.wd-chip:hover:not(:disabled), .wd-leg-btn:hover:not(:disabled) { border-color: var(--wd-accent); }
.wd-chip.is-on { border-color: var(--wd-accent); background: var(--wd-chip-on); font-weight: 700; box-shadow: inset 0 0 0 1px var(--wd-accent); }
.wd-chip.is-on::before { content: '●'; margin-right: 6px; color: var(--wd-accent); }
.wd-chip-m { position: absolute; right: 8px; font-weight: 800; }
.wd-chip.is-key { border-color: var(--wd-ok); box-shadow: inset 0 0 0 2px var(--wd-ok); }
.wd-chip.is-key .wd-chip-m { color: var(--wd-ok); }
.wd-chip.is-wrong { border-color: var(--wd-bad); border-style: dashed; }
.wd-chip.is-wrong .wd-chip-m { color: var(--wd-bad); }
.wd-chip:disabled { cursor: default; opacity: 1; }
.wd-q { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px; }
.wd-q--col { grid-template-columns: 1fr; gap: 2px; }
.wd-q-l { font-weight: 700; line-height: 1.15; }
.wd-q:not(.wd-q--col) .wd-q-l { max-width: 170px; }
.wd input:focus-visible, .wd button:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }

/* number */
.wd-num { display: grid; gap: 1px; }
.wd-num-l { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; font-weight: 700; }
.wd-num-row { display: flex; align-items: center; gap: 6px; }
.wd-num input { flex: 1 1 auto; min-width: 0; width: 100%; font-size: 17px; min-height: 40px; padding: 3px 8px; border: 2px solid #8796a1; border-radius: 8px; background: #fff; color: #17242c; }
html[data-theme="dark"] .wd-num input { background: #10171c; color: #eef3f6; border-color: #6d7f8c; }
.wd-unit { flex: none; font-weight: 700; }
.wd-num-n { flex: none; color: var(--wd-muted); }
.wd-num input { max-width: 130px; }

/* process chart pop-up */
.wd-pop { position: absolute; z-index: 5; padding: 8px 10px 10px; background: var(--wd-panel-bg1); color: var(--wd-ink); border: 3px solid var(--wd-accent); border-radius: 14px; box-shadow: 0 10px 28px rgba(0,0,0,.32); }
.wd-pop-h { margin: 0 0 6px; font-size: 16px; }
.wd-pop.is-sheet { position: fixed; left: 8px; right: 8px; top: 8px; max-height: calc(100vh - 16px); overflow: auto; z-index: 1000; }
.wd-pop-g { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.wd-pop-opt { display: grid; gap: 1px; padding: 4px 8px; min-height: 44px; border: 2px solid #9fb0bc; border-radius: 10px; background: var(--wd-chip); color: var(--wd-ink); text-align: left; font-size: 16px; line-height: 1.15; cursor: pointer; }
html[data-theme="dark"] .wd-pop-opt { border-color: #4d606d; }
.wd-pop-opt:hover, .wd-pop-opt:focus-visible { border-color: var(--wd-accent); background: var(--wd-chip-on); }
.wd-pop-opt.is-on { border-color: var(--wd-accent); box-shadow: inset 0 0 0 2px var(--wd-accent); }
.wd-pop-w { color: var(--wd-muted); }
.wd-pop-c { font-weight: 700; color: var(--wd-accent); }

/* right column */
.wd-card { flex: none; padding: 5px 12px; border: 2px solid var(--wd-accent); border-radius: 12px; background: var(--wd-panel-bg1); color: var(--wd-ink); }
.wd-card p { margin: 0; line-height: 1.35; }
.wd-trip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 18px; }
.wd-trip-k { font-size: 16px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--wd-accent); margin-right: 4px; }
.wd-stop { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.wd-stop-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #ffd23f; color: #10283a; font-size: 16px; border: 2px solid #8a6a00; }
.wd-trip-a { color: var(--wd-muted); }
.wd-budget { margin-top: 2px !important; }
.wd-scene { flex: none; border-radius: 12px; overflow: hidden; border: 2px solid var(--wd-line); background: #bfe0f4; }
.wd-svg { display: block; width: 100%; height: auto; }
.wd-svg text { font-family: var(--tlg-font); }
.wd-edge { fill: none; stroke: #ffffff; stroke-width: 2.5; stroke-dasharray: 5 5; opacity: .85; }
.wd-nl { font-size: calc(16px * var(--wd-k, 1)); font-weight: 800; fill: #10283a; paint-order: stroke; stroke: #ffffff; stroke-width: 4px; stroke-linejoin: round; }
.wd-nl[data-node="ocean"], .wd-nl[data-node="groundwater"], .wd-nl[data-node="river"], .wd-nl[data-node="soil"], .wd-nl[data-node="lake"] { fill: #ffffff; stroke: #0c2034; }
.wd-nl--in { stroke: none; fill: #24435e; }
.wd-model { font-size: calc(16px * var(--wd-k, 1)); font-weight: 700; font-style: italic; fill: #e8eef5; paint-order: stroke; stroke: #2b2f38; stroke-width: 3px; }
.wd-badge circle { fill: #ffd23f; stroke: #5c4700; stroke-width: 2.5; }
.wd-badge text { font-size: calc(16px * var(--wd-k, 1)); font-weight: 800; fill: #10283a; }
.wd-leg-p { fill: none; stroke-width: 5; stroke-linecap: round; }
.wd-leg-p0 { stroke: #e8650a; } .wd-leg-p1 { stroke: #c2185b; } .wd-leg-p2 { stroke: #6a1b9a; }
.wd-leg-tag circle { stroke: #ffffff; stroke-width: 2.5; }
.wd-leg-tag0 circle { fill: #e8650a; } .wd-leg-tag1 circle { fill: #c2185b; } .wd-leg-tag2 circle { fill: #6a1b9a; }
.wd-leg-tag text { font-size: calc(16px * var(--wd-k, 1)); font-weight: 800; fill: #ffffff; }
.wd-leg-n0 { background: #e8650a; } .wd-leg-n1 { background: #c2185b; } .wd-leg-n2 { background: #6a1b9a; }
.wd-pop-r { fill: #10283a; opacity: .92; }
.wd-pop-t { font-size: calc(16px * var(--wd-k, 1)); font-weight: 800; fill: #ffffff; }
.wd-vapor path { animation: wd-drift 6s linear infinite; }
@keyframes wd-drift { to { stroke-dashoffset: -36; } }
.wd-readout { flex: none; padding: 5px 12px; border-radius: 10px; background: var(--wd-panel-bg2); color: var(--wd-ink); line-height: 1.3; }
.wd-readout p { margin: 2px 0; }
.wd-warn { color: var(--wd-bad); }
.wd-strip-w { max-width: 640px; }
.wd-strip { display: block; width: 100%; height: auto; }
.wd-strip text { font-family: var(--tlg-font); fill: var(--wd-ink); }
.wd-strip-tk { stroke: var(--wd-ink); stroke-width: 2; }
.wd-strip-tl { font-size: calc(16px * var(--wd-ks, 1)); }
.wd-strip-m circle { stroke: var(--wd-ink); stroke-width: 2.5; }
.wd-strip-m text { font-size: calc(16px * var(--wd-ks, 1)); font-weight: 800; }
.wd-strip-m.is-air circle { fill: #ffffff; }
.wd-strip-m.is-sea circle { fill: #0c2f5a; }
.wd-strip-m.is-you circle { fill: #ffd23f; }
.wd-strip-span { stroke: var(--wd-ink); fill: none; }
.wd-strip-note { font-size: 16px; color: var(--wd-muted); }
.wd-about { flex: none; padding: 2px 10px; border: 1px solid var(--tlg-border); border-radius: 8px; }
.wd-about summary { cursor: pointer; min-height: 32px; font-weight: 700; display: flex; align-items: center; }
.wd-about p { margin: 4px 0; }
.wd-ex { display: grid; gap: 8px; --wd-k: 1.3; }
.wd-ex-scene { max-width: 560px; border-radius: 10px; overflow: hidden; border: 2px solid var(--wd-line); }
.wd-ex-scene .wd-svg { width: 100% !important; height: auto !important; max-height: none; }
.wd-ex-t { border-collapse: collapse; font-size: 16px; }
.wd-ex-t th, .wd-ex-t td { padding: 3px 8px; border-bottom: 1px solid var(--tlg-border); text-align: left; }
@media (max-width: 900px) {
  .wd { position: static; grid-template-columns: 1fr; }
  .wd-controls, .wd-right { overflow: visible; }
  .wd-right { order: -1; }
  .wd { position: relative; }
}
@media (max-width: 440px) {
  .wd-leg { grid-template-columns: 24px minmax(0, 1fr); grid-template-areas: "n r" "n b"; row-gap: 3px; }
  .wd-chips--2, .wd-pop-g { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .wd *, .wd *::before { animation: none !important; transition: none !important; } }
