/* SPDX-License-Identifier: AGPL-3.0-or-later
   Copyright (C) 2026 Jasmin Redžepagić */

/* App chrome. The canvas styles itself (see js/render.js CANVAS_CSS) so that
   exported SVG carries its own look. */

:root {
  --bg: #10151f;
  --bg-2: #182131;
  --bg-3: #202c40;
  --line: #2b3a52;
  --fg: #e6edf7;
  --fg-dim: #93a3ba;
  --accent: #38bdf8;
  --accent-ink: #06263a;
  --danger: #f87171;
  --radius: 8px;
  --rail: 268px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

button, input, select, textarea { font: inherit; color: inherit; }

/* --------------------------------------------------------------- toolbar -- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  z-index: 20;
}

.tb-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 6px;
  border-right: 1px solid var(--line);
}
.tb-group:last-child { border-right: 0; }
.tb-group.right { margin-left: auto; border-right: 0; }

.brand { gap: 8px; }
.brand-mark {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: var(--accent); stroke-width: 1.8;
  stroke-linecap: round;
}
.brand-mark circle { fill: var(--accent); stroke: none; }

.doc-title {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  width: 210px;
  font-weight: 600;
}
.doc-title:hover { border-color: var(--line); }
.doc-title:focus { outline: none; border-color: var(--accent); background: var(--bg); }

.toolbar button, .toolbar select {
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.toolbar button:hover, .toolbar select:hover { background: #2a3a55; }
.toolbar button:active { transform: translateY(1px); }
.toolbar button.icon { min-width: 30px; padding: 5px 6px; text-align: center; font-size: 14px; }
.toolbar button.on, .toolbar button.toggle.on {
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.toolbar button.toggle { opacity: .85; }
.toolbar button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.toolbar button:disabled { opacity: .35; cursor: default; }
.toolbar select { padding: 5px 6px; }
#zoom-level { min-width: 56px; font-variant-numeric: tabular-nums; }

/* dropdown menus */
.menu { position: relative; }
.menu > summary {
  list-style: none;
  background: var(--bg-3);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " ▾"; opacity: .6; }
.menu[open] > summary { background: var(--accent); color: var(--accent-ink); }
.menu-body {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 230px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .5);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu-body button {
  background: transparent;
  text-align: left;
  width: 100%;
  border-radius: 5px;
  padding: 7px 9px;
}
.menu-body button:hover { background: var(--bg-3); }
.menu-body small { display: block; color: var(--fg-dim); font-size: 11px; }

/* ------------------------------------------------------------- workspace -- */
.workspace { flex: 1; display: flex; min-height: 0; }

.rail {
  width: var(--rail);
  flex: none;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rail.left { border-right: 1px solid var(--line); }
.rail.right { border-left: 1px solid var(--line); overflow-y: auto; }

.canvas-wrap { flex: 1; position: relative; min-width: 0; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.canvas-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}

/* --------------------------------------------------------------- palette -- */
.palette-search { padding: 10px; border-bottom: 1px solid var(--line); }
.palette-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
}
.palette-search input:focus { outline: none; border-color: var(--accent); }

.palette-list { overflow-y: auto; padding: 8px 8px 20px; flex: 1; }
.palette-group h3 {
  margin: 12px 4px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-dim);
}
.palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

.palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 4px 6px;
  cursor: grab;
  text-align: center;
}
.palette-item:hover { border-color: var(--accent); background: #26344c; }
.palette-item.armed { border-color: var(--accent); background: var(--accent); }
.palette-item.armed .pal-label { color: var(--accent-ink); font-weight: 600; }
.palette-item.armed .pal-ico { color: var(--accent-ink) !important; }
.pal-ico { width: 26px; height: 26px; }
.pal-ico .f { fill: currentColor; stroke: none; }
.pal-ico .t { fill: var(--bg-2); stroke: none; font-size: 7px; font-weight: 700; text-anchor: middle; }
.pal-label { font-size: 10.5px; line-height: 1.25; color: var(--fg-dim); }
.palette-empty { color: var(--fg-dim); padding: 16px 8px; }

/* ------------------------------------------------------------- inspector -- */
.panel { padding: 12px 12px 32px; }
.panel h2 {
  margin: 0 0 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h3 {
  margin: 18px 0 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-dim);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.panel h3 small { text-transform: none; letter-spacing: 0; }
.accent-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.fld { display: block; margin-bottom: 10px; }
.fld > span {
  display: block;
  font-size: 11px;
  color: var(--fg-dim);
  margin-bottom: 4px;
}
.fld > span em {
  font-style: normal;
  display: inline-block;
  width: 13px; height: 13px;
  line-height: 13px;
  text-align: center;
  border-radius: 50%;
  background: var(--bg-3);
  cursor: help;
  font-size: 10px;
}
.fld input[type=text], .fld input[type=number], .fld input[type=search],
.fld select, .fld textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}
.fld textarea { resize: vertical; font: inherit; }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.fld input[type=range] { width: 100%; }
.fld input[type=color] { width: 100%; height: 30px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.fld small { color: var(--fg-dim); font-size: 10.5px; }
.fld.inline { display: flex; align-items: center; gap: 8px; }
.fld.inline > span { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.svc-filter {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 8px;
}
.svc-filter:focus { outline: none; border-color: var(--accent); }
.svc-group { margin-bottom: 10px; }
.svc-group h4 {
  margin: 0 0 5px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.svc-wrap { display: flex; flex-wrap: wrap; gap: 4px; }
.svc {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg-dim);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  cursor: pointer;
}
.svc:hover { border-color: var(--svc); color: var(--fg); }
.svc.on { background: var(--svc); border-color: var(--svc); color: #fff; }
.svc.partial {
  background: transparent;
  border-color: var(--svc);
  color: var(--svc);
  border-style: dashed;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.btn-row button {
  flex: 1 1 auto;
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}
.btn-row button:hover { background: #2a3a55; }
.btn-row button.danger { color: var(--danger); }
.btn-row button.danger:hover { background: #3a2129; }

.align-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.align-grid button {
  background: var(--bg-3);
  border: 0;
  border-radius: 6px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 14px;
}
.align-grid button:hover { background: var(--accent); color: var(--accent-ink); }

.swatches { display: flex; gap: 6px; }
.zone-swatch {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: var(--zc);
  cursor: pointer;
}
.zone-swatch.on { border-color: var(--fg); }

.stat-row { display: flex; gap: 8px; margin: 12px 0; }
.stat-row div {
  flex: 1;
  background: var(--bg);
  border-radius: 7px;
  padding: 8px;
  text-align: center;
}
.stat-row b { display: block; font-size: 17px; }
.stat-row span { font-size: 10px; color: var(--fg-dim); }

.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.chip-swatch {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  min-width: 44px;
  text-align: center;
}
.legend-label { flex: 1; color: var(--fg-dim); font-size: 11.5px; }
.legend-count { color: var(--fg-dim); font-variant-numeric: tabular-nums; }

.endpoints {
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 12px;
}
.endpoints span { color: var(--fg-dim); margin: 0 4px; }

.hint { color: var(--fg-dim); font-size: 11.5px; line-height: 1.6; }
.hint.keys { list-style: none; padding: 0; margin: 0; }
.hint.keys li { padding: 3px 0; border-bottom: 1px solid var(--bg-3); }
kbd {
  background: var(--bg);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  font: inherit;
  font-size: 10.5px;
}

/* ------------------------------------------------------------ status bar -- */
.statusbar {
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  color: var(--fg-dim);
  font-size: 11.5px;
}
#status-right { margin-left: auto; }
.status-src { color: inherit; text-decoration: none; margin-left: 16px; }
.status-src:hover { text-decoration: underline; }

/* --------------------------------------------------------------- present -- */
body.presenting .toolbar,
body.presenting .rail,
body.presenting .statusbar { display: none; }

.present-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 21, 31, .92);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .45);
  z-index: 60;
  opacity: .28;
  transition: opacity .18s;
}
.present-bar:hover { opacity: 1; }
.present-bar button {
  background: var(--bg-3);
  border: 0;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}
.present-bar button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.present-bar .sep { width: 1px; height: 18px; background: var(--line); }
#step-label { font-variant-numeric: tabular-nums; min-width: 62px; text-align: center; }

/* ----------------------------------------------------------------- toast -- */
.toast {
  position: fixed;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  padding: 9px 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  z-index: 80;
}
.toast.error { border-left-color: var(--danger); }

@media (max-width: 1100px) {
  :root { --rail: 220px; }
}
