/* PANDECTA VISUAL R1 — CANONICAL V2 STYLESHEET */
/* Zero external dependencies · Strict CSP compliant · High-performance SSR */

:root,
:root[data-theme-root="b"] {
  --heading-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --body-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Color Palette — Contemporary blue (owner-selected option B) */
  --accent: #155a82;            /* Azul principal */
  --accent-dark: #103f60;       /* Azul oscuro para interacción y hover */
  --accent-sky: #2e83b0;        /* Celeste de apoyo, solo decorativo */
  --accent-soft: #eaf4f9;       /* Fondo celeste tenue para badges y chips */
  --ink: #17283a;               /* Slate profundo para lectura crítica */
  --ink-secondary: #334155;     /* Slate medio para subtítulos */
  --muted: #4a5568;             /* Gris medio para metadatos y sumarios */
  --muted-light: #5f6e80;       /* Etiquetas y placeholders con contraste AA */
  --paper: #ffffff;             /* Blanco puro para tarjetas y hojas */
  --surface-subtle: #f8fafc;    /* Fondo sutil de rails */
  --wash: #f4f9fc;              /* Fondo global celeste claro */
  --line: #d7e1eb;              /* Divisor tenue */
  --line-strong: #abb8c7;       /* Divisor enfático */
  --control-border: #7f90a5;    /* Borde de campos con contraste 3:1 */
  --focus: #155a82;             /* Foco visible de alto contraste */
  
  /* Status Colors */
  --status-active-bg: #e6f4ea;   /* Verde bosque tenue para Vigente */
  --status-active-text: #137333;
  --status-caution-bg: #fef7e0;  /* Ámbar tenue para Vigente con medidas/reformas */
  --status-caution-text: #995500;
  --danger: #9d2929;
  --highlight-match: #fef08a;    /* Resaltador suave para búsquedas */

  /* Typography Stacks (Native System Only - Zero External Fonts) */
  --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --reader-font: ui-serif, Georgia, "Times New Roman", Cambria, serif;

  /* Sizing & Spacing Scale */
  --max: 1180px;
  --reading: 72ch;               /* ~760px ancho óptimo de lectura */
  --control-height: 44px;        /* Mínimo accesible táctil */
  --control-height-lg: 52px;     /* Altura de buscador protagonista */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius: 8px;
  --radius-pill: 9999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  font-family: var(--ui-font);
  color: var(--ink);
  background: var(--wash);
}

/* Reset & Accessibility */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--wash); line-height: 1.55; color: var(--ink); }
body, input, select, button, textarea { font-family: var(--ui-font); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.shell { width: min(calc(100% - 48px), var(--max)); margin-inline: auto; }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 100; }
.skip-link:focus { left: 16px; top: 16px; padding: 10px 16px; color: var(--paper); background: var(--accent); border-radius: var(--radius-sm); }

/* Typography */
h1, h2, h3, h4 { margin-top: 0; color: var(--ink); line-height: 1.22; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.eyebrow { margin-bottom: 8px; color: var(--accent); font-size: 12px; line-height: 1.2; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.lede { max-width: 68ch; color: var(--muted); font-size: 1.1rem; line-height: 1.55; }
.muted { color: var(--muted); font-size: 13px; }

/* Global Header (RESTRICTION-01: Single Unified Header) */
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--paper); background: var(--accent); border-radius: var(--radius-sm); box-shadow: inset 0 -3px 0 var(--accent-sky); font-size: 18px; font-weight: 800; }
.brand .wordmark { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; color: var(--ink); }
.brand small { display: none; }

.site-nav { display: flex; align-items: center; gap: 24px; font-size: 14px; font-weight: 600; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 6px 2px; position: relative; }
.site-nav a:hover { color: var(--accent); }
.site-nav a.active { color: var(--accent); font-weight: 700; border-bottom: 2px solid var(--accent); }
.menu-toggle { display: none; background: transparent; border: 1px solid var(--line); padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; color: var(--ink); font-size: 18px; }

/* Global Footer */
.site-footer { margin-top: 80px; padding: 32px 0 40px; color: var(--muted); border-top: 1px solid var(--line); background: var(--paper); font-size: 13px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.footer-brand strong { color: var(--ink); font-size: 14px; }
.footer-nav { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-nav a { color: var(--muted); text-decoration: none; }
.footer-nav a:hover { color: var(--accent); text-decoration: underline; }

/* Form Controls & Buttons */
input, select, button, .button-link, .secondary-link { min-height: var(--control-height); padding: 9px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--ink); background: var(--paper); font-size: 15px; }
input, select, textarea { border-color: var(--control-border); }
input::placeholder { color: var(--muted-light); }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 1px var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: none; }
button, .button-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-color: var(--accent); color: #ffffff; background: var(--accent); font-weight: 700; text-decoration: none; cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease; }
button:hover, .button-link:hover { color: #ffffff; background: var(--accent-dark); border-color: var(--accent-dark); }
.secondary-link { display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--accent); border-color: var(--line); background: var(--paper); font-weight: 600; text-decoration: none; cursor: pointer; }
.secondary-link:hover { border-color: var(--accent); background: var(--surface-subtle); }
.quiet-link { color: var(--muted); font-size: 13px; text-decoration: none; font-weight: 500; }
.quiet-link:hover { color: var(--accent); text-decoration: underline; }

/* Scope Switcher */
.scope-switcher { display: inline-flex; background: var(--accent-soft); padding: 3px; border-radius: var(--radius-pill); margin-bottom: 20px; border: 1px solid var(--line); gap: 2px; }
.scope-switcher a, .scope-switcher button { min-height: 32px; padding: 5px 18px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; border-radius: var(--radius-pill); text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s ease; }
.scope-switcher a.active, .scope-switcher button.active { background: var(--paper); color: var(--accent); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.scope-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-sky); display: inline-block; }

/* Search Inputs with Icon */
.search-input-wrapper { position: relative; flex: 1; display: flex; align-items: center; min-width: 0; }
.search-input-wrapper .search-icon { position: absolute; left: 16px; color: var(--muted-light); pointer-events: none; flex-shrink: 0; }
.search-input-wrapper input { width: 100%; padding-left: 44px; }

/* Home Screen */
.home-hero { max-width: 860px; margin: 44px auto 60px; text-align: center; }
.home-hero .eyebrow { margin-bottom: 12px; }
.home-hero h1 { font-size: clamp(2rem, 3.8vw, 2.6rem); margin-bottom: 12px; font-weight: 800; color: var(--ink); }
.home-hero .lede { margin: 0 auto 28px; max-width: 64ch; font-size: 1.05rem; }
.home-search { max-width: 800px; margin: 0 auto; text-align: left; }
.home-search .search-row { display: flex; gap: 10px; }
.home-search input { min-height: var(--control-height-lg); font-size: 15px; border-radius: var(--radius); }
.home-search button { min-height: var(--control-height-lg); padding-inline: 26px; font-size: 15px; border-radius: var(--radius); font-weight: 700; }
.home-search .form-hint { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
.home-trust { margin-top: 36px; }
.legislation-search-title { margin-bottom: 0; font-size: 24px; }
.legislation-result-year { font-size: 12px; }
.legislation-shortcuts-grid { margin-top: 24px; }

/* Thematic Discovery Grid (Home) */
.thematic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; max-width: 860px; margin: 44px auto 0; text-align: left; }
.shortcut-box { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.shortcut-box h2 { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.shortcut-box-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.shortcut-box-header h2 { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.see-all-codes-link { font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; white-space: nowrap; }
.see-all-codes-link:hover { text-decoration: underline; }
.touch-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.touch-chip { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 14px; background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 500; transition: all 0.15s ease; }
.touch-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.norm-cards-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; background: #ffffff; }
.norm-card-link { display: block; padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 500; transition: all 0.15s ease; }
.norm-card-link:last-child { border-bottom: none; }
.norm-card-link:hover { background: var(--surface-subtle); color: var(--accent); }

/* Search Page & Results */
.search-page { max-width: 1100px; margin: 32px auto 80px; }
.search-header-compact { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }
.search-header-compact h1 { font-size: 24px; font-weight: 800; color: var(--ink); margin: 0; }
.search-form-compact { margin-bottom: 20px; }
.search-form-compact .search-row { display: flex; gap: 10px; }
.search-form-compact input { border-radius: var(--radius-md); font-size: 15px; }
.search-form-compact button { border-radius: var(--radius-md); padding-inline: 22px; font-size: 15px; }

/* Filter Console Box & Active Chips */
.filter-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; }
.filters { border: none; margin: 0; padding: 0; background: transparent; }
.filters-summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 13.5px; color: var(--ink); user-select: none; }
.filters-summary:hover .filters-toggle-text { color: var(--accent); }
.filters-toggle-text { font-size: 13px; font-weight: 600; color: var(--muted); }
.filters-toggle-tail { white-space: nowrap; }
.filter-console { padding-top: 16px; margin-top: 14px; border-top: 1px solid var(--line); }
.filter-grid-4col { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.filter-group { min-width: 0; }
.filter-group label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.filter-group select, .filter-group input { width: 100%; min-width: 0; max-width: 100%; font-size: 13.5px; height: 38px; min-height: 38px; }
.date-inputs { display: flex; gap: 8px; }
.date-inputs input { flex: 1; min-width: 0; }
.filter-actions-bar { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 14px; }

/* Active Facet Chips Bar */
.facet-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--surface-subtle); }
.facet-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--accent-soft); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; font-weight: 600; color: var(--accent); text-decoration: none; transition: background-color 0.15s; }
.facet-chip:hover { background: #dce7f0; }
.facet-chip-remove { font-size: 12px; font-weight: 700; line-height: 1; }

/* Results List — Card-Table Row Architecture */
.results-meta-bar { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 12px; font-size: 13px; color: var(--muted); }
.results-meta-bar strong { color: var(--ink); font-weight: 700; font-size: 13.5px; }
.results-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }

.result-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; display: grid; grid-template-columns: 210px 1fr 130px; gap: 20px; align-items: start; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.result-card:hover { border-color: var(--line-strong); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03); }

/* Zone 1: Context Rail (Left) */
.context-rail { display: flex; flex-direction: column; gap: 8px; border-right: 1px solid var(--line); padding-right: 18px; height: 100%; }
.context-court { font-size: 13px; font-weight: 700; line-height: 1.35; color: var(--ink); }
.context-instance { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); line-height: 1.35; }
.context-fuero { display: inline-block; padding: 2px 8px; background: var(--accent-soft); border-radius: var(--radius-sm); color: var(--accent); font-size: 11px; font-weight: 700; width: fit-content; letter-spacing: 0.02em; }
.context-date { font-size: 12px; font-weight: 600; color: var(--muted-light); margin-top: auto; }

/* Status Badges */
.status-badge { display: inline-block; padding: 3px 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; width: fit-content; text-transform: uppercase; letter-spacing: 0.04em; }
.status-badge.vigente { background: var(--status-active-bg); color: var(--status-active-text); }
.status-badge.modificada { background: var(--status-caution-bg); color: var(--status-caution-text); }

/* Zone 2: Primary Content (Center) */
.primary-content { min-width: 0; display: flex; flex-direction: column; }
.result-title { margin: 0 0 8px; font-size: 16.5px; font-weight: 700; line-height: 1.35; }
.result-title a { color: var(--ink); text-decoration: none; }
.result-title a:hover { color: var(--accent); text-decoration: underline; }

/* Factual Fallback for Uncaptioned Cases (DEC-05) */
.fallback-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.fallback-id { font-family: monospace; font-size: 15px; font-weight: 700; color: var(--ink); }
.fallback-note { font-size: 12px; color: var(--muted-light); font-style: italic; font-family: var(--ui-font); }

.result-snippet { margin: 0 0 10px; font-size: 13.5px; line-height: 1.55; color: var(--ink-secondary); }
.result-snippet mark, mark.match, .document-highlight { background: var(--highlight-match); color: var(--ink); padding: 1px 3px; border-radius: 2px; }

.result-badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.source-badge { display: inline-block; padding: 2px 8px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.03em; }

/* Zone 3: Action Area (Right) */
.action-area { display: flex; flex-direction: column; gap: 10px; align-items: stretch; height: 100%; }
.action-area .button-link, .action-area button { min-height: 38px; padding: 6px 12px; font-size: 13px; font-weight: 700; width: 100%; border-radius: var(--radius-md); background: var(--accent); color: #ffffff; border: 1px solid var(--accent); display: flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; transition: background-color 0.15s ease; }
.action-area .button-link:hover, .action-area button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.action-area .pdf-link { font-size: 12px; color: var(--muted); text-decoration: none; font-weight: 600; padding: 4px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: auto; }
.action-area .pdf-link:hover { color: var(--accent); text-decoration: underline; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 40px 0; font-size: 13.5px; }
.pagination a, .pagination span { min-height: 36px; min-width: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper); text-decoration: none; color: var(--ink); font-weight: 600; }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current-page { background: var(--accent); color: #ffffff; border-color: var(--accent); font-weight: 700; }
.pagination [aria-disabled="true"] { color: var(--muted-light); background: var(--wash); border-color: var(--line); cursor: not-allowed; }
.pagination-ellipsis { border: none !important; background: transparent !important; color: var(--muted); cursor: default; }

/* Document Reader (Fallo & Norm) */
.reader-page { max-width: 1140px; margin: 0 auto 96px; }
.sticky-utility-bar { position: sticky; top: 64px; z-index: 30; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px; margin: 16px 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: 0 2px 6px rgba(0,0,0,0.03); }
.sticky-utility-bar .back-link { font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; white-space: nowrap; }
.in-doc-search { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 440px; }
.in-doc-search input { height: 34px; min-height: 34px; padding: 4px 10px; font-size: 13px; width: 100%; border-radius: var(--radius-sm); }
.in-doc-search .match-count { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.nav-arrows { display: inline-flex; gap: 2px; }
.nav-arrow-btn { min-height: 28px; padding: 2px 8px; font-size: 12px; border-radius: var(--radius-sm); }

/* Pre-Documental Header (Rich Contextual Card) */
.pre-documental-header { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.pre-documental-header h1 { font-size: 22px; line-height: 1.3; margin-bottom: 12px; }
.fact-strip { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.fact-strip span + span::before { content: "·"; margin-right: 16px; color: var(--line-strong); }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tag-chip { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.summary-box { background: var(--surface-subtle); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px; font-size: 14px; line-height: 1.55; }
.summary-box h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.summary-box p { margin: 0; }
.citation-provenance { font-size: 12px; color: var(--muted); margin-top: 12px; }

/* Open Legal Reading Folio (84ch centered open surface without heavy card box) */
.document-folio { max-width: 84ch; margin: 0 auto; background: var(--paper); border: none; border-radius: 0; box-shadow: none; padding: 36px 40px; }
.reading-text { font-family: var(--reader-font); font-size: 17.5px; line-height: 1.78; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Legislation Specifics */
.pre-normative-header { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.norm-relation-card { background: var(--surface-subtle); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 16px; font-size: 13.5px; }
.relation-header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.norm-relation-card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; font-weight: 700; }
.relation-count-badge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 10px; border: 1px solid var(--line); }
.relation-compact-list { list-style: none; padding: 0; margin: 0 0 10px; }
.relation-compact-list li { margin: 6px 0; font-size: 13.5px; line-height: 1.45; }
.relation-role-tag { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: var(--radius-sm); text-transform: uppercase; letter-spacing: 0.03em; margin-right: 4px; }
.relations-expandable { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.relations-expand-summary { font-size: 13px; font-weight: 700; color: var(--accent); cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 4px 0; user-select: none; }
.relations-expand-summary::-webkit-details-marker { display: none; }
.relations-expand-summary:hover { color: var(--accent-dark); }
.expand-chevron { font-size: 12px; transition: transform 0.2s ease; }
.relations-expandable[open] .expand-chevron { transform: rotate(180deg); }
.relation-expanded-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.relation-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.relation-group h3, .relation-group h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 4px; }
.relation-group ul { list-style: none; padding: 0; margin: 0; }
.relation-group li { margin: 4px 0; font-size: 13px; line-height: 1.4; }
.utility-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.utility-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.article-jump-select { height: 34px; min-height: 34px; padding: 4px 10px; font-size: 13px; font-family: var(--ui-font); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }
.fact-item { display: inline-flex; align-items: center; gap: 4px; }
.action-btn { display: inline-flex; align-items: center; justify-content: center; height: 34px; min-height: 34px; padding: 4px 14px; font-size: 13px; font-weight: 600; text-decoration: none; border-radius: var(--radius-sm); border: 1px solid var(--line); color: var(--ink); background: var(--paper); transition: all 0.15s; }
.action-btn:hover { background: var(--surface-subtle); border-color: var(--line-strong); }
.action-btn.action-primary { background: var(--accent); color: #ffffff; border-color: var(--accent); }
.action-btn.action-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.article-block { border-top: 1px solid var(--line); padding: 24px 0; }
.article-block:first-child { border-top: none; }
.article-title { font-family: var(--ui-font); font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.norm-division-title { font-family: var(--ui-font); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 24px 0 12px; }

/* Responsive Layout — Tablet & Mobile */
@media (max-width: 900px) {
  .result-card { grid-template-columns: 180px 1fr 110px; gap: 14px; padding: 16px; }
  .thematic-grid { grid-template-columns: 1fr; gap: 16px; }
  .filter-grid-4col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-folio { padding: 32px 24px; }
}

@media (max-width: 768px) {
  .shell { width: min(calc(100% - 32px), var(--max)); }
  .header-inner { min-height: 56px; }
  .menu-toggle { display: inline-flex; }
  .site-nav { display: none; width: 100%; flex-direction: column; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
  .site-nav.open { display: flex; }
  
  /* Result Card Mobile Stack (Deliberate Vertical Flow) */
  .result-card { grid-template-columns: 1fr; gap: 12px; }
  .context-rail { border-right: 0; border-bottom: 1px solid var(--line); padding-right: 0; padding-bottom: 10px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .action-area { flex-direction: column; align-items: stretch; margin-top: 4px; }
  .action-area .button-link, .action-area button { min-height: 44px; font-size: 14px; }
  
  .filter-grid-4col { grid-template-columns: minmax(0, 1fr); }
  .home-search .search-row { flex-direction: column; }
  .home-search button { min-height: 44px; width: 100%; }
  .search-form-compact .search-row { flex-direction: column; }
  .search-form-compact .search-row input, .search-form-compact .search-row button { width: 100%; min-width: 0; }
  
  .sticky-utility-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .utility-left, .utility-right { width: 100%; justify-content: space-between; gap: 10px; }
  .article-jump-select { max-width: 100%; flex: 1; min-height: 44px; }
  .action-btn { min-height: 44px; width: 100%; }
  .in-doc-search { max-width: 100%; order: 3; flex-basis: 100%; }
  
  .document-folio { padding: 24px 16px; border-inline: none; border-radius: 0; }
  .reading-text { font-size: 16px; line-height: 1.7; }
  
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 390px) {
  .shell { width: calc(100% - 24px); }
  .pre-documental-header, .pre-normative-header { padding: 16px; }
  .result-card { padding: 14px; }
}

/* Codes Library Surface (R1.1B Redesign) */
.codes-library-page { max-width: 1140px; margin: 0 auto 80px; }
.jurisdiction-codes-section { margin-bottom: 40px; }
.jurisdiction-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
  margin-bottom: 20px;
}
.jurisdiction-title {
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--ink);
}
.jurisdiction-count-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.code-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  min-height: 44px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.code-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.code-card:active {
  transform: translateY(1px);
}
.code-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.code-law-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}
.code-category-badge {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.code-card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 12px;
  flex-grow: 1;
}
.code-card:hover .code-card-title {
  color: var(--accent);
}
.code-card-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--surface-subtle);
}
.code-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  transition: transform 0.15s;
}
.code-card:hover .code-cta {
  transform: translateX(3px);
}

/* Editorial Analysis Index (R1.1B Layout) */
.analysis-page { max-width: 900px; margin: 0 auto 96px; }
.analysis-list { display: flex; flex-direction: column; gap: 20px; margin-top: 28px; }
.analysis-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.analysis-item:hover {
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}
.analysis-item-meta-top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 10px;
}
.court-label { font-weight: 500; }
.decision-date { color: var(--muted); }
.analysis-item-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 10px;
}
.analysis-item-title a {
  color: var(--ink);
  text-decoration: none;
}
.analysis-item-title a:hover {
  color: var(--accent);
}
.analysis-item-subtitle {
  font-size: 14.5px;
  color: var(--ink-secondary);
  line-height: 1.55;
  margin: 0 0 16px;
}
.analysis-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.analysis-read-link {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.analysis-read-link:hover {
  text-decoration: underline;
}

/* Editorial Analysis Reader (R1.1B Editorial Strategy) */
.analysis-reader { max-width: 820px; margin: 0 auto 96px; }
.editorial-header {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}
.editorial-meta-top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}
.editorial-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.28;
  color: var(--ink);
  margin: 0 0 12px;
}
.editorial-subtitle {
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--ink-secondary);
  margin: 0 0 18px;
}
.editorial-meta-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding-top: 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.source-header-link a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.source-header-link a:hover {
  text-decoration: underline;
}

/* Summary Panel: Single discrete editorial panel, no AI chatbot cards */
.editorial-summary-panel {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  margin: 24px 0 32px;
}
.summary-item {
  margin-bottom: 16px;
}
.summary-item:last-child {
  margin-bottom: 0;
}
.summary-item + .summary-item {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.summary-label {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0 6px;
}
.summary-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0;
}

/* Continuous Reading Column (76-82ch) */
.editorial-body {
  max-width: 80ch;
  margin: 32px 0;
  font-family: var(--reader-font);
  font-size: 17.5px;
  line-height: 1.8;
  color: var(--ink);
}
.editorial-section {
  margin-bottom: 32px;
}
.editorial-section-heading {
  font-family: var(--body-font);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.editorial-prose {
  white-space: pre-line;
}

/* Mandatory Source Document Card */
.analysis-source-card {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 36px;
}
.analysis-source-info strong {
  display: block;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 2px;
}
.analysis-source-info span {
  font-size: 13px;
  color: var(--muted);
}

/* Codes Page Header */
.codes-page-header {
  margin-bottom: 28px;
}
.codes-back-row {
  margin-bottom: 14px;
}
.codes-back-row .back-link,
.codes-back-row .quiet-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}
.codes-back-row .back-link:hover,
.codes-back-row .quiet-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Editorial Metadata Layout */
.editorial-meta-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 14px;
}
.analysis-item-meta-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
}
.editorial-court-date {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.editorial-court-date .court-label {
  color: var(--muted);
}
.editorial-court-date .meta-sep {
  color: var(--muted);
  user-select: none;
}
.editorial-court-date .decision-date {
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 768px) {
  .codes-grid { grid-template-columns: 1fr; gap: 12px; }
  .code-card { padding: 14px 16px; }
  .analysis-item { padding: 18px 20px; }
  .analysis-item-title { font-size: 18px; }
  .editorial-header { padding: 20px; }
  .editorial-title { font-size: 22px; }
  .editorial-subtitle { font-size: 15px; }
  .editorial-summary-panel { padding: 16px 18px; }
  .editorial-body { font-size: 16px; line-height: 1.7; }
  .analysis-source-card { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
  .editorial-meta-top,
  .analysis-item-meta-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .editorial-court-date {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }
  .editorial-court-date .meta-sep {
    display: none;
  }
}

@media (max-width: 390px) {
  .code-card-title { font-size: 15px; }
  .editorial-title { font-size: 20px; }
  .editorial-header { padding: 16px; }
}

textarea{width:100%;font:inherit;border:1px solid var(--control-border);border-radius:var(--radius);padding:.72rem .78rem;background:#fff;color:var(--ink);resize:vertical}
.admin-actions{display:flex;gap:1rem;align-items:center;flex-wrap:wrap}

/* Production layout rules synchronized from the live CSS overlay. */
.summary-label, .match-label { margin: 2px 0 3px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; }
.card-summary { color: var(--ink); }
.match-label { color: var(--muted); margin-top: 2px; }
@media (max-width: 760px) {
  .card-summary { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
  .match-context { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
}
.editorial-page pre { max-width: 100%; box-sizing: border-box; white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: auto; }
.editorial-page small { overflow-wrap: anywhere; }
/* Optional semantic search mode; text remains the checked default. */
.search-mode-choice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin: 14px 0 4px; padding: 0; border: 0; }
.search-mode-choice legend { margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.search-mode-choice label { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-secondary); font-size: 14px; }
.search-mode-choice input { accent-color: var(--accent); }
.search-mode-note { max-width: 80ch; margin: 3px 0 14px; color: var(--muted); font-size: 12px; }
.filter-unavailable-select:disabled { opacity: .72; cursor: not-allowed; }
.filter-unavailable .navigation-note { margin: 6px 0 0; }
