@font-face { font-family: Michroma; src: url(fonts/michroma.ttf) format("truetype"); font-display: swap; }

/* Dark command display: near-black ground, floating panels with thin borders, small uppercase headings,
   monospace readouts. Colours are tokens, so a light theme is one block. */
:root {
  /* From the brand emblem: green-black ground, bone white, khaki ring, olive hills, blue friend, red hostile. */
  --ground: #0a1113; --panel: rgba(13, 20, 21, .93); --panel2: #121c1d; --line: #223031; --line2: #2f3f3f;
  --text: #ece4cf; --dim: #9a9c88; --faint: #626a5f;
  --accent: #c2b98f; --ok: #8bc34a; --warn: #f0b429; --alarm: #ff3b30; --hostile: #e53935; --friend: #3aa0e8;
  --olive: #626949; --olive-dark: #313a2a;
  --radius: 10px; --mono: "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; --sans: Inter, system-ui, sans-serif;
  /* The wide geometric letters of the brand word mark. */
  --brand: Michroma, var(--sans);
}
:root[data-theme="light"] {
  --ground: #e9ecef; --panel: rgba(255, 255, 255, .94); --panel2: #f3f5f7; --line: #d5dae0; --line2: #c4cad1;
  --text: #15191d; --dim: #56606a; --faint: #8a939c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--text); font: 13px/1.45 var(--sans); }
/* The start screens: the ground has faint contour rings, as in the brand art. */
.screen { background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--olive-dark) 55%, transparent), transparent 60%),
  repeating-radial-gradient(circle at 30% 70%, transparent 0 38px, rgba(98, 105, 73, .07) 38px 39px), var(--ground); }
.hidden { display: none !important; }
.mono, .mono * { font-family: var(--mono); }
h3 { font: 600 10.5px/1 var(--sans); letter-spacing: .14em; color: var(--dim); margin: 16px 0 8px; }
small { font-size: 9.5px; letter-spacing: .12em; color: var(--faint); text-transform: uppercase; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 6px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font: 600 10px/1 var(--sans); letter-spacing: .12em; color: var(--dim); }
button { font: 600 11px/1 var(--sans); letter-spacing: .08em; color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 6px; padding: 9px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #0a1113; border-color: var(--accent); }
button.ghost { background: transparent; }
button.small { padding: 6px 9px; font-size: 10px; }
button.danger { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 50%, transparent); }
button.alarm { background: var(--alarm); border-color: var(--alarm); color: #fff; }
.row { display: flex; gap: 8px; align-items: center; }
.msg { color: var(--dim); }
.screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 16px; }
.card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.card h3 { margin-top: 0; }
#eventList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#eventList button { width: 100%; text-align: left; display: flex; justify-content: space-between; padding: 12px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { font: 400 15px/1 var(--brand); letter-spacing: .14em; display: block; color: var(--text); }
.brand small { display: block; margin-top: 4px; }
.brand.big { flex-direction: column; text-align: center; }
.brand.big b { font-size: 34px; }
.brand.big small { font-size: 10px; letter-spacing: .3em; margin-top: 10px; }
.logo { width: 34px; height: 34px; }
.brand.big .logo { width: 96px; height: 96px; }

/* Live layout: the map fills the screen; panels float over it. */
#live { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; }
.panel { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(6px); z-index: 2; }
#top { top: 12px; left: 12px; right: 12px; height: 56px; display: flex; align-items: center; gap: 24px; padding: 0 16px; }
#top .stats { display: flex; gap: 22px; margin-left: 16px; }
#top .stats div { display: flex; flex-direction: column; gap: 3px; }
#top .stats b { font: 600 15px/1 var(--mono); }
#top .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.alarmText { color: var(--alarm); }
.live { font: 600 10px/1 var(--mono); letter-spacing: .12em; padding: 6px 9px; border-radius: 20px; border: 1px solid var(--line2); }
.live::before { content: "●"; margin-right: 6px; }
.live.on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.live.off { color: var(--alarm); }
#left { top: 80px; left: 12px; bottom: 60px; width: 250px; padding: 4px 14px 14px; overflow: auto; }
#right { top: 80px; right: 12px; bottom: 60px; width: 360px; display: flex; flex-direction: column; overflow: hidden; }
#tabs { display: flex; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; border: none; border-radius: 0; background: transparent; padding: 14px 6px; color: var(--dim); border-bottom: 2px solid transparent; }
#tabs button.on { color: var(--text); border-bottom-color: var(--accent); background: linear-gradient(to top, color-mix(in srgb, var(--olive) 22%, transparent), transparent); }
#right section { overflow: auto; padding: 12px 14px; flex: 1; }
.pill { background: var(--alarm); color: #fff; border-radius: 10px; padding: 2px 6px; margin-left: 4px; font-size: 9px; }
#telemetry { left: 274px; right: 384px; bottom: 12px; height: 38px; display: flex; align-items: center; gap: 22px; padding: 0 14px; font-size: 11.5px; }
#telemetry div { display: flex; gap: 8px; align-items: baseline; white-space: nowrap; }

/* Layer switches */
.layer { display: flex; align-items: center; gap: 10px; padding: 7px 2px; cursor: pointer; user-select: none; }
.layer .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.layer .sw.diamond { border-radius: 2px; transform: rotate(45deg); }
.layer .name { flex: 1; }
.layer .n { font: 11px var(--mono); color: var(--dim); }
.toggle { width: 30px; height: 16px; border-radius: 10px; background: var(--line2); position: relative; flex: none; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--dim); transition: left .15s; }
.layer.on .toggle { background: var(--olive); }
.layer.on .toggle::after { left: 16px; background: #fff; }
.tools { display: flex; flex-direction: column; gap: 6px; }

/* Calls */
.call { border: 1px solid var(--line2); border-left: 3px solid var(--alarm); border-radius: 8px; padding: 10px; margin-bottom: 10px; background: var(--panel2); }
.call.open { animation: pulse 1.6s infinite; }
.call.done { border-left-color: var(--faint); opacity: .65; animation: none; }
.call .head { display: flex; justify-content: space-between; gap: 8px; }
.call .head b { font-size: 13px; }
.call .meta { color: var(--dim); font: 11px var(--mono); margin-top: 4px; }
.call .actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.state { font: 600 9.5px/1 var(--mono); letter-spacing: .1em; padding: 4px 6px; border-radius: 4px; border: 1px solid currentColor; height: fit-content; }
.state.OPEN { color: var(--alarm); } .state.RESPONDING { color: var(--warn); } .state.ON_SCENE { color: var(--accent); }
.state.CLOSED, .state.CANCELLED { color: var(--faint); }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--alarm) 25%, transparent); } }

/* Tables and lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.item .grow { flex: 1; min-width: 0; }
.item .sub { color: var(--dim); font-size: 11px; }
.item select { width: auto; padding: 4px 6px; font-size: 11px; }
.links a { color: var(--accent); cursor: pointer; margin-right: 10px; font: 600 10.5px var(--mono); }
.form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 12px; }
.kv span:nth-child(odd) { color: var(--dim); font: 600 10px var(--sans); letter-spacing: .1em; text-transform: uppercase; padding-top: 2px; }
.code { font: 600 16px var(--mono); letter-spacing: .12em; color: var(--accent); }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: middle; }

/* Ring menu (right click on the map) */
.ring { position: fixed; z-index: 5; width: 0; height: 0; }
.ring::before { content: ""; position: absolute; left: -86px; top: -86px; width: 172px; height: 172px; border-radius: 50%; border: 2px solid var(--line2); }
.ringBtn { position: absolute; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; background: var(--panel); border: 1px solid var(--accent); }
.ringBtn small { font-size: 7px; color: var(--dim); }
.ringBtn.center { width: 38px; height: 38px; margin: -19px 0 0 -19px; left: 0; top: 0; }

/* Entity card */
#entityCard { left: 274px; bottom: 60px; width: 280px; padding: 14px; }
#entityCard .close { position: absolute; top: 8px; right: 8px; padding: 4px 7px; }

/* MapLibre controls in the theme */
.maplibregl-ctrl-group { background: var(--panel) !important; border: 1px solid var(--line); }
.maplibregl-ctrl-group button { background: transparent; border-color: var(--line) !important; }
.maplibregl-ctrl-group button span { filter: invert(.85); }
.maplibregl-ctrl-top-right { top: 74px; right: 384px; }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: 56px; }
.maplibregl-ctrl-bottom-left { left: 268px; }
.maplibregl-ctrl-attrib { background: transparent !important; color: var(--faint); font-size: 9px; }
.maplibregl-ctrl-attrib a { color: var(--faint) !important; }
.maplibregl-ctrl-scale { background: var(--panel); color: var(--dim); border-color: var(--dim); font: 10px var(--mono); }

@media (max-width: 900px) {
  #left { display: none; }
  #right { top: auto; height: 42vh; left: 12px; width: auto; }
  #telemetry { display: none; }
  #top .stats div:nth-child(n+3) { display: none; }
  #entityCard { left: 12px; bottom: calc(42vh + 20px); }
  .maplibregl-ctrl-top-right { right: 12px; }
}

/* Notices: short messages at the top, in the style of the panels. */
#notices { position: fixed; top: 78px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; width: min(480px, calc(100vw - 32px)); pointer-events: none; }
.notice { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line2); border-left: 3px solid var(--accent); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); cursor: pointer; animation: noticeIn .2s ease-out; font-size: 12.5px; }
.notice .text { flex: 1; }
.notice .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.notice.ok { border-left-color: var(--ok); } .notice.ok .dot { background: var(--ok); }
.notice.error { border-left-color: var(--alarm); } .notice.error .dot { background: var(--alarm); }
.notice.alarm { border-color: var(--alarm); border-left-width: 4px; background: color-mix(in srgb, var(--alarm) 14%, var(--panel)); font-weight: 600; letter-spacing: .02em; }
.notice.alarm .dot { background: var(--alarm); animation: blink 1s infinite; }
.notice.out { opacity: 0; transform: translateY(-6px); transition: all .25s; }
@keyframes noticeIn { from { opacity: 0; transform: translateY(-8px); } }
@keyframes blink { 50% { opacity: .2; } }

/* Dialogs: in place of the browser prompt and confirm. */
.backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(4, 8, 9, .62); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 16px 48px rgba(0, 0, 0, .6); }
.dialog h3 { margin: 0; }
.dialog textarea { resize: vertical; }
.row.end { justify-content: flex-end; }
