/* Ariadne — estilos próprios. Tailwind (CDN) só para utilitários de layout. */

:root {
    --bg: #f8fafc; --surface: #ffffff; --surface-2: #f1f5f9; --border: #e2e8f0; --border-strong: #cbd5e1;
    --text: #334155; --text-strong: #0f172a; --text-muted: #64748b; --text-faint: #94a3b8;
    --accent: #0f172a; --accent-text: #ffffff; --relation: #7c3aed; --studied: #16a34a; --review: #f59e0b;
    --shadow: 0 1px 2px rgba(0,0,0,.05); --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
    --ramo: #475569;
}
:root[data-theme="dark"] {
    --bg: #0b1220; --surface: #111827; --surface-2: #1e293b; --border: #1f2937; --border-strong: #334155;
    --text: #e2e8f0; --text-strong: #f8fafc; --text-muted: #94a3b8; --text-faint: #64748b;
    --accent: #e2e8f0; --accent-text: #0f172a; --relation: #a78bfa; --studied: #4ade80; --review: #fbbf24;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.5);
    color-scheme: dark;
}

html, body { height: 100%; }
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; margin: 0; background: var(--bg); color: var(--text); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
.surface { background: var(--surface); color: var(--text); }
.border-b-ui { border-bottom: 1px solid var(--border); }
.border-t-ui { border-top: 1px solid var(--border); }
.muted { color: var(--text-muted); }
.strong { color: var(--text-strong); }

/* Layout crítico independente do Tailwind */
#workspace { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#tree-container { flex: 1 1 auto; min-height: 0; min-width: 0; position: relative; background: var(--bg); }
/* Celular e tablet: folha inferior; recolhida ocupa a altura de antes, expandida chega a 85vh */
#reading-panel { height: 36%; min-height: 190px; flex: 0 0 auto; display: flex; flex-direction: column; position: relative; border-top: 1px solid var(--border); box-shadow: 0 -10px 15px -3px rgba(0,0,0,.05); transition: height .25s ease; }
@media (min-width: 768px) { #reading-panel { height: 32%; } }
#reading-panel.expanded { height: 85vh; }
#panel-toggle { flex: 0 0 auto; height: 18px; width: 100%; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; cursor: pointer; }
#panel-toggle .grip { width: 40px; height: 4px; border-radius: 999px; background: var(--border-strong); }
#panel-toggle:hover .grip, #panel-toggle:focus-visible .grip { background: var(--text-faint); }
/* Telas largas: painel lateral de 460px, altura total sob o cabeçalho */
@media (min-width: 1024px) {
    #workspace { flex-direction: row; }
    #reading-panel, #reading-panel.expanded { height: auto; width: 460px; flex: 0 0 460px; min-height: 0; border-top: 0; border-left: 1px solid var(--border); box-shadow: none; }
    #panel-toggle { display: none; }
}
body.mode-aula #workspace { display: none !important; }

/* Painel do nó */
#content-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.panel-head { flex: 0 0 auto; padding: .5rem 1.5rem 0; display: flex; flex-direction: column; gap: .5rem; }
@media (min-width: 1024px) { .panel-head { padding-top: 1.25rem; } }
.panel-tags { display: flex; flex-wrap: wrap; gap: .375rem; }
.panel-tags:empty { display: none; }
.panel-title { font-size: 22px; font-weight: 700; line-height: 1.25; color: var(--text-strong); text-wrap: pretty; margin: 0; }
.panel-subtitle { font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); margin: 0; }
.panel-tabs { display: flex; gap: 1.25rem; margin-top: .5rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.panel-tabs [role="tab"] { font-size: 14px; font-weight: 600; padding: 0 0 .6rem; color: var(--text-faint); background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.panel-tabs [role="tab"][aria-selected="true"] { color: var(--text-strong); border-bottom-color: var(--relation); }
.panel-tabs [role="tab"]:focus-visible { outline: 2px solid var(--relation); outline-offset: 2px; border-radius: 2px; }
.tab-count { font-size: 11px; color: var(--text-faint); }
.panel-tabs [role="tab"][aria-selected="true"] .tab-count { color: var(--relation); }
.panel-head:not(:has(.panel-tabs)) { border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1.25rem 1.5rem; }
.tabpanel { display: flex; flex-direction: column; gap: 1rem; }
.tabpanel[hidden] { display: none; }
.panel-text { font-size: 17px; line-height: 1.6; margin: 0; }
.panel-note { font-size: .875rem; color: var(--text-muted); margin: .5rem 0 0; }
.panel-progress { display: flex; flex-direction: column; gap: .25rem; }
.panel-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.panel-actions:empty { display: none; }
.panel-foot { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: .5rem; padding: .85rem 1.5rem; border-top: 1px solid var(--border); }
.panel-foot:empty { display: none; }
.panel-foot .btn .trail-dot { margin-right: 0; width: 8px; height: 8px; }
.panel-foot .btn[aria-pressed="true"] { background: var(--surface-2); color: var(--text-strong); border-color: var(--text-muted); font-weight: 600; }
.rel-group-head { display: flex; flex-direction: column; gap: .15rem; font-size: 12px; }
.rel-group-head > span:first-child { font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.rel-group-head .muted { font-size: 13px; color: var(--text-faint); }
.rel-card { display: flex; flex-direction: column; gap: .35rem; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; text-decoration: none; }
.rel-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.rel-card-head { display: flex; align-items: center; gap: .5rem; font-size: 14px; }
.rel-card-head b { color: var(--text-strong); }
.rel-card-head .rel-type { margin-left: auto; color: var(--relation); font-weight: 700; white-space: nowrap; }
.rel-mark { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 2px; border: 1.5px solid; }
.rel-mark.dashed { border-style: dashed; }
.rel-note { font-size: 14px; line-height: 1.5; }
.rel-via { font-size: 12px; color: var(--text-muted); }
.relations { display: flex; flex-direction: column; gap: .6rem; }
.relations .rel-card + .rel-group-head, .relations p + .rel-group-head { margin-top: .75rem; }
.timeline-v { list-style: none; margin: 0 0 0 6px; padding: 0; border-left: 2px solid var(--border-strong); }
.timeline-v li { position: relative; padding: 0 0 1rem 1rem; font-size: 14px; line-height: 1.5; }
.timeline-v li:last-child { padding-bottom: 0; }
.timeline-v li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 999px; background: var(--relation); }
.timeline-v li.origem::before { background: var(--text-strong); }
.timeline-v li.fim::before { background: #e11d48; }
.timeline-v b { color: var(--text-strong); font-size: 13px; }
.tl-year { font-family: inherit; font-size: 13px; font-weight: 700; color: var(--text-strong); background: none; border: 0; padding: 0; text-decoration: underline dotted; cursor: pointer; }
.tl-year:hover { color: var(--relation); }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: .5rem .75rem; font-size: 13px; margin: 0; align-items: baseline; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; min-width: 0; }
.kv code { color: var(--text-strong); word-break: break-all; font-family: ui-monospace, monospace; }
.code-block { margin: 0; background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 14px; font: 12px/1.6 ui-monospace, monospace; overflow: auto; white-space: pre; }
:root[data-theme="dark"] .code-block { background: #020617; border: 1px solid var(--border); }
#view-main, #view-compare { position: absolute; inset: 0; }
#view-compare { display: flex; }
#view-main.hidden, #view-compare.hidden, #outline.hidden { display: none; }
#view-compare .pane { flex: 1 1 0; position: relative; min-width: 0; }
#view-compare .pane + .pane { border-left: 1px solid var(--border); }
#view-compare .pane-title { position: absolute; top: .5rem; left: .75rem; z-index: 2; font-size: .75rem; font-weight: 700; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: .375rem; padding: .15rem .5rem; pointer-events: none; }
#view-compare .pane.active .pane-title { color: var(--text-strong); border-color: var(--border-strong); }
#tree-container.comparing > .hint { display: none; }
@media (max-width: 767px) { #view-compare { flex-direction: column; } #view-compare .pane + .pane { border-left: 0; border-top: 1px solid var(--border); } }

/* Botões e controles */
.btn { display: inline-flex; align-items: center; gap: .35rem; font-size: .875rem; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: .5rem; padding: .5rem .9rem; line-height: 1.1; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.btn-primary:hover { opacity: .9; }
.btn.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn[aria-pressed="true"], .btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.ctl { width: 2.25rem; height: 2.25rem; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); border-radius: .5rem; box-shadow: var(--shadow); font-weight: 600; cursor: pointer; }
.ctl:hover { background: var(--surface-2); }
.ctl:disabled { opacity: .45; cursor: not-allowed; }
.ctl.wide { width: auto; padding: 0 .75rem; font-size: .8rem; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: .15rem .55rem; border-radius: 999px; color: #fff; }
.chip.outline { background: transparent !important; color: var(--text-muted); border: 1px solid var(--border-strong); }
.count { font-size: 10px; font-weight: 700; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: .15rem .4rem; line-height: 1; }
kbd { font: 600 11px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--text-muted); }
.hint { font-size: .75rem; color: var(--text-muted); background: color-mix(in srgb, var(--surface) 90%, transparent); border: 1px solid var(--border); border-radius: .375rem; padding: .5rem .75rem; box-shadow: var(--shadow); backdrop-filter: blur(2px); }
input[type="search"], select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: .5rem; font-size: .875rem; }
input[type="search"]:focus, select:focus { outline: 2px solid var(--text-faint); outline-offset: 1px; }
input[type="checkbox"] { accent-color: var(--text-strong); }

/* Barra de ferramentas */
.toolbar { display: flex; align-items: center; justify-content: flex-start; gap: .5rem; overflow-x: auto; scrollbar-width: thin; max-width: 100%; flex: 0 0 auto; }
.toolbar > * { flex: 0 0 auto; }
.toolbar .sep { width: 1px; height: 1.25rem; background: var(--border-strong); flex: 0 0 auto; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: .5rem; overflow: hidden; }
.seg button { font-size: .8rem; padding: .35rem .7rem; background: var(--surface); color: var(--text); border: 0; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg a { font-size: .8rem; padding: .35rem .7rem; background: var(--surface); color: var(--text); text-decoration: none; }
.seg a + a { border-left: 1px solid var(--border-strong); }
.seg a[aria-current="page"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
#mode-nav { flex: 0 0 auto; }
/* Celular: o seletor de vistas ganha linha própria */
@media (max-width: 639px) {
    .header-top { flex-wrap: wrap; row-gap: .5rem; }
    #mode-nav { order: 3; width: 100%; display: flex; }
    #mode-nav a { flex: 1 1 auto; text-align: center; white-space: nowrap; font-size: .75rem; padding-left: .3rem; padding-right: .3rem; }
}

/* Popovers */
.pop { position: absolute; right: 0; margin-top: .25rem; background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; box-shadow: var(--shadow-lg); z-index: 30; font-size: .875rem; }
.pop label { display: flex; align-items: center; gap: .5rem; padding: .3rem .25rem; border-radius: .375rem; cursor: pointer; }
.pop label:hover { background: var(--surface-2); }
.pop .focus-link { margin-left: auto; font-size: 11px; color: var(--text-muted); text-decoration: underline dotted; }
.pop .focus-link:hover { color: var(--text-strong); }
#search-results:empty { display: none; }
#search-results li a { display: block; padding: .6rem 1rem; border-bottom: 1px solid var(--border); }
#search-results li:last-child a { border-bottom: 0; }
#search-results li a:hover { background: var(--surface-2); }

/* Trilha de navegação */
.crumb + .crumb::before { content: "›"; margin: 0 .4rem; color: var(--text-faint); }
.crumb a, a.crumb { text-decoration: underline dotted; }
.crumb.current { font-weight: 600; color: var(--text-strong); }

/* Árvore (SVG) */
.link { fill: none; stroke: var(--ramo); stroke-opacity: .7; stroke-width: 2.25px; stroke-linecap: round; }
.link.l1 { stroke-opacity: .85; stroke-width: 4px; }
.link.l2 { stroke-opacity: .8; stroke-width: 3px; }
.link.l3 { stroke-opacity: .65; stroke-width: 2px; }
:root[data-theme="dark"] .link { stroke-opacity: .8; }
.relation { fill: none; stroke: var(--relation); stroke-opacity: .95; stroke-width: 3px; stroke-dasharray: 8 5; stroke-linecap: round; filter: drop-shadow(0 0 3px var(--relation)); }
.relation.resolved { stroke-dasharray: none; }
.relation-arrow { fill: var(--relation); }
.relation-label { font-size: 11px; font-weight: 700; fill: var(--relation); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.node { cursor: pointer; }
.node.planned { cursor: help; }
.node text { pointer-events: none; user-select: none; }
.node.processual rect.box, .node.processual circle.box { stroke-dasharray: 5 3; }
.node.planned rect.box { stroke-dasharray: 2 3; }
.node.planned text.label { font-style: italic; }
.node .badge, .node .trail-mark, .node .rel-ring { pointer-events: none; }
.node:focus-visible rect.box, .node:focus-visible circle.box { outline: none; stroke-width: 3px; }
.hide-labels .node.division text.label { opacity: 0; }

/* Painel de leitura */
.fade { transition: opacity .25s ease; }
.gloss { text-decoration: underline dotted var(--relation); text-decoration-thickness: 1.5px; cursor: help; }
.rel-basis { font: 12px/1.4 ui-monospace, monospace; color: var(--text-muted); margin-top: .15rem; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; display: flex; width: 100%; max-width: 20rem; }
.progress .studied { background: var(--studied); }
.progress .review { background: var(--review); }
.trail-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 999px; margin-right: .35rem; vertical-align: middle; }
.trail-dot.studied { background: var(--studied); } .trail-dot.review { background: var(--review); }

/* Modo estudo */
.study-card { text-align: left; width: 100%; padding: 1.25rem 1.5rem; overflow-y: auto; box-sizing: border-box; }
.study-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; font-size: .8rem; }
.study-prompt { font-size: 1.05rem; color: var(--text-strong); margin: .25rem 0; }
.study-body { color: var(--text); margin: .5rem 0 .75rem; line-height: 1.5; }
.study-options { display: grid; gap: .5rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .study-options { grid-template-columns: 1fr 1fr; } }
.study-opt { white-space: normal; text-align: left; justify-content: flex-start; }
.study-foot { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: .9rem; font-size: .85rem; }

/* Lista acessível */
#outline { position: absolute; top: 0; left: 0; bottom: 0; width: min(26rem, 100%); background: var(--surface); border-right: 1px solid var(--border); overflow: auto; z-index: 5; padding: .75rem 1rem; font-size: .85rem; }
#outline ul { list-style: none; margin: 0; padding-left: 0; }
#outline ul ul { padding-left: 1rem; border-left: 1px dashed var(--border); margin-left: .35rem; }
#outline li { margin: .15rem 0; }
#outline a { display: block; padding: .15rem .35rem; border-radius: .25rem; text-decoration: none; }
#outline a:hover { background: var(--surface-2); }
#outline a.current { background: var(--accent); color: var(--accent-text); }
#outline a .muted { font-size: .75rem; }

/* Linha do tempo */
#timeline-bar input[type="range"] { accent-color: var(--text-strong); height: 1.5rem; }
#timeline-bar.hidden { display: none; }
#tl-events .ev { display: inline-flex; align-items: center; gap: .35rem; }
#tl-events .ev::before { content: ""; width: .5rem; height: .5rem; border-radius: 999px; background: var(--text-faint); flex: 0 0 auto; }
#tl-events .ev.diploma::before { background: var(--text-strong); }
#tl-events .ev.antecessor::before { background: var(--text-faint); }
#tl-events .ev.marco::before { background: var(--relation); }
#tl-events .ev.inclusao::before { background: var(--studied); }
#tl-events a { text-decoration: underline dotted; }
.year-chip { background: var(--relation) !important; }

/* Percurso guiado */
#tour-card { position: absolute; left: .75rem; bottom: .75rem; z-index: 12; width: min(26rem, calc(100% - 1.5rem)); background: var(--surface); border: 1px solid var(--border-strong); border-radius: .75rem; box-shadow: var(--shadow-lg); padding: .9rem 1rem; font-size: .9rem; }
#tour-card.hidden { display: none; }
#tour-card .tour-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .75rem; color: var(--text-muted); margin-bottom: .35rem; }
#tour-card .tour-title { font-weight: 700; color: var(--text-strong); font-size: .95rem; }
#tour-card .tour-text { line-height: 1.5; margin: .35rem 0 .7rem; }
#tour-card .tour-node { font-size: .78rem; color: var(--text-muted); margin-bottom: .5rem; }
#tour-card .tour-foot { display: flex; align-items: center; gap: .5rem; }
#tour-card .tour-dots { margin-left: auto; display: flex; gap: .25rem; }
#tour-card .tour-dots i { width: .45rem; height: .45rem; border-radius: 999px; background: var(--border-strong); display: inline-block; }
#tour-card .tour-dots i.done { background: var(--text-muted); }
#tour-card .tour-dots i.cur { background: var(--relation); }
#tours-pop .tour-item { display: block; padding: .5rem .6rem; border-radius: .5rem; }
#tours-pop .tour-item:hover { background: var(--surface-2); }
#tours-pop .tour-item b { color: var(--text-strong); }
@media (max-width: 639px) { #tour-card { bottom: 5.5rem; } }

/* Tela cheia: alternativa quando a Fullscreen API não existe ou é recusada */
.pseudo-fullscreen { position: fixed !important; inset: 0; z-index: 100; width: 100vw !important; height: 100vh !important; background: var(--bg); }
#tree-container:fullscreen { background: var(--bg); }
.fs-btn { gap: .4rem; }

/* Modo aula */
#aula { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
#aula.hidden { display: none; }
body.mode-aula > header, body.mode-aula #toolbar-row, body.mode-aula #timeline-bar, body.mode-aula #tree-container, body.mode-aula #reading-panel { display: none !important; }
#aula-bar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); overflow-x: auto; }
#aula-bar > * { flex: 0 0 auto; }
#aula-bar .flex-1 { flex: 1 1 auto; }
#aula-bar .sep { width: 1px; height: 1.25rem; background: var(--border-strong); }
.aula-brand { display: inline-flex; align-items: center; gap: .5rem; font-size: 1.1rem; font-weight: 700; color: var(--text-strong); text-decoration: none; }
.aula-title { font-size: .95rem; font-weight: 600; color: var(--text-strong); }
#aula-count { font-size: .8rem; }
.switch { gap: .5rem; }
.switch .track { width: 30px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; display: inline-block; transition: background .2s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .2s; }
.switch[aria-checked="true"] .track { background: var(--relation); }
.switch[aria-checked="true"] .knob { left: 14px; }
#aula-stage { flex: 1 1 auto; min-height: 0; position: relative; }
#aula-view { position: absolute; inset: 0; }
#aula-hint { position: absolute; top: .9rem; left: .9rem; max-width: 20rem; font-size: .8rem; line-height: 1.45; color: var(--text); pointer-events: none; }
#aula-types { position: absolute; left: .9rem; right: .9rem; bottom: .9rem; display: flex; flex-wrap: wrap; gap: .4rem; pointer-events: none; }
.type-chip { pointer-events: auto; display: inline-flex; align-items: center; gap: .4rem; font-size: 13px; font-weight: 600; border-radius: 999px; padding: .3rem .75rem; cursor: pointer; background: var(--surface); color: var(--text-muted); border: 1px solid var(--border-strong); }
.type-chip span { font-size: 11px; opacity: .8; font-variant-numeric: tabular-nums; }
.type-chip[aria-pressed="true"] { background: var(--relation); border-color: var(--relation); color: var(--accent-text); }
#aula-foot { flex: 0 0 auto; height: 190px; box-sizing: border-box; padding: 1rem 1.25rem; background: var(--surface); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .6rem; overflow: hidden; }
.aula-foot-head { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.aula-foot-title { font-size: 1.4rem; font-weight: 700; color: var(--text-strong); }
.aula-foot-text { font-size: .95rem; line-height: 1.5; max-width: 56rem; margin: 0; }
.aula-legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .8rem; color: var(--text-muted); }
.aula-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.aula-legend .lg-box { width: 22px; height: 12px; border-radius: 3px; border: 2px solid var(--text-muted); }
.aula-legend .lg-box.dashed { border-style: dashed; }
.aula-legend .lg-rel { width: 22px; border-top: 3px solid var(--relation); }
.aula-cards { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .25rem; min-height: 0; flex: 1 1 auto; align-items: stretch; }
.aula-card { flex: 0 0 320px; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; display: flex; flex-direction: column; gap: .25rem; overflow: auto; }
.aula-card-head { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.aula-card-head .rel-type { color: var(--relation); }
.aula-card-note { font-size: 13px; line-height: 1.45; }
@media (max-width: 767px) { #aula-foot { height: 150px; } .aula-foot-title { font-size: 1.1rem; } .aula-card { flex-basis: 260px; } }

/* Vista Grafo */
#grafo { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
#grafo.hidden { display: none; }
body.mode-grafo #toolbar-row, body.mode-grafo #timeline-bar, body.mode-grafo #workspace,
body.mode-tempo #toolbar-row, body.mode-tempo #timeline-bar, body.mode-tempo #workspace,
body.mode-dados #toolbar-row, body.mode-dados #timeline-bar, body.mode-dados #workspace { display: none !important; }

/* Vista Dados */
#dados { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2rem 1.5rem; background: var(--bg); }
#dados.hidden { display: none; }
.data-intro { max-width: 60rem; margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: .5rem; }
.data-cols { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 1024px) { .data-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.data-col { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.data-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: .35rem; }
.data-card p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.data-card-head { display: flex; align-items: center; gap: .5rem; }
.data-card-head code { font-size: 13px; font-weight: 700; color: var(--text-strong); }
.data-card-head a { text-decoration: none; }
.data-card-head a:hover code { text-decoration: underline; }
.data-badge { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-muted); }
.data-badge.fonte { border-color: var(--studied); color: var(--studied); }
.data-badge.gerado { border-color: var(--text-muted); }
.data-badge.proposta { border-color: var(--relation); color: var(--relation); }
.g-head .data-badge { margin-left: .5rem; vertical-align: middle; }
.data-who { margin-left: auto; font: 11px ui-monospace, monospace; color: var(--text-faint); }
.data-sig { font-size: 12px; color: var(--relation); word-break: break-word; }
#dados .code-block { white-space: pre-wrap; word-break: break-all; }
.data-card.kv { display: grid; grid-template-columns: 96px 1fr; }

/* Camada de dispositivos (gerada) */
.disp { display: flex; flex-direction: column; gap: .5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.data-badge.gerado-warn { border-color: var(--review); color: color-mix(in srgb, var(--review) 75%, var(--text-strong)); margin-left: .5rem; vertical-align: middle; }
.disp-warn { margin: 0; font-size: 13px; line-height: 1.5; padding: .6rem .75rem; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--review) 55%, var(--border)); background: color-mix(in srgb, var(--review) 10%, var(--surface)); }
.disp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; font-size: 13px; }
.disp-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; padding: .25rem .4rem; border-radius: 6px; transition: background .3s; }
.disp-item.flash { background: color-mix(in srgb, var(--relation) 18%, transparent); }
.disp-paragrafo { padding-left: 1.4rem; }
.disp-inciso { padding-left: 2.4rem; }
.disp-alinea { padding-left: 3.4rem; }
.disp-num { font-weight: 700; color: var(--text-strong); min-width: 5.5rem; }
.disp-artigo .disp-num { font-family: ui-monospace, monospace; }
.disp-urn { font: 11px ui-monospace, monospace; color: var(--text-faint); }
.disp-refs { font-size: 12px; color: var(--text-muted); }
.disp-ref { font: 600 11px ui-monospace, monospace; border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 .3rem; background: var(--surface); color: var(--relation); cursor: pointer; }
.disp-ref.out { color: var(--text-muted); cursor: default; }
#grafo-main { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
#grafo-bar { display: flex; align-items: center; gap: .75rem; padding: .5rem 1.25rem; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 70%, transparent); overflow-x: auto; }
#grafo-bar > * { flex: 0 0 auto; }
#grafo-bar .flex-1 { flex: 1 1 auto; }
#grafo-count { font-size: .8rem; }
#grafo-stage { flex: 1 1 auto; min-height: 0; position: relative; }
#grafo-stage svg { position: absolute; inset: 0; cursor: grab; }
.g-legend { position: absolute; top: .9rem; left: .9rem; display: flex; flex-direction: column; gap: .2rem; pointer-events: none; z-index: 1; }
#grafo-aside { flex: 0 0 auto; max-height: 45%; overflow-y: auto; background: var(--surface); border-top: 1px solid var(--border); padding: 1.25rem; display: flex; flex-direction: column; gap: 1.25rem; }
@media (min-width: 1024px) {
    #grafo { flex-direction: row; }
    #grafo-aside { width: 420px; max-height: none; border-top: 0; border-left: 1px solid var(--border); }
}
.g-section { display: flex; flex-direction: column; gap: .5rem; }
.g-summary { align-items: flex-start; }
.g-title { font-size: 22px; font-weight: 700; color: var(--text-strong); margin: 0; line-height: 1.25; text-wrap: pretty; }
.g-sub { font-size: 14px; color: var(--text-muted); margin: 0; line-height: 1.5; }
.g-sub b { color: var(--text-strong); }
.g-head { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.g-type { display: flex; align-items: center; gap: .6rem; font-size: 14px; cursor: pointer; }
.g-type input { accent-color: var(--relation); }
.g-type-label { flex: 1 1 auto; }
.g-bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--relation) 30%, var(--surface)); }
.g-type-n { width: 1.25rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.g-matrix { display: grid; gap: 2px; font: 10px ui-monospace, monospace; color: var(--text-muted); overflow-x: auto; }
.g-matrix .mx { height: 22px; border-radius: 3px; display: flex; align-items: center; justify-content: center; font: 700 10px ui-monospace, monospace; border: 0; padding: 0; }
.g-matrix button.mx { cursor: pointer; }
.g-matrix button.mx:hover, .g-matrix button.mx.on { outline: 2px solid var(--text-strong); outline-offset: -1px; }
.g-matrix .m0 { background: var(--surface-2); }
.g-matrix .m1 { background: #ddd6fe; color: #4c1d95; }
.g-matrix .m2 { background: #a78bfa; color: #fff; }
.g-matrix .m4 { background: var(--relation); color: #fff; }
.g-matrix .diag { background: var(--border); }
:root[data-theme="dark"] .g-matrix .m1 { background: color-mix(in srgb, var(--relation) 25%, var(--surface)); color: var(--text-strong); }
:root[data-theme="dark"] .g-matrix .m2 { background: color-mix(in srgb, var(--relation) 55%, var(--surface)); color: var(--text-strong); }
:root[data-theme="dark"] .g-matrix .m4 { color: #0f172a; }
.g-matrix .mx-col { writing-mode: vertical-rl; transform: rotate(180deg); height: 44px; text-align: left; white-space: nowrap; }
.g-matrix .mx-row { display: flex; align-items: center; white-space: nowrap; overflow: hidden; }
.g-matrix .mx-sum { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--text); }
.g-caption { font-size: 12px; color: var(--text-muted); margin: 0; }
.g-edge { fill: none; stroke: var(--relation); stroke-linecap: round; }
.g-edge.dim { stroke: var(--text-faint); }
.graph-arrow-dim { fill: var(--text-faint); }
.g-edge-label { font-size: 11px; font-weight: 700; fill: var(--relation); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.g-node { cursor: pointer; outline: none; }
.g-node:focus-visible circle { stroke: var(--text-strong) !important; stroke-width: 3px !important; }
.g-label { font-size: 11px; font-weight: 700; fill: var(--text); pointer-events: none; user-select: none; }
.g-label.on-color { fill: #fff; }
.g-label.center { font-size: 14px; }
.g-label.outside { font-weight: 600; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
#grafo:fullscreen, #grafo.pseudo-fullscreen { background: var(--bg); }

/* Vista Linha do tempo */
#tempo { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
#tempo.hidden { display: none; }
#tempo-main { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
#tempo-bar { display: flex; align-items: center; gap: .6rem; padding: .5rem 1.25rem; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 70%, transparent); overflow-x: auto; }
#tempo-bar > * { flex: 0 0 auto; }
#tempo-bar .flex-1 { flex: 1 1 auto; }
.tempo-year { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--relation); color: var(--relation); border-radius: 8px; padding: .15rem .4rem .15rem .6rem; font-weight: 700; font-size: 13px; }
.tempo-year.b { background: var(--relation); color: var(--accent-text); }
.tempo-year input { width: 4.2rem; background: transparent; color: inherit; border: 0; font: inherit; font-variant-numeric: tabular-nums; }
.tempo-year input:focus { outline: none; }
.tempo-year:focus-within { outline: 2px solid var(--text-faint); outline-offset: 1px; }
#tempo-lanes { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 1.5rem 1.5rem 2rem; }
.tl-ticks { position: relative; height: 20px; margin-left: 120px; }
.tl-ticks span { position: absolute; transform: translateX(-50%); font: 11px ui-monospace, monospace; color: var(--text-faint); white-space: nowrap; }
.tl-body { position: relative; display: flex; flex-direction: column; gap: 6px; }
.tl-overlay { position: absolute; left: 120px; right: 0; top: -4px; bottom: -4px; pointer-events: none; z-index: 2; }
.tl-window { position: absolute; top: 0; bottom: 0; background: rgba(124,58,237,.08); border-left: 2px solid var(--relation); border-right: 2px solid var(--relation); }
:root[data-theme="dark"] .tl-window { background: color-mix(in srgb, var(--relation) 14%, transparent); }
.tl-handle { position: absolute; top: 0; bottom: 0; width: 14px; pointer-events: auto; cursor: ew-resize; touch-action: none; }
.tl-handle[data-edge="a"] { left: -8px; }
.tl-handle[data-edge="b"] { right: -8px; }
.tl-handle:focus-visible { outline: 2px solid var(--relation); outline-offset: 1px; border-radius: 4px; }
.tl-handle-label { position: absolute; right: 50%; font: 700 11px ui-monospace, monospace; color: #fff; background: var(--relation); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
/* A em cima e B embaixo, os dois para a esquerda da borda: não se encavalam nem saem da tela */
.tl-handle[data-edge="a"] .tl-handle-label { top: -22px; }
.tl-handle[data-edge="b"] .tl-handle-label { bottom: -22px; }
:root[data-theme="dark"] .tl-handle-label { color: #0f172a; }
.tl-lane { display: flex; align-items: center; height: 34px; }
.tl-lane-label { width: 120px; flex: 0 0 auto; display: flex; align-items: center; gap: .5rem; font-size: 13px; font-weight: 600; color: var(--text-strong); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.tl-lane-label:hover, .tl-lane-label.on { color: var(--relation); }
.tl-lane-label.on { text-decoration: underline; text-underline-offset: 3px; }
.tl-dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.tl-track { position: relative; flex: 1 1 auto; height: 34px; cursor: pointer; border-radius: 4px; }
.tl-track:hover { background: var(--surface-2); }
.tl-seg { position: absolute; top: 7px; height: 20px; box-sizing: border-box; border: 1px solid; border-radius: 4px; font-size: 10.5px; color: #fff; display: flex; align-items: center; padding-left: 6px; overflow: hidden; white-space: nowrap; }
.tl-seg.ghost { background: var(--surface-2); border-style: dotted; border-color: var(--text-faint); color: var(--text-muted); }
.tl-mark { position: absolute; top: 11px; width: 12px; height: 12px; margin-left: -6px; border-radius: 999px; background: var(--relation); border: 2px solid var(--surface); box-sizing: border-box; z-index: 1; }
.tempo-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; padding: .75rem 1.5rem 1rem; font-size: 12px; color: var(--text-muted); }
.tempo-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.tempo-legend .lg-seg { width: 20px; height: 10px; border-radius: 3px; background: var(--text-strong); }
.tempo-legend .lg-seg.ghost { background: var(--surface-2); border: 1px dotted var(--text-faint); }
.tempo-legend .lg-mark { width: 10px; height: 10px; border-radius: 999px; background: var(--relation); }
.tempo-legend .lg-window { width: 20px; height: 10px; background: rgba(124,58,237,.12); border-left: 2px solid var(--relation); border-right: 2px solid var(--relation); }
#tempo-aside { flex: 0 0 auto; max-height: 45%; overflow-y: auto; background: var(--surface); border-top: 1px solid var(--border); padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
@media (min-width: 1024px) {
    #tempo { flex-direction: row; }
    #tempo-aside { width: 420px; max-height: none; border-top: 0; border-left: 1px solid var(--border); }
}
.diff-legend { display: flex; flex-wrap: wrap; gap: .5rem; font-size: 13px; }
.diff-legend span { border-radius: 6px; padding: .2rem .5rem; font-weight: 600; }
.diff-legend .add { background: color-mix(in srgb, var(--studied) 18%, var(--surface)); color: var(--studied); }
.diff-legend .chg { background: color-mix(in srgb, var(--review) 20%, var(--surface)); color: color-mix(in srgb, var(--review) 70%, var(--text-strong)); }
.diff-legend .rem { background: color-mix(in srgb, #e11d48 15%, var(--surface)); color: #e11d48; }
.diff-group { display: flex; flex-direction: column; gap: .5rem; }
.diff-item { display: grid; grid-template-columns: 20px 1fr; gap: .5rem; font-size: 14px; line-height: 1.45; text-decoration: none; padding: .25rem .35rem; margin: 0 -.35rem; border-radius: 6px; }
.diff-item:hover { background: var(--surface-2); }
.diff-sym { font-size: 15px; }
.diff-sym.add { color: var(--studied); }
.diff-sym.chg { color: var(--review); }
.diff-sym.rem { color: #e11d48; }
.diff-meta { display: block; font-size: 12px; color: var(--text-muted); }
.gen-chain { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: 13px; }
.gen-chip { border: 1.5px solid; border-radius: 6px; padding: .3rem .5rem; color: var(--text-strong); font-weight: 600; }
.gen-chip.dashed { border-style: dashed; }
.gen-chip.ghost { border: 1px dotted var(--text-faint); background: var(--surface-2); color: var(--text-muted); font-weight: 400; }
.gen-arrow { color: var(--text-faint); }

/* Renderizadores no Modo aula: galhos em segundo plano, rótulos maiores, sem badges nem trilha */
.lecture .link.l1 { stroke-width: 3px; stroke-opacity: .4; }
.lecture .link.l2 { stroke-width: 2px; stroke-opacity: .35; }
.lecture.has-sel .link.l1 { stroke-opacity: .15; }
.lecture.has-sel .link.l2 { stroke-opacity: .12; }
.lecture .relation { filter: none; }
.lecture .node.ramo { cursor: default; }
.lecture .node.ramo text.label { font-size: 13px !important; }
.lecture .node.diploma text.label { font-size: 12px !important; }
.lecture .node.center text.label { font-size: 16px !important; }
.lecture .relation-label { font-size: 12px; }
.lecture .node .badge, .lecture .node .trail-mark { display: none !important; }

/* Diálogo */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
dialog::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); }

/* Toast */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--accent-text); font-size: .875rem; padding: .5rem 1rem; border-radius: .5rem; box-shadow: var(--shadow-lg); z-index: 50; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

@media (max-width: 639px) { #legend { display: none !important; } }

/* Impressão: só a árvore e o painel de leitura, em página inteira. */
@media print {
    body { height: auto; overflow: visible; display: block; background: #fff; color: #000; }
    header, #toolbar-row, #legend, .hint, #controls, #outline, #search-results, dialog { display: none !important; }
    #aula-bar, #aula-types, #aula-hint { display: none !important; }
    #aula-stage { height: 60vh; }
    #breadcrumb { border: 0; padding: 0 0 .5rem; font-size: 11pt; }
    #workspace { display: block; }
    #tree-container { position: static; height: 60vh; page-break-inside: avoid; background: #fff; }
    #view-main, #view-compare { position: static; height: 60vh; }
    #reading-panel, #reading-panel.expanded { height: auto; width: auto; min-height: 0; overflow: visible; border: 0; border-top: 1px solid #000; box-shadow: none; display: block; }
    #panel-toggle, .panel-tabs, .panel-foot, #node-actions, #tabpanel-dados { display: none !important; }
    .panel-body { overflow: visible; }
    .tabpanel[hidden] { display: flex; margin-top: 1rem; }
    .print-footer { display: block !important; font-size: 9pt; color: #555; margin-top: 1rem; }
}
.print-footer { display: none; }
