:root {
  --bg: #070b12;
  --panel: #0d1420;
  --line: #1c2a3d;
  --text: #d6e4f5;
  --muted: #7d8fa8;
  --accent: #3fd0ff;
  --warn: #ffb347;
  --err: #ff5470;
  font-family: "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
main { display: grid; grid-template-columns: minmax(0, 1fr) 380px 420px; height: 100vh; height: 100dvh; }

#graph-pane { flex: 1; position: relative; overflow: hidden; }
#graph { width: 100%; height: 100%; display: block; cursor: grab; }
#graph.dragging { cursor: grabbing; }
#graph-info { position: absolute; top: 12px; left: 14px; font-size: 12px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
#demo-badge { background: var(--warn); color: #000; padding: 2px 8px; border-radius: 4px; font-weight: 700; letter-spacing: .05em; }
#legend { position: absolute; bottom: 12px; left: 14px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 10px; max-width: 70%; }
#legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 5px; }

#viewer { border-left: 1px solid var(--line); background: #0a101a; overflow-y: auto; position: relative; min-height: 0; }
.pane-title { font: 700 11px/1 ui-monospace, monospace; letter-spacing: .25em; color: var(--muted); padding: 14px 14px 0; }
#note-empty { color: var(--muted); font-size: 13px; padding: 24px 14px; }
#note-panel { position: relative; padding: 10px 14px 20px; }
#note-panel h3 { margin: 0 24px 6px 0; }
#note-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
#note-body { white-space: pre-wrap; font: 13px/1.5 ui-monospace, monospace; margin: 0; }
#note-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }

#side { display: flex; min-height: 0; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); }
#hud { text-align: center; padding: 10px 0 6px; border-bottom: 1px solid var(--line); }
#reactor { width: 170px; height: 170px; }
#hud-state { font: 700 13px/1 ui-monospace, monospace; letter-spacing: .25em; color: var(--accent); }
#hud-status { font-size: 11px; color: var(--muted); margin-top: 6px; }

#chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 9px 12px; border-radius: 8px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.msg.user { background: #16304a; align-self: flex-end; max-width: 85%; }
.msg.axon { background: #101c2b; border: 1px solid var(--line); }
.msg.fallback { background: #2a1d0b; border: 1px solid var(--warn); }
.msg .tag { display: block; font-size: 10px; letter-spacing: .1em; color: var(--muted); margin-bottom: 4px; }
.msg .warn { margin-top: 6px; font-size: 12px; color: var(--warn); }
.msg ul { margin: 4px 0 0; padding-left: 18px; }
.msg a { color: var(--accent); cursor: pointer; }

#composer { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
#composer input { flex: 1; background: #0a111b; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 9px; font-size: 14px; }
button { background: #13263b; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
#mic.recording { background: var(--err); border-color: var(--err); }
#options { display: flex; justify-content: space-between; align-items: center; padding: 0 10px 10px; font-size: 12px; color: var(--muted); }

#alerts { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 10; display: flex; flex-direction: column; gap: 6px; width: min(720px, 92vw); }
.alert { background: #3a0d16; border: 1px solid var(--err); color: #ffd7de; padding: 10px 36px 10px 14px; border-radius: 6px; font-size: 13px; position: relative; }
.alert.warn { background: #3a2a0d; border-color: var(--warn); color: #ffe7c2; }
.alert button { position: absolute; top: 4px; right: 6px; background: none; border: 0; color: inherit; font-size: 16px; padding: 2px 6px; }

#tabs { display: none; }

@media (max-width: 1200px) and (min-width: 901px) {
  main { grid-template-columns: minmax(0, 1fr) 320px 360px; }
}
/* Móvil: un panel a la vez, con pestañas abajo. */
@media (max-width: 900px) {
  main { display: block; height: calc(100dvh - 52px); }
  main > section { display: none; height: 100%; border-left: 0; }
  main > section.active { display: flex; flex-direction: column; }
  #graph-pane.active { display: block; }
  #tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 52px; background: var(--panel); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); }
  #tabs button { flex: 1; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 13px; letter-spacing: .08em; }
  #tabs button.active { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
}
