:root {
  --ink: #eef0ea;
  --ink-soft: #a8ac9f;
  --bg: #0b0d10;
  --panel: rgba(23, 27, 32, 0.72);
  --panel-solid: #171b20;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #ffc93c;
  --accent-2: #3e7c82;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-shell[hidden] { display: none; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.toolbar-brand {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--accent);
}
.toolbar-search {
  position: relative;
  flex: 1;
  max-width: 360px;
}
.toolbar-search input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px 14px;
  color: var(--ink);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.toolbar-search input:focus { border-color: var(--accent-2); }
.toolbar-search-results {
  position: absolute;
  top: 38px;
  left: 0;
  right: 0;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 20;
}
.toolbar-search-results[hidden] { display: none; }
.toolbar-search-results button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.toolbar-search-results button:hover { background: rgba(255, 255, 255, 0.06); }
.toolbar-action {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
}
.toolbar-action:hover { border-color: var(--accent-2); }
.toolbar-action:disabled { opacity: 0.5; cursor: default; }

/* ---------- Body layout ---------- */
.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr 340px;
  min-height: 0;
}
@media (max-width: 900px) {
  .app-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
}

.canvas-wrap { position: relative; min-height: 0; order: 2; }
.canvas-wrap canvas { display: block; width: 100%; height: 100%; }
.sidebar { order: 1; border-right: 1px solid var(--line); background: rgba(255,255,255,0.02); padding: 16px; overflow-y: auto; }
.info-panel { order: 3; border-left: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(14px); padding: 22px; overflow-y: auto; }
@media (max-width: 900px) {
  .sidebar, .info-panel, .canvas-wrap { order: initial; border: none; border-top: 1px solid var(--line); }
}

/* ---------- Layer / mode toggle ---------- */
.layer-toggle { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.layer-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}
.layer-btn--active { background: rgba(62,124,130,0.22); border-color: var(--accent-2); color: var(--ink); }
.layer-btn--stub { opacity: 0.55; }
.layer-btn:disabled { cursor: default; }
.layer-btn-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  border: 1px dashed var(--ink-soft);
  padding: 2px 6px;
  border-radius: 10px;
}

/* ---------- Structure list ---------- */
.structure-list { display: flex; flex-direction: column; gap: 2px; }
.structure-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--ink);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}
.structure-row:hover { background: rgba(255,255,255,0.05); }
.structure-row--active { background: rgba(255,201,60,0.16); }
.structure-code { margin-left: auto; font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--ink-soft); }
.structure-list-empty { font-size: 12.5px; color: var(--ink-soft); font-style: italic; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }

/* ---------- Info panel ---------- */
.info-panel--empty { display: flex; align-items: center; }
.info-placeholder, .info-stub { color: var(--ink-soft); font-size: 13px; font-style: italic; line-height: 1.6; }
.info-code { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--accent); text-transform: uppercase; }
.info-title { font-size: 24px; margin: 6px 0 4px; }
.info-location { font-size: 12.5px; color: var(--ink-soft); font-style: italic; margin-bottom: 4px; }
.info-section { margin-top: 16px; }
.info-section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  margin-bottom: 5px;
}
.info-section p { font-size: 13.5px; line-height: 1.6; margin: 0; color: #d5d8cf; }
.info-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.7; color: #d5d8cf; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  padding: 4px 9px;
  border-radius: 12px;
}

/* ---------- Debug panel ---------- */
.toolbar-action--active { background: rgba(255,201,60,0.25); border-color: var(--accent); color: var(--accent); }
.debug-panel {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  max-height: 55%;
  display: flex;
  flex-direction: column;
  background: rgba(10,12,14,0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  z-index: 15;
  backdrop-filter: blur(8px);
}
.debug-panel[hidden] { display: none; }
.debug-title { color: var(--accent); font-weight: 700; letter-spacing: 0.06em; margin-bottom: 8px; flex: 0 0 auto; }
.debug-summary { display: flex; flex-wrap: wrap; gap: 14px; color: var(--ink-soft); margin-bottom: 8px; flex: 0 0 auto; }
.debug-summary b { color: var(--ink); font-weight: 600; }
.debug-filter {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 9px;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.debug-table-wrap { overflow-y: auto; flex: 1 1 auto; min-height: 0; border: 1px solid var(--line); border-radius: 4px; }
.debug-table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.debug-table th {
  position: sticky; top: 0;
  background: #171b20;
  text-align: left;
  padding: 6px 8px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 9.5px;
  border-bottom: 1px solid var(--line);
}
.debug-table td { padding: 4px 8px; color: var(--ink-soft); border-bottom: 1px solid rgba(255,255,255,0.04); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.debug-table tr { cursor: pointer; }
.debug-table tr:hover td { background: rgba(255,255,255,0.04); color: var(--ink); }
.debug-row-selected td { background: rgba(255,201,60,0.14) !important; color: var(--ink) !important; }
.debug-row-hovered td { background: rgba(62,124,130,0.16) !important; color: var(--ink) !important; }
.debug-match-yes { color: #6fbf73 !important; }
.debug-match-no { color: #d98a5f !important; }
.debug-count { flex: 0 0 auto; margin-top: 6px; color: var(--ink-soft); font-size: 10px; }
.debug-empty { color: var(--ink-soft); font-size: 12px; }

/* ---------- Loading screen ---------- */
.loading-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg);
}
.loading-screen[hidden] { display: none; }
.loading-brand { font-family: 'IBM Plex Mono', monospace; font-weight: 700; letter-spacing: 0.1em; color: var(--accent); font-size: 14px; }
.loading-text { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-soft); }

/* ---------- Mode transitions & search suggestions ---------- */
.toolbar-suggestion {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,201,60,0.1);
  border: none;
  border-top: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.toolbar-suggestion:hover { background: rgba(255,201,60,0.18); }
.toolbar-suggestion b { color: var(--accent); }

.mode-transition-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11,13,16,0.55);
  backdrop-filter: blur(3px);
  z-index: 12;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: 0.03em;
}
.mode-transition-overlay[hidden] { display: none; }
.mode-transition-overlay--error { background: rgba(60,20,20,0.6); color: #e8a5a5; }
