/* UrbanLLMind visualizer: dark "night city" theme shared with the COLM 2026 poster. */
:root {
  --bg: #06110C;
  --land: #0D2119;
  --surface: #0B1B14;
  --surface-2: #10271D;
  --line: rgba(244, 240, 226, 0.12);
  --text: #F4F0E2;
  --text-soft: #C9D6CE;
  --muted: #8FA79A;
  --gold: #FFCC33;
  /* agent stages, same as the COLM 2026 poster: PLAN teal · DECIDE gold · REFLECT violet */
  --plan: #2DD4BF;
  --decide: #FFCC33;
  --reflect: #A78BFA;
  --green: #1B4D37;
  --storm: #7DD3FC;
  --here: #FF5A5F;
  --topbar-h: 56px;
  --timeline-h: 76px;
  --panel-w: 420px;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
             -webkit-font-smoothing: antialiased; font-feature-settings: "tnum"; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------------- top bar ---------------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 1000; display: flex; align-items: center;
          gap: 16px; padding: 0 16px; background: #0E2A1D; border-bottom: 2px solid var(--gold); }
.brand { display: flex; flex-direction: column; min-width: 0; margin-right: auto; line-height: 1.15; }
.brand-name { font-weight: 900; font-size: 19px; color: var(--gold); letter-spacing: -0.2px; }
.brand-sub { font-size: 13px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.18); border-radius: 20px; padding: 3px; }
.seg button { white-space: nowrap; border: 0; background: transparent; padding: 6px 14px; border-radius: 16px; font-size: 13px; font-weight: 700; color: var(--text-soft); }
.seg button.active { background: var(--gold); color: #10271D; }
.seg button[data-run="storm"].active { background: var(--storm); color: #062033; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.btn-gold { background: var(--gold); color: #10271D; border: 0; border-radius: 18px; padding: 7px 14px; font-weight: 800; font-size: 13px; white-space: nowrap; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-icon { width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3); background: transparent; font-weight: 800; }
.btn-ghost { background: transparent; border: 1px solid var(--line); border-radius: 16px; padding: 5px 12px; font-size: 13px; color: var(--text-soft); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

/* ---------------- layout ---------------- */
.layout { position: fixed; top: var(--topbar-h); bottom: var(--timeline-h); left: 0; right: 0; display: flex; }
.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font: inherit; }
.leaflet-control-attribution { background: rgba(6,17,12,0.7) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-soft) !important; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--line) !important; }
#agentsCanvas, #rainCanvas { position: absolute; inset: 0; pointer-events: none; z-index: 450; }
#rainCanvas { z-index: 440; }
.storm-tint { position: absolute; inset: 0; z-index: 430; pointer-events: none; background: rgba(40, 90, 140, 0.16);
              opacity: 0; transition: opacity 0.6s; }
body.is-storm .storm-tint { opacity: 1; }

/* storm banner */
.storm-banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 700; width: min(640px, calc(100% - 24px));
                background: rgba(6, 22, 34, 0.92); border: 1.5px solid var(--storm); border-radius: var(--radius); padding: 10px 14px; }
.storm-banner.calm { border-color: var(--muted); }
.sb-tag { font-size: 12px; font-weight: 900; letter-spacing: 1.2px; text-transform: uppercase; color: var(--storm); }
.storm-banner.calm .sb-tag { color: var(--muted); }
.sb-text { font-size: 14px; line-height: 1.4; margin-top: 3px; color: #E0F2FE; }
.storm-banner.calm .sb-text { color: var(--text-soft); }

/* clock */
.clock { position: absolute; left: 12px; bottom: 12px; z-index: 700; background: rgba(6,17,12,0.85); border: 1px solid var(--line);
         border-radius: var(--radius); padding: 8px 12px; pointer-events: none; }
.clock-time { font-size: 26px; font-weight: 900; color: var(--gold); letter-spacing: -0.5px; line-height: 1; }
.clock-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.clock-sub b { color: var(--text); }

/* legend */
.legend { position: absolute; right: 12px; bottom: 12px; z-index: 700; background: rgba(6,17,12,0.88); border: 1px solid var(--line);
          border-radius: var(--radius); font-size: 12px; color: var(--text-soft); max-width: 300px; }
.legend summary { padding: 7px 12px; cursor: pointer; font-weight: 700; list-style: none; }
.legend summary::-webkit-details-marker { display: none; }
.legend[open] summary { border-bottom: 1px solid var(--line); }
.legend-body { padding: 8px 12px 10px; display: grid; gap: 6px; }
.lg-row { display: flex; align-items: center; gap: 8px; }
.lg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.lg-grid span { display: flex; align-items: center; gap: 6px; }
.lg-grid i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg-car { width: 18px; height: 9px; border-radius: 2px; background: #F1F5F9; border-left: 6px solid #3B82F6; display: inline-block; }
.lg-dot { width: 8px; height: 8px; border-radius: 50%; background: #10B981; display: inline-block; margin: 0 5px; }
.lg-here { width: 12px; height: 12px; border-radius: 50%; background: var(--here); border: 2px solid #fff; display: inline-block; margin: 0 3px; }

/* venue + stop markers (Leaflet divIcons) */
.venue-icon { width: 18px; height: 18px; border-radius: 50%; background: var(--here); border: 3px solid #fff;
              box-shadow: 0 0 0 6px rgba(255,90,95,0.35), 0 0 0 12px rgba(255,90,95,0.14); }
.venue-label { position: absolute; left: 22px; top: -13px; white-space: nowrap; background: rgba(6,17,12,0.92); border: 1.5px solid var(--here);
               border-radius: 8px; padding: 3px 8px; font-size: 12px; font-weight: 800; color: var(--text); }
.venue-label b { color: var(--here); letter-spacing: 0.8px; }
.stop-icon { min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--gold); color: #06110C;
             border: 2px solid #06110C; font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center;
             transform: translate(-50%, -50%); position: absolute; white-space: nowrap; }

/* ---------------- track an agent ---------------- */
.track-pop { position: fixed; top: calc(var(--topbar-h) + 8px); right: 16px; width: 330px; z-index: 1500; background: var(--surface);
             border: 1.5px solid var(--gold); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 12px 34px rgba(0,0,0,0.5); }
.tp-title { font-size: 15px; font-weight: 800; margin-bottom: 10px; }
.tp-row { display: flex; gap: 8px; }
.tp-row input { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
                padding: 8px 10px; font-size: 15px; }
.tp-row input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.tp-msg { font-size: 12.5px; color: #FCA5A5; min-height: 0; margin-top: 6px; }
.tp-msg:empty { display: none; }
.tp-random { width: 100%; margin-top: 10px; padding: 7px 12px; }
.tp-hint { font-size: 12px; color: var(--muted); margin: 10px 0 8px; }
.tp-tour { background: none; border: 0; padding: 0; color: var(--gold); font-size: 13px; font-weight: 700; text-align: left; }
.tp-tour:hover { text-decoration: underline; }
.recenter { position: absolute; top: 12px; left: 12px; z-index: 760; background: var(--gold); color: #10271D; border: 0; border-radius: 18px;
            padding: 7px 14px; font-weight: 800; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,0.4); }
.grip-close { display: none; }

/* ---------------- story card ---------------- */
.story-card { position: absolute; left: 12px; top: 12px; z-index: 800; width: min(420px, calc(100% - 24px));
              background: rgba(8, 24, 17, 0.96); border: 1.5px solid var(--gold); border-radius: var(--radius);
              padding: 14px 16px 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.45); }
.sc-step { font-size: 11px; font-weight: 900; letter-spacing: 1.4px; color: var(--gold); text-transform: uppercase; }
.sc-title { font-size: 18px; font-weight: 800; margin: 4px 0 6px; }
.sc-body { font-size: 14px; line-height: 1.45; color: var(--text-soft); }
.sc-quote { margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--gold); background: rgba(255,204,51,0.06);
            font-size: 14px; line-height: 1.45; color: var(--text); border-radius: 0 6px 6px 0; }
.sc-quote.storm { border-left-color: var(--storm); background: rgba(125,211,252,0.07); }
.sc-quote.plan { border-left-color: var(--plan); background: rgba(45,212,191,0.07); }
.sc-quote.decide { border-left-color: var(--decide); background: rgba(255,204,51,0.06); }
.sc-quote.reflect { border-left-color: var(--reflect); background: rgba(167,139,250,0.08); }
.sc-quote.memory { border-left-color: var(--muted); background: rgba(143,167,154,0.08); }   /* recalled memories: neutral, like the poster's MEMORY node */
.sc-quote small { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 3px; }
.sc-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; }
.sc-dots { display: flex; gap: 5px; }
.sc-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.2); display: inline-block; }
.sc-dots i.on { background: var(--gold); }

/* ---------------- agent panel ---------------- */
/* the panel exists only while an agent is tracked; otherwise the map is full width */
.panel { width: var(--panel-w); flex: 0 0 var(--panel-w); background: var(--surface); border-left: 1px solid var(--line);
         display: none; flex-direction: column; min-height: 0; z-index: 900; }
body.tracking .panel { display: flex; }
.panel-grip { display: none; }
.panel-inner { overflow-y: auto; flex: 1; padding: 14px 16px 24px; scroll-behavior: smooth; }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.p-title { font-size: 20px; font-weight: 900; }
.p-title small { color: var(--muted); font-weight: 700; font-size: 13px; }
.p-sub { color: var(--text-soft); font-size: 14px; margin: 3px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font-size: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 3px 8px; color: var(--text-soft); }
.p-profile { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.p-profile summary { cursor: pointer; color: var(--text-soft); }
.p-profile pre { white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; line-height: 1.5; color: var(--text-soft);
                 background: var(--surface-2); border-radius: 6px; padding: 8px; margin: 6px 0 0; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 8px 0 10px; }
.days button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 7px; padding: 5px 0; font-size: 12px; font-weight: 800; color: var(--text-soft); }
.days button.storm { color: var(--storm); }
.days button.active { background: var(--gold); color: #10271D; border-color: var(--gold); }
.days button small { display: block; font-size: 10px; font-weight: 700; opacity: 0.8; }
.p-toolbar { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.p-toolbar label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.card { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--gold));
        border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.card:hover { border-color: rgba(255,204,51,0.4); border-left-color: var(--c, var(--gold)); }
.card.now { background: #163426; box-shadow: 0 0 0 1.5px var(--gold) inset; }
.card.stay { padding: 6px 11px; opacity: 0.85; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-kind { font-size: 11px; font-weight: 900; letter-spacing: 1.1px; text-transform: uppercase; color: var(--c, var(--gold)); }
.card.decide .card-kind { color: var(--decide); }     /* stripe keeps the destination-activity colour */
.card-time { font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.card-main { font-size: 14px; line-height: 1.45; margin-top: 4px; }
.card.stay .card-main { font-size: 13px; color: var(--text-soft); }
.card-move { font-size: 12px; color: var(--text-soft); margin-top: 5px; }
.card-move b { color: var(--text); }
.card details { margin-top: 6px; font-size: 12.5px; }
.card details summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.card details summary:hover { color: var(--text-soft); }
.mem { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 5px; }
.mem li { font-size: 12.5px; line-height: 1.4; color: var(--text-soft); padding-left: 10px; border-left: 2px solid #3A5A4A; }
.mem li.r { border-left-color: var(--reflect); }
.mem li em { font-style: normal; color: var(--muted); font-size: 11px; font-weight: 700; margin-right: 4px; }
.thought { white-space: pre-wrap; font-size: 12.5px; line-height: 1.45; color: var(--text-soft); background: rgba(0,0,0,0.25);
           border-radius: 6px; padding: 7px 9px; margin-top: 6px; max-height: 260px; overflow-y: auto; }
.note { font-size: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 7px 10px; margin-bottom: 8px; }
.act-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 5px; vertical-align: 0; }

/* ---------------- timeline ---------------- */
.timeline { position: fixed; left: 0; right: 0; bottom: 0; height: var(--timeline-h); z-index: 1000; display: flex; align-items: center;
            gap: 12px; padding: 0 14px calc(env(safe-area-inset-bottom)) 14px; background: #0A1A13; border-top: 1px solid var(--line); }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--gold); color: #10271D; font-size: 17px; font-weight: 900; flex: 0 0 44px; }
.tl-track { position: relative; flex: 1; height: 58px; min-width: 0; }
#tlCanvas { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; }
.speed { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.speed select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; font-size: 12px; }

/* ---------------- loading + modal ---------------- */
.loading { position: fixed; inset: 0; z-index: 3000; background: var(--bg); display: flex; flex-direction: column; align-items: center;
           justify-content: center; gap: 14px; color: var(--text-soft); font-size: 14px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,204,51,0.2); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal { position: fixed; inset: 0; z-index: 2500; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { position: relative; max-width: 560px; max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1.5px solid var(--gold);
              border-radius: 12px; padding: 20px 22px; font-size: 14.5px; line-height: 1.55; }
.modal-card h2 { margin: 0 0 8px; color: var(--gold); font-size: 20px; }
.modal-card p { margin: 0 0 10px; color: var(--text-soft); }
.modal-card b { color: var(--text); }
.modal-card .fine { font-size: 12.5px; color: var(--muted); }
.about-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.about-links a { text-decoration: none; display: inline-block; }
.modal-close { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 24px; color: var(--muted); }

/* ---------------- kiosk (presentation screen) ---------------- */
body.kiosk .panel, body.kiosk .top-actions, body.kiosk .legend { display: none; }
body.kiosk .clock-time { font-size: 40px; }
body.kiosk .clock-sub { font-size: 15px; }
body.kiosk .storm-banner { top: 18px; }
body.kiosk .sb-text { font-size: 17px; }

/* ---------------- small screens: panel becomes a bottom sheet ---------------- */
@media (max-width: 820px) {
  :root { --topbar-h: 52px; --timeline-h: 64px; }
  .brand-sub, .hide-sm { display: none; }
  .brand-name { font-size: 15px; }
  .brand { min-width: 0; flex-shrink: 0; }
  .topbar { gap: 6px; padding: 0 8px; }
  .seg { padding: 2px; }
  .seg button { padding: 5px 8px; font-size: 12px; }
  .btn-gold { padding: 6px 9px; font-size: 12px; }
  .btn-icon { width: 28px; height: 28px; }
  .panel { position: fixed; left: 0; right: 0; bottom: var(--timeline-h); width: auto; height: 62vh; border-left: 0; border-top: 1.5px solid var(--gold);
           z-index: 1100;                        /* above Leaflet's control corners (z 1000) */
           border-radius: 14px 14px 0 0; transform: translateY(calc(100% - 46px)); transition: transform 0.25s ease; }
  .panel.open { transform: translateY(0); }
  .panel-grip { display: block; height: 46px; flex: 0 0 46px; cursor: pointer; position: relative; }
  .panel-grip::before { content: ""; position: absolute; left: 50%; top: 8px; width: 44px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.35); transform: translateX(-50%); }
  .grip-close { display: block; position: absolute; right: 10px; top: 8px; width: 30px; height: 30px; border-radius: 50%; z-index: 1;
                background: rgba(255,255,255,0.08); border: 1px solid var(--line); color: var(--text); font-size: 14px; }
  .track-pop { left: 8px; right: 8px; width: auto; }
  .recenter { top: 8px; left: 8px; }
  .panel-grip::after { content: attr(data-label); position: absolute; left: 16px; right: 52px; top: 18px; font-size: 14px; font-weight: 800; color: var(--text);
                       white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
  .panel-inner { padding-top: 0; }
  .clock { bottom: 56px; padding: 6px 10px; }
  .clock-time { font-size: 20px; }
  .legend { display: none; }
  .story-card { top: auto; bottom: 56px; left: 8px; width: calc(100% - 16px); max-height: 52vh; overflow-y: auto; }
  .storm-banner { top: 8px; padding: 7px 10px; }
  .leaflet-control-zoom { display: none; }    /* phones pinch-zoom; the buttons sat under the storm banner */
  .sb-text { font-size: 12.5px; }
  .speed select { padding: 4px; }
  .tl-track { height: 50px; }
  .play { width: 40px; height: 40px; flex-basis: 40px; }
}
@media (prefers-reduced-motion: reduce) { .panel, .storm-tint { transition: none; } }
