/* Chrome, sidebar, and controls. */

:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #14171b;
  --panel-2: #191d22;
  --panel-3: #20252b;
  --line: #2b3138;
  --line-strong: #3b434d;
  --text: #edf0f3;
  --muted: #9aa4ae;
  --subtle: #66717c;
  --accent: #60a5fa;
  --accent-2: #2563eb;
  --radio: #a78bfa;
  --mqtt: #38bdf8;
  --success: #34d399;
  --route-ack: #f8fafc;
  --warning: #fbbf24;
  --danger: #fb7185;
  --node-repeater: #7c3aed;
  --node-companion: #0f766e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

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

button {
  color: inherit;
}

.app {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  flex: none;
  width: 28px;
  height: 28px;
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar-author {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.build-id {
  margin-left: 8px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.02em;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.top-actions,
.section-heading,
.legend,
.clock,
.event-filters {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: 248px minmax(420px, 1fr) 304px;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  background: var(--panel);
}

.left-sidebar {
  border-right: 1px solid var(--line);
}

.right-sidebar {
  border-left: 1px solid var(--line);
}

.sidebar section {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.sidebar section.grow {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 220px;
}

.sidebar section.collapsed > :not(h2):not(.section-heading) {
  display: none !important;
}

.sidebar section.collapsed.grow {
  flex: 0 0 auto;
  min-height: 0;
}

.sidebar section.panel-animating {
  flex: none !important;
  min-height: 0 !important;
  overflow: hidden;
}

.sidebar section[data-animating="collapse"] > :not(h2):not(.section-heading) {
  animation: panel-content-out 360ms ease forwards;
}

.sidebar section[data-animating="expand"] > :not(h2):not(.section-heading) {
  animation: panel-content-in 520ms ease both;
}

@keyframes panel-content-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@keyframes panel-content-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.sidebar section.panel-flash > h2,
.sidebar section.panel-flash > .section-heading {
  border-radius: 4px;
  animation: panel-heading-flash 900ms ease;
}

@keyframes panel-heading-flash {
  0%,
  100% {
    background: transparent;
    box-shadow: none;
  }
  25% {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar section > *,
  .section-toggle::before {
    animation: none !important;
    transition: none !important;
  }
}

h2 {
  margin: 0 0 11px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h2 .section-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.section-toggle::before {
  content: "";
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--muted);
  transform: rotate(90deg);
  transition: transform 520ms cubic-bezier(0.4, 0, 0.2, 1);
}

.section-toggle[aria-expanded="false"]::before {
  transform: none;
}

.section-toggle:hover::before {
  border-left-color: var(--text);
}

.section-heading {
  justify-content: space-between;
}

.section-heading h2 {
  margin-bottom: 0;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.tool {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
}

.tool:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.tool.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, var(--panel-2));
  color: var(--text);
}

.tool-icon {
  display: inline-grid;
  width: 15px;
  height: 15px;
  place-items: center;
  font-size: 16px;
}

.repeater-icon,
.companion-icon {
  border: 2px solid var(--node-repeater);
  border-radius: 50%;
}

.companion-icon {
  border-color: var(--node-companion);
  border-radius: 4px;
  transform: rotate(45deg) scale(0.82);
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.node-coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field > span {
  color: var(--muted);
  font-size: 11px;
}

.field input,
.field select,
.field textarea,
.clock select {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: none;
  background: var(--panel-2);
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.clock select:focus {
  border-color: var(--accent);
}

.field input:disabled {
  color: var(--subtle);
}

.field textarea {
  resize: vertical;
}

.checkbox-field {
  display: flex;
  align-items: center;
}

.checkbox-field input {
  width: auto;
  accent-color: var(--accent);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 8px;
}

.hint,
.empty {
  color: var(--subtle);
  font-size: 11px;
  line-height: 1.45;
}

.packet-hint {
  margin: -4px 0 10px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.hidden {
  display: none !important;
}

.desktop-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.desktop-gate-card {
  width: min(420px, 100%);
  padding: 22px 22px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
}

.desktop-gate-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.desktop-gate-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.button,
.icon-button,
.text-button,
.filter {
  border: 0;
  cursor: pointer;
}

.button {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel-3);
  font-size: 12px;
}

.button:hover {
  filter: brightness(1.13);
}

.button.primary {
  border-color: var(--accent-2);
  background: var(--accent-2);
}

.button.secondary {
  background: var(--panel-3);
}

.button.danger-quiet {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: transparent;
  color: var(--danger);
}

.button.full {
  width: 100%;
}

.mqtt-space-members {
  display: grid;
  gap: 5px;
  margin: 8px 0 12px;
}

.mqtt-member {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px auto;
  align-items: center;
  gap: 6px;
  font-size: 10px;
}

.mqtt-member > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mqtt-member label {
  display: flex;
  align-items: center;
  gap: 3px;
}

.mqtt-member input {
  width: 48px;
  padding: 4px;
}

.mqtt-member i {
  color: var(--muted);
  font-style: normal;
}

