:root {
  --navy: #0b1d32;
  --blue: #3793c8;
  --blue-ink: #1f6f9e;
  --blue-soft: #e6f3fa;
  --sky: #81c4ea;
  --bg: #f7fbfd;
  --card: #ffffff;
  --ink: #0b1d32;
  --muted: #52657a;
  --line: #dde8ef;
  --urgent: #b42318;
  /* Depth scale: ankle → above waist */
  --d1: #f2b632;
  --d2: #ef7d2d;
  --d3: #c8363a;
  --d4: #7b3fc4;
  --d0: #8a9aab;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(11 29 50 / 8%), 0 6px 24px rgb(11 29 50 / 12%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 Nunito, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--blue-ink); text-underline-offset: 3px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: "Space Grotesk", Nunito, sans-serif; letter-spacing: -0.02em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.req { color: var(--urgent); }

.app { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; }

.panel {
  position: absolute;
  z-index: 2;
  background: rgb(255 255 255 / 96%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.label {
  margin: 0 0 6px;
  font: 800 11px/1.2 Nunito, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Brand */
.brand-panel { top: 12px; left: 12px; width: 300px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--navy); font: 700 22px/1 "Space Grotesk", sans-serif; letter-spacing: -0.03em; }
.brand-mark { width: 30px; height: 30px; }
.tagline { margin: 8px 0 12px; color: var(--muted); font-size: 14px; }
.brand-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 7px 12px; font-weight: 800; font-size: 14px; color: var(--navy); text-decoration: none;
}
.btn:hover { border-color: var(--sky); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  font-size: 20px; line-height: 1; display: inline-grid; place-items: center; color: var(--navy);
}
.icon-btn:disabled { opacity: 0.4; cursor: default; }

/* Legend */
.legend { top: 12px; right: 56px; width: 210px; }
.scale { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.scale i { height: 8px; border-radius: 4px; }
.d1, .scale .d1 { background: var(--d1); }
.d2, .scale .d2 { background: var(--d2); }
.d3, .scale .d3 { background: var(--d3); }
.d4, .scale .d4 { background: var(--d4); }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 4px 0 14px; }
.where { display: grid; gap: 4px; }
.where label { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; cursor: pointer; }
.where input { accent-color: var(--blue); width: 16px; height: 16px; }
.where .n { margin-left: auto; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.where .note { font-size: 12px; color: var(--muted); font-weight: 600; margin: 4px 0 0; }

/* Timeline */
.timeline { left: 50%; bottom: 20px; transform: translateX(-50%); width: min(640px, calc(100% - 24px)); padding: 10px 14px; }
.tl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.tl-nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tl-nav .icon-btn { width: 26px; height: 26px; font-size: 16px; }
.tl-nav strong { font-family: "Space Grotesk", sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stormMeta { font-size: 12px; white-space: nowrap; }
.tl-body { display: flex; align-items: end; gap: 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.bars { flex: 1; min-width: 0; height: 40px; display: flex; align-items: end; gap: 2px; position: relative; padding-bottom: 14px; }
.bars i { flex: 1; min-width: 2px; background: #c6d3de; border-radius: 2px 2px 0 0; }
.bars i.on { background: var(--blue); }
.bars span { position: absolute; bottom: 0; font-size: 10px; color: var(--muted); transform: translateX(-50%); }

/* List */
.list { top: 12px; left: 12px; bottom: 12px; width: 340px; z-index: 3; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0; font-size: 18px; }
.list ol { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.list li button {
  width: 100%; text-align: left; display: grid; grid-template-columns: 12px 1fr; gap: 4px 10px; align-items: start;
  border: 0; background: none; border-radius: 10px; padding: 10px;
}
.list li button:hover { background: var(--blue-soft); }
.list .dot { margin-top: 5px; }
.list .t { font-weight: 800; line-height: 1.3; }
.list .s { grid-column: 2; font-size: 13px; color: var(--muted); }
.list .empty { padding: 16px; color: var(--muted); }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--d0); flex: none; }

.status { position: absolute; z-index: 2; left: 50%; top: 45%; transform: translate(-50%, -50%); margin: 0; background: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 700; max-width: 320px; text-align: center; }
.status:empty { display: none; }
.demo-banner { position: absolute; z-index: 2; top: 12px; left: 50%; transform: translateX(-50%); background: #fff5dc; color: #7a5300; border: 1px solid #f0dca6; padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 13px; }

/* Map markers */
.maplibregl-ctrl-group { border-radius: 10px !important; }

/* Dialogs */
.dialog { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; color: var(--ink); }
.dialog::backdrop { background: rgb(11 29 50 / 45%); backdrop-filter: blur(3px); }
.sheet {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto;
  background: #fff; border-radius: 20px; padding: 18px 20px 20px; box-shadow: var(--shadow);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { margin: 0; font-size: 22px; }

/* Clip viewer */
.clip-dialog { width: min(980px, calc(100vw - 24px)); height: min(640px, calc(100dvh - 24px)); display: none; align-items: center; gap: 12px; }
.clip-dialog[open] { display: flex; }
.nav-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; font-size: 24px; box-shadow: var(--shadow); color: var(--navy); }
.nav-btn:disabled { opacity: 0.35; cursor: default; }
.clip-card { flex: 1; height: 100%; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: #fff; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.clip-media { background: var(--navy); display: grid; place-items: center; min-height: 0; padding: 12px; }
.clip-media iframe { width: 100%; height: 100%; border: 0; border-radius: 12px; background: #000; }
.clip-media .placeholder { color: #c9d8e6; text-align: center; max-width: 28ch; }
.clip-media .placeholder a { color: #fff; font-weight: 800; }
.clip-info { position: relative; padding: 20px 22px; display: flex; flex-direction: column; overflow-y: auto; min-height: 0; }
.clip-info .close { position: absolute; top: 14px; right: 14px; }
.depth-line { display: flex; align-items: center; gap: 8px; margin: 0 40px 8px 0; font-size: 22px; font-family: "Space Grotesk", sans-serif; }
.depth-line .muted { margin-left: auto; font-size: 16px; }
.depth-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 14px; }
.depth-bar i { height: 8px; border-radius: 4px; background: #e6edf2; }
.depth-bar i.on { background: var(--c, var(--d0)); height: 12px; margin-top: -2px; }
.clip-info h2 { margin: 4px 0 2px; font-size: 18px; line-height: 1.25; }
.meta { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.caption { margin: 0; }
.spacer { flex: 1; min-height: 12px; }
.attrib { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px 14px; }
.attrib .label { margin-bottom: 2px; }
.fine { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.removal summary { font-size: 13px; color: var(--muted); text-decoration: underline; cursor: pointer; width: fit-content; }
.removal form { display: grid; gap: 8px; margin-top: 8px; font-size: 14px; }
.removal label { display: grid; gap: 4px; font-weight: 700; }
.removal textarea, .removal input, .field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; font-weight: 400;
}
.form-msg { margin: 0; font-weight: 700; font-size: 14px; }
.form-msg.ok { color: #167a30; }
.form-msg.err { color: var(--urgent); }

/* Submit form */
#submitForm { display: grid; gap: 14px; }
#submitForm > .muted { margin: 0; }
.field { display: grid; gap: 5px; font-weight: 800; font-size: 14px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field legend { padding: 0; margin-bottom: 6px; }
.field small, .pick-wrap small { font-weight: 600; color: var(--muted); font-size: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-ink); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }
.pick-wrap { display: grid; gap: 5px; }
.pick-map { height: 220px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 600; }
.consent input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--blue); flex: none; }
.hp { position: absolute; left: -9999px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* Phones */
.no-map { margin: 40vh auto 0; max-width: 30ch; text-align: center; color: var(--muted); }
@media (max-width: 720px) {
  .maplibregl-ctrl-top-right, .where .note { display: none; }
  .brand-panel { right: 12px; width: auto; padding: 10px 12px; }
  .tagline { display: none; }
  .brand { font-size: 19px; margin-bottom: 8px; }
  .legend { top: auto; right: 12px; bottom: 132px; width: 168px; padding: 10px 12px; }
  .legend .scale-ends { margin-bottom: 8px; }
  .timeline { bottom: 12px; }
  .list { right: 12px; width: auto; }
  .demo-banner { top: auto; bottom: 128px; left: 12px; transform: none; max-width: calc(100% - 200px); border-radius: 12px; }
  .clip-dialog { width: 100vw; height: 100dvh; gap: 0; }
  .nav-btn { display: none; }
  .clip-card { border-radius: 0; grid-template-columns: 1fr; grid-template-rows: minmax(0, 55%) auto; overflow-y: auto; }
  .clip-info { overflow: visible; }
  .two { grid-template-columns: 1fr; }
}
