/* ===== Tipografías (alojadas en la herramienta; sin pedidos a terceros) — SIL Open Font License, ver fonts/LICENSE-OFL.txt ===== */
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(/fonts/source-serif-4-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(/fonts/source-serif-4-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 200 900; font-display: swap;
  src: url(/fonts/source-serif-4-latin-wght-italic.woff2) format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(/fonts/source-sans-3-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(/fonts/source-sans-3-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ===== Paleta ===== */
:root {
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Source Sans 3", -apple-system, "Segoe UI", Roboto, sans-serif;

  --paper: #f6f4ef;         /* fondo */
  --surface: #ffffff;       /* tarjetas */
  --surface-2: #faf9f6;     /* campos, zonas secundarias */
  --ink: #1b2331;           /* texto */
  --ink-2: #3a4252;         /* texto secundario fuerte */
  --muted: #6a7080;         /* metadatos */
  --line: #ddd8cd;          /* bordes */
  --line-2: #ebe7de;        /* separadores suaves */
  --navy: #1d3557;          /* principal */
  --navy-2: #152845;        /* principal, hover */
  --on-navy: #ffffff;
  --gold: #a88642;          /* filetes y foco */
  --warn: #8a5a00;
  --warn-bg: #fbf3e2;
  --err: #9b2c2c;
  --ok: #2f6b4f;

  --saij: #2e6b66;          /* verde petróleo */
  --csjn: #7a2e3a;          /* bordó */
  --infoleg: #2c4f7c;       /* azul */
  --doctrina: #7a5a1e;      /* ocre */

  --radius: 6px;
  --shadow: 0 1px 2px rgba(27, 35, 49, .06), 0 1px 1px rgba(27, 35, 49, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161d;
    --surface: #1a1f28;
    --surface-2: #151a22;
    --ink: #e8e6e1;
    --ink-2: #c9c7c1;
    --muted: #9aa0ab;
    --line: #2c333f;
    --line-2: #242a35;
    --navy: #8fb0da;
    --navy-2: #a9c3e6;
    --on-navy: #0f1a2b;
    --gold: #c9a861;
    --warn: #e0b35a;
    --warn-bg: #2a2416;
    --err: #e59393;
    --ok: #86c2a2;
    --saij: #7cc3bb;
    --csjn: #e39aa6;
    --infoleg: #9dbbe3;
    --doctrina: #d9b574;
    --shadow: none;
    color-scheme: dark;
  }
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--navy); text-underline-offset: 2px; }
a:hover { color: var(--navy-2); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.small { font-size: 13px; color: var(--muted); }

/* ===== Encabezado ===== */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px max(16px, calc((100vw - 1000px) / 2));
  background: #1d3557; color: #fff; border-bottom: 3px solid #a88642;
}
header h1 { margin: 0; font-weight: 400; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center; flex-shrink: 0;
  border: 1px solid rgba(201, 168, 97, .7); border-radius: 4px;
  font-family: var(--serif); font-size: 22px; color: #d9bd7e; line-height: 1;
}
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: .2px; line-height: 1.1; }
.brand-sub { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: #c7d2e2; margin-top: 2px; }
header .user { display: flex; gap: 12px; align-items: center; font-size: 14px; color: #dfe6f0; }
header .user button, header .user .btn {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.45); padding: 6px 12px; font-size: 13.5px;
}
header .user button:hover { background: rgba(255,255,255,.08); border-color: #fff; }

main { max-width: 1000px; margin: 0 auto; padding: 24px 16px 72px; }

/* ===== Controles ===== */
input[type=text], input[type=password], input[type=date], input[type=number], select {
  font: inherit; font-size: 14.5px; color: var(--ink); background: var(--surface-2);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }
input[type=checkbox] { accent-color: var(--navy); width: 15px; height: 15px; }
button, a.btn {
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--navy); background: var(--navy); color: var(--on-navy);
  transition: background .12s, border-color .12s, color .12s;
}
button:hover { background: var(--navy-2); border-color: var(--navy-2); }
button.secondary, a.btn {
  background: transparent; color: var(--ink-2); border-color: var(--line); font-weight: 500;
}
button.secondary:hover, a.btn:hover { border-color: var(--navy); color: var(--navy); background: transparent; }
button:disabled { opacity: .55; cursor: default; }

/* ===== Buscador ===== */
form.search {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 18px 14px; display: grid; gap: 14px;
}
.row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
input.q {
  flex: 1 1 320px; font-size: 17px; padding: 11px 14px; background: var(--surface);
  font-family: var(--serif);
}
input.q::placeholder { color: var(--muted); font-style: italic; }
form.search button[type=submit] { padding: 0 24px; min-height: 42px; font-size: 15px; letter-spacing: .02em; align-self: stretch; }
form.search .row:first-child { align-items: stretch; }
.court { font-weight: 600; color: var(--ink-2); }
label.chk { display: inline-flex; gap: 7px; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; }
details.filters { border-top: 1px solid var(--line-2); padding-top: 10px; }
details.filters summary {
  cursor: pointer; color: var(--muted); font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600;
  list-style: none; display: inline-flex; gap: 6px; align-items: center;
}
details.filters summary::-webkit-details-marker { display: none; }
details.filters summary::before { content: "▸"; font-size: 11px; transition: transform .15s; }
details.filters[open] summary::before { transform: rotate(90deg); }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px 24px; margin-top: 12px; }
.filter { display: grid; gap: 5px; align-content: start; }
.filter .small { color: var(--ink-2); font-size: 13.5px; }
.applies { font-size: 12px; color: var(--muted); line-height: 1.4; }

.notice { font-size: 12.5px; color: var(--muted); margin: 14px 2px 4px; font-style: italic; }

/* ===== Secciones por fuente ===== */
.src-section { margin-top: 28px; }
.sec-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  position: relative;
}
.sec-title::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 56px; height: 2px; background: var(--gold); }
.sec-title > .small { font-size: 12.5px; letter-spacing: .04em; white-space: nowrap; }
.sec-toggle {
  all: unset; cursor: pointer; display: inline-flex; gap: 9px; align-items: baseline;
  font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--ink);
}
/* Es un <button>: se anulan los estilos generales de botón (fondo al pasar el mouse) */
button.sec-toggle, button.sec-toggle:hover, button.sec-toggle:active { background: transparent; border: 0; padding: 0; color: var(--ink); }
.sec-toggle:hover span:last-child { color: var(--navy); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.sec-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 3px; }
.chev { display: inline-block; width: 12px; font-family: var(--sans); font-size: 12px; color: var(--muted); }
#sec-SAIJ { --src: var(--saij); }
#sec-CSJN { --src: var(--csjn); }
#sec-INFOLEG { --src: var(--infoleg); }
#sec-SAIJ_DOCTRINA { --src: var(--doctrina); }
.err-text { color: var(--err); }
.warn-line { color: var(--warn); font-size: 13px; margin: 0 0 10px; }
.empty { text-align: center; color: var(--muted); padding: 22px 0; font-style: italic; }
.pager { display: flex; justify-content: center; margin: 14px 0 0; }

/* ===== Tarjeta de resultado ===== */
.result {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--src, var(--navy));
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 20px 14px; margin-bottom: 12px;
}
.result .meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center;
  font-size: 12.5px; color: var(--muted);
}
.result > .meta:first-child { text-transform: uppercase; letter-spacing: .08em; font-size: 11.5px; font-weight: 600; }
.result > .meta:first-child b { color: var(--ink-2); letter-spacing: .04em; }
.result h3 {
  font-family: var(--serif); font-size: 18.5px; font-weight: 600; line-height: 1.3;
  margin: 8px 0 4px; color: var(--ink);
}
.result h3 + .meta { font-size: 13.5px; color: var(--ink-2); margin-bottom: 2px; }
.result .summary {
  font-family: var(--serif); font-size: 16px; line-height: 1.6; color: var(--ink);
  margin: 10px 0 8px; white-space: pre-line;
}
.result .kw { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.result .summary.clamp { display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
button.linklike { background: none; border: none; padding: 0; color: var(--navy); font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: underline; }
.result .actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2);
}
.result .actions a, .result .actions button { font-size: 13.5px; padding: 7px 12px; }
.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 3px;
  color: var(--src, var(--navy)); background: color-mix(in srgb, var(--src, var(--navy)) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--src, var(--navy)) 35%, transparent);
}
.vs { font-size: 10.5px; letter-spacing: .06em; }
.vs.ok { color: var(--ok); }
.vs.ok::before { content: "✓ "; }
.vs.partial { color: var(--warn); }
.vs.partial::before { content: "◌ "; }
.rel { font-size: 13px; margin-top: 6px; }
.rel.ok { color: var(--ok); }
.rel.info { color: var(--muted); }
.rel.warn { color: var(--warn); font-weight: 600; }
.fallos { border-left: 2px solid var(--line); padding: 2px 0 2px 14px; margin: 12px 0 4px; display: grid; gap: 10px; }
.fallos > .small { text-transform: uppercase; letter-spacing: .08em; font-size: 11.5px; }
.fallo-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; font-size: 14.5px; }
.fallo-row > div > div:first-child { font-family: var(--serif); font-weight: 600; }
.fallo-row button { font-size: 13px; padding: 6px 11px; flex-shrink: 0; }

/* ===== Avisos ===== */
.warn {
  background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-left: 3px solid var(--warn); border-radius: var(--radius);
  padding: 10px 12px; font-size: 14px; margin: 10px 0; color: var(--ink);
}
.aviso-fuentes { margin: 0 0 14px; }
.sec-note { color: var(--muted); margin: 0 0 8px; }
.norm-verify .verdict { margin: 10px 0; }
.srcs { display: grid; gap: 6px; margin-top: 10px; }
.src-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.src-cat { width: 100%; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.src-cat .linklike, .linklike { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: 11.5px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.linklike:hover { color: var(--ink); background: none; }
.aviso-fuentes div + div { margin-top: 4px; }
.kv { font-size: 12.5px; color: var(--muted); word-break: break-all; margin: 3px 0; }
.error { color: var(--err); font-size: 14px; min-height: 1.2em; }

/* ===== Página del documento ===== */
.doc-page { max-width: 820px; }
.doc-page > .small { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 600; }
.doc-title { font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1.25; margin: 6px 0 18px; }
.facts {
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 14px; font-size: 14px;
}
.facts > div { display: contents; }
.facts b { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; padding-top: 2px; }
.doc-text {
  font-family: var(--serif); font-size: 17.5px; line-height: 1.7; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 36px clamp(18px, 6vw, 64px); margin-top: 18px; box-shadow: var(--shadow);
}
.doc-text p { margin: 0 0 1em; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
details summary.small { cursor: pointer; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--paper); }
.login {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 28px 24px; display: grid; gap: 14px;
}
.login.oauth { max-width: 460px; font-size: 14.5px; }
.login.oauth p { margin: 4px 0; }
.login.oauth .actions { display: flex; gap: 8px; margin-top: 8px; }
.login.oauth .actions button { flex: 1; }
.login .brand-mark { color: var(--gold); border-color: var(--gold); margin: 0 auto; width: 44px; height: 44px; font-size: 28px; }
.login h1 { font-family: var(--serif); font-size: 24px; font-weight: 600; margin: 4px 0 0; text-align: center; }
.login .brand-sub { color: var(--muted); text-align: center; margin: 0 0 6px; }
.login input { font-size: 15px; padding: 10px 12px; }
.login button { justify-content: center; padding: 11px; font-size: 15px; }

/* ===== Pantallas chicas ===== */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 18px; }
  main { padding: 16px 12px 56px; }
  form.search { padding: 14px; }
  form.search button[type=submit] { width: 100%; justify-content: center; }
  .result { padding: 14px 14px 12px; }
  .result h3 { font-size: 17px; }
  .result .summary { font-size: 15.5px; }
  .fallo-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts b { padding-top: 8px; }
  .doc-title { font-size: 22px; }
  .doc-text { font-size: 16.5px; padding: 20px 16px; text-align: left; }
  .doc-text p { text-align: left; }
}
@media print {
  header, form.search, .actions, .pager, #volver { display: none !important; }
  body { background: #fff; }
  .result, .doc-text, .facts { box-shadow: none; border-color: #ccc; }
}

/* Fallo con varios sumarios */
.result.group .sumario { border-top: 1px dashed var(--line-2); padding-top: 8px; margin-top: 8px; }
.result.group .sumario:first-of-type { border-top: 0; padding-top: 0; }
.sumario-links { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sumario-links a { color: var(--navy); }
button.linklike, button.linklike:hover { all: unset; cursor: pointer; color: var(--navy); text-decoration: underline; text-underline-offset: 2px; font-size: 12.5px; }
details.mas-sumarios { margin-top: 10px; }
details.mas-sumarios > summary { cursor: pointer; font-size: 13px; color: var(--navy); font-weight: 600; }
details.mas-sumarios[open] > summary { margin-bottom: 4px; }
.provenance { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 3px; }
.court[title] { cursor: help; }

/* ===== Pestañas ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
button.tab, button.tab:hover { background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--muted); padding: 8px 14px; font-weight: 600; }
button.tab:hover { color: var(--ink); }
button.tab.active { color: var(--navy); border-bottom-color: var(--gold); }

/* ===== Verificar una cita ===== */
#vform textarea, .vfields textarea { font-family: var(--serif); font-size: 16px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); resize: vertical; }
.vfields { margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px 18px; }
.vfields .vtitle, .vfields .wide, .vfields .row { grid-column: 1 / -1; }
.vfields label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.vfields input { text-transform: none; letter-spacing: 0; font-weight: 400; }
.vfields .inline { display: flex; gap: 6px; align-items: center; }
.vfields .inline input { width: 90px; }
.verdict { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; border-top: 4px solid var(--line); }
.verdict.ok { border-top-color: var(--ok); }
.verdict.warn { border-top-color: var(--warn); }
.verdict.none { border-top-color: var(--muted); }
.verdict-head { display: flex; gap: 10px; align-items: center; font-family: var(--serif); font-size: 22px; font-weight: 600; margin-bottom: 10px; }
.verdict.ok .verdict-head { color: var(--ok); }
.verdict.warn .verdict-head { color: var(--warn); }
.verdict.none .verdict-head { color: var(--ink-2); }
.verdict-icon { font-size: 24px; }
table.diffs { width: 100%; border-collapse: collapse; margin: 6px 0 14px; font-size: 14px; }
table.diffs th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; }
table.diffs td { border-bottom: 1px solid var(--line-2); padding: 7px 8px; vertical-align: top; }
table.diffs td.cited { color: var(--warn); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--warn) 50%, transparent); }
table.diffs td.real { font-weight: 600; }
.vmatch { border-top: 1px solid var(--line-2); padding-top: 10px; }
.vmatch h3 { font-family: var(--serif); font-size: 18px; margin: 6px 0 4px; }
.passage { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius); border-left: 3px solid var(--line); background: var(--surface-2); font-size: 14px; }
.passage.ok { border-left-color: var(--ok); }
.passage.warn { border-left-color: var(--warn); }
.passage blockquote { font-family: var(--serif); margin: 8px 0 0; padding-left: 12px; border-left: 2px solid var(--line); color: var(--ink-2); }
.alts { margin-top: 12px; }
.vsources { margin-top: 12px; }
