/* Spot3. Yellow / blue / green / red are kept ONLY for the 4 status lamps (UI rule), so buttons use teal, fuchsia and orange. */
:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #14202b; --muted: #5b6875; --line: #d9e0e6;
  --accent: #0d9488; --accent-ink: #fff; --sos: #a21caf; --fam: #c2410c; --code-bg: #eef2f5;
  --lamp-on: #facc15; --lamp-work: #3b82f6; --lamp-done: #22c55e; --lamp-err: #ef4444; --lamp-off: #c7ced5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1720; --panel: #17212c; --ink: #e8eef3; --muted: #9aa8b5; --line: #2a3744; --code-bg: #0f1922;
    --accent: #14b8a6; --sos: #c026d3; --fam: #ea580c; --lamp-off: #34414e; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1720; --panel: #17212c; --ink: #e8eef3; --muted: #9aa8b5; --line: #2a3744; --code-bg: #0f1922;
  --accent: #14b8a6; --sos: #c026d3; --fam: #ea580c; --lamp-off: #34414e; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 12px; min-height: 40px; }
button:hover { border-color: var(--accent); }
input, select { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 40px; }
code, .mono, output { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

#top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.logo { color: var(--accent); }
.tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.tools button { padding: 6px 10px; min-height: 36px; }
.tools .help { font-weight: 700; border-color: var(--accent); }
#soundBtn.off { opacity: .45; }

#lamps { display: flex; gap: 10px; font-size: 12px; color: var(--muted); }
.lamp { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.lamp i { width: 13px; height: 13px; border-radius: 50%; background: var(--lamp-off); display: inline-block; border: 1px solid rgba(0,0,0,.25); }
.lamp.on.lit i { background: var(--lamp-on); box-shadow: 0 0 6px var(--lamp-on); }
.lamp.work.lit i { background: var(--lamp-work); box-shadow: 0 0 6px var(--lamp-work); animation: flash .7s infinite alternate; }
.lamp.done.lit i { background: var(--lamp-done); box-shadow: 0 0 6px var(--lamp-done); }
.lamp.err.lit i { background: var(--lamp-err); box-shadow: 0 0 6px var(--lamp-err); }
.lamp.lit { color: var(--ink); font-weight: 600; }
@keyframes flash { from { opacity: 1; } to { opacity: .25; } }

#search { display: flex; gap: 8px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
#search input { flex: 1; min-width: 0; font-size: 17px; }
#search button { background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 700; padding: 8px 18px; }

main { flex: 1; display: flex; min-height: 0; position: relative; }
#map { flex: 1; min-height: 300px; background: var(--code-bg); }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); } }

#card { width: 400px; max-width: 100%; background: var(--panel); border-left: 1px solid var(--line); padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.where { color: var(--muted); }
.where b { color: var(--ink); }
.code { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; background: var(--code-bg); border-radius: 10px; padding: 8px 10px; }
.code label { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.code label select { min-height: 26px; padding: 0 4px; font-size: 12px; }
.code output { font-size: 17px; word-break: break-all; }
.code.big output { font-size: 21px; font-weight: 700; color: var(--accent); word-break: normal; overflow-wrap: normal; }
.code button { padding: 4px 10px; min-height: 34px; font-size: 14px; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 4px; }
.act { font-weight: 800; font-size: 16px; color: #fff; border: 0; min-height: 56px; border-radius: 12px; }
.act.find { background: var(--accent); }
.act.sos { background: var(--sos); }
.act.fam { background: var(--fam); }
#keepBar { display: flex; align-items: center; gap: 8px; background: var(--code-bg); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
#keepBar span { flex: 1; }
.stop { font-weight: 800; border: 2px solid var(--ink); }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog.full { width: min(760px, calc(100vw - 16px)); }
.dlg, .sosWrap { padding: 16px; overflow-y: auto; }
.sosHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sosHead h2 { margin: 0; }
.x { font-size: 18px; min-width: 44px; }
.calls { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 6px; }
.call { display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: #fff; background: var(--sos); border-radius: 14px; padding: 10px 22px; min-width: 120px; min-height: 76px; }
.call b { font-size: 32px; line-height: 1; }
.call small { font-size: 12px; opacity: .9; }
.readout { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 14px; }
.readout div { background: var(--code-bg); border-radius: 12px; padding: 10px 12px; }
.readout small { display: block; color: var(--muted); font-size: 13px; }
.readout b { font-size: 24px; line-height: 1.25; overflow-wrap: break-word; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row .act { flex: 1; min-width: 140px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.msg { background: var(--code-bg); border-radius: 10px; padding: 10px; white-space: pre-wrap; word-break: break-word; font-size: 14px; margin: 10px 0; }
.urg { display: flex; gap: 8px; align-items: center; }
#famList { display: flex; flex-direction: column; gap: 6px; }
.person { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: var(--code-bg); border-radius: 10px; padding: 6px 8px; }
.person b { flex: 1; min-width: 100px; }
.person a { text-decoration: none; font-weight: 700; color: #fff; background: var(--fam); border-radius: 8px; padding: 8px 12px; }
.person a.wa { background: var(--accent); }
.person button { min-height: 34px; padding: 4px 10px; }
#famAdd input { flex: 1; min-width: 120px; }
#qr { display: flex; justify-content: center; margin: 12px 0; }
#qr img, #qr svg { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 8px; }
.helpBody h3 { margin: 16px 0 4px; }
.helpBody li { margin: 4px 0; }
.lights { list-style: none; padding: 0; }
.lights .lamp { min-width: 92px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; z-index: 2000; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.3); }
#toast.big { font-size: 18px; font-weight: 700; }
#toast button { margin-left: 10px; background: var(--fam); color: #fff; border: 0; font-weight: 800; }

.pin { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,.4); }
.me { background: var(--fam); box-shadow: 0 0 0 2px var(--fam), 0 2px 8px rgba(0,0,0,.4); }

@media (max-width: 760px) {
  main { flex-direction: column; }
  #map { min-height: 42vh; flex: none; height: 42vh; }
  #card { width: 100%; border-left: 0; border-top: 1px solid var(--line); flex: 1; }
  #lamps { order: 3; width: 100%; justify-content: space-between; }
  .tools .help { font-size: 14px; }
  .readout b { font-size: 21px; }
  .act { font-size: 15px; min-height: 60px; }
}
