:root {
  --bg-0: #040817;
  --bg-1: #0b1c48;
  --bg-2: #17377e;
  --panel: rgba(8, 16, 36, 0.88);
  --panel-solid: #0a1429;
  --line: rgba(150, 190, 255, 0.16);
  --line-strong: rgba(150, 190, 255, 0.34);
  --text: #e6eefc;
  --muted: #8ea3c7;
  --dim: #5d7198;
  --ice: #8ec5ff;
  --ice-soft: rgba(142, 197, 255, 0.14);
  --gold: #f4c86e;
  --gold-soft: rgba(244, 200, 110, 0.14);
  --danger: #ff8f8f;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  --left-w: 286px;
  --right-w: 408px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background:
    radial-gradient(ellipse 70% 60% at 42% 48%, var(--bg-2) 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--text);
  font: 13px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#space { position: fixed; inset: 0; z-index: 0; }

.cap {
  font: 10px/1 var(--mono);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
}
.wordmark {
  position: fixed; top: 20px; left: 24px; z-index: 3;
  font: 600 12px/1 var(--mono); letter-spacing: 0.62em; color: var(--text);
  pointer-events: none;
}

/* Tudo que some quando o zoom entra no buraco negro */
.fade-deep { transition: opacity 0.45s ease, transform 0.45s ease; }
body.deep .fade-deep { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.45s ease, transform 0.45s ease, visibility 0s 0.45s; }
body.deep .left { transform: translateX(-24px); }
body.deep .right { transform: translateX(24px); }

/* ───────── coluna esquerda */
.left {
  position: fixed; z-index: 2; top: 54px; left: 20px; bottom: 20px; width: var(--left-w);
  display: flex; flex-direction: column; gap: 12px; overflow-y: auto; scrollbar-width: none;
}
.widget {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.widget > header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 13px; cursor: pointer; user-select: none;
}
.wtitle { display: flex; align-items: center; gap: 9px; }
.logo { width: 17px; height: 17px; flex: none; }
.widget > header .meta { font-size: 11px; color: var(--ice); }
.widget .body { padding: 0 13px 12px; }
.widget.closed .body { display: none; }
.empty { color: var(--dim); font-size: 12px; padding: 2px 0 4px; }
.mail { padding: 7px 0; border-top: 1px solid var(--line); }
.mail:first-child { border-top: 0; padding-top: 0; }
.mail b { display: block; font-weight: 600; font-size: 12px; }
.mail span { color: var(--muted); font-size: 12px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 8px; font: 10px/1 var(--mono); text-align: center; }
.cal-grid .dow { color: var(--dim); padding: 3px 0 5px; }
.cal-grid .day { padding: 5px 0; color: var(--muted); border-radius: 5px; position: relative; }
.cal-grid .day.has::after { content: ""; position: absolute; left: 50%; bottom: 1px; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: var(--ice); }
.cal-grid .day.today { background: var(--gold-soft); color: var(--gold); box-shadow: inset 0 0 0 1px rgba(244, 200, 110, 0.5); }
.event { display: flex; gap: 9px; font-size: 12px; padding: 3px 0; }
.event time { font-family: var(--mono); font-size: 11px; color: var(--ice); flex: none; width: 74px; }

.stage { margin-top: 8px; }
.stage:first-child { margin-top: 0; }
.stage .row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.stage .row span:last-child { color: var(--muted); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.stage .bar { height: 3px; margin-top: 4px; background: var(--ice-soft); border-radius: 2px; overflow: hidden; }
.stage .bar i { display: block; height: 100%; background: linear-gradient(90deg, #4f86e8, var(--ice)); border-radius: 2px; }

.brief-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; color: var(--dim); font-size: 11px; }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px;
  font: 10px/1.2 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
}
.ghost:hover:not(:disabled) { border-color: var(--ice); color: var(--text); }
.ghost:disabled { opacity: 0.5; cursor: default; }

/* ───────── centro: seletor, nós, dica */
.pill {
  position: fixed; z-index: 2; display: flex; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(6, 13, 28, 0.6);
  left: 0; top: 0; will-change: transform;
}
.pill button {
  border: 0; background: transparent; border-radius: 999px; padding: 5px 12px;
  font: 10px/1 var(--mono); letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim);
}
.pill button.on { background: var(--ice-soft); color: var(--ice); }

#nodes { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.node {
  position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; padding: 4px 6px 4px 0; pointer-events: auto;
  font: 11px/1 var(--mono); color: var(--muted); white-space: nowrap; will-change: transform;
}
.node i {
  width: 9px; height: 9px; border-radius: 50%; flex: none; margin-left: -4.5px;
  background: #0a1429; border: 1.5px solid var(--ice);
  box-shadow: 0 0 8px rgba(142, 197, 255, 0.5);
  transition: transform 0.18s, background 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.node span { max-width: 190px; overflow: hidden; text-overflow: ellipsis; transition: color 0.18s; }
.node:hover span, .node.on span { color: var(--gold); }
.node:hover i, .node.on i {
  transform: scale(1.55); background: var(--gold); border-color: var(--gold);
  box-shadow: 0 0 14px rgba(244, 200, 110, 0.9);
}
.node:focus { outline: none; }
.node:focus-visible span { color: var(--gold); text-decoration: underline; }
.node.new i { border-style: dashed; }
.node.new span { color: var(--dim); }

.tip {
  position: fixed; z-index: 4; max-width: 300px; padding: 8px 11px; pointer-events: none;
  background: rgba(6, 12, 26, 0.94); border: 1px solid var(--line-strong); border-radius: 7px;
  font-size: 12px; color: var(--text); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.tip b { display: block; font: 600 11px/1.3 var(--mono); color: var(--gold); margin-bottom: 3px; }
.tip span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.zoom-hint {
  position: fixed; z-index: 3; left: 50%; bottom: 22px; transform: translateX(-50%);
  font: 10px/1 var(--mono); letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted);
  pointer-events: none;
}

/* ───────── painéis de documento */
.doc-card {
  position: fixed; z-index: 4; left: 28px; top: 76px; bottom: 60px; width: 400px;
  display: flex; flex-direction: column;
  background: rgba(7, 14, 30, 0.93); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.doc-card > header, .doc-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.doc-card > header .cap, .doc-head .cap { flex: 1; color: var(--gold); letter-spacing: 0.18em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; }
.doc-card .md { padding: 14px 16px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 5px; }
.x:hover { color: var(--text); background: var(--ice-soft); }

/* ───────── coluna direita */
.right {
  position: fixed; z-index: 2; top: 20px; right: 20px; bottom: 20px; width: var(--right-w);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.panel-head { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.panel-head .status { flex: 1; text-align: right; font: 10px/1.2 var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .status.busy { color: var(--gold); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.seg { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 7px; }
.seg button { border: 0; background: transparent; border-radius: 5px; padding: 4px 10px; font: 10px/1.2 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.seg button.on { background: var(--gold-soft); color: var(--gold); }
.controls select {
  flex: 1 1 86px; min-width: 0; appearance: none; background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font: 11px/1.2 var(--sans); cursor: pointer; text-overflow: ellipsis;
}
.controls select:hover, .controls select:focus { border-color: var(--ice); color: var(--text); outline: none; }
.controls select option { background: var(--panel-solid); color: var(--text); }
.controls.locked { opacity: 0.55; pointer-events: none; }
.sess { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 7px; }
.sess:hover { border-color: var(--ice); }
.sess.current { border-color: rgba(244, 200, 110, 0.5); }
.sess b { display: block; font-weight: 500; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess span { font: 10px/1.4 var(--mono); color: var(--dim); }
.login-page { display: grid; place-items: center; }
.login { width: min(320px, 86vw); display: flex; flex-direction: column; gap: 10px; padding: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.login input { background: rgba(5, 11, 24, 0.75); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); padding: 9px 11px; font: 14px var(--sans); outline: none; }
.login input:focus { border-color: var(--ice); }
.login .btn { padding: 9px; }
.wordmark-static { font: 600 12px/1 var(--mono); letter-spacing: 0.62em; margin-bottom: 12px; }
.login-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.msg { max-width: 100%; border-radius: 10px; padding: 9px 12px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 88%; border: 1px solid rgba(244, 200, 110, 0.45); background: var(--gold-soft); white-space: pre-wrap; }
.msg.claude { border: 1px solid var(--line); background: rgba(8, 16, 34, 0.7); }
.msg.notice { align-self: center; color: var(--dim); font: 10px/1.4 var(--mono); letter-spacing: 0.1em; padding: 2px 0; }
.msg.error { border: 1px solid rgba(255, 143, 143, 0.4); color: var(--danger); font-size: 12px; }
.tool {
  display: flex; align-items: center; gap: 8px; padding: 2px 4px; font: 11px/1.4 var(--mono); color: var(--dim);
}
.tool.sub { padding-left: 18px; }
.tool i { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--gold); box-shadow: 0 0 8px var(--gold); animation: blink 1s ease-in-out infinite; }
.tool.done i { background: var(--ice); box-shadow: none; animation: none; opacity: 0.7; }
.tool.fail i { background: var(--danger); box-shadow: none; animation: none; }
.tool b { color: var(--muted); font-weight: 600; flex: none; }
.tool span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes blink { 50% { opacity: 0.3; } }
.thinking { color: var(--dim); font: 11px/1.4 var(--mono); padding: 2px 4px; }
.thinking::after { content: "…"; animation: blink 1s infinite; }

.perm { border: 1px solid rgba(244, 200, 110, 0.5); background: rgba(20, 22, 30, 0.8); border-radius: 10px; padding: 11px 12px; }
.perm .cap { color: var(--gold); display: block; margin-bottom: 7px; }
.perm p { margin: 0 0 6px; font-size: 12px; }
.perm pre { max-height: 150px; overflow: auto; margin: 0 0 9px; padding: 8px; background: rgba(0, 0, 0, 0.35); border-radius: 6px; font: 11px/1.45 var(--mono); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.perm .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { border: 1px solid var(--line-strong); background: transparent; border-radius: 6px; padding: 5px 11px; font-size: 12px; }
.btn:hover { border-color: var(--ice); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1405; font-weight: 600; }
.btn.sel { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.perm .q { margin-bottom: 10px; }
.perm .q small { display: block; color: var(--muted); margin: 2px 0 6px; }

.composer { display: flex; align-items: flex-end; gap: 6px; margin: 0 12px 12px; padding: 7px 7px 7px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: rgba(5, 11, 24, 0.75); }
.composer:focus-within { border-color: var(--ice); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); font: 13px/1.45 var(--sans); max-height: 160px; padding: 4px 0; }
.composer textarea::placeholder { color: var(--dim); }
.icon { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.icon:hover { color: var(--text); background: var(--ice-soft); }
.icon.send { background: var(--ice-soft); color: var(--ice); }
.icon.send.stop { background: var(--gold-soft); color: var(--gold); }
.icon.rec { color: var(--gold); background: var(--gold-soft); animation: blink 1s infinite; }

.doc-body { flex: 1; overflow-y: auto; padding: 14px 16px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ───────── markdown */
.md { font-size: 13px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md table, .md blockquote { margin: 0 0 9px; }
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 6px; line-height: 1.3; font-weight: 600; }
.md h1 { font-size: 16px; } .md h2 { font-size: 14px; } .md h3, .md h4 { font-size: 13px; color: var(--ice); }
.md ul, .md ol { padding-left: 20px; }
.md li { margin: 2px 0; }
.md a { color: var(--ice); }
.md code { font: 12px/1.4 var(--mono); background: rgba(142, 197, 255, 0.1); padding: 1px 5px; border-radius: 4px; }
.md pre { background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }
.md pre code { background: transparent; padding: 0; }
.md blockquote { border-left: 2px solid var(--line-strong); padding-left: 10px; color: var(--muted); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 12px; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.md th { color: var(--ice); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

@media (max-width: 1180px) {
  :root { --left-w: 240px; --right-w: 350px; }
}
@media (prefers-reduced-motion: reduce) {
  .fade-deep { transition: none; }
  .tool i, .thinking::after, .icon.rec { animation: none; }
}
