:root {
  /* Nautical-chart theme: parchment land, chart-blue water, ink strokes. */
  --water-color: #a9cddd;
  --land-color: #ecdfc2;
  --coast-stroke: #4a3a22;
  --border-stroke: #7a6a4a;
  --state-stroke: #7d6740;
  --grid-stroke: rgba(74, 58, 34, 0.42);
  --ui-bg: #eef2f6;
  --ui-panel: #ffffff;
  --ui-border: #cbd5e1;
  --ui-text: #122033;
  --ui-muted: #607083;
  --ui-accent: #2469d8;
  --ui-accent-soft: #eaf2ff;
  --ui-danger: #b83232;
  --annotation-draft-color: #b8562a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ui-text);
  background: var(--ui-bg);
}
button, input { font: inherit; }
h3 { margin: 0 0 4px; font-size: 14px; }

.app-shell { height: 100%; display: flex; flex-direction: column; }

.local-mode-banner {
  background: #fab219; color: #241900; font-size: 12.5px; font-weight: 700;
  text-align: center; padding: 6px 10px;
}
.local-mode-banner[hidden] { display: none; }

/* Full-screen gate: nothing of the editor (toolbar/sidebar/map) exists in
   the page's visible layout until this is hidden -- login-gate and
   editor-shell are always exact opposites of each other (see
   updateAuthGate() in main.js), never both visible. */
.editor-shell { height: 100%; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.editor-shell[hidden], .login-gate[hidden] { display: none; }

.login-gate {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 20px;
  background: #0b1f3a;
}
.login-card {
  width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px;
  background: #fff; border-radius: 16px; padding: 28px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.login-card__mark {
  align-self: center; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 4px;
  background: #0b1f3a; color: #fff; font-weight: 800; font-size: 19px;
}
.login-card h1 { margin: 0; font-size: 19px; }
.login-card__subtitle { margin: 0 0 6px; color: var(--ui-muted); font-size: 13px; }
.login-card input {
  border: 1px solid var(--ui-border); border-radius: 9px; padding: 10px 12px; font-size: 14px; width: 100%;
}
.login-card button { padding: 10px; font-size: 14px; margin-top: 4px; }
.login-error { color: var(--ui-danger); font-weight: 600; font-size: 12.5px; min-height: 1em; }
.login-gate__notice {
  max-width: 360px; text-align: center; color: #cfe0ff; font-size: 13px; line-height: 1.5; margin: 0;
}
.login-gate__notice[hidden] { display: none; }

.user-status { display: flex; align-items: center; gap: 8px; }
.user-status[hidden] { display: none; }
.user-status button { padding: 5px 10px; font-size: 12.5px; }
#user-status-label { color: var(--ui-muted); font-weight: 600; font-size: 12.5px; }
#user-status-label strong { color: var(--ui-text); }

.toolbar {
  min-height: 56px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--ui-panel);
  border-bottom: 1px solid var(--ui-border);
  box-shadow: 0 2px 10px rgba(24, 45, 72, 0.07);
  z-index: 20;
}
.toolbar__title { display: flex; align-items: baseline; gap: 8px; margin-right: 10px; }
.toolbar__title strong { font-size: 15px; }
.toolbar__title span { color: var(--ui-muted); font-size: 12px; }
.toolbar__mark {
  display: flex; align-items: center; justify-content: center; align-self: center;
  width: 22px; height: 22px; border-radius: 7px; background: #0a1628; flex-shrink: 0;
}
.toolbar__spacer { flex: 1; }
.placement-hint {
  font-size: 12.5px;
  color: var(--ui-accent);
  font-weight: 600;
}
.placement-hint[hidden] { display: none; }

button {
  border: 1px solid var(--ui-border);
  background: #fff;
  color: var(--ui-text);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
button:hover { border-color: #9db0c7; }
button.is-active { color: #fff; background: var(--ui-accent); border-color: var(--ui-accent); }
button.primary { color: #fff; background: var(--ui-accent); border-color: var(--ui-accent); }
button.danger { color: var(--ui-danger); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:disabled:hover { border-color: var(--ui-border); }

.workspace { flex: 1; min-height: 0; display: flex; }

.sidebar {
  width: 300px;
  flex: 0 0 300px;
  overflow-y: auto;
  padding: 12px;
  background: #f7f9fc;
  border-right: 1px solid var(--ui-border);
}
.panel-section {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.panel-section h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ui-muted);
  margin: 0 0 10px;
}

.systems-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.systems-list__row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.systems-list__row:hover { background: var(--ui-accent-soft); }
.systems-list__row.is-selected { background: var(--ui-accent-soft); outline: 1.5px solid var(--ui-accent); }
.systems-list__name { flex: 1; }
.systems-list__pct { color: var(--ui-muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.systems-list__empty { color: var(--ui-muted); font-size: 13px; padding: 6px 4px; }
.tier-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,.25); }

.empty-hint { color: var(--ui-muted); font-size: 13px; }
.selected-meta { color: var(--ui-muted); font-size: 12px; margin-bottom: 10px; }
.selected-form { display: flex; flex-direction: column; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ui-muted); }
.field input, .field textarea {
  border: 1px solid var(--ui-border); border-radius: 7px; padding: 6px 8px; font-size: 13px; color: var(--ui-text);
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 60px; }
/* flex-wrap: with 3 buttons (Save/Investigate/Delete), their combined
   natural width can exceed the sidebar's ~276px content width -- without
   wrap, flex items don't shrink below their text's min-content width, so
   the row overflows the panel instead of breaking to a second line. */
.selected-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.selected-actions button { flex: 1; }

.map-wrap { flex: 1; position: relative; background: var(--water-color); }
#map { width: 100%; height: 100%; display: block; cursor: default; user-select: none; touch-action: none; }
#map.tool-create, #map.tool-draw { cursor: crosshair; }
#map.is-panning { cursor: grabbing; }

.discussion-callout {
  position: absolute; z-index: 20; max-width: 340px; max-height: calc(100% - 24px);
  overflow-y: auto; padding: 10px 12px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.97); border: 1px solid var(--ui-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.5; color: var(--ui-text);
  white-space: pre-wrap; word-break: break-word;
}
.discussion-callout[hidden] { display: none; }

.land { fill: var(--land-color); stroke: var(--coast-stroke); stroke-width: 1.4px; vector-effect: non-scaling-stroke; }
.lake { fill: var(--water-color); stroke: var(--coast-stroke); stroke-width: 0.9px; vector-effect: non-scaling-stroke; }
.country-borders { fill: none; stroke: var(--border-stroke); stroke-width: 1.1px; vector-effect: non-scaling-stroke; }
.state-borders { fill: none; stroke: var(--state-stroke); stroke-width: 1.2px; vector-effect: non-scaling-stroke; }
.grid-line { stroke: var(--grid-stroke); stroke-width: 0.7px; vector-effect: non-scaling-stroke; pointer-events: none; }
.grid-label { fill: rgba(20, 35, 55, 0.55); font-family: inherit; }

.point-x-outline { stroke: #000; stroke-width: 7px; stroke-linecap: round; vector-effect: non-scaling-stroke; cursor: pointer; }
.point-x-fill { stroke-width: 4px; stroke-linecap: round; vector-effect: non-scaling-stroke; cursor: pointer; }
.point-label { fill: #0b1f3a; font-weight: 700; text-anchor: middle; paint-order: stroke fill; stroke: #fff; stroke-width: 3px; vector-effect: non-scaling-stroke; }
.point-selection-ring { fill: none; stroke: var(--ui-accent); stroke-width: 1.6px; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }

/* Not-yet-formed systems: hide the X/label (nothing physically exists to
   point to yet) but keep the same hit-area interactive -- opacity, not
   display/visibility, so click-to-select and drag-to-move still work. */
.system-point.unformed .point-x-outline,
.system-point.unformed .point-x-fill,
.system-point.unformed .point-label {
  opacity: 0;
}

/* Shapes & arrows: fills/lines always render (see annotationRenderer.js);
   only .annotation-vertex-handle circles are gated on selection. Color
   (fill/stroke) is deliberately NOT set here for the non-draft classes --
   it's applied per-instance via presentation attributes in
   annotationRenderer.js (each annotation's owning system has its own
   probability color), and a CSS class rule would win over that inline
   value if declared here. */
.annotation-shape-fill {
  stroke-width: 1.6px; vector-effect: non-scaling-stroke; cursor: pointer;
}
.annotation-shape-preview {
  fill: none; stroke-width: 1.6px; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; cursor: pointer;
}
.annotation-arrow-line {
  fill: none; stroke-width: 2.2px; stroke-linecap: round; vector-effect: non-scaling-stroke;
}
.annotation-arrow-hit {
  fill: none; stroke: transparent; stroke-width: 14px; vector-effect: non-scaling-stroke; cursor: pointer;
}
.annotation-arrowhead { stroke: none; }

.annotation-draft-shape-fill {
  fill: color-mix(in srgb, var(--annotation-draft-color) 18%, transparent);
  stroke: var(--annotation-draft-color); stroke-width: 1.6px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke;
}
.annotation-draft-shape-preview {
  fill: none; stroke: var(--annotation-draft-color); stroke-width: 1.6px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke;
}
.annotation-draft-arrow-line {
  fill: none; stroke: var(--annotation-draft-color); stroke-width: 2.2px; stroke-linecap: round; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke;
}
.annotation-draft-arrow-hit { fill: none; stroke: none; }
.annotation-draft-arrowhead { fill: var(--annotation-draft-color); stroke: none; }

.annotation-vertex-handle {
  fill: #fff; stroke-width: 1.8px; vector-effect: non-scaling-stroke; cursor: grab;
}
.annotation-draft-handle { stroke: var(--annotation-draft-color); }
.annotation-draft-handle--origin { fill: var(--annotation-draft-color); }

/* Forecast track + cone of uncertainty: translucent white fill (dimmer for
   the Day 4-5 continuation, standing in for a dotted "less certain" look
   without a separate SVG pattern), a dark outer outline once a Day 4-5
   period exists, a lighter inner outline around Day 1-3, and a dark
   centerline through every sample. The fill/outline/centerline itself is
   never interactive -- only the point markers below (and the system's own
   marker) are selectable/draggable. */
.forecast-cone, .forecast-cone-late, .forecast-cone-outline, .forecast-track { pointer-events: none; }
.forecast-cone.cone-fill { fill: rgba(255, 255, 255, .92); stroke: none; }
.forecast-cone-late.cone-day4-5 { fill: rgba(255, 255, 255, .55); stroke: none; }
.forecast-cone-outline { stroke: none; }
.forecast-cone-outline-full { fill: rgba(255, 255, 255, .95); }
.forecast-cone-outline-early { fill: rgba(17, 17, 17, .9); }
.forecast-track { fill: none; stroke: #111820; stroke-width: 2.1px; vector-effect: non-scaling-stroke; }

/* Forecast-point dot + hour label at each real forecast point (not the
   synthetic hour-0 "current" sample -- that's the system's own X marker).
   Named forecast-point-marker-label, distinct from the sidebar's own
   .forecast-point-label (that's a <span> in the "Forecast track" list
   row, not the on-map SVG text this draws). */
.forecast-point-marker { cursor: grab; }
.forecast-point-marker:active { cursor: grabbing; }
.forecast-point-core { fill: #050505; stroke: #050505; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.forecast-point-symbol { fill: #fff; font-weight: 800; font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
.forecast-point-marker-label {
  fill: #111; font-weight: 800; font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  paint-order: stroke; stroke: rgba(255, 255, 255, .88); stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

/* Selected forecast point's cone-spread drag handle: a dashed ring at the
   current radius, a guide line, and a handle at its end. */
.spread-ring {
  fill: rgba(45, 105, 216, .035); stroke: rgba(45, 105, 216, .62);
  stroke-width: 1.2px; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.spread-guide {
  stroke: rgba(45, 105, 216, .52); stroke-width: 1px;
  vector-effect: non-scaling-stroke; pointer-events: none;
}
.spread-handle {
  fill: var(--ui-accent); stroke: #fff; stroke-width: 1.8px;
  vector-effect: non-scaling-stroke; cursor: ew-resize;
}

/* Wind field envelope + quadrant drag handles, for the selected system's
   current position. Colors carried over from the old prototype's ts/hu
   (tropical storm / hurricane force) scheme, now gale/hfw. */
.wind-field { vector-effect: non-scaling-stroke; pointer-events: none; stroke-width: 1.35px; }
.wind-field-gale { fill: rgba(240, 188, 74, .46); stroke: #c9912b; }
.wind-field-hfw { fill: rgba(159, 72, 72, .5); stroke: #8f4141; }

/* Watch/warning zones -- color comes from watchColor() inline per
   instance (severity, not an owning system), same "CSS gives shape/
   non-scaling-stroke, JS gives per-instance color" split as wind-field. */
.watch-zone-fill { vector-effect: non-scaling-stroke; pointer-events: none; stroke-width: 2px; }
.wind-guide {
  stroke: rgba(29, 48, 70, .45); stroke-width: 1px;
  stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; pointer-events: none;
}
.wind-handle { stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; cursor: grab; }
.wind-handle:active { cursor: grabbing; }
.wind-handle-gale { fill: #c9912b; }
.wind-handle-hfw { fill: #8f4141; }
.wind-handle-label {
  fill: #111; font-weight: 800; font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  paint-order: stroke; stroke: rgba(255, 255, 255, .88); stroke-width: 2px;
  vector-effect: non-scaling-stroke; pointer-events: none;
}

.wind-threshold-toggle { display: flex; gap: 6px; margin: 10px 0; }
.wind-threshold-toggle button { flex: 1; font-size: 12px; padding: 7px 6px; }

.annotations-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--ui-border); }
.annotations-section h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ui-muted); }
.selected-annotation-panel .empty-hint { margin: 0 0 10px; }
.selected-annotation-panel button { width: 100%; }

/* flex-wrap: same overflow reasoning as .selected-actions above -- with a
   label, three inputs (hour/wind/spread), and two buttons, this row's
   natural width exceeds the sidebar's content width without wrapping. */
.forecast-point-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; border-radius: 7px; }
.forecast-point-row.is-selected { background: var(--ui-accent-soft); outline: 1.5px solid var(--ui-accent); }
.forecast-point-label { font-size: 12px; color: var(--ui-muted); width: 34px; flex-shrink: 0; cursor: pointer; }
.forecast-point-row input {
  width: 44px; min-width: 0; border: 1px solid var(--ui-border); border-radius: 7px;
  padding: 5px 6px; font-size: 12px; color: var(--ui-text);
}
.forecast-point-row input:disabled { background: var(--ui-bg); color: var(--ui-muted); }
.forecast-point-row select {
  border: 1px solid var(--ui-border); border-radius: 7px; padding: 5px 4px;
  font-size: 12px; color: var(--ui-text); background: #fff; flex-shrink: 0;
}
.forecast-point-row button { padding: 5px 8px; font-size: 12px; flex-shrink: 0; }

.formed-toggle {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 999px; margin-bottom: 10px;
}

.intensity-readout {
  font-size: 13px; font-weight: 600; margin: 0 0 10px;
  padding: 8px 10px; border-radius: 8px; background: var(--ui-accent-soft);
}
.intensity-reference { margin-bottom: 10px; }
.intensity-reference summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ui-accent); }
.intensity-reference p, .intensity-reference li { font-size: 12px; color: var(--ui-muted); }
.intensity-reference ul { margin: 4px 0 10px; padding-left: 18px; }
.intensity-section > button { width: 100%; }

.account-user-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 4px; font-size: 12.5px;
  border-bottom: 1px solid var(--ui-border);
}
.account-user-row:last-of-type { border-bottom: none; }
.account-user-row__name { flex: 1; }
.account-user-row__name small { display: block; color: var(--ui-muted); font-size: 11px; }
.account-user-row select {
  border: 1px solid var(--ui-border); border-radius: 7px; padding: 4px; font-size: 11.5px; background: #fff;
}
.account-create-form { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.account-create-form input, .account-create-form select {
  border: 1px solid var(--ui-border); border-radius: 7px; padding: 6px 8px; font-size: 12.5px;
}
.account-create-form button { width: 100%; }
.account-error { color: var(--ui-danger); font-size: 12px; font-weight: 600; }

.fatal-error {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #fff; color: var(--ui-danger); font-size: 14px; padding: 20px; text-align: center;
}
