/* Ready Kiwi chrome. Seismic colours remain owned by scale.js and main.js. */
@font-face {
  font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/fonts/Inter-400-normal-latin-bec94a4d.woff2') format('woff2');
}
@font-face {
  font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/fonts/Inter-400-normal-latin-ext-367ba69a.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020-202F,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
:root {
  color-scheme: dark;
  --bg: #111c18; --panel: #192923; --panel-border: #405349;
  --text: #f4f1e8; --text-dim: #bccbc2; --accent: #8bdeba;
  --panel-hover: #253b30; --alert-red: #b32326; --alert-red-deep: #971e22;
  --sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: var(--sans); --header-h: 84px; --rail-w: 370px;
}
body.theme-light {
  color-scheme: light;
  --bg: #f4f1e8; --panel: #fff; --panel-border: #d6ddd7;
  --text: #18271f; --text-dim: #58685e; --accent: #126447; --panel-hover: #edf2ee;
}
* { box-sizing: border-box; }
/* The translated phone sheet must not make focus scroll the entire app. */
html, body { margin: 0; height: 100%; overflow: clip; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button, summary, a { touch-action: manipulation; }
button, .research-actions a {
  border: 1px solid var(--panel-border); background: var(--panel); color: var(--text);
  border-radius: 9px; padding: 10px 14px; min-height: 44px; cursor: pointer;
  font-weight: 600; text-decoration: none;
}
button:hover, .research-actions a:hover { background: var(--panel-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
:is(#event-details, #map-key, #research-tools) > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 10px; font-weight: 600; }
:is(#event-details, #map-key, #research-tools) > summary::before { content: '+'; font-size: 18px; flex: 0 0 12px; }
:is(#event-details, #map-key, #research-tools)[open] > summary::before { content: '−'; }
:is(#event-details, #map-key, #research-tools) > summary::-webkit-details-marker { display: none; }
.hidden { display: none !important; }
#map { position: absolute; top: var(--header-h); bottom: 0; left: 0; right: var(--rail-w); }
#titlebar {
  position: absolute; inset: 0 0 auto; height: var(--header-h); z-index: 45;
  padding: 10px 20px; background: #0c3b2e; color: #f4f1e8;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 16px;
  border-bottom: 1px solid #ffffff24;
}
.brand { display: flex; align-items: baseline; gap: 18px; min-width: 0; }
.brand-name { font-size: 21px; font-weight: 850; letter-spacing: -.8px; }
.brand-name > span { color: #ff6d38; }
.brand-sub { font-size: 15px; font-weight: 600; }
.research-label { font-size: 11px; font-weight: 500; color: #bed0c5; margin-left: 6px; }
#tools-btn { background: #f4f1e8; color: #0c3b2e; border-color: transparent; grid-column: 2; grid-row: 1 / 3; }
#service-status { grid-column: 1; display: flex; flex-wrap: wrap; gap: 4px 18px; color: #c5d9cd; font-size: 12px; }
.conn { display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: #e8b859; }
.dot.ok { background: #8bdeba; }
.dot.bad { background: #ff9386; }
#detector-status[data-state='off'], #detector-status[data-state='unknown'] { color: #f5d69a; }
#detail-rail {
  position: absolute; top: var(--header-h); right: 0; bottom: 0; width: var(--rail-w);
  background: var(--bg); border-left: 1px solid var(--panel-border); z-index: 15;
  overflow-y: auto; scrollbar-width: thin; overscroll-behavior: contain; padding: 16px;
}
#panel-left, #panel-right, #sheet-body { display: flex; flex-direction: column; gap: 16px; }
#sheet { margin-top: 16px; }
#sheet-handle { display: none; }
.card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 16px; }
.card-kicker { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.card-title { font-size: 22px; font-weight: 750; line-height: 1.22; letter-spacing: -.5px; margin-top: 8px; overflow-wrap: anywhere; }
.card-meta { font-size: 14px; margin-top: 8px; color: var(--text-dim); }
#event-details { margin-top: 12px; border-top: 1px solid var(--panel-border); }
#event-details > summary { font-size: 12px; }
.card-times, #rev-trail { font-size: 12px; line-height: 1.6; color: var(--text-dim); margin-top: 10px; white-space: pre-line; }
#alert-card.active.sev-warning, #alert-card.active.sev-advisory, #alert-card.shaking {
  --text: #fff; --text-dim: #f7e8da; --panel-border: #ffffff45; color: var(--text);
}
#alert-card.active.sev-warning { background: var(--alert-red-deep); border-color: #d66666; }
#alert-card.active.sev-advisory, #alert-card.shaking { background: #674911; border-color: #a58545; }
#alert-card.provisional { border-left: 4px solid #ffb52e; }
#alert-card.demo { outline: 2px dashed #d59e36; outline-offset: -2px; }
#alert-card.expired { border-style: dashed; }
#alert-card.expired .card-title { text-decoration: line-through; }
#arrival-hero { margin: 16px 0; }
.arrival-count { display: flex; gap: 8px; align-items: baseline; font-size: 60px; font-weight: 750; line-height: 1; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.arrival-count::before { content: '~'; font-size: .55em; align-self: center; }
.arrival-unit { font-size: 18px; font-weight: 500; letter-spacing: 0; }
.arrival-where { margin-top: 8px; font-size: 15px; }
.arrival-what { margin-top: 4px; font-size: 13px; color: var(--text-dim); }
#action-line { border-top: 1px solid var(--panel-border); padding-top: 12px; }
#action-line b { display: block; font-size: 20px; letter-spacing: -.3px; }
#action-line span { display: block; margin-top: 4px; font-size: 13px; }
.mmi-chips { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 8px; }
.mmi-chip { flex: 1; min-width: 110px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.mmi-chip b { font-size: 24px; font-variant-numeric: tabular-nums; padding: 0 8px; border-radius: 5px; color: #04121a; }
.mmi-chip-label, .mmi-chip-sub { font-size: 12px; color: var(--text-dim); }
#tsunami-line { padding: 12px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; font-size: 13px; }
#tsunami-line.threat { background: #621b20; color: #fff; border-color: #e77d7d; font-weight: 600; }
#secondary-events { display: flex; flex-direction: column; gap: 8px; }
.card.mini { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; border-left: 3px solid #ffb52e; }
.card.mini .label { flex: 1; min-width: 100px; }
.card.mini .sub { font-size: 12px; color: var(--text-dim); }
.card.mini.flash { animation: incoming 1s ease-in-out 5; }
@keyframes incoming { 50% { border-left-color: #fff; } }
.card-section-label { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.fine-print { font-size: 12px; color: var(--text-dim); margin-top: 12px; line-height: 1.6; }
#forecast-list, #quake-list, #station-list { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 32px minmax(0,1fr) auto; gap: 4px 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--panel-border); font-size: 14px; }
.row:first-child { border-top: 0; }
.chip { grid-column: 1; grid-row: 1 / 3; min-width: 30px; min-height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; font-weight: 700; font-variant-numeric: tabular-nums; color: #04121a; padding: 2px 4px; }
.row .label { grid-column: 2 / -1; line-height: 1.4; overflow-wrap: anywhere; }
.row .sub { grid-column: 2 / -1; color: var(--text-dim); font-size: 12px; }
#forecast-list .row .label { grid-column: 2; }
#forecast-list .row .sub { grid-column: 2; }
#forecast-list .eta { grid-column: 3; grid-row: 1 / 3; font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
#forecast-list .eta.arrived { color: var(--text-dim); font-size: 13px; }
#quake-list .replayable { cursor: pointer; padding-right: 22px; position: relative; }
#quake-list .replayable:hover { background: var(--panel-hover); }
#quake-list .replayable::after { content: '↶'; position: absolute; right: 0; top: 14px; font-size: 18px; color: var(--text-dim); }
.deleted .label, .deleted .sub { text-decoration: line-through; }
.deleted .chip { filter: grayscale(.85); }
.deleted-tag, .unconfirmed-tag { grid-column: 2 / -1; font-size: 12px; color: #eed093; }
body.theme-light .deleted-tag, body.theme-light .unconfirmed-tag { color: #805816; }
.unconfirmed .chip { filter: grayscale(.55); }
.placeholder { font-size: 13px; color: var(--text-dim); padding: 8px 0; }
#minis { display: flex; flex-direction: column; gap: 12px; }
.mini { position: relative; border: 1px solid var(--panel-border); border-radius: 10px; overflow: hidden; background: var(--bg); }
#inset2 { height: 180px; }
#inset-nat { height: 150px; }
#inset-map, #inset2-map, #inset-nat-map { position: absolute; inset: 0; }
.inset-label { position: absolute; top: 8px; left: 8px; padding: 3px 6px; background: var(--panel); color: var(--text); font-size: 12px; border-radius: 4px; }
#eew-banner {
  width: min(660px, 100%);
  display: grid; grid-template-columns: minmax(140px, .85fr) minmax(0,1fr); min-height: 188px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; overflow: hidden; z-index: 22;
}
#eew-banner #inset { display: flex; flex-direction: column; border: 0; border-right: 1px solid var(--panel-border); border-radius: 0; min-height: 188px; }
#inset-map { position: relative; flex: 1; min-height: 128px; }
#eew-banner-text { min-width: 0; }
#eew-banner-head { background: var(--alert-red); color: #fff; font-size: 15px; font-weight: 750; padding: 10px 14px; }
#eew-banner-sub { color: var(--text-dim); padding: 10px 14px 0; font-size: 12px; }
#eew-banner-regions { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px 12px; padding: 10px 14px; font-size: 17px; font-weight: 700; }
#eew-banner-regions > span::before { content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 2px; background: var(--shaking-color); }
.inset-legend { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 3px 9px; padding: 6px; background: var(--panel); color: var(--text); border-radius: 4px; font-size: 11px; }
.inset-legend span { display: flex; align-items: center; gap: 4px; }
.inset-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
/* Overlay items share normal flow, so expanded keys and wrapped labels cannot collide. */
#map-overlays { position: absolute; top: calc(var(--header-h) + 12px); left: 16px; right: calc(var(--rail-w) + 16px); bottom: calc(var(--attribution-h, 36px) + 8px); z-index: 24; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; scrollbar-width: thin; pointer-events: none; }
#map-overlay-top, #map-overlay-bottom { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; flex-shrink: 0; }
#map-overlay-bottom { margin-top: auto; }
#map-overlays :is(#map-overlay-top, #map-overlay-bottom) > * { pointer-events: auto; flex-shrink: 0; }
#statusbar { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 8px; }
#map-key { border: 1px solid var(--panel-border); background: var(--panel); border-radius: 10px; max-width: 100%; }
#map-key > summary { padding: 0 12px; font-size: 12px; }
.legend-row { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 6px; }
#fill-mode { font-size: 12px; color: var(--text-dim); }
.legend { display: flex; flex-wrap: wrap; gap: 2px; font-size: 11px; color: var(--text-dim); }
.legend .swatch { width: 15px; height: 9px; border-radius: 2px; }
#clock { margin-left: auto; flex-shrink: 0; white-space: nowrap; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px; padding: 7px 10px; }
#clock-time { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
#clock-date { margin-left: 8px; font-size: 11px; color: var(--text-dim); }
#clock-time.replaying { color: #ffba67; }
body.theme-light #clock-time.replaying { color: #895100; }
#disclaimer { font-size: 12px; color: var(--text-dim); line-height: 1.6; margin: 0; padding: 8px 0; }
.maplibregl-ctrl-attrib { background: var(--panel) !important; color: var(--text-dim); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: inherit; }
#shake-pill, #prealert-pill, #replay-badge {
  max-width: 100%;
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; z-index: 24;
  background: #123d29; border: 1px solid #35d178; color: #c7f5da; font-size: 13px;
}
#prealert-pill.dim { opacity: .7; }
.pill-dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: #35d178; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
#replay-badge { white-space: pre-line; line-height: 1.6; background: #342044; border-color: #b78fdb; color: #f1dcff; }
#playback-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; max-width: 100%; border: 1px solid var(--panel-border); border-radius: 10px; background: var(--panel); }
#playback-mode { font-size: 12px; font-weight: 650; padding: 0 6px; }
#playback-controls button { font-size: 12px; padding: 8px; }
#shaking-caption { max-width: 100%; padding: 8px 12px; border: 1px solid var(--panel-border); border-radius: 8px; background: var(--panel); color: var(--text-dim); font-size: 12px; }
#boot-loader { position: absolute; top: 45%; left: 25%; padding: 10px; color: var(--text-dim); background: var(--panel); border-radius: 8px; z-index: 5; }
/* Native dialog provides focus containment, Escape and focus return. */
#controls-dialog { width: min(420px, calc(100% - 24px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px; }
#controls-dialog::backdrop { background: #061b1480; }
.controls-heading { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--panel-border); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.controls-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.5px; }
.controls-body { padding: 4px 20px 20px; }
.setting { border: 0; border-bottom: 1px solid var(--panel-border); padding: 20px 0; margin: 0; min-width: 0; }
.setting legend { padding: 0; float: left; width: 100%; margin-bottom: 12px; }
.setting legend, .setting h3, .switch-row { font-size: 15px; font-weight: 650; }
.setting h3 { margin: 0 0 12px; }
.setting p { margin: 8px 0 0; font-size: 13px; color: var(--text-dim); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; cursor: pointer; }
#sound-btn { appearance: none; width: 46px; height: 28px; margin: 0; border-radius: 20px; background: #6a786f; position: relative; flex-shrink: 0; cursor: pointer; }
#sound-btn::before { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; }
#sound-btn:checked { background: #147452; }
#sound-btn:checked::before { transform: translateX(18px); }
.segments { clear: both; display: flex; border: 1px solid var(--panel-border); border-radius: 10px; padding: 3px; gap: 3px; }
.segments label { position: relative; flex: 1; min-width: 0; cursor: pointer; }
.segments input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segments span { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 7px 4px; border-radius: 7px; font-size: 13px; }
.segments input:checked + span { background: #0c3b2e; color: #fff; }
.segments input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
#loc-row { display: flex; flex-wrap: wrap; gap: 8px; }
#loc-status { flex-basis: 100%; font-size: 13px; color: var(--text-dim); }
#research-tools { margin-top: 12px; }
.research-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 16px; }
.research-actions > * { display: flex; align-items: center; font-size: 13px; }
#demo-btn.running { border-color: #a97623; }
#counts { display: flex; flex-wrap: wrap; gap: 5px; font-size: 12px; color: var(--text-dim); }
#counts b { color: var(--text); }
#kbd-help { position: absolute; top: calc(var(--header-h) + 12px); left: 16px; z-index: 44; max-width: calc(100% - 32px); padding: 16px; border-radius: 12px; border: 1px solid var(--panel-border); background: var(--panel); }
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 13px; }
kbd { display: inline-block; min-width: 24px; padding: 2px 5px; border: 1px solid var(--panel-border); border-radius: 4px; margin-right: 6px; font: inherit; }
@media (min-width: 701px) and (max-width: 1024px) { :root { --rail-w: 320px; } #clock-date { display: none; } #eew-banner { grid-template-columns: 130px minmax(0,1fr); } }
@media (max-width: 700px) {
  :root { --header-h: calc(108px + env(safe-area-inset-top)); --rail-w: 0px; --sheet-peek: calc(68px + env(safe-area-inset-bottom)); }
  #titlebar { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; column-gap: 8px; }
  .brand { gap: 4px; flex-direction: column; }
  .brand-name { font-size: 19px; }
  .brand-sub { font-size: 12px; }
  #tools-btn { grid-row: 1; padding: 8px 12px; }
  #service-status { grid-column: 1 / -1; gap: 3px 12px; font-size: 11px; }
  #map { bottom: var(--sheet-peek); }
  #detail-rail { position: static; padding: 0; width: auto; border: 0; overflow: visible; }
  #panel-left { position: absolute; top: calc(var(--header-h) + 8px); left: 10px; right: 10px; gap: 8px; max-height: 46dvh; overflow-y: auto; overscroll-behavior: contain; z-index: 20; scrollbar-width: thin; }
  body.protect-alert #panel-left { z-index: 30; }
  #alert-card { padding: 12px 14px; }
  .card-title { font-size: 19px; margin-top: 5px; }
  .card-kicker { font-size: 11px; }
  #alert-card.idle .card-meta, #alert-card.replay .card-meta { display: none; } /* Latest reports remain in the activity sheet. */
  #alert-card.idle #event-details { margin-top: 5px; }
  #arrival-hero { margin: 12px 0; }
  .arrival-count { font-size: 46px; }
  .arrival-where { font-size: 14px; }
  .arrival-what { font-size: 12px; }
  #action-line b { font-size: 19px; }
  #action-line span { font-size: 12px; }
  body.banner-on #alert-title, body.banner-on #alert-meta { display: none; } /* Also present in the warning banner. */
  #sheet { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; z-index: 28; display: flex; flex-direction: column;
    height: calc(100dvh - var(--header-h) - var(--protected-height, 0px) - 12px); max-height: calc(100dvh - var(--header-h));
    background: var(--bg); border: 1px solid var(--panel-border); border-bottom: 0; border-radius: 18px 18px 0 0;
    transform: translateY(calc(var(--sheet-y, 0px) + var(--drag, 0px))); transition: transform .22s ease; }
  #sheet.peek { --sheet-y: calc(100% - var(--sheet-peek)); }
  #sheet.half { --sheet-y: 45%; }
  #sheet.full { --sheet-y: 0px; }
  #sheet.dragging { transition: none; }
  #sheet-handle { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 68px; flex-shrink: 0; border: 0; border-radius: 18px 18px 0 0; background: var(--bg); padding: 8px 16px; touch-action: none; }
  .grabber { width: 34px; height: 4px; background: var(--text-dim); border-radius: 4px; margin-bottom: 3px; }
  #sheet-hint { font-size: 14px; }
  #sheet-state-label { font-size: 11px; color: var(--text-dim); font-weight: 400; }
  #sheet-body > #event-details { margin-top: 0; padding: 4px 14px; border: 1px solid var(--panel-border); border-radius: 12px; background: var(--panel); }
  #sheet-body { overflow-y: auto; min-height: 0; padding: 0 12px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  #eew-banner { position: relative; left: auto; bottom: auto; width: 100%; flex-shrink: 0; grid-template-columns: 112px minmax(0,1fr); min-height: 160px; z-index: auto; }
  #eew-banner #inset { min-height: 160px; }
  #eew-banner-head { font-size: 13px; padding: 8px 10px; }
  #eew-banner-sub { font-size: 12px; padding: 6px 10px 0; }
  #eew-banner-regions { font-size: 14px; gap: 3px 8px; padding: 6px 10px 8px; }
  .inset-legend { flex-direction: column; font-size: 10px; }
  #map-overlays { top: calc(var(--header-h) + var(--panel-height, 0px) + 16px); left: 10px; right: 10px; bottom: calc(var(--sheet-peek) + var(--attribution-h, 36px) + 8px); }
  #clock-date { display: none; }
  #clock-time { font-size: 12px; }
  #map-key > summary { min-height: 44px; }
  #shake-pill, #prealert-pill { font-size: 12px; }
  body.playback-on #statusbar { display: none; }
  #controls-dialog { max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px); }
  #kbd-help { max-height: calc(100dvh - var(--header-h) - 24px); overflow: auto; }
  .kbd-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .pill-dot, .card.mini.flash { animation: none; } #sheet { transition: none; } }
