/* ───────────── Tokens ───────────── */
:root {
  --bg: #f5f3ee;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #e3efe4 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 10%, #ece7f7 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #191b18;
  --ink-2: #3b3f39;
  --muted: #6c7068;
  --line: #e5e2da;
  --line-2: #d7d3c9;
  --canvas-dot: #dcd8ce;

  --accent: #1f8a4c;
  --accent-ink: #ffffff;
  --accent-soft: #e2f2e7;

  --anc: #4f5bd5;        /* vem antes (pré-requisitos) */
  --anc-soft: #e8eafc;
  --desc: #d9792b;       /* liberadas */
  --desc-soft: #fcefe2;

  --lvl-intro: #2e9e6b;
  --lvl-mid: #d9a12b;
  --lvl-adv: #d6534a;

  --shadow-sm: 0 1px 2px rgb(20 24 18 / .06), 0 1px 1px rgb(20 24 18 / .04);
  --shadow-md: 0 10px 30px -12px rgb(20 24 18 / .22), 0 2px 6px rgb(20 24 18 / .06);
  --shadow-lg: 0 30px 80px -20px rgb(20 24 18 / .35), 0 4px 14px rgb(20 24 18 / .08);
  --radius: 14px;

  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e100f;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, #132a1c 0%, transparent 60%),
               radial-gradient(900px 500px at 110% 10%, #1d1a2c 0%, transparent 55%);
    --surface: #161917; --surface-2: #1b1f1c;
    --ink: #ecebe5; --ink-2: #c9c8c1; --muted: #8d918a;
    --line: #262a27; --line-2: #333833; --canvas-dot: #262b27;
    --accent: #3fbf74; --accent-ink: #07130b; --accent-soft: #173322;
    --anc: #8b93ff; --anc-soft: #20234a;
    --desc: #f0a05a; --desc-soft: #3a2614;
    --lvl-intro: #43c48b; --lvl-mid: #e8b649; --lvl-adv: #f0766c;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-md: 0 14px 34px -14px rgb(0 0 0 / .7), 0 2px 6px rgb(0 0 0 / .35);
    --shadow-lg: 0 30px 80px -20px rgb(0 0 0 / .8), 0 4px 14px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e100f;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #132a1c 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 10%, #1d1a2c 0%, transparent 55%);
  --surface: #161917; --surface-2: #1b1f1c;
  --ink: #ecebe5; --ink-2: #c9c8c1; --muted: #8d918a;
  --line: #262a27; --line-2: #333833; --canvas-dot: #262b27;
  --accent: #3fbf74; --accent-ink: #07130b; --accent-soft: #173322;
  --anc: #8b93ff; --anc-soft: #20234a;
  --desc: #f0a05a; --desc-soft: #3a2614;
  --lvl-intro: #43c48b; --lvl-mid: #e8b649; --lvl-adv: #f0766c;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 14px 34px -14px rgb(0 0 0 / .7), 0 2px 6px rgb(0 0 0 / .35);
  --shadow-lg: 0 30px 80px -20px rgb(0 0 0 / .8), 0 4px 14px rgb(0 0 0 / .4);
  color-scheme: dark;
}

/* ───────────── Base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; font: 15px/1.55 var(--font); color: var(--ink);
  background: var(--bg-grad), var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
kbd {
  font: 11px var(--mono); padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--surface);
}
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ───────────── Topbar ───────────── */
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 75%, transparent);
  backdrop-filter: blur(10px); position: relative; z-index: 40; /* acima do painel, para a engrenagem abrir por cima */
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark svg { width: 34px; height: 34px; stroke: none; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { stroke: var(--accent-ink); stroke-width: 2.6; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font: 700 18px/1.1 var(--display); letter-spacing: -.02em; }
.brand-text span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); text-decoration: none;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); }
:root[data-theme="dark"] :root[data-theme="dark"] @media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])   :root:not([data-theme="light"]) }

.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 13px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); font-weight: 500; font-size: 13.5px;
  text-decoration: none; transition: transform .1s, background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 88%, #000); border-color: transparent; }
.btn-sm { height: 32px; font-size: 12.5px; padding: 0 11px; }
.chip-btn {
  height: 34px; padding: 0 12px; border-radius: 9px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.chip-btn:hover { border-color: var(--muted); }

/* ───────────── Chat ───────────── */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; padding: 32px 20px 12px; scroll-behavior: smooth; }

.empty { max-width: 720px; margin: 7vh auto 0; animation: rise .5s ease both; }
.eyebrow {
  margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
}
.empty h1 { margin: 0; font: 700 clamp(34px, 5vw, 54px)/1.02 var(--display); letter-spacing: -.035em; }
.empty h1 em { font-style: normal; color: var(--accent); }
.lede { color: var(--muted); font-size: 16px; max-width: 56ch; margin: 16px 0 26px; }
.lede kbd { font-size: 12px; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.suggestion {
  text-align: left; padding: 14px 15px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 7px;
  transition: transform .15s, box-shadow .15s, border-color .15s; animation: rise .5s ease both;
}
.suggestion:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.suggestion .s-tag { font-size: 11.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.suggestion .s-tag svg { width: 14px; height: 14px; color: var(--accent); }
.suggestion .s-text { font-size: 14px; color: var(--ink); line-height: 1.4; }
.suggestion .s-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.msg { max-width: 780px; margin: 0 auto 24px; display: flex; gap: 12px; animation: rise .35s ease both; }
.msg-user { justify-content: flex-end; }
.msg-user .bubble-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 85%; }
.msg-user .bubble {
  background: var(--ink); color: var(--bg); padding: 10px 15px; border-radius: 18px 18px 5px 18px;
  white-space: pre-wrap; word-wrap: break-word;
}
.bubble-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.avatar { width: 30px; height: 30px; border-radius: 9px; flex: none; margin-top: 2px; background: var(--accent); display: grid; place-items: center; }
.avatar svg { width: 16px; height: 16px; stroke: var(--accent-ink); stroke-width: 2.6; }
.msg-bot .body { flex: 1; min-width: 0; }

.answer { color: var(--ink-2); overflow-wrap: anywhere; }
.answer > :first-child { margin-top: 2px; }
.answer > :last-child { margin-bottom: 0; }
.answer h1, .answer h2, .answer h3 { color: var(--ink); font-family: var(--display); line-height: 1.2; margin: 22px 0 8px; letter-spacing: -.02em; }
.answer h1 { font-size: 21px; } .answer h2 { font-size: 18px; } .answer h3 { font-size: 16px; }
.answer p { margin: 0 0 11px; }
.answer ul, .answer ol { margin: 0 0 12px; padding-left: 22px; }
.answer li { margin: 3px 0; }
.answer li::marker { color: var(--muted); }
.answer strong { color: var(--ink); font-weight: 600; }
.answer code { font: 12.5px var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }
.answer pre { background: var(--surface-2); border: 1px solid var(--line); padding: 12px; border-radius: 10px; overflow-x: auto; }
.answer pre code { border: 0; padding: 0; background: none; }
.answer blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.answer hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.answer .table-wrap { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.answer table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.answer th, .answer td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.answer th { font-weight: 600; color: var(--ink); background: var(--surface-2); font-size: 12.5px; }
.answer tr:last-child td { border-bottom: 0; }

/* Chips: página, código de disciplina, disciplina no contexto */
.page-ref, .code-ref {
  display: inline-flex; align-items: center; gap: 4px; font: 600 11.5px/1 var(--font);
  padding: 3px 7px; border-radius: 999px; text-decoration: none; vertical-align: 1px; white-space: nowrap;
  transition: transform .1s, filter .15s;
}
.page-ref { background: var(--accent-soft); color: var(--accent); }
.page-ref svg { width: 11px; height: 11px; stroke-width: 2.4; }
.code-ref { background: var(--anc-soft); color: var(--anc); border: 0; font-family: var(--mono); font-weight: 500; }
.page-ref:hover, .code-ref:hover { filter: brightness(1.08); transform: translateY(-1px); }

.dchip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  height: 28px; padding: 0 4px 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink);
  animation: pop .2s ease both;
}
.dchip .dot { flex: none; }
.dchip .dchip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dchip button {
  width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; flex: none;
}
.dchip button:hover { background: var(--surface-2); color: var(--ink); }
.dchip button svg { width: 13px; height: 13px; }
.dchip.is-static { padding-right: 10px; height: 24px; font-size: 12px; cursor: pointer; }
.msg-user .dchip.is-static { background: var(--surface-2); }

.msg-footer { display: flex; align-items: center; gap: 10px; margin-top: 10px; min-height: 26px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.msg-footer .tool {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 7px;
  border: 1px solid transparent; background: none; color: var(--muted); font-size: 12px;
}
.msg-footer .tool:hover { border-color: var(--line); background: var(--surface); color: var(--ink); }
.msg-footer .tool svg { width: 14px; height: 14px; }
.usage .bolt { color: var(--accent); font-weight: 600; }
.tag-stopped { color: var(--desc); font-weight: 500; }
.error-box {
  border: 1px solid color-mix(in oklab, var(--lvl-adv) 45%, transparent);
  background: color-mix(in oklab, var(--lvl-adv) 10%, var(--surface));
  color: var(--ink); padding: 10px 13px; border-radius: 10px; font-size: 14px;
}

.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 4px 0; }
.orb {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: conic-gradient(from 0deg, var(--accent), var(--anc), var(--desc), var(--accent));
  animation: spin 1.1s linear infinite;
  mask: radial-gradient(circle, transparent 4px, #000 5px); -webkit-mask: radial-gradient(circle, transparent 4px, #000 5px);
}
.thinking .status { animation: fade .4s ease both; }
.caret::after {
  content: ""; display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px;
  background: var(--accent); border-radius: 2px; animation: blink 1s steps(2) infinite;
}

/* Raciocínio (resumo do thinking) */
.reasoning { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-size: 13px; color: var(--muted); }
.reasoning summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-weight: 500; user-select: none; }
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary > * { flex: none; }
.reasoning summary::after {
  content: ""; margin-left: auto; width: 7px; height: 7px; flex: none;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.reasoning[open] summary::after { transform: rotate(225deg) translateY(-1px); }
.reasoning .reasoning-preview { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 400; font-style: italic; opacity: .85; }
.reasoning[open] .reasoning-preview { display: none; }
.reasoning .orb { width: 12px; height: 12px; display: none; }
.reasoning.is-live .orb { display: inline-block; }
.reasoning.is-live .reasoning-label {
  background: linear-gradient(90deg, var(--muted) 0%, var(--ink) 50%, var(--muted) 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.6s linear infinite;
}
.reasoning-body { max-height: 180px; overflow-y: auto; padding: 2px 14px 10px; line-height: 1.5; border-top: 1px dashed var(--line); }
.reasoning-body p { margin: 8px 0 0; }

/* ───────────── Composer ───────────── */
.composer { padding: 10px 20px 16px; }
.composer-box {
  position: relative; max-width: 780px; margin: 0 auto;
  padding: 8px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-md); transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: var(--shadow-md), 0 0 0 4px var(--accent-soft); }
.context { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 4px 8px; border-bottom: 1px dashed var(--line); margin-bottom: 6px; }
.context-label { font-size: 11.5px; font-weight: 600; color: var(--muted); align-self: center; margin-right: 2px; letter-spacing: .02em; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.add-btn {
  width: 40px; height: 40px; flex: none; border-radius: 12px; border: 1px solid transparent;
  background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center;
  transition: background .15s, color .15s, border-color .15s;
}
.add-btn:hover, .add-btn[aria-expanded="true"] { background: var(--anc-soft); color: var(--anc); border-color: color-mix(in oklab, var(--anc) 30%, transparent); }
#input {
  flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 15px; line-height: 1.5; max-height: 180px; padding: 9px 4px; overflow-y: hidden;
}
#input::placeholder { color: var(--muted); }
.send {
  width: 40px; height: 40px; border-radius: 12px; border: 0; flex: none;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  transition: transform .1s, opacity .15s, background .15s;
}
.send:disabled { opacity: .35; cursor: not-allowed; }
.send:not(:disabled):active { transform: scale(.94); }
.send .i-stop { display: none; fill: currentColor; stroke: none; }
.composer.is-busy .send { background: var(--ink); color: var(--bg); }
.composer.is-busy .send .i-send { display: none; }
.composer.is-busy .send .i-stop { display: block; }
.hint { max-width: 780px; margin: 8px auto 0; text-align: center; font-size: 11.5px; color: var(--muted); }

/* Seletor de disciplinas */
.picker {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 10px); z-index: 20;
  max-height: min(52vh, 420px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: rise .18s ease both; overflow: hidden;
}
.picker-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 600;
}
.picker-keys { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.picker-list { overflow-y: auto; padding: 6px; }
.picker-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.picker-item {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: 10px; border: 0; background: transparent;
}
.picker-item.is-active { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.picker-item .p-code { font: 500 11px var(--mono); color: var(--muted); width: 68px; flex: none; }
.picker-item .p-name { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item .p-name mark { background: color-mix(in oklab, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; }
.picker-item .p-meta { font-size: 11.5px; color: var(--muted); flex: none; }
.picker-item .p-check { width: 18px; height: 18px; flex: none; color: var(--accent); opacity: 0; }
.picker-item.is-selected .p-check { opacity: 1; }
.picker-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* ───────────── Estrutura curricular (tela cheia) ───────────── */
.drawer {
  position: fixed; inset: var(--topbar-h, 61px) 0 0 0; z-index: 31; /* abaixo do cabeçalho, que fica sempre visível */ display: flex; flex-direction: column; background: var(--bg);
  /* Só opacidade e um deslocamento curto: animação barata, roda na GPU */
  opacity: 0; transform: translateY(10px); visibility: hidden; pointer-events: none;
  transition: opacity .16s ease, transform .2s ease, visibility 0s .2s;
}
.drawer.is-open {
  opacity: 1; transform: none; visibility: visible; pointer-events: auto;
  transition: opacity .16s ease, transform .2s ease;
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.drawer-actions { display: flex; align-items: center; gap: 8px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }

.search {
  position: relative; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--muted);
}
.search svg { width: 15px; height: 15px; }
.search input { border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 13px; width: 170px; }
.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 320px; max-height: 320px; overflow-y: auto; z-index: 5;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px;
}

.view { display: none; flex: 1; min-height: 0; }
.view.is-visible { display: flex; }

/* Árvore */
.view-tree { gap: 0; }
.tree-wrap { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.tree-canvas {
  flex: 1; min-height: 0; overflow: auto; position: relative; contain: strict;
  scrollbar-gutter: stable; /* a barra vertical, se aparecer, não empurra o conteúdo para os lados */
  background-image: radial-gradient(var(--canvas-dot) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
}
.tree-inner { position: relative; margin: auto; }
.tree-edges { position: absolute; inset: 0; overflow: visible; pointer-events: none; z-index: 0; }
.tree-inner .node, .tree-inner .col-label { z-index: 1; }
.tree-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 6px 12px 6px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.tree-crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; min-width: 0; }
.panel-toggle { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 32px; }
.panel-toggle svg { width: 15px; height: 15px; }
/* Painel de detalhes fechado: a árvore ocupa a largura toda */
.view-tree.info-hidden .tree-info { display: none; }
/* Aba na borda direita para reabrir o painel (só aparece com ele fechado) */
.panel-tab {
  display: none; position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 3;
  flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border: 1px solid var(--line-2); border-right: 0;
  border-radius: 12px 0 0 12px; background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow-md);
  font-size: 12px; font-weight: 600; letter-spacing: .04em; transition: padding .15s, color .15s, background .15s;
}
.panel-tab span { writing-mode: vertical-rl; transform: rotate(180deg); }
.panel-tab:hover { padding-right: 12px; color: var(--accent); background: var(--surface-2); }
.view-tree.info-hidden .panel-tab { display: flex; }
.view-tree.info-hidden .panel-toggle { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tree-info { position: relative; }
.info-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; }
.tree-info h3 { padding-right: 30px; }
.tree-info .back-btn { max-width: calc(100% - 40px); }
.crumb { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 4px 8px; border-radius: 8px; font-weight: 600; color: var(--muted); }
button.crumb:hover { background: var(--surface); color: var(--ink); }
button.crumb svg { width: 14px; height: 14px; }
.crumb.is-current { color: var(--ink); padding-left: 2px; }
.crumb-sep { color: var(--muted); }
.crumb-hint { color: var(--muted); font-size: 12px; }
.tree-edges path { fill: none; stroke-width: 2; stroke-linecap: round; transition: opacity .2s, stroke-width .2s; }
.tree-edges .e-anc { stroke: var(--anc); }
.tree-edges .e-desc { stroke: var(--desc); }
.tree-edges path.e-anim { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw .32s ease forwards; animation-delay: var(--delay, 0s); }
/* Re-layout (redimensionar a janela) não repete as animações */
.tree-inner.no-anim .node, .tree-inner.no-anim .tree-edges path { animation: none; opacity: 1; transform: none; stroke-dasharray: none; stroke-dashoffset: 0; }
.tree-edges circle.e-anc { fill: var(--anc); }
.tree-edges circle.e-desc { fill: var(--desc); }
/* Curso inteiro: setas neutras; o hover pinta a cadeia da disciplina */
.tree-edges .e-all { stroke: color-mix(in oklab, var(--muted) 55%, transparent); stroke-width: 1.5; }
.tree-edges circle.e-all { fill: color-mix(in oklab, var(--muted) 70%, transparent); stroke: none; }
.tree-inner.is-hovering .tree-edges path, .tree-inner.is-hovering .tree-edges circle { opacity: .12; }
.tree-inner.is-hovering .tree-edges .is-anc-hot { opacity: 1; stroke: var(--anc); stroke-width: 2.4; }
.tree-inner.is-hovering .tree-edges .is-desc-hot { opacity: 1; stroke: var(--desc); stroke-width: 2.4; }
.tree-inner.is-hovering .tree-edges circle.is-anc-hot { fill: var(--anc); stroke: none; }
.tree-inner.is-hovering .tree-edges circle.is-desc-hot { fill: var(--desc); stroke: none; }
/* filter em vez de opacity: a animação de entrada (fill forwards) prende a opacidade em 1 */
.tree-inner.is-hovering .node.is-dim { filter: opacity(.28) saturate(.6); }
.tree-inner .node { transition: box-shadow .18s, border-color .18s, translate .18s, filter .15s; }
.tree-edges.has-hover path { opacity: .15; }
.tree-edges.has-hover path.is-hot { opacity: 1; stroke-width: 2.8; }
.tree-edges circle { transition: opacity .2s; }
.tree-edges.has-hover circle { opacity: .15; }
.tree-edges.has-hover circle.is-hot { opacity: 1; }

.col-label {
  position: absolute; top: 14px; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap; padding: 3px 9px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line);
}
.col-label.anc { color: var(--anc); }
.col-label.desc { color: var(--desc); }
.col-label.focus { color: var(--ink); }

.node {
  position: absolute; width: var(--node-w); text-align: left;
  display: flex; flex-direction: column; gap: 5px; padding: 10px 12px 10px 14px;
  border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateX(var(--from, 0)) scale(.97);
  animation: node-in .26s cubic-bezier(.2,.8,.2,1) forwards; animation-delay: var(--delay, 0s);
  transition: box-shadow .18s, border-color .18s, translate .18s;
  overflow: hidden;
}
.node::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--stripe, var(--line-2)); }
.node:hover { box-shadow: var(--shadow-md); translate: 0 -2px; }
.node.anc { --stripe: var(--anc); }
.node.desc { --stripe: var(--desc); }
.node.direct { border-color: color-mix(in oklab, var(--stripe) 45%, var(--line-2)); }
.node-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.node-code { font: 500 10.5px var(--mono); color: var(--muted); }
.node-name {
  font-size: 13px; font-weight: 600; line-height: 1.28; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.node-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.node.is-focus {
  padding: 14px 16px 14px 18px; border: 0; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 55%, var(--anc)));
  box-shadow: 0 18px 40px -16px color-mix(in oklab, var(--accent) 70%, transparent), var(--shadow-md);
}
.node.is-focus::before { display: none; }
.node.is-focus .node-name { color: var(--accent-ink); font: 700 16px/1.2 var(--display); letter-spacing: -.01em; -webkit-line-clamp: 3; }
.node.is-focus .node-code, .node.is-focus .node-meta { color: color-mix(in oklab, var(--accent-ink) 78%, transparent); }
.node.is-focus .meter { background: color-mix(in oklab, var(--accent-ink) 25%, transparent); }
.node.is-focus .meter i { background: var(--accent-ink) !important; }
.node.in-context { box-shadow: 0 0 0 2px var(--anc), var(--shadow-sm); }
/* Curso inteiro: cards compactos para os 8 semestres caberem na tela sem rolagem */
.tree-inner.is-course .node { padding: 7px 9px 7px 12px; gap: 3px; border-radius: 11px; }
.tree-inner.is-course .node-name { font-size: 12px; line-height: 1.22; }
.tree-inner.is-course .node-code { font-size: 9.5px; }
.tree-inner.is-course .node-meta { font-size: 10.5px; }
.tree-inner.is-course .meter { height: 3px; }
.node.is-solo:not(.is-focus) { border-style: dashed; box-shadow: none; background: color-mix(in oklab, var(--surface) 70%, transparent); }
.node.is-solo:not(.is-focus)::before { background: var(--line-2); }
.node .ctx-badge { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: var(--anc-soft); color: var(--anc); }
.node.is-focus .ctx-badge { background: color-mix(in oklab, var(--accent-ink) 20%, transparent); color: var(--accent-ink); }
.tree-empty { position: absolute; left: 50%; transform: translateX(-50%); font-size: 13px; color: var(--muted); text-align: center; width: 320px; }

.tree-legend {
  position: absolute; left: 14px; bottom: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 7px 12px; border-radius: 12px; font-size: 11.5px; color: var(--ink-2);
  background: color-mix(in oklab, var(--surface) 88%, transparent); border: 1px solid var(--line); backdrop-filter: blur(6px);
  max-width: calc(100% - 28px);
}
.tree-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-sep { width: 1px; height: 12px; background: var(--line-2); }
.sw { width: 14px; height: 4px; border-radius: 3px; display: inline-block; }
.sw-anc { background: var(--anc); }
.sw-sel { background: var(--accent); height: 10px; width: 10px; }
.sw-desc { background: var(--desc); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.lvl-introdutoria { background: var(--lvl-intro); }
.lvl-intermediaria { background: var(--lvl-mid); }
.lvl-avancada { background: var(--lvl-adv); }
.meter { height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; }

/* Painel de informações da disciplina em foco */
.tree-info {
  width: 360px; flex: none; overflow-y: auto; padding: 20px; border-left: 1px solid var(--line); background: var(--surface);
}
.info-code { font: 500 11px var(--mono); color: var(--muted); }
.tree-info h3 { margin: 4px 0 10px; font: 700 22px/1.15 var(--display); letter-spacing: -.02em; }
.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pill { padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; font-size: 12px; color: var(--ink-2); }
.info-actions { display: flex; flex-direction: column; gap: 6px; margin: 16px 0 6px; }
.info-actions .btn { justify-content: center; }
.info-actions .row { display: flex; gap: 6px; }
.info-actions .row .btn { flex: 1; white-space: nowrap; justify-content: center; padding: 0 8px; }
.back-btn { max-width: 100%; margin-bottom: 14px; }
.back-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-section { margin-top: 18px; }
.info-section h4 { margin: 0 0 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-card { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.stat-card b { display: block; font: 700 22px/1.1 var(--display); letter-spacing: -.02em; }
.stat-card span { font-size: 11.5px; color: var(--muted); }
.stat-card.anc b { color: var(--anc); }
.stat-card.desc b { color: var(--desc); }
.complexity { display: flex; align-items: center; gap: 12px; }
.complexity .score { font: 700 30px/1 var(--display); letter-spacing: -.03em; }
.complexity .meter { flex: 1; height: 7px; }
.topics { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.topics li { margin: 2px 0; }
.small-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.chip-go {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); text-align: left;
}
.chip-go:hover { border-color: var(--muted); color: var(--ink); }
.chip-go b { color: var(--desc); font-weight: 600; }
.chain { margin: 0; padding-left: 20px; font-size: 13px; }
.chain li { margin: 3px 0; }
.chain li::marker { color: var(--muted); font-size: 11px; }
.link { border: 0; background: none; padding: 0; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; text-align: left; }
.link:hover { color: var(--accent); text-decoration-color: currentColor; }

/* Grade */
.view-grid { flex-direction: column; }
.grid-hint { margin: 0; padding: 12px 22px 0; font-size: 13px; }
.board { flex: 1; min-height: 0; overflow: auto; padding: 8px 22px 22px; contain: strict; }
/* Em tela cheia, as colunas se esticam para ocupar a largura disponível */
.board-inner { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(130px, 1fr); gap: 10px; width: 100%; }
.column { min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.col-head {
  position: sticky; top: 0; z-index: 2; padding: 8px 2px 6px; display: flex; justify-content: space-between; align-items: baseline;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.col-head b { font: 700 14px var(--display); letter-spacing: -.01em; }
.col-head span { font-size: 11.5px; color: var(--muted); }
.card {
  text-align: left; width: 100%; padding: 10px 11px 9px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 6px; transition: transform .18s, box-shadow .18s, opacity .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card.in-context { box-shadow: 0 0 0 2px var(--anc), var(--shadow-sm); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.card-code { font: 500 10.5px var(--mono); color: var(--muted); }
.card-name { font-size: 12.5px; font-weight: 600; line-height: 1.28; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
.badge-gate { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: var(--desc-soft); color: var(--desc); white-space: nowrap; }
.board.is-filtering .card:not(.is-match) { opacity: .22; }

/* Modal e toast */
.modal {
  width: min(640px, calc(100vw - 32px)); max-height: min(80vh, 720px); padding: 0;
  border: 1px solid var(--line-2); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgb(10 12 10 / .45); backdrop-filter: blur(3px); }
.modal[open] { animation: rise .25s ease both; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 6px; }
.modal-head h3 { margin: 0; font: 700 21px/1.15 var(--display); letter-spacing: -.02em; }
.modal-body { padding: 6px 18px 18px; overflow-y: auto; }
.rule { padding: 12px 0; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.rule b { display: block; margin-bottom: 3px; }
.rule p { margin: 0; color: var(--ink-2); font-size: 14px; }
.wake {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 14px; font-size: 13.5px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg);
  animation: rise .25s ease both;
}
.wake b { color: var(--ink); }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 9px 15px; border-radius: 11px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───────────── Animações ───────────── */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes node-in { to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { to { visibility: hidden; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ───────────── Responsivo ───────────── */
.info-fab { display: none; }
@media (max-width: 900px) {
  .info-fab { display: inline-flex; position: absolute; right: 12px; bottom: 12px; z-index: 2; box-shadow: var(--shadow-md); }
  .tree-legend { max-width: calc(100% - 200px); }
  .tree-info { display: none; }
  .view-tree { flex-direction: column; }
  .tree-info.is-mobile-open {
    display: block; position: absolute; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 58%;
    border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow-lg); z-index: 3;
    animation: rise .25s ease both;
  }
}
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .messages { padding: 22px 14px 8px; }
  .composer { padding: 8px 12px 12px; }
  .suggestions { grid-template-columns: 1fr; }
  .hint { display: none; }
  .picker-keys { display: none; }
  .drawer-head { padding: 12px 12px 10px 16px; }
      .drawer-actions { width: 100%; }
  .drawer-actions .search { flex: 1; }
  .search input { width: 100%; }
  .search-results { left: 0; right: auto; width: calc(100vw - 28px); }
  .tree-legend { display: none; }
  .crumb-hint { display: none; }
  .panel-toggle, .view-tree.info-hidden .panel-tab { display: none; }
  .node { padding: 8px 10px 8px 12px; }
  .node-name { font-size: 12px; }
  .node.is-focus .node-name { font-size: 14px; }
  .grid-hint { padding: 10px 14px 0; }
  .board { padding: 8px 14px 14px; }
}

/* ───────────── Dados do SUAP ───────────── */
.st-badge {
  display: inline-flex; align-items: center; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  white-space: nowrap; letter-spacing: .01em;
}
.st-badge.st-concluida { background: color-mix(in oklab, var(--lvl-intro) 18%, transparent); color: var(--lvl-intro); }
.st-badge.st-cursando { background: var(--anc-soft); color: var(--anc); }
.st-badge.st-liberada { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 60%, transparent); }
.st-badge.st-reprovada { background: color-mix(in oklab, var(--lvl-adv) 16%, transparent); color: var(--lvl-adv); }
/* Na árvore: feitas ficam "apagadas" em verde, cursando com contorno azul, liberadas destacadas */
.node.st-concluida:not(.is-focus) { background: color-mix(in oklab, var(--lvl-intro) 9%, var(--surface)); }
.node.st-concluida:not(.is-focus)::before { background: var(--lvl-intro); }
.node.st-concluida:not(.is-focus) .node-name { color: var(--ink-2); }
.node.st-cursando:not(.is-focus) { box-shadow: 0 0 0 1.5px var(--anc), var(--shadow-sm); }
.node.st-liberada:not(.is-focus) { box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--accent) 70%, transparent), var(--shadow-sm); }
.node.st-reprovada:not(.is-focus)::before { background: var(--lvl-adv); }
.node.is-focus .st-badge { background: color-mix(in oklab, var(--accent-ink) 22%, transparent); color: var(--accent-ink); box-shadow: none; }
.st-line { margin: -4px 0 10px; font-size: 13px; font-weight: 600; }
.st-line.st-concluida { color: var(--lvl-intro); } .st-line.st-cursando { color: var(--anc); }
.st-line.st-liberada { color: var(--accent); } .st-line.st-reprovada { color: var(--lvl-adv); }
.progress { padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.progress-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.progress-row b { font: 700 18px var(--display); color: var(--ink); }
.meter.big { height: 8px; }
.progress-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.progress-pills .st-badge { font-size: 11.5px; padding: 3px 9px; }
.suap-modal .modal-body > p { margin: 0 0 12px; color: var(--ink-2); }
.steps { margin: 6px 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; font-size: 14px; }
.steps li::marker { font-weight: 700; color: var(--accent); }
.steps .small-note { display: block; }
.bookmarklet {
  display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 2px; padding: 7px 14px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13.5px; text-decoration: none;
  cursor: grab; box-shadow: var(--shadow-md);
}
.bookmarklet::before { content: "⠿"; opacity: .7; }

/* Demonstração animada do arrastar: um "fantasma" do botão sobe até a barra e o favorito aparece lá */
.bm-demo {
  position: relative; width: 300px; max-width: 100%; height: 92px; margin: 10px 0 4px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-size: 11.5px;
}
.bm-demo-bar {
  display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; white-space: nowrap;
  border-bottom: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.bm-demo-fav { padding: 2px 6px; border-radius: 6px; }
.bm-demo-new { background: var(--accent-soft); color: var(--accent); font-weight: 600; animation: bm-appear 4s infinite; }
.bm-demo-btn, .bm-demo-ghost {
  position: absolute; left: 14px; top: 48px; padding: 5px 10px; border-radius: 8px; white-space: nowrap;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.bm-demo-btn { opacity: .35; }
.bm-demo-ghost { box-shadow: var(--shadow-md); animation: bm-drag 4s infinite; }
.bm-demo-ghost::after { content: "👆"; position: absolute; right: -10px; bottom: -14px; font-size: 16px; }
@keyframes bm-drag {
  0%, 12% { transform: translate(0, 0); opacity: 1; }
  55% { transform: translate(126px, -48px) scale(.8); opacity: 1; }
  62%, 100% { transform: translate(126px, -48px) scale(.8); opacity: 0; }
}
@keyframes bm-appear { 0%, 55% { opacity: 0; } 62%, 94% { opacity: 1; } 100% { opacity: 0; } }
.bm-warn {
  margin: 8px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 13px;
  background: var(--desc-soft); color: var(--ink); border: 1px solid color-mix(in oklab, var(--desc) 40%, transparent);
}
.bm-warn.shake { animation: bm-shake .4s; }
@keyframes bm-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.bm-more { margin-top: 8px; font-size: 13px; }
.bm-more .small-note { margin-top: 6px; }
.bar-help { margin-top: 8px; }
.bar-help-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.bar-help-tab {
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); font-size: 12px; cursor: pointer;
}
.bar-help-tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.bar-help-text { margin: 8px 0 0; color: var(--ink-2); }
.suap-mobile { padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.suap-mobile p { margin: 0 0 8px; }
.suap-mobile .btn { margin-top: 6px; }
@media (prefers-reduced-motion: reduce) {
  .bm-demo-ghost { animation: none; transform: translate(126px, -48px) scale(.8); }
  .bm-demo-new { animation: none; opacity: 1; }
}
.diag { margin-top: 12px; font-size: 13px; }
.diag summary, .bm-more summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.diag-list { margin: 8px 0 0; padding: 0; list-style: none; }
.diag-list li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.diag-list li span:last-child { color: var(--muted); }

/* ───────────── Navegação do painel ───────────── */
.tree-bar-actions { display: flex; align-items: center; gap: 6px; }

/* Engrenagem com interruptores */
.settings { position: relative; }
.settings-btn[aria-expanded="true"] { background: var(--surface); border-color: var(--line-2); }
.settings-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: 290px; padding: 10px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: rise .16s ease both;
}
.settings-title { margin: 2px 6px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 10px; cursor: pointer; position: relative; }
.switch-row:hover { background: var(--surface-2); }
.switch-row span { flex: 1; display: flex; flex-direction: column; }
.switch-row b { font-size: 13.5px; }
.switch-row small { font-size: 12px; color: var(--muted); }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 36px; height: 20px; border-radius: 99px; background: var(--line-2); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .18s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:disabled + .switch { opacity: .45; }
.switch-row:has(input:disabled) { cursor: default; opacity: .7; }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-note { margin: 6px 6px 2px; font-size: 12px; color: var(--muted); }

/* Notas */
.grade {
  display: inline-grid; place-items: center; min-width: 30px; padding: 1px 6px; border-radius: 7px;
  font: 700 11px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
.grade.g-high { background: color-mix(in oklab, var(--lvl-intro) 18%, transparent); color: var(--lvl-intro); }
.grade.g-mid { background: color-mix(in oklab, var(--lvl-mid) 20%, transparent); color: var(--lvl-mid); }
.grade.g-low { background: color-mix(in oklab, var(--lvl-adv) 18%, transparent); color: var(--lvl-adv); }
.grade.big { min-width: 46px; padding: 6px 8px; border-radius: 11px; font: 700 17px/1 var(--display); letter-spacing: -.01em; }
.node.is-focus .grade { background: color-mix(in oklab, var(--accent-ink) 22%, transparent); color: var(--accent-ink); }

/* Grade com progresso */
.card.st-concluida { background: color-mix(in oklab, var(--lvl-intro) 8%, var(--surface)); }
.card.st-cursando { box-shadow: 0 0 0 1.5px var(--anc), var(--shadow-sm); }
.card.st-liberada { box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--accent) 70%, transparent), var(--shadow-sm); }

/* ───────────── Meu percurso ───────────── */
.view-me { overflow-y: auto; }
.me { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 24px 48px; }
.me-empty { max-width: 520px; margin: 10vh auto; text-align: center; }
.me-empty h3 { margin: 0 0 8px; font: 700 30px/1.1 var(--display); letter-spacing: -.03em; }
.me-empty .btn { margin-top: 18px; }

.me-banner {
  margin-top: 14px; padding: 12px 16px; border-radius: 14px; font-size: 13.5px;
  background: color-mix(in oklab, var(--lvl-mid) 12%, var(--surface)); border: 1px solid color-mix(in oklab, var(--lvl-mid) 40%, transparent);
}

.me-card { padding: 20px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); }
.me-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.me-card h4 { margin: 0; font: 700 18px/1.2 var(--display); letter-spacing: -.02em; }
.me-card h5 { margin: 18px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.me-card header .muted { font-size: 12.5px; }

.me-bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.me-bar i { display: block; height: 100%; border-radius: inherit; background: var(--anc); transition: width .6s ease; }
.me-bar.ok i, .me-bar.full i { background: var(--lvl-intro); }
.me-bar.acc i { background: var(--desc); }

.me-card > .me-bar { margin-bottom: 16px; }

.acc-types { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.acc-type-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; margin-bottom: 5px; }
.acc-type-top span:last-child { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.acc-types .me-bar { height: 6px; }
.acc-log-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.acc-log-head .link { font-size: 12px; }
.acc-log { list-style: none; margin: 0; padding: 0; }
.acc-log li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.acc-log li:last-child { border-bottom: 0; }
.acc-log b { display: block; font-size: 13px; font-weight: 600; }
.acc-log small { font-size: 12px; color: var(--muted); }
.acc-reason { margin: 6px 0 0; font-size: 12px; color: var(--lvl-adv); }


@media (max-width: 720px) {
        .me { padding: 14px 12px 32px; }
}

/* Fluxograma: modo Conexões | Grade */
.segmented.mini { padding: 2px; border-radius: 10px; }
.seg-mode { border: 0; background: transparent; padding: 4px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg-mode.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ───────────── Meu percurso: trilha ───────────── */
.pc-hero {
  display: grid; grid-template-columns: 1fr auto; gap: 18px 28px; align-items: start;
  padding: 26px 28px; border-radius: 24px; border: 1px solid var(--line);
  background:
    radial-gradient(520px 240px at 0% 0%, var(--accent-soft), transparent 70%),
    radial-gradient(420px 220px at 100% 120%, var(--anc-soft), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}
.pc-hero .eyebrow { margin-bottom: 8px; }
.pc-hero h3 { margin: 0; font: 700 clamp(26px, 3.4vw, 40px)/1.05 var(--display); letter-spacing: -.035em; }
.pc-hero h3 em { font-style: normal; color: var(--accent); }
.pc-hero h3 span { display: block; margin-top: 8px; font: 500 15px/1.3 var(--font); letter-spacing: 0; color: var(--ink-2); }
.pc-hero h3 span b { color: var(--desc); font-weight: 700; }
.pc-hero .muted { margin: 10px 0 0; font-size: 12.5px; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.pc-progress { grid-column: 1 / -1; }
.pc-progress-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-bottom: 7px; }
.pc-progress-top b { color: var(--ink); }
.pc-meter { height: 10px; border-radius: 99px; background: color-mix(in oklab, var(--line) 80%, transparent); overflow: hidden; }
.pc-meter i {
  display: block; height: 100%; width: var(--w); border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--lvl-intro) 60%, var(--anc));
  animation: grow 1s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes grow { from { width: 0; } }
.pc-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pc-stats > * { padding: 11px 14px; border-radius: 14px; background: color-mix(in oklab, var(--surface-2) 80%, transparent); border: 1px solid var(--line); }
.pc-stats b { display: block; font: 700 22px/1.1 var(--display); letter-spacing: -.02em; }
.pc-stats span { font-size: 12px; color: var(--muted); }
.pc-stats .is-acc b { color: var(--desc); }

.trail-card {
  margin-top: 16px; padding: 10px 18px 16px; border-radius: 24px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.trail { position: relative; width: 100%; }
.trail-svg { position: absolute; inset: 0; width: 100%; height: 100%; stroke-width: 1; overflow: visible; }
.trail-svg path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trail-base { stroke: var(--line-2); stroke-width: 3; stroke-dasharray: 2 9; }
.trail-done { stroke: url(#trail-grad); stroke-width: 6; }
.trail-done.is-drawing { animation: draw 1.4s cubic-bezier(.4, 0, .2, 1) both; }
@keyframes draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
.trail-now { stroke: var(--anc); stroke-width: 6; opacity: .55; }
.tg-a { stop-color: var(--accent); }
.tg-b { stop-color: var(--lvl-intro); }
.trail-start { fill: var(--ink); stroke: none; }

.stop {
  position: absolute; width: 132px; height: 0; margin-left: -66px; padding: 0; border: 0; background: none;
  color: var(--ink); animation: pop .5s cubic-bezier(.2, .9, .3, 1.3) both; animation-delay: calc(var(--i) * 60ms + 200ms);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.9); } }
.stop:focus-visible { outline: none; }
.stop:focus-visible .stop-node { outline: 2px solid var(--accent); outline-offset: 4px; }
.stop-num {
  position: absolute; left: 0; right: 0; bottom: 16px; text-align: center;
  font: 800 46px/1 var(--display); letter-spacing: -.05em; color: var(--muted);
  transition: transform .2s;
}
.stop-num svg { width: 36px; height: 36px; stroke-width: 1.8; }
.stop-node {
  position: absolute; left: 50%; top: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  background: var(--surface); border: 3px dashed var(--line-2); transition: transform .2s, box-shadow .2s;
}
.stop-label { position: absolute; left: 0; right: 0; top: 20px; display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.stop-label b { font: 700 14px var(--font); font-variant-numeric: tabular-nums; }
.stop-label small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.stop:hover .stop-num { transform: translateY(-3px); }
.stop:hover .stop-node { transform: scale(1.15); }

.stop.k-done .stop-num {
  background: linear-gradient(160deg, var(--lvl-intro), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stop.k-done .stop-node { border: 0; background: var(--accent); box-shadow: 0 0 0 4px var(--surface); }
.stop.k-done .stop-node::after {
  content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 5px;
  border: solid var(--accent-ink); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg);
}
.stop.k-now .stop-num { color: var(--anc); }
.stop.k-now .stop-node { border: 0; background: var(--anc); box-shadow: 0 0 0 4px var(--surface); }
.stop.k-now .stop-node::before {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--anc); animation: pulse 2s ease-out infinite;
}
@keyframes pulse { from { transform: scale(.8); opacity: .9; } to { transform: scale(2.1); opacity: 0; } }
.stop.k-now .stop-label b { color: var(--anc); }
.stop.k-future .stop-num { color: color-mix(in oklab, var(--muted) 55%, transparent); }
.stop.k-end .stop-num { color: var(--desc); }
.stop.k-end .stop-node { border: 3px solid var(--desc); background: var(--desc-soft); }
.stop.k-end .stop-label b { color: var(--desc); }

.stop.is-selected .stop-node { transform: scale(1.25); box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px color-mix(in oklab, var(--ink) 18%, transparent); }
.stop.is-selected .stop-num { transform: translateY(-4px) scale(1.08); }
.stop.k-future.is-selected .stop-num { color: var(--ink-2); }
.stop.is-selected .stop-label b { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.trail.is-vertical .stop { width: auto; right: 0; margin-left: -34px; padding-left: 34px; height: 0; }
.trail.is-vertical .stop-node { left: 34px; }
.trail.is-vertical .stop-num { left: 60px; right: auto; bottom: auto; top: -18px; width: 46px; font-size: 32px; text-align: left; }
.trail.is-vertical .stop-num svg { width: 28px; height: 28px; }
.trail.is-vertical .stop-label { left: 108px; right: auto; top: -18px; align-items: flex-start; }

.trail-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; font-size: 12px; color: var(--muted); }
.trail-legend span { display: inline-flex; align-items: center; gap: 6px; }
.trail-legend i { width: 18px; height: 4px; border-radius: 9px; }
.lg-done { background: var(--accent); }
.lg-now { background: var(--anc); }
.lg-future { background: repeating-linear-gradient(90deg, var(--line-2) 0 3px, transparent 3px 7px); }

.stop-detail {
  --tone: var(--muted);
  margin-top: 16px; padding: 22px 22px 20px; border-radius: 24px; border: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in oklab, var(--tone) 7%, var(--surface)), var(--surface) 140px);
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden; scroll-margin-top: 12px;
}
.stop-detail::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--tone); }
.stop-detail.k-done { --tone: var(--accent); }
.stop-detail.k-now { --tone: var(--anc); }
.stop-detail.k-future { --tone: var(--line-2); }
.stop-detail.k-end { --tone: var(--desc); }
.sd-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sd-num {
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; flex: none;
  background: color-mix(in oklab, var(--tone) 16%, var(--surface)); color: var(--tone);
  font: 800 30px/1 var(--display); letter-spacing: -.04em;
}
.stop-detail.k-future .sd-num { color: var(--ink-2); }
.sd-num svg { width: 28px; height: 28px; }
.sd-title { flex: 1; min-width: 180px; }
.sd-title .eyebrow { margin: 0 0 2px; }
.sd-title h4 { margin: 0; font: 700 22px/1.15 var(--display); letter-spacing: -.02em; }
.sd-facts { display: flex; flex-wrap: wrap; gap: 8px; }
.sd-facts div { padding: 7px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); min-width: 84px; }
.sd-facts b { display: block; font: 700 17px/1.15 var(--display); }
.sd-facts span { font-size: 11.5px; color: var(--muted); }
.sd-note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }
.pc-courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 16px; }
.pc-course {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px; border-radius: 15px;
  border: 1px solid var(--line); background: var(--surface); transition: transform .15s, box-shadow .15s, border-color .15s;
  animation: rise .3s ease both;
}
.pc-course:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.stop-detail.k-future .pc-course { border-style: dashed; background: transparent; }
.pc-course-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pc-course-main b { font-size: 13.5px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pc-course-main small { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.pc-check { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.pc-check svg { width: 15px; height: 15px; stroke-width: 3; }

@media (max-width: 720px) {
  .pc-hero { grid-template-columns: 1fr; padding: 20px; }
  .pc-actions { justify-content: flex-start; }
  .trail-card { padding: 8px 12px 14px; }
  .stop-detail { padding: 18px 14px; }
  .pc-courses { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .trail-done.is-drawing, .stop, .pc-meter i, .acc-meter i, .stop.k-now .stop-node::before { animation: none; }
}

/* Meu percurso: abas Semestres | Atividades complementares */
.pc-stats button:hover { border-color: var(--desc); transform: translateY(-1px); }
.pc-stats button { text-align: left; font: inherit; color: inherit; cursor: pointer; transition: border-color .15s, transform .15s; }
.me-tabs { display: flex; width: fit-content; margin: 16px auto 0; padding: 3px; border-radius: 12px; }
.me-tabs .seg-mode { padding: 6px 16px; font-size: 13px; }

.grad-todo { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.grad-todo > * {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 16px; text-align: left;
  border: 1px solid var(--line); background: var(--surface-2); font: inherit; color: inherit;
}
.grad-todo b { font: 700 26px/1.1 var(--display); letter-spacing: -.02em; }
.grad-todo b svg { width: 24px; height: 24px; stroke-width: 3; }
.grad-todo span { font-size: 12.5px; color: var(--muted); }
.grad-todo .is-ok b { color: var(--accent); }
.grad-todo .is-acc { cursor: pointer; border-color: color-mix(in oklab, var(--desc) 40%, var(--line)); transition: transform .15s, box-shadow .15s; }
.grad-todo .is-acc b { color: var(--desc); }
.grad-todo .is-acc:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.acc-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.acc-tipos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.acc-tipo-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; font-size: 13.5px; }
.acc-tipo-top b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.acc-tipo-top small { color: var(--muted); font-weight: 500; }
.acc-room { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); }
.acc-room.is-full { color: var(--lvl-intro); }
.acc-log + h5 { margin-top: 16px; }

@media (max-width: 720px) {
  .acc-cols { grid-template-columns: 1fr; }
}

/* ───────────── Cabeçalho: marca + novo chat | seções + ajustes ───────────── */
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface); border-color: var(--line); }
.topnav { display: flex; align-items: center; gap: 4px; margin-left: auto; padding: 4px; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in oklab, var(--surface) 70%, transparent); }
.nav-btn {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink-2); font-size: 13.5px; font-weight: 600; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-btn svg { width: 17px; height: 17px; }
.nav-btn:hover { background: var(--surface); color: var(--ink); }
.nav-btn.is-active, .settings-btn[aria-expanded="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.nav-btn.is-active svg { color: var(--accent); }
.nav-status { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); flex: none; }
.nav-status.is-on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.theme-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 4px 6px; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.theme-seg button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; }
.theme-seg button svg { width: 16px; height: 16px; }
.theme-seg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.settings-pop .settings-title { margin-top: 12px; }
.settings-pop .settings-title:first-child { margin-top: 2px; }
.menu-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 10px; text-decoration: none; }
.menu-row:hover { background: var(--surface-2); }
.menu-row svg { color: var(--accent); }
.menu-row span { display: flex; flex-direction: column; }
.menu-row b { font-size: 13.5px; }
.menu-row small { font-size: 12px; color: var(--muted); }

.course-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: -10px 0 26px; font-size: 13px; color: var(--muted); }
.course-facts b { color: var(--ink); font-weight: 600; }

@media (max-width: 720px) {
  .nav-btn span { display: none; }
  .nav-btn { padding: 0 10px; }
  .nav-status { position: absolute; top: 6px; right: 6px; }
  .settings-pop { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h, 61px) + 6px); width: auto; max-height: calc(100vh - var(--topbar-h, 61px) - 20px); overflow-y: auto; }
}

/* Horas complementares em rosca */
.acc-hero { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; flex: none; }
.donut circle { fill: none; stroke-width: 18; transform: rotate(-90deg); transform-origin: 80px 80px; }
.donut-track { stroke: color-mix(in oklab, var(--line) 85%, transparent); }
.donut-done { stroke: var(--desc); animation: donut-in 1s cubic-bezier(.2, .8, .2, 1) both; }
.donut-pending { stroke: color-mix(in oklab, var(--desc) 40%, transparent); }
@keyframes donut-in { from { stroke-dasharray: 0 var(--c); } }
.donut text { stroke: none; text-anchor: middle; }
.donut-val { font: 800 34px var(--display); fill: var(--ink); letter-spacing: -.03em; }
.donut-val tspan { font-size: 18px; font-weight: 700; fill: var(--muted); }
.donut-sub { font: 600 13px var(--font); fill: var(--desc); }
.donut-side { flex: 1; min-width: 220px; }
.donut-side h3 { margin: 0 0 12px; font: 700 22px/1.15 var(--display); letter-spacing: -.02em; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.donut-legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.donut-legend i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.donut-legend b { min-width: 62px; font-variant-numeric: tabular-nums; }
.donut-legend span { color: var(--muted); }
.donut-legend .lg-done { background: var(--desc); }
.donut-legend .lg-pending { background: color-mix(in oklab, var(--desc) 40%, transparent); }
.donut-legend .lg-left { background: var(--line-2); }
.donut-foot { margin: 12px 0 10px; font-size: 12.5px; color: var(--muted); }
.donut-foot .is-denied { color: var(--lvl-adv); }
.donut-side .btn { margin-left: -10px; }
@media (max-width: 720px) {
  .acc-hero { flex-direction: column; align-items: flex-start; }
  .donut { align-self: center; }
}
@media (prefers-reduced-motion: reduce) { .donut-done { animation: none; } }

.acc-hero { margin-top: 16px; padding: 22px 26px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); }

/* Ajustes: apagar dados do SUAP (dois cliques) */
button.menu-row { width: 100%; border: 0; background: none; text-align: left; font: inherit; color: inherit; }
.menu-row.danger svg { color: var(--lvl-adv); }
.menu-row .when-confirm { display: none; }
.menu-row.is-confirming { background: color-mix(in oklab, var(--lvl-adv) 12%, transparent); }
.menu-row.is-confirming .when-idle { display: none; }
.menu-row.is-confirming .when-confirm { display: inline; color: var(--lvl-adv); }


/* ───────────── Barra lateral (como a do ChatGPT): marca, novo chat e conversas ───────────── */
body { flex-direction: row; }
.app { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sidebar {
  width: 0; flex: none; height: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: color-mix(in oklab, var(--surface) 70%, var(--bg)); border-right: 1px solid transparent;
  transition: width .2s ease, border-color .2s;
}
body.sidebar-open .sidebar { width: 268px; border-right-color: var(--line); }
.sidebar > * { min-width: 268px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 10px 10px 14px; }
.sidebar-head .brand-mark svg { width: 30px; height: 30px; }
.sidebar-head .brand-text strong { font-size: 17px; }
.sidebar-head .brand-text span { font-size: 11.5px; }
.side-item {
  display: flex; align-items: center; gap: 10px; margin: 4px 10px; padding: 9px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink); font-size: 14px; font-weight: 600; text-align: left;
}
.side-item svg { width: 17px; height: 17px; }
.side-item:hover { background: var(--surface); }
.side-section { margin: 18px 24px 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.conv-list { flex: 1; overflow-y: auto; padding: 0 10px 12px; }
.conv-empty { margin: 6px 14px; font-size: 13px; color: var(--muted); }
.conv { position: relative; display: flex; align-items: center; border-radius: 10px; transition: background .12s; }
.conv:hover, .conv:focus-within { background: var(--surface); }
.conv.is-active { background: var(--surface); }
.conv-open {
  flex: 1; min-width: 0; padding: 9px 12px 9px 14px; border: 0; background: none; text-align: left;
  font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv.is-active .conv-open { color: var(--ink); font-weight: 600; }
.conv-actions { display: none; gap: 2px; padding-right: 4px; }
.conv:hover .conv-actions, .conv:focus-within .conv-actions, .conv.is-confirming .conv-actions { display: flex; }
.conv-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; min-width: 28px; justify-content: center; padding: 0 6px;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted);
}
.conv-btn svg { width: 15px; height: 15px; }
.conv-btn:hover { background: var(--surface-2); color: var(--ink); }
.conv-del span { display: none; font-size: 12px; font-weight: 600; }
.conv.is-confirming .conv-del { background: color-mix(in oklab, var(--lvl-adv) 16%, transparent); color: var(--lvl-adv); }
.conv.is-confirming .conv-del span { display: inline; }
.conv.is-confirming .conv-btn[data-act="rename"] { display: none; }
.conv-rename {
  flex: 1; margin: 3px; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; outline: none;
}
.sidebar-note { margin: 0; padding: 10px 24px 14px; font-size: 11.5px; color: var(--muted); }
.sidebar-scrim { display: none; }

/* Cabeçalho: com a barra fechada, ganha o botão de abrir, a marca e o novo chat */
.topbar-lead { display: flex; align-items: center; gap: 6px; }
.topbar-lead .brand-mark svg { width: 28px; height: 28px; }
.lead-name { font: 700 17px/1 var(--display); letter-spacing: -.02em; margin-right: 4px; }
body.sidebar-open .topbar-lead { display: none; }
body.sidebar-open .drawer { left: 268px; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: min(300px, 86vw) !important;
    background: var(--surface); border-right: 1px solid var(--line); box-shadow: var(--shadow-lg);
    transform: translateX(-102%); transition: transform .22s ease;
  }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar > * { min-width: 0; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgb(0 0 0 / .35); }
  body.sidebar-open .topbar-lead { display: flex; }
  body.sidebar-open .drawer { left: 0; }
  .conv-actions { display: flex; }
}
@media (max-width: 720px) {
  .lead-name { display: none; }
}

/* ───────────── Multi-curso: troca de curso e tela Explorar ───────────── */
.course-switch {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; max-width: 280px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  font: 600 13px var(--font); cursor: pointer; white-space: nowrap; overflow: hidden;
}
.course-switch:hover { border-color: var(--line-2); }
.course-switch #course-switch-label { overflow: hidden; text-overflow: ellipsis; }
.course-switch svg { flex: none; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.course-switch-mine {
  flex: none; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--accent-soft); color: var(--accent);
}
body.exploring .composer, body.no-course .composer,
body.no-course .nav-btn[data-nav="flow"], body.no-course .nav-btn[data-nav="me"] { display: none; }
.explore { max-width: 860px; margin: 6vh auto 40px; animation: rise .5s ease both; }
.explore h1 { margin: 0; font: 700 clamp(30px, 4.4vw, 46px)/1.05 var(--display); letter-spacing: -.03em; }
.explore h1 em { font-style: normal; color: var(--accent); }
.explore-group { margin: 26px 0 10px; font: 700 13px var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.course-card {
  display: flex; flex-direction: column; gap: 6px; padding: 16px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.course-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.course-card.is-current { border-color: var(--accent); }
.course-card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.course-sigla { font: 700 12px var(--mono); color: var(--accent); }
.course-tag { padding: 1px 8px; border-radius: 999px; font-size: 11px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.course-tag.is-mine { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.course-card-name { font: 700 17px/1.2 var(--display); }
.course-card-facts { font-size: 12.5px; color: var(--muted); }
.conv-course { margin-right: 6px; font: 700 10.5px var(--mono); color: var(--muted); }
@media (max-width: 720px) {
  .course-switch { max-width: 150px; }
  .explore { margin-top: 3vh; }
}
.topnav .nav-btn { white-space: nowrap; }
@media (max-width: 1000px) { .course-switch { max-width: 190px; } }
