:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-2: #0a1120;
  --panel: rgba(13, 21, 38, 0.78);
  --border: rgba(148, 163, 184, 0.13);
  --border-strong: rgba(148, 163, 184, 0.26);
  --text: #e6edf7;
  --muted: #93a4bb;
  --muted-2: #6f8199;
  --accent: #22d3ee;
  --accent-2: #34d399;
  --amber: #fbbf24;
  --danger: #f87171;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(34, 211, 238, 0.08), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(52, 211, 153, 0.05), transparent 55%),
    var(--bg);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(34, 211, 238, 0.28); }

* { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.24) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid rgba(34, 211, 238, 0.6); outline-offset: 2px; }

/* ---------------------------------------------------------------- header */
.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 13, 24, 0.78);
  backdrop-filter: blur(16px);
  z-index: 10;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #06222a;
  background: linear-gradient(145deg, #67e8f9, #22d3ee 45%, #34d399);
  box-shadow: 0 6px 20px rgba(34, 211, 238, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  flex: 0 0 auto;
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.brand-text p { margin: 1px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }

.header-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.history-group { display: flex; gap: 3px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--border); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.028);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; opacity: 0.8; }
.btn:hover { background: rgba(148, 163, 184, 0.1); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.primary {
  background: linear-gradient(135deg, #22d3ee, #34d399);
  border-color: transparent;
  color: #04222b;
  font-weight: 650;
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.2);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: #fecaca; border-color: rgba(248, 113, 113, 0.28); background: rgba(248, 113, 113, 0.07); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.14); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex: 0 0 auto;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover:not(:disabled) { background: rgba(148, 163, 184, 0.1); color: var(--text); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 15px; height: 15px; }
.icon-btn.help { border-color: var(--border); font-weight: 650; font-size: 14px; color: var(--muted); }
.icon-btn.help:hover { color: var(--accent); border-color: rgba(34, 211, 238, 0.35); }

/* ----------------------------------------------------------------- menu */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu .caret { width: 12px; height: 12px; transition: transform 0.15s ease; }
.menu[open] .caret { transform: rotate(180deg); }
.menu[open] > summary { background: rgba(148, 163, 184, 0.1); border-color: var(--border-strong); }

.menu-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 278px;
  padding: 6px;
  border-radius: 13px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #0e1829, #0a1120);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  z-index: 40;
}
.menu-pop button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.menu-pop button:hover { background: rgba(34, 211, 238, 0.08); }
.menu-pop button strong { font-size: 13px; font-weight: 550; }
.menu-pop button span { font-size: 11px; color: var(--muted); }
.menu-pop button sub { font-size: 0.78em; }

/* -------------------------------------------------------------- layout */
.app-main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 380px;
  min-height: 0;
}

/* -------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 21, 38, 0.55), rgba(7, 12, 22, 0.9));
  min-height: 0;
}
.tool-group { display: flex; flex-direction: column; gap: 5px; width: 100%; }

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 9px 2px 7px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 9.5px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tool svg { width: 22px; height: 22px; }
.tool:hover { background: rgba(148, 163, 184, 0.08); color: var(--text); }
.tool.active {
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.3);
  color: var(--accent);
  box-shadow: inset 0 0 24px rgba(34, 211, 238, 0.06);
}

.toolbar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  width: 100%;
}

/* --------------------------------------------------------------- canvas */
.canvas-wrap {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(1100px 640px at 48% 38%, rgba(20, 38, 70, 0.75) 0%, rgba(9, 16, 31, 0.9) 55%, #060a13 100%);
}
.canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(2, 5, 11, 0.55) 100%);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}

.canvas-status {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(8, 14, 26, 0.8);
  backdrop-filter: blur(10px);
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
  max-width: calc(100% - 210px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.15);
  flex: 0 0 auto;
}
.canvas-status.ok { color: #bdf5dc; border-color: rgba(52, 211, 153, 0.24); }
.canvas-status.ok .status-dot { background: var(--accent-2); box-shadow: 0 0 10px rgba(52, 211, 153, 0.75), 0 0 0 3px rgba(52, 211, 153, 0.12); }
.canvas-status.error { color: #fecaca; border-color: rgba(248, 113, 113, 0.3); }
.canvas-status.error .status-dot { background: var(--danger); box-shadow: 0 0 10px rgba(248, 113, 113, 0.7), 0 0 0 3px rgba(248, 113, 113, 0.12); }

.canvas-toggles {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(8, 14, 26, 0.74);
  backdrop-filter: blur(10px);
}
.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.pill-toggle svg { width: 13px; height: 13px; }
.pill-toggle:hover { color: var(--text); }
.pill-toggle.on { background: rgba(34, 211, 238, 0.13); color: #a5f3fc; }

.canvas-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 3;
  max-width: calc(100% - 30px);
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(8, 14, 26, 0.76);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.canvas-hint strong { color: #cbd5e1; font-weight: 550; }
.canvas-hint kbd { margin: 0 1px; }

kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.35;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}
.empty-card {
  pointer-events: auto;
  width: min(430px, 100%);
  padding: 26px 28px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(14, 24, 43, 0.88), rgba(8, 14, 27, 0.92));
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  text-align: center;
}
.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--accent);
  background: rgba(34, 211, 238, 0.09);
  border: 1px solid rgba(34, 211, 238, 0.18);
}
.empty-icon svg { width: 30px; height: 30px; }
.empty-card h2 { margin: 0 0 6px; font-size: 17px; font-weight: 620; }
.empty-card p { margin: 0 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.empty-card p strong { color: #cbd5e1; font-weight: 550; }
.empty-actions { display: flex; justify-content: center; gap: 8px; }

/* --------------------------------------------------------------- sidebar */
.sidebar {
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(11, 18, 33, 0.82), rgba(7, 11, 21, 0.96));
  display: flex;
  flex-direction: column;
}
.panel { border-bottom: 1px solid var(--border); }
.panel-results { flex: 1 0 auto; border-bottom: none; }
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 10px;
}
.panel-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #cbd5e1;
}
.panel-kicker { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }
.panel-body { padding: 2px 16px 18px; }

.properties-empty {
  padding: 10px 2px 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.properties-empty .hint-line { display: flex; gap: 9px; align-items: flex-start; margin-top: 4px; }
.properties-empty svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; color: var(--muted-2); }

.prop-head { display: flex; align-items: center; gap: 10px; padding: 4px 0 14px; }
.chip {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex: 0 0 auto;
}
.chip-r { background: rgba(56, 189, 248, 0.13); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.28); }
.chip-v { background: rgba(251, 191, 36, 0.12); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.28); }
.chip-w { background: rgba(148, 163, 184, 0.12); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.25); }
.chip-g { background: rgba(148, 163, 184, 0.1); color: #a8b8cc; border: 1px solid rgba(148, 163, 184, 0.22); }
.prop-title { min-width: 0; }
.prop-title h3 { margin: 0; font-size: 15px; font-weight: 600; }
.prop-title p { margin: 1px 0 0; font-size: 11px; color: var(--muted); }
.prop-id { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted-2); white-space: nowrap; }

.field { display: block; margin: 0 0 6px; }
.field-label { display: block; margin-bottom: 6px; font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 48px 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(3, 8, 17, 0.62);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-wrap input:focus {
  border-color: rgba(34, 211, 238, 0.6);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.11);
}
.input-wrap input.invalid {
  border-color: rgba(248, 113, 113, 0.68);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.1);
}
.input-wrap .unit {
  position: absolute;
  right: 12px;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--muted);
  pointer-events: none;
}
.field-hint { margin: 7px 0 0; font-size: 10.5px; color: var(--muted-2); line-height: 1.5; }
.field-hint code {
  font-family: var(--mono);
  font-size: 10px;
  background: rgba(148, 163, 184, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
  color: #cbd5e1;
}
.field-error { margin: 6px 0 0; font-size: 11px; color: #fca5a5; }

.note {
  margin: 10px 0 0;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(251, 191, 36, 0.055);
  border: 1px solid rgba(251, 191, 36, 0.16);
  color: #e8d5a3;
  font-size: 11px;
  line-height: 1.5;
}
.note b { color: #fde68a; }

.prop-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.prop-actions.single { grid-template-columns: 1fr; }
.prop-actions .btn { justify-content: center; height: 36px; }

/* --------------------------------------------------------------- tables */
.alert {
  display: flex;
  gap: 9px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 11.5px;
  line-height: 1.5;
}
.alert strong { display: block; font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.alert p { margin: 0; opacity: 0.85; }
.alert svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.alert.ok { background: rgba(52, 211, 153, 0.06); border-color: rgba(52, 211, 153, 0.2); color: #b6f3da; }
.alert.error { background: rgba(248, 113, 113, 0.075); border-color: rgba(248, 113, 113, 0.26); color: #fecaca; }
.alert.warn { background: rgba(251, 191, 36, 0.05); border-color: rgba(251, 191, 36, 0.18); color: #e8d5a3; }

.table-block { margin-bottom: 16px; overflow-x: auto; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 5px; }
.block-head h4 { margin: 0; font-size: 11px; font-weight: 600; color: #cbd5e1; letter-spacing: 0.03em; }
.block-head span { font-size: 10px; color: var(--muted-2); }

.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  padding: 5px 5px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 7px 5px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.055);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .num.neg { color: #fca5a5; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: rgba(34, 211, 238, 0.055); }

.node-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 6px;
  border-radius: 50%;
  background: #60a5fa;
  vertical-align: 1px;
}
.mini-chip {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin-right: 6px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  vertical-align: -3px;
}
.mini-chip.chip-r { background: rgba(56, 189, 248, 0.13); color: #7dd3fc; border-color: transparent; }
.mini-chip.chip-v { background: rgba(251, 191, 36, 0.12); color: #fbbf24; border-color: transparent; }
.badge-ground, .badge-ref {
  display: inline-block;
  margin-left: 5px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 8.5px;
  line-height: 1.5;
  vertical-align: 1px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.14);
}
.badge-ref { color: #93c5fd; background: rgba(96, 165, 250, 0.09); border-color: rgba(96, 165, 250, 0.16); }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 2px 0 12px; }
.metric { padding: 9px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.022); border: 1px solid var(--border); }
.metric span { display: block; font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 3px; }
.metric strong { font-family: var(--mono); font-size: 13px; font-weight: 500; color: #dbe7f5; }

.warnings { margin-top: 4px; }
.warnings details { border-radius: 9px; border: 1px solid var(--border); background: rgba(251, 191, 36, 0.035); padding: 8px 10px; }
.warnings summary { cursor: pointer; font-size: 11px; color: #e8d5a3; }
.warnings ul { margin: 7px 0 0; padding-left: 16px; font-size: 11px; line-height: 1.55; color: var(--muted); }
.warnings li + li { margin-top: 4px; }

.results-note { margin: 10px 0 0; font-size: 10px; line-height: 1.55; color: var(--muted-2); }
.results-note b { color: var(--muted); font-weight: 550; }

.results-empty { padding: 14px 2px 8px; font-size: 12px; color: var(--muted); line-height: 1.6; }

.skeleton { display: grid; gap: 8px; padding: 4px 0 8px; }
.skeleton span { height: 10px; border-radius: 6px; background: linear-gradient(90deg, rgba(148, 163, 184, 0.08), rgba(148, 163, 184, 0.16), rgba(148, 163, 184, 0.08)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------------------------------------------------------------- modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 6, 12, 0.75);
  backdrop-filter: blur(7px);
}
.modal-card {
  width: min(780px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #0e182b, #0a101d);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65);
}
.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 24, 43, 0.94);
  backdrop-filter: blur(10px);
  z-index: 1;
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 620; }
.modal-body { padding: 6px 20px 22px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; }
.help-grid h3 { margin: 16px 0 6px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.help-grid ul { margin: 0; padding-left: 16px; font-size: 12px; line-height: 1.65; color: var(--muted); }
.help-grid li + li { margin-top: 5px; }
.help-grid strong { color: #dbe7f5; font-weight: 550; }
.help-grid .keys { list-style: none; padding-left: 0; }
.help-grid em { color: #cbd5e1; font-style: normal; }
.modal-note { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted-2); line-height: 1.55; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 80;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  background: rgba(8, 18, 30, 0.96);
  color: #d1fae5;
  font-size: 12.5px;
  opacity: 0;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(248, 113, 113, 0.36); color: #fecaca; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .app-main { grid-template-columns: 78px minmax(0, 1fr) 336px; }
}

@media (max-width: 940px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }
  .app-main { display: flex; flex-direction: column; }
  .toolbar {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .tool-group { flex-direction: row; width: auto; gap: 4px; }
  .tool { width: auto; min-width: 60px; padding: 7px 8px 6px; }
  .toolbar-bottom {
    margin-top: 0;
    margin-left: auto;
    flex-direction: row;
    width: auto;
    padding-top: 0;
    border-top: none;
  }
  .canvas-wrap { height: 54vh; min-height: 400px; flex: 0 0 auto; }
  .sidebar { border-left: none; border-top: 1px solid var(--border); overflow: visible; }
  .panel-results { border-bottom: none; }
}

@media (max-width: 700px) {
  .app-header { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .brand-text p { display: none; }
  .header-actions { gap: 5px; }
  .btn-label { display: none; }
  .btn { padding: 0 10px; }
  .history-group { padding-right: 3px; margin-right: 0; }
  .canvas-status { max-width: calc(100% - 170px); font-size: 10.5px; }
  .canvas-toggles { top: 10px; right: 10px; }
  .canvas-status { top: 10px; left: 10px; }
  .pill-toggle { padding: 0 8px; }
  .canvas-hint { font-size: 10.5px; padding: 6px 10px; }
  .help-grid { grid-template-columns: 1fr; }
  .sidebar .panel-body { padding-left: 12px; padding-right: 12px; }
  .empty-card { padding: 20px; }
}

@media (max-width: 520px) {
  .tool span { display: none; }
  .tool { min-width: 42px; padding: 8px 5px; }
  .tool svg { width: 20px; height: 20px; }
  .canvas-wrap { height: 48vh; min-height: 340px; }
  .pill-toggle svg { display: none; }
  .canvas-toggles .pill-toggle { font-size: 10px; padding: 0 7px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-text h1 { font-size: 15px; }
  .canvas-status { max-width: calc(100% - 150px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
