/* Leitor de Legislação — visual com tema claro e escuro (variáveis em :root e [data-theme="dark"]) */
:root {
  --fs: 17px;
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f0f2f8; --surface-3: #e8ebf4;
  --ink: #1a1f2e; --ink-2: #39415a; --muted: #6a7389; --line: #e2e6ef; --line-2: #cfd5e3;
  /* identidade Lexico: azul-marinho (marca e botões) e os três pontos da logo (laranja, coral, verde-azulado) */
  --marca: #14213d; --marca-hover: #22335a; --marca-ink: #ffffff; --marca-centro: #14213d;
  --lx-laranja: #f5a623; --lx-coral: #e35d45; --lx-verde: #1f9488;
  --accent: #127a71; --accent-2: #1f9488; --accent-ink: #ffffff; --accent-soft: #e0f2ef;
  --ok: #15803d; --ok-soft: #dcfce7; --bad: #b91c1c; --bad-soft: #fee2e2; --warn: #a16207; --warn-soft: #fef3c7;
  --pop: #eef3fa; --pop-borda: #b9c4da; /* prévia de remissão: tom frio, distinto do papel da lei */
  --paper: #fffdf8; --paper-ink: #1d1d1f; --struck: #9a9aa0; --quote-line: #d8d4cb; --flash: #ffe58a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --radius: 12px;
  --serif: "Source Serif Pro", "Georgia", "Cambria", "Times New Roman", serif;
  /* texto das normas (leitura, prévias, painéis): Roboto, carregada do Google Fonts no index.html */
  --lei: "Roboto", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
  /* cores por tipo de norma */
  --t-constituicao: #b45309; --t-emenda-constitucional: #c2410c; --t-lei-complementar: #7c3aed; --t-lei: #2563eb;
  --t-lei-delegada: #0891b2; --t-medida-provisoria: #db2777; --t-decreto-lei: #0d9488; --t-decreto: #16a34a;
  --t-instrucao-normativa: #65a30d; --t-resolucao: #ca8a04; --t-portaria: #9333ea; --t-outro: #64748b;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1120; --surface: #151a2e; --surface-2: #1b2139; --surface-3: #232a47;
  --ink: #e6e9f2; --ink-2: #c3c9da; --muted: #9099b1; --line: #262d4a; --line-2: #343c5f;
  --marca: #2bb3a5; --marca-hover: #45c4b6; --marca-ink: #0d1120; --marca-centro: #ffffff;
  --accent: #4fc9bb; --accent-2: #2bb3a5; --accent-ink: #0d1120; --accent-soft: #173638;
  --ok: #4ade80; --ok-soft: #12321f; --bad: #f87171; --bad-soft: #3a1717; --warn: #fbbf24; --warn-soft: #3a2e0e;
  --pop: #222b4a; --pop-borda: #46507a;
  --paper: #121729; --paper-ink: #e3e6ee; --struck: #6d7590; --quote-line: #3a4266; --flash: #5b4a12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* o atributo hidden vale mesmo em elementos com display definido (ex.: botões) */
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, .filebtn { font: inherit; font-size: 13.5px; cursor: pointer; border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px;
  padding: 6px 12px; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, transform .05s; }
button:hover, .filebtn:hover { border-color: var(--accent); background: var(--surface-2); }
button:active { transform: translateY(1px); }
button.primary { background: var(--marca); border-color: transparent; color: var(--marca-ink); font-weight: 600; }
button.primary:hover { background: var(--marca-hover); border-color: transparent; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-2); border-color: transparent; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=url], input[type=search], input[type=date], input[type=password], input[type=number], textarea, select {
  font: inherit; font-size: 14px; color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input[type=url], .row input[type=text] { flex: 1; min-width: 200px; }

/* ------------------------------------------------------------------ barra superior */
#topbar { position: fixed; top: 0; left: 0; right: 0; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--line); z-index: 20; }
.brand { border: none; background: none; font-weight: 800; font-size: 19px; letter-spacing: -.035em; white-space: nowrap; padding: 4px 6px;
  color: var(--marca-centro); gap: 7px; }
.brand .logo { width: 30px; height: 30px; flex: none; color: var(--marca-centro); }
.brand .nome { line-height: 1; padding-bottom: 2px; }
.brand:hover { background: none; }
.auth-card .brand .logo { width: 38px; height: 38px; }
.law-title { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.actions button { padding: 5px 10px; font-size: 13px; }
.actions .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.tgl { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.user-area { display: flex; align-items: center; gap: 6px; margin-left: auto; }
body:not(.no-law) .user-area { margin-left: 0; }
#user-menu { position: fixed; top: 52px; right: 12px; z-index: 70; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; }
#user-menu[hidden] { display: none; }
#user-menu button { width: 100%; justify-content: flex-start; border: none; background: none; }
#user-menu button:hover { background: var(--surface-2); }
#user-menu .who { padding: 6px 10px 8px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
body.no-law .law-only, body.no-law #law { display: none !important; }
body:not(.no-law) #home { display: none; }

/* ------------------------------------------------------------------ login */
#auth { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% 10%, rgba(31, 148, 136, .28), transparent 60%),
              radial-gradient(900px 500px at 90% 90%, rgba(245, 166, 35, .22), transparent 60%), var(--bg); }
#auth[hidden] { display: none; }
/* convite durante a leitura: a norma continua visível atrás (a troca obrigatória da senha mantém o fundo opaco) */
#auth:not(.obrigatorio) { background: rgba(10, 14, 28, .55); backdrop-filter: blur(3px); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 30px 28px 24px; }
.auth-card .brand { display: flex; align-items: center; gap: 9px; font-size: 26px; padding: 0; margin-bottom: 4px; }
.auth-card h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 0 0 22px; }
.auth-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; }
.auth-card input { width: 100%; }
.auth-card button.primary { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; font-size: 14.5px; }
.auth-erro { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 10px; }
.auth-aviso { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 4px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px; border: 1px solid var(--line-2);
  border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; box-sizing: border-box; }
.btn-google:hover { background: var(--surface-2); }
.btn-google .g { font-weight: 800; font-size: 16px; background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.btn-google[hidden], .auth-ou[hidden] { display: none; }
.auth-ou { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.auth-ou::before, .auth-ou::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.auth-troca { text-align: center; font-size: 13px; color: var(--muted); margin-top: 12px; }
.auth-troca a { color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ layout da leitura */
#layout { position: fixed; top: 56px; bottom: 0; left: 0; right: 0; display: flex; }
#sidebar { width: 320px; min-width: 240px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; resize: horizontal; }
.side-tools { padding: 10px; display: grid; gap: 6px; border-bottom: 1px solid var(--line); }
#toc { overflow: auto; padding: 8px 10px 40px; font-size: 13px; flex: 1; }
#search-results { overflow: auto; max-height: 45%; border-bottom: 1px solid var(--line); font-size: 13px; padding: 6px 10px; }
#search-results[hidden] { display: none; }
.sr-item { padding: 6px 4px; border-bottom: 1px dotted var(--line); cursor: pointer; }
.sr-item:hover { background: var(--surface-2); }
.sr-item b { color: var(--accent); }
.sr-item em { background: var(--warn-soft); font-style: normal; }
#reader { flex: 1; overflow: auto; position: relative; background: var(--paper); }
body.no-law #reader { background: var(--bg); }
#panel { width: 420px; border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; }
#panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; }
#panel-body { overflow: auto; padding: 12px 14px 40px; font-size: 13.5px; }

.toc-node > summary { padding: 3px 0; list-style: none; display: flex; align-items: flex-start; gap: 4px; }
.toc-node > summary::-webkit-details-marker { display: none; }
.toc-car { cursor: pointer; width: 16px; flex: none; text-align: center; color: var(--muted); border-radius: 4px; transition: transform .15s; line-height: 1.4; }
.toc-car:hover { background: var(--surface-2); color: var(--accent); }
details[open] > summary > .toc-car { transform: rotate(90deg); }
.toc-txt { cursor: pointer; flex: 1; min-width: 0; }
.toc-txt:hover .toc-title, .toc-txt:hover .toc-lbl, .toc-leaf:hover { color: var(--accent); }
.toc-acoes { display: flex; gap: 4px; }
.toc-acoes button { flex: 1; justify-content: center; font-size: 12px; padding: 3px 6px; }
.toc-node .toc-node, .toc-node .toc-leaf, .toc-node .toc-arts { margin-left: 12px; }
.toc-lbl { font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; }
.toc-leaf { padding: 3px 0 3px 14px; cursor: pointer; }
.toc-arts { display: flex; flex-wrap: wrap; gap: 3px; padding: 4px 0 6px 14px; }
.chip { font-size: 11.5px; padding: 1px 7px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--ink); text-decoration: none; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.s-revogado, .chip.s-futuro { color: var(--struck); text-decoration: line-through; }

#breadcrumb { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted); padding: 7px 24px; min-height: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#old-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); padding: 8px 24px; font-size: 13px; }
#old-banner[hidden] { display: none; }
#law { max-width: 860px; margin: 0 auto; padding: 24px 32px 50vh; font-family: var(--lei); font-size: var(--fs); line-height: 1.62; color: var(--paper-ink); }
.law-head { text-align: center; margin-bottom: 28px; }
.epigrafe { font-size: 1.15em; letter-spacing: .02em; margin: 0 0 14px; }
.ementa { margin: 0 0 14px 38%; text-align: justify; font-size: .93em; color: var(--ink-2); }
.preambulo { text-align: justify; text-indent: 2em; }
.fecho { margin-top: 40px; font-size: .9em; color: var(--muted); text-align: center; }
.fecho p { margin: .2em 0; }
.dv { margin: .35em 0; text-align: justify; position: relative; scroll-margin-top: 80px; }
.st { text-align: center; margin: 1.6em 0 .9em; }
.st-lbl { font-weight: 700; letter-spacing: .04em; }
.st-title { font-weight: 700; }
.t-parte .st-lbl, .t-livro .st-lbl { font-size: 1.25em; color: var(--accent); }
.t-titulo .st-lbl { font-size: 1.12em; }
.t-secao .st-lbl, .t-subsecao .st-lbl { font-weight: 600; }
.t-secao .st-title, .t-subsecao .st-title { font-weight: 600; font-style: italic; }
.t-titulo { border-top: 1px solid var(--line); padding-top: 1.2em; }
.anx { border-top: 2px solid var(--line); padding-top: 1.2em; margin-top: 3em; }
.t-artigo { margin-top: 1.1em; text-indent: 2em; }
.t-artigo > .lbl, .t-paragrafo > .lbl { font-weight: 700; }
.t-paragrafo { text-indent: 2em; }
.t-inciso { margin-left: 2.2em; }
.t-alinea { margin-left: 4.2em; }
.t-item { margin-left: 6em; }
.t-texto { text-indent: 2em; color: var(--ink-2); }
.t-inciso > .lbl, .t-alinea > .lbl, .t-item > .lbl { font-weight: 600; }
.tx { white-space: pre-line; }
.nt { font-family: var(--sans); font-size: .7em; color: var(--muted); white-space: normal; }
body.hide-notes .nt, body.hide-notes .st-notes { display: none; }
.s-revogado, .s-futuro { color: var(--struck); }
.s-revogado > .tx, .s-revogado > .lbl, .s-futuro > .tx, .s-futuro > .lbl { text-decoration: line-through; }
body.hide-revoked .dv.s-revogado, .dv.s-futuro { display: none; }
body.hide-revoked .chip.s-revogado, .chip.s-futuro { display: none; }
.s-vetado { color: var(--muted); }
.quote { margin: .4em 0 .8em 3em; padding-left: 1em; border-left: 3px solid var(--quote-line); font-size: .93em; color: var(--ink-2); }
.quote p { margin: .25em 0; }
.q-struck { text-decoration: line-through; color: var(--struck); }
body.hide-revoked .q-struck { display: none; }
.tbl-wrap { overflow-x: auto; margin: .8em 0; }
.anx-tbl { border-collapse: collapse; font-family: var(--sans); font-size: .78em; }
.anx-tbl td, .anx-tbl th { border: 1px solid var(--quote-line); padding: 3px 6px; vertical-align: top; text-align: left; }
.flash { animation: flash 2.2s ease-out; }
@keyframes flash { 0% { background: var(--flash); } 100% { background: transparent; } }
.ref { color: var(--accent); border-bottom: 1px dotted var(--accent); cursor: pointer; }
.ref:hover { background: var(--accent-soft); }
.ref-ext { border-bottom: 1px dashed var(--muted); }
.ref-broken { border-bottom: 1px dashed var(--bad); }
.ref-ext, .ref-broken { cursor: help; }
.ref-man { border-bottom-style: solid; }
.pv-status { font-family: var(--sans); font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.pv-status .bad, .aj-prev .bad { color: var(--bad); }
.pv-status .ok { color: var(--ok); }
.aj-q { font-family: var(--lei); font-size: 15px; margin: 0 0 4px; }
.aj-op { display: block; margin: 10px 0 4px; }
.aj-in { width: 100%; box-sizing: border-box; margin-left: 0; }
.aj-prev { font-size: 12.5px; color: var(--ok); min-height: 1em; margin-top: 4px; }
.modal-box.wide { width: min(1000px, 96vw); }
.aj-dest { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; margin: 4px 0 6px 22px; }
.aj-col { min-width: 0; }
.aj-sub { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.aj-sub .muted { font-weight: 400; }
.aj-arv { height: 300px; overflow: auto; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: var(--surface-2); font-size: 13px; }
.tr-row { display: flex; gap: 6px; align-items: baseline; padding: 2px 4px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.tr-row:hover { background: var(--accent-soft); }
.tr-row.foco { outline: 1px dashed var(--accent); }
.tr-row.sel { background: var(--accent); color: var(--accent-ink); }
.tr-row.sel .tr-tx { color: inherit; }
.tr-car { width: 14px; flex: none; color: var(--muted); text-align: center; }
.tr-lbl { font-weight: 600; flex: none; }
.tr-tx { color: var(--muted); overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tr-add { flex: none; padding: 0 7px; font-size: 12px; line-height: 1.5; visibility: hidden; }
.tr-row:hover .tr-add, .tr-row.sel .tr-add { visibility: visible; }
.tr-kids { margin-left: 12px; border-left: 1px dotted var(--line-2); padding-left: 2px; }
.tr-n.s-revogado > .tr-row .tr-tx { text-decoration: line-through; }
.aj-leg { border-collapse: collapse; font-size: 12.5px; margin-top: 10px; width: 100%; }
.aj-leg th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
.aj-leg td, .aj-leg th { padding: 2px 6px; vertical-align: top; }
.aj-leg td.mono { white-space: nowrap; }
.aj-nota { font-size: 12px; margin-top: 6px; }
@media (max-width: 760px) { .aj-dest { grid-template-columns: 1fr; margin-left: 0; } }
.tools { margin-left: 6px; white-space: nowrap; text-indent: 0; display: inline-block; }
.ico { font-family: var(--sans); font-size: 12px; padding: 0 6px; border-radius: 10px; color: var(--muted); line-height: 18px; }
.ico sup { font-size: 9px; }
.nbtn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
mark.hl { color: inherit; border-radius: 2px; padding: 0 1px; cursor: pointer; }
.hl-amarelo { background: #fff07a; } .hl-verde { background: #b9f3c0; } .hl-azul { background: #bfe0ff; } .hl-rosa { background: #ffc9e3; }
[data-theme="dark"] .hl-amarelo { background: #6b5d0f; } [data-theme="dark"] .hl-verde { background: #1f5a2b; }
[data-theme="dark"] .hl-azul { background: #1d4a78; } [data-theme="dark"] .hl-rosa { background: #6b2550; }
mark.has-note { border-bottom: 2px solid var(--warn); }

#popover { position: fixed; z-index: 50; max-width: 560px; max-height: 60vh; overflow: auto; background: var(--pop); color: var(--ink); border: 1px solid var(--pop-borda); border-top: 4px solid var(--accent-2); border-radius: 10px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.04); padding: 10px 14px 10px; font-family: var(--lei); font-size: 14.5px; line-height: 1.5; }
.pv-line { margin: .2em 0; text-align: justify; }
.pv-paragrafo { margin-left: .6em; }
.pv-inciso { margin-left: 1.4em; } .pv-alinea { margin-left: 2.8em; } .pv-item { margin-left: 4.2em; }
.pv-hit { background: var(--warn-soft); border-radius: 3px; }
.pv-gap { color: var(--muted); margin: .15em 0; }
.pv-link { color: var(--accent); cursor: pointer; text-decoration: underline; }
.pv-art + .pv-art { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.pv-actions { margin-top: 10px; display: flex; gap: 6px; font-family: var(--sans); font-size: 12.5px; }
.pv-line.s-revogado { text-decoration: line-through; }
#seltool, #markmenu { position: fixed; z-index: 60; background: #23263a; border-radius: 10px; padding: 5px; display: flex; gap: 4px; box-shadow: var(--shadow-lg); }
#seltool[hidden], #markmenu[hidden], #popover[hidden], #backbtn[hidden], #modal[hidden] { display: none; }
#seltool button, #markmenu button { background: #343850; color: #fff; border: none; font-size: 12.5px; }
#seltool button:hover, #markmenu button:hover { background: #474c69; }
.sw { width: 22px; height: 22px; border-radius: 50% !important; padding: 0 !important; }
.sw-amarelo { background: #ffe94d !important; } .sw-verde { background: #7ee08a !important; } .sw-azul { background: #7fbfff !important; } .sw-rosa { background: #ff9ccd !important; }
#backbtn { position: fixed; bottom: 22px; left: 340px; z-index: 30; background: var(--accent); color: var(--accent-ink); border: none; box-shadow: var(--shadow-lg); }
#toast { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: grid; gap: 6px; }
.toast { background: #23263a; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow-lg); max-width: 460px; }
.toast.err { background: #a51d2d; }
#modal { position: fixed; inset: 0; background: rgba(8, 10, 20, .45); backdrop-filter: blur(2px); z-index: 90; display: flex; align-items: center; justify-content: center; }
.modal-box { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 18px 20px; width: min(600px, 92vw); max-height: 85vh; overflow: auto; }
.modal-box h3 { margin-top: 0; }
.modal-box textarea { width: 100%; min-height: 130px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.texto-bruto { white-space: pre-wrap; font-family: var(--lei); font-size: 14px; line-height: 1.55; max-height: 55vh; overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }

/* ------------------------------------------------------------------ painéis laterais da leitura */
.pn-sec { margin-bottom: 18px; }
.pn-sec h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.pn-item { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: var(--surface); }
.pn-item .path { font-size: 11.5px; color: var(--muted); cursor: pointer; }
.pn-item .path:hover { color: var(--accent); }
.pn-item .q { font-family: var(--lei); margin: 4px 0; }
.pn-item .note { background: var(--warn-soft); border-left: 3px solid var(--warn); padding: 4px 8px; white-space: pre-wrap; }
.badge { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 8px; background: var(--surface-3); margin-right: 4px; text-transform: uppercase; letter-spacing: .03em; }
.b-incluido { background: var(--ok-soft); color: var(--ok); } .b-alterado { background: var(--warn-soft); color: var(--warn); }
.b-revogado, .b-excluido { background: var(--bad-soft); color: var(--bad); }
ins { background: var(--ok-soft); text-decoration: none; } del { background: var(--bad-soft); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.ver-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dotted var(--line); }
body.show-ids .dv[data-id]::after { content: attr(data-id); font-family: var(--mono); font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 4px; padding: 0 5px; margin-left: 8px; text-indent: 0; display: inline-block; }
table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.grid td, table.grid th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }

/* ------------------------------------------------------------------ catálogo (tela inicial) */
#home { height: 100%; }
#cat-layout { display: flex; height: 100%; }
#cat-side { width: 270px; flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 8px; }
.side-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
#folder-tree { overflow: auto; padding: 0 8px 20px; flex: 1; font-size: 14px; }
.fd { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--ink-2); user-select: none; }
.fd:hover { background: var(--surface-2); }
.fd.sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fd .fd-ico { width: 18px; text-align: center; flex: none; }
.fd .fd-nome { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd .fd-qtd { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 0 7px; }
.fd .fd-acoes { display: none; gap: 2px; }
.fd:hover .fd-acoes { display: flex; }
.fd:hover .fd-qtd { display: none; }
.fd .fd-acoes button { padding: 1px 6px; font-size: 12px; border: none; background: transparent; }
.fd .fd-acoes button:hover { background: var(--surface-3); }
.fd-filhos { margin-left: 14px; border-left: 1px dashed var(--line-2); padding-left: 4px; }
.fd.drop { outline: 2px dashed var(--accent); }
.side-sep { height: 1px; background: var(--line); margin: 8px 6px; }
#cat-main { flex: 1; min-width: 0; overflow: auto; padding: 22px 28px 60px; }
.cat-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.cat-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.cat-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 140px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; letter-spacing: -.01em; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.c1 b { color: var(--accent); } .stat.c2 b { color: var(--t-decreto-lei); } .stat.c3 b { color: var(--ok); } .stat.c4 b { color: var(--t-lei-complementar); }
.cat-search { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); }
.cat-search input[type=search] { flex: 1; border: none; box-shadow: none !important; font-size: 15px; padding: 8px 10px; background: transparent; }
.cat-search .lupa { padding-left: 8px; color: var(--muted); font-size: 16px; }
#cat-adv { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 22px; }
#cat-adv[hidden] { display: none; }
.flt h5 { margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.flt label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; padding: 2px 0; cursor: pointer; }
.flt label .n { margin-left: auto; color: var(--muted); font-size: 12px; }
.flt .anos { display: flex; gap: 6px; align-items: center; }
.flt .anos input { width: 90px; }
.flt-acoes { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
#cat-ativos { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 10px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.pill button { border: none; background: none; padding: 0 2px; color: inherit; font-size: 13px; }
#cat-bulk { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 13.5px; }
#cat-bulk[hidden] { display: none; }
#cat-bulk b { margin-right: 6px; }
.cat-table-wrap { margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
#cat-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
#cat-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
#cat-table th[data-ordem] { cursor: pointer; }
#cat-table th[data-ordem]:hover { color: var(--accent); }
#cat-table th .seta { color: var(--accent); }
#cat-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
#cat-table tr:last-child td { border-bottom: none; }
#cat-table tbody tr { transition: background .1s; }
#cat-table tbody tr:hover { background: var(--surface-2); }
#cat-table tbody tr.sel { background: var(--accent-soft); }
#cat-table .c-chk { width: 34px; }
#cat-table .c-nome { min-width: 230px; }
#cat-table .c-nome a { font-weight: 600; color: var(--ink); text-decoration: none; cursor: pointer; }
#cat-table .c-nome a:hover { color: var(--accent); }
#cat-table .c-nome .cod { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#cat-table .c-data { white-space: nowrap; color: var(--ink-2); }
#cat-table .c-ementa { color: var(--ink-2); max-width: 560px; }
#cat-table .c-ementa .ementa-txt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tp { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap;
  color: var(--tc, var(--t-outro)); background: color-mix(in srgb, var(--tc, var(--t-outro)) 14%, transparent); }
.vg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.vg::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.vg-vigente { color: var(--ok); background: var(--ok-soft); }
.vg-nao_vigente { color: var(--bad); background: var(--bad-soft); }
.vg-nao_informada { color: var(--muted); background: var(--surface-2); }
.esf { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.est { font-size: 11px; padding: 0 6px; border-radius: 6px; background: var(--ok-soft); color: var(--ok); }
.fpill { font-size: 11px; padding: 0 7px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); }
.cat-vazio { padding: 40px; text-align: center; color: var(--muted); }
#cat-pag { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
#cat-pag .row { gap: 6px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); margin-bottom: 12px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin: 0 0 10px; }
.card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.lib-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); margin-bottom: 8px; }
.lib-item h4 { margin: 0 0 4px; font-size: 15px; cursor: pointer; color: var(--accent); }
.lib-item p { margin: 0; font-size: 12.5px; color: var(--muted); }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 8px; background: var(--surface-3); color: var(--ink-2); margin-left: 6px; text-transform: uppercase; }
.pastas-lista { display: grid; gap: 4px; max-height: 50vh; overflow: auto; margin: 6px 0 10px; }
.pastas-lista label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.pastas-lista label:hover { background: var(--surface-2); }

@media (max-width: 900px) {
  #cat-side { display: none; }
  #cat-main { padding: 16px; }
  #cat-table .c-ementa { display: none; }
}
@media print {
  #topbar, #sidebar, #panel, #breadcrumb, #backbtn, #toast, .tools, #popover, #seltool { display: none !important; }
  #layout, #reader { position: static; overflow: visible; display: block; background: #fff; }
  #law { padding: 0; max-width: none; color: #000; }
  .ref { color: inherit; border: none; }
}

/* painel Gestão (js/gestao.js) */
#gestao { position: fixed; inset: 0; z-index: 95; background: rgba(8, 10, 20, .45); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; }
#gestao[hidden] { display: none; }
.gs-box { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: min(1100px, 100%); max-height: 92vh; display: flex; flex-direction: column; }
.gs-cab { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.gs-cab h3 { margin: 0; font-size: 17px; }
.gs-abas { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.gs-abas button.ativa { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#gs-corpo { padding: 14px 18px; overflow: auto; }
.gs-topo { margin-bottom: 2px; }
.gs-tab { width: 100%; border-collapse: collapse; font-size: 13px; }
.gs-tab th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px; }
.gs-tab td { border-bottom: 1px solid var(--line); padding: 6px; vertical-align: top; }
.b-pendente { background: var(--warn-soft); color: var(--warn); } .b-comunidade { background: var(--accent-soft); color: var(--accent); }
.b-aprovada { background: var(--ok-soft); color: var(--ok); } .b-rejeitada { background: var(--bad-soft); color: var(--bad); }
.ref-glob { border-bottom-style: double; }
.aj-aviso { background: var(--accent-soft); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; margin: 6px 0 2px; }

/* ---------- abas (normas abertas) */
#abas { position: fixed; top: 56px; left: 0; right: 0; height: 34px; display: flex; align-items: flex-end; gap: 2px; padding: 0 10px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); z-index: 19; overflow-x: auto; overflow-y: hidden; }
#abas[hidden] { display: none; }
body.com-abas #layout { top: 90px; }
.aba { display: flex; align-items: center; gap: 4px; max-width: 240px; padding: 4px 6px 4px 12px; font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0; background: var(--surface-3); cursor: pointer; white-space: nowrap; flex: none; }
.aba:hover { color: var(--ink); }
.aba.ativa { background: var(--paper); color: var(--ink); font-weight: 600; position: relative; top: 1px; }
.aba-t { overflow: hidden; text-overflow: ellipsis; }
.aba-x { border: none; background: transparent; padding: 0 5px; font-size: 15px; line-height: 1.2; color: var(--muted); border-radius: 5px; }
.aba-x:hover { background: var(--surface); color: var(--bad); }
/* ---------- remissão a outra norma */
.ref-ext.ref-out { color: var(--accent-2); border-bottom: 1px dotted var(--accent-2); cursor: pointer; }
.ref-ext.ref-out:hover { background: var(--accent-soft); }
.pv-ext b { color: var(--ink); }
.aj-ext { margin: 4px 0 6px 22px; }
.ae-sel { margin: 2px 0 6px; font-size: 14px; }
.ae-res { max-height: 180px; overflow: auto; margin-top: 4px; }
.ae-item { padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ae-item:hover { background: var(--accent-soft); }
.cit-item { font-size: 13px; }
@media print { #abas { display: none !important; } body.com-abas #layout { top: 0; } }

/* ---------- pop-up de importação */
#importar { position: fixed; inset: 0; z-index: 95; background: rgba(8, 10, 20, .45); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 12px; }
#importar[hidden] { display: none; }
.imp-box { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: min(680px, 100%); max-height: 84vh; overflow: auto; }
.imp-cab { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.imp-cab h3 { margin: 0; font-size: 17px; }
.imp-corpo { padding: 6px 18px 18px; }
.imp-corpo h4 { margin: 14px 0 8px; font-size: 14px; }
.imp-corpo .row input[type=url] { flex: 1; min-width: 0; }
.imp-fontes { margin: 0 0 6px; padding-left: 20px; font-size: 13px; line-height: 1.55; }
.imp-fontes li { margin-bottom: 3px; }

/* jurisprudência */
.jbtn { color: var(--accent); }
.ju-head { margin-bottom: 2px; }
.ju-item.ju-inativa .q { color: var(--muted); }
.ju-aprox { font-size: 12px; margin-top: 4px; }
.ju-mais { margin-top: 4px; font-size: 12.5px; }
.ju-mais > div { margin: 3px 0; }
.ju-devs { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; margin: 4px 0; }
.ju-devs a { text-decoration: none; }
.ju-devs a:hover { text-decoration: underline; }

/* leitura pública: convite ao login */
.auth-motivo { background: var(--accent-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin: -8px 0 16px; line-height: 1.45; }
.auth-depois { text-align: center; font-size: 12.5px; margin-top: 10px; }
.auth-depois a { color: var(--muted); }
#auth.obrigatorio .auth-depois { display: none; }
#btn-entrar { padding: 5px 16px; }

/* desempenho: o navegador só calcula o layout dos dispositivos perto da área visível (a Constituição tem ~25 mil
   elementos; calcular tudo levava ~2,4 s). contain-intrinsic-size guarda a altura medida de cada um depois de desenhado. */
#law > .dv, #law > .quote, #law > .anx-p, #law > .tbl-wrap { content-visibility: auto; contain-intrinsic-size: auto 2.4em; }
@media print { #law > .dv, #law > .quote, #law > .anx-p, #law > .tbl-wrap { content-visibility: visible; } }

/* ---------- celular e telas estreitas (até 900px)
   O índice da norma (#sidebar) e as pastas do catálogo (#cat-side) viram uma gaveta que abre pelo ☰ (body.gaveta);
   as ações da norma vão para o menu ⋯ (body.menu-acoes); os painéis ocupam a tela; a prévia de remissão vira uma
   folha presa à borda da tela (#popover.folha). A lógica fica em app.js (gaveta, menuAcoes, posicionarPopover). */
.so-celular { display: none !important; }
#gaveta-fundo { display: none; position: fixed; inset: 0; z-index: 44; background: rgba(8, 10, 20, .4); }
@media (max-width: 900px) {
  .so-celular { display: inline-flex !important; }
  body.no-law #btn-mais { display: none !important; }
  #btn-gaveta, #btn-mais { font-size: 20px; padding: 2px 10px; }
  #topbar { gap: 4px; padding: 0 6px; }
  .brand { padding: 4px 2px; }
  .brand .nome, #user-nome { display: none; }
  .law-title { font-size: 13px; }
  .user-area { gap: 2px; }
  #btn-entrar { padding: 5px 10px; }

  body.gaveta #gaveta-fundo, body.menu-acoes #gaveta-fundo { display: block; }
  body.menu-acoes #gaveta-fundo { background: transparent; }
  #sidebar, #cat-side { position: fixed; top: 56px; bottom: 0; left: 0; width: min(86vw, 340px); z-index: 46; resize: none;
    transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.com-abas #sidebar, body.com-abas #cat-side { top: 90px; }
  body.gaveta #sidebar, body.gaveta #cat-side { transform: none; }
  #cat-side { display: flex; }
  body:not(.no-law) #cat-side { display: none; }

  /* ações da norma: menu suspenso */
  .actions { display: none; }
  body.menu-acoes .actions { display: flex; position: fixed; top: 52px; right: 8px; z-index: 47; flex-direction: column; align-items: stretch; gap: 2px;
    min-width: 220px; max-height: calc(100vh - 70px); overflow: auto; padding: 6px; background: var(--surface); border: 1px solid var(--line);
    border-radius: 10px; box-shadow: var(--shadow-lg); }
  body.menu-acoes .actions button { justify-content: flex-start; border-color: transparent; padding: 9px 12px; font-size: 14px; }
  body.menu-acoes .actions .tgl { padding: 8px 12px; font-size: 14px; }
  body.menu-acoes .actions .sep { width: auto; height: 1px; margin: 4px 0; }

  /* painel (anotações, versões, jurisprudência…) ocupa a tela */
  #panel { position: fixed; top: 56px; left: 0; right: 0; bottom: 0; width: auto; z-index: 45; }
  body.com-abas #panel { top: 90px; }

  /* texto da norma */
  #law { padding: 14px 14px 50vh; }
  #breadcrumb, #old-banner { padding-left: 14px; padding-right: 14px; }
  .ementa { margin-left: 0; }
  .t-artigo, .t-paragrafo, .preambulo, .t-texto { text-indent: 1.2em; }
  .t-inciso { margin-left: 1em; } .t-alinea { margin-left: 2em; } .t-item { margin-left: 3em; }
  .quote { margin-left: .6em; padding-left: .7em; }

  /* prévia de remissão como folha na borda da tela */
  #popover.folha { left: 8px !important; right: 8px; max-width: none; max-height: 52vh; }
  .pv-actions { flex-wrap: wrap; }
  .pv-actions button { padding: 8px 12px; }

  #seltool { flex-wrap: wrap; max-width: calc(100vw - 16px); justify-content: center; }
  #seltool button { padding: 8px 10px; }
  .sw { width: 30px; height: 30px; }
  #backbtn { left: 12px; bottom: 16px; }
  #toast { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
  #abas { padding: 0 4px; }
  .aba { max-width: 170px; }
  #cat-main { padding: 14px 12px 60px; }
  /* tabela do catálogo: sem Esfera e Ementa (colunas 4 e 6); no celular, só seleção, Norma e Vigência */
  #cat-table th:nth-child(4), #cat-table td:nth-child(4), #cat-table th:nth-child(6), #cat-table td:nth-child(6) { display: none; }
  .cat-head h1 { font-size: 21px; }
}
@media (max-width: 600px) {
  #cat-table th:nth-child(3), #cat-table td:nth-child(3), #cat-table th:nth-child(5), #cat-table td:nth-child(5) { display: none; }
  #cat-table .c-nome { min-width: 0; }
  #cat-table td, #cat-table th { padding: 9px 6px; }
  #cat-table .c-chk { width: 28px; }
}
/* telas de toque (sem mouse): o que só aparecia ao passar o mouse fica sempre visível */
@media (hover: none) {
  .tr-add { visibility: visible; }
  .fd .fd-acoes { display: flex; }
  .fd .fd-qtd { display: none; }
  .aba-x { padding: 2px 8px; }
}
