* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: contain;
  transition: background .25s ease, color .25s ease;
}

/* ---------- THEME: DARK (negro y amarillo) ---------- */
body[data-theme="dark"] {
  --bg: #0d0d0d;
  --bg-alt: #161616;
  --surface: #1a1a1a;
  --surface-2: #212121;
  --border: #2b2b2b;
  --text: #f5f5f0;
  --text-dim: #a8a8a0;
  --accent: #f5c518;
  --accent-grad: #f5c518;
  --accent-text: #14120a;
  --accent-soft: rgba(245, 197, 24, .14);
  --danger: #e05a4e;
  --shadow: 0 8px 24px rgba(0,0,0,.45);
  --header-bg: linear-gradient(120deg, #ffdd66 0%, #f5c518 45%, #d69f0a 80%, #b0810a 100%);
  --nav-bg: #121212;
}

/* ---------- THEME: LIGHT (verde y blanco, degradado) ---------- */
body[data-theme="light"] {
  --bg: #eef8f1;
  --bg-alt: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2fbf5;
  --border: #d9ece0;
  --text: #123023;
  --text-dim: #5c7d6c;
  --accent: #1f9d5a;
  --accent-grad: linear-gradient(135deg, #5be0a0, #14a866 45%, #0a6b3a);
  --accent-text: #ffffff;
  --accent-soft: rgba(31, 157, 90, .12);
  --danger: #d1483a;
  --shadow: 0 8px 24px rgba(31,157,90,.16);
  --header-bg: linear-gradient(120deg, #3fd68e 0%, #1cb06a 45%, #0d7a47 80%, #085430 100%);
  --nav-bg: #ffffff;
}
body[data-theme="light"] #app {
  background:
    radial-gradient(620px 420px at 112% -8%, rgba(63, 214, 142, .55), transparent 68%),
    radial-gradient(520px 400px at -12% 18%, rgba(20, 168, 102, .32), transparent 70%),
    radial-gradient(640px 480px at 100% 82%, rgba(10, 107, 58, .30), transparent 72%),
    radial-gradient(500px 360px at 10% 98%, rgba(91, 224, 160, .28), transparent 70%),
    linear-gradient(180deg, #d8f3e3 0%, #eafaf1 28%, #ffffff 64%);
  background-attachment: fixed;
}
body[data-theme="light"] .bottom-nav,
body[data-theme="light"] .modal {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
}
body[data-theme="light"] .side-menu {
  background: linear-gradient(180deg, #d8f3e3 0%, #ffffff 70px);
}

#app { min-height: 100vh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; position: relative; }
body[data-textsize="large"] #app { zoom: 1.15; }

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px calc(14px + env(safe-area-inset-top,0px));
  background: var(--header-bg);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { flex: 1; }
.topbar-title h1 {
  font-size: 19px; font-weight: 800;
  color: var(--text);
}
body[data-theme="light"] .topbar-title h1 { color: #fff; }
body[data-theme="dark"] .topbar-title h1 { color: #14120a; }
.topbar-title p { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
body[data-theme="light"] .topbar-title p { color: rgba(255,255,255,.85); }
body[data-theme="dark"] .topbar-title p { color: rgba(20,18,10,.7); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: none;
  background: var(--surface-2); color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
body[data-theme="light"] .icon-btn { background: rgba(255,255,255,.22); color: #fff; }
body[data-theme="dark"] .icon-btn { background: rgba(20,18,10,.16); color: #14120a; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- SIDE MENU ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.overlay.hidden { display: none; }
.side-menu {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 50;
  background: linear-gradient(180deg, #2c2410 0%, var(--bg-alt) 70px);
  border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 2px;
  transform: translateX(0); transition: transform .2s ease;
  overflow-y: auto;
}
.side-menu.hidden { transform: translateX(-110%); display: flex; }
.side-menu-title { font-weight: 800; font-size: 18px; padding: 4px 6px 18px; color: var(--accent); }
.side-item {
  display: flex; align-items: center; gap: 14px; padding: 10px 10px;
  border: none; background: transparent; color: var(--text-dim); font-size: 15px; font-weight: 600;
  text-align: left; cursor: pointer; border-radius: 16px;
  border-bottom: 1px solid var(--border);
}
.side-item:last-child { border-bottom: none; }
.side-item .si-icon {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%;
  background: var(--accent-grad); display: flex; align-items: center; justify-content: center;
}
.side-item .si-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--accent-text); stroke-width: 1.8; flex-shrink: 0; }
.side-item.active {
  background: var(--accent-grad); color: var(--accent-text);
  border-bottom-color: transparent; box-shadow: var(--shadow);
}
.side-item.active .si-icon { box-shadow: 0 0 0 2px rgba(0,0,0,.12); }
.side-item:hover:not(.active) { color: var(--text); }

/* ---------- MAIN / VIEWS ---------- */
main { flex: 1; padding: 16px 16px 90px; }
.view.hidden { display: none; }

.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow);
}
.search-bar svg { width: 18px; height: 18px; fill: none; stroke: var(--text-dim); stroke-width: 2; flex-shrink: 0; }
.search-placeholder { color: var(--text-dim); font-size: 14.5px; }
.search-bar input {
  border: none; outline: none; background: transparent; color: var(--text);
  font-size: 14.5px; width: 100%; font-family: inherit;
}
.search-bar input::placeholder { color: var(--text-dim); }

.code-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.code-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text); text-align: center;
  box-shadow: var(--shadow);
}
.code-card-icon {
  width: 58px; height: 58px; border-radius: 18px; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.code-card-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--accent-text); stroke-width: 1.8; }
.code-card-icon svg.icon-filled,
.si-icon svg.icon-filled,
.quick-btn svg.icon-filled {
  fill: currentColor; stroke: none;
}
.code-card-icon svg.icon-filled { color: var(--accent-text); width: 34px; height: 34px; }
.si-icon svg.icon-filled { color: var(--accent-text); width: 24px; height: 24px; }
.quick-btn svg.icon-filled { color: var(--accent); width: 24px; height: 24px; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.quick-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-dim); cursor: pointer;
}
.quick-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.8; }

.section-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 10px; }
.section-head h2 { font-size: 15px; font-weight: 700; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer; }

.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 12px; cursor: pointer;
}
.recent-item .ri-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-grad); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.recent-item .ri-icon svg { width: 15px; height: 15px; fill: none; stroke: var(--accent-text); stroke-width: 2; }
.recent-item .ri-main { flex: 1; min-width: 0; }
.recent-item .ri-main .ri-title { font-size: 13.5px; font-weight: 600; }
.recent-item .ri-main .ri-sub { font-size: 11.5px; color: var(--text-dim); }
.recent-item .ri-time { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.recent-item .chev { color: var(--text-dim); }

/* ---------- LIST VIEW ---------- */
.list-title { font-size: 17px; font-weight: 800; margin: 16px 0 10px; }
.list-title-row { display: flex; justify-content: space-between; align-items: center; }
.list-title-row .list-title { margin: 16px 0 10px; }
.link-btn-danger { color: var(--danger); }

.gaceta-banner {
  position: relative; margin: 0 -16px 14px; overflow: hidden;
  background: #fff;
}
.gaceta-banner img { display: block; width: 100%; height: auto; }
.gaceta-banner::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 46px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, var(--bg) 100%);
  pointer-events: none;
}
.article-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.article-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 13px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
  position: relative; overflow: hidden;
}
.article-row.is-derogado::after,
.detail-article.is-derogado::after {
  content: 'DEROGADO';
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-16deg);
  font-size: 26px; font-weight: 800; letter-spacing: .08em; white-space: nowrap;
  color: var(--accent); opacity: .2; pointer-events: none;
}
.detail-article.is-derogado::after { font-size: 40px; }
.article-row .ar-num { font-size: 13px; font-weight: 700; color: var(--accent); }
.article-row .ar-epigrafe { font-size: 12.5px; font-weight: 600; color: var(--text); }
.article-row .ar-snippet { font-size: 12px; color: var(--text-dim); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.article-row.is-vacante { opacity: .85; }
.article-row .ar-badge-vacante {
  align-self: flex-start; font-size: 10.5px; font-weight: 800; letter-spacing: .03em;
  color: var(--accent-text); background: var(--accent-grad); border: none;
  border-radius: 20px; padding: 3px 10px; text-transform: uppercase;
}
.load-more {
  display: block; margin: 14px auto 0; padding: 10px 22px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--accent); font-weight: 700; cursor: pointer;
}
.load-more.hidden { display: none; }

.filter-row { display: flex; gap: 8px; margin-top: 12px; }
.filter-chip {
  padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.filter-chip.active { background: var(--accent-grad); color: var(--accent-text); border-color: var(--accent); }

/* ---------- DETAIL ---------- */
.back-btn {
  display: flex; align-items: center; gap: 9px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 800; margin-bottom: 16px; padding: 9px 16px 9px 12px;
  border-radius: 999px; background: var(--accent-grad); color: var(--accent-text);
  /* Sin esto, en vistas largas (ej. Historial de Consultas) el botón vuelve a
     quedar fuera de pantalla al bajar y hay que subir todo para encontrarlo.
     El offset tiene que ser igual a la altura real del topbar (que sí es
     sticky y tiene más z-index): si no, este botón queda "pegado" pero
     tapado detrás del topbar en vez de debajo. */
  position: sticky; top: calc(70px + env(safe-area-inset-top, 0px)); z-index: 15;
}
.back-btn:active { filter: brightness(.92); }
.back-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; flex-shrink: 0; }
.detail-body h2 { font-size: 13.5px; color: var(--text-dim); font-weight: 600; margin-bottom: 2px; }
.detail-body h1 { font-size: 22px; font-weight: 800; color: var(--accent); margin-bottom: 14px; }
.detail-article { position: relative; }
.detail-epigrafe { font-size: 14.5px; font-weight: 700; margin-bottom: 10px; }
.detail-text { font-size: 15px; line-height: 1.65; color: var(--text); white-space: pre-wrap; }
.reform-note {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border-left: 3px solid var(--accent);
  font-size: 12.5px; line-height: 1.55; color: var(--text-dim); font-style: italic;
}
.reform-note strong { color: var(--text); font-style: normal; }

.vacante-banner {
  padding: 14px 16px; border-radius: 12px; background: var(--surface-2);
  border-left: 3px solid var(--text-dim);
}
.vacante-banner-label {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .03em;
  text-transform: uppercase; color: var(--accent-text); background: var(--accent-grad);
  border-radius: 20px; padding: 3px 11px; margin-bottom: 8px;
}
.vacante-banner p { font-size: 13.5px; line-height: 1.55; color: var(--text); }

.historica-note {
  margin-top: 10px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border-left: 3px solid var(--text-dim);
  font-size: 12.5px; line-height: 1.55; color: var(--text-dim);
}
.historica-note strong { color: var(--text); }
.historica-note q { font-style: italic; }

.concordancia-note { margin-top: 10px; }
.concordancia-note .cn-label {
  font-size: 11.5px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; display: block;
}
.concordancia-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.concordancia-chip {
  padding: 5px 11px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); color: var(--accent); font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.concordancia-chip:hover { background: var(--accent-soft); }

.boletin-note { margin-bottom: 10px; }
.boletin-chip {
  padding: 5px 11px; border-radius: 20px; border: 1px dashed var(--border);
  background: var(--surface); color: var(--text-dim); font-size: 12px; font-weight: 700;
}
.boletin-caveat { font-size: 11px; color: var(--text-dim); margin-top: 6px; font-style: italic; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.action-btn {
  flex: 1 1 calc(50% - 5px); min-width: 0; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer;
}
.action-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.action-btn.is-fav { color: var(--danger); border-color: var(--danger); }
.action-btn.is-fav svg { fill: var(--danger); }
.action-btn.primary { background: var(--accent-grad); color: var(--accent-text); border-color: var(--accent); }

.detail-section-head { display: flex; justify-content: space-between; align-items: center; margin: 26px 0 10px; }
.detail-section-head h3 { font-size: 14.5px; font-weight: 700; }
.placeholder-card {
  background: var(--surface); border: 1px dashed var(--border); border-radius: 12px;
  padding: 16px; font-size: 12.5px; color: var(--text-dim); text-align: center;
}

.note-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 8px;
}
.note-card .nc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.note-card .nc-type { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.note-card .nc-date { font-size: 11px; color: var(--text-dim); }
.note-card .nc-del { background: none; border: none; color: var(--danger); font-size: 11px; cursor: pointer; }
.note-card p { font-size: 13.5px; line-height: 1.5; }
.note-card img { width: 100%; border-radius: 8px; margin-top: 4px; }
.note-card audio { width: 100%; margin-top: 4px; }

/* ---------- NOTAS LIST ---------- */
.notas-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.notas-list .note-card { cursor: pointer; }
.notas-list .nc-article { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }

.empty-state { text-align: center; color: var(--text-dim); font-size: 13px; padding: 40px 20px; line-height: 1.6; }
.empty-state.hidden { display: none; }

/* ---------- SETTINGS ---------- */
.settings-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; margin-top: 14px;
}
.settings-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; }
.settings-note { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; margin: 6px 0; }
.theme-switch { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.theme-opt { padding: 7px 14px; border-radius: 8px; border: none; background: transparent; color: var(--text-dim); font-size: 12.5px; font-weight: 700; cursor: pointer; }
.theme-opt.active { background: var(--accent-grad); color: var(--accent-text); }

.primary-btn {
  width: 100%; padding: 12px; border-radius: 10px; border: none; background: var(--accent-grad);
  color: var(--accent-text); font-weight: 700; font-size: 13.5px; cursor: pointer; margin-top: 6px;
}
.primary-btn.hidden { display: none; }
.ghost-btn {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: transparent;
  color: var(--danger); font-weight: 700; font-size: 13.5px; cursor: pointer; margin-top: 8px;
}
.ghost-btn.hidden { display: none; }
.secondary-btn {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: transparent;
  color: var(--text); font-weight: 700; font-size: 13.5px; cursor: pointer; margin-top: 8px;
}

.settings-row-text { display: flex; flex-direction: column; gap: 2px; }
.settings-row-sub { font-size: 11.5px; font-weight: 500; color: var(--text-dim); }
.settings-card .settings-row + .settings-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.toggle-switch {
  width: 46px; height: 27px; border-radius: 20px; border: none; background: var(--surface-2);
  padding: 3px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center;
}
.toggle-knob { width: 21px; height: 21px; border-radius: 50%; background: var(--text-dim); transition: transform .18s ease, background .18s ease; }
.toggle-switch.active { background: var(--accent-grad); }
.toggle-switch.active .toggle-knob { transform: translateX(19px); background: var(--accent-text); }

.settings-card-link {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.settings-link-chevron { width: 18px; height: 18px; fill: none; stroke: var(--text-dim); stroke-width: 2.4; flex-shrink: 0; }

.settings-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.settings-list li { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }
.settings-list strong { color: var(--text); }
.settings-inline-link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 700; font-size: inherit; cursor: pointer; text-decoration: underline; }

.settings-contact { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.settings-contact-item { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; }
.settings-contact-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; flex-shrink: 0; }
.settings-card a { color: var(--accent); }

.settings-aviso { font-size: 11.5px; color: var(--text-dim); line-height: 1.6; text-align: center; margin: 22px 0 4px; }

.sug-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-dim); margin: 14px 0 6px; }
.sug-label:first-child { margin-top: 0; }
.sug-field {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 13.5px; font-family: inherit;
}
.sug-textarea { resize: vertical; }

/* ---------- BOTTOM NAV ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  display: flex; background: var(--nav-bg); border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom,0px));
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-dim); font-size: 10.5px; cursor: pointer; padding: 4px;
}
.nav-item svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { fill: var(--accent-soft); }
.nav-item svg.icon-filled { fill: currentColor; stroke: none; }
.nav-item.active svg.icon-filled { fill: currentColor; }

/* ---------- MODAL ---------- */
.modal {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60;
  max-width: 536px; margin: 0 auto;
  background: var(--surface); border-radius: 18px; padding: 16px; box-shadow: var(--shadow);
}
.modal.hidden { display: none; }
.modal-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.modal-tab {
  flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-dim); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.modal-tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.note-textarea {
  width: 100%; min-height: 110px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); padding: 12px; font-size: 14px; font-family: inherit; resize: vertical;
}
.note-panel.hidden { display: none; }
.record-btn {
  padding: 10px 18px; border-radius: 10px; border: none; background: var(--danger); color: #fff;
  font-weight: 700; cursor: pointer; margin-right: 10px;
}
.record-btn.recording { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
#audioTimer { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.note-panel audio, .note-panel img { display: block; width: 100%; margin-top: 12px; border-radius: 10px; }
#imageFileInput { color: var(--text); font-size: 13px; }

/* ---------- NOTA IMAGEN: escáner (foto + recorte + filtros) ---------- */
.scan-step.hidden { display: none; }
.scan-hint { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.crop-stage {
  position: relative; width: 100%; touch-action: none; user-select: none;
  border-radius: 10px; overflow: hidden; background: #000;
}
.crop-stage img { display: block; width: 100%; margin: 0; border-radius: 0; }
.crop-box {
  position: absolute; border: 2px solid var(--accent); background: rgba(245,197,24,.12);
  box-shadow: 0 0 0 999px rgba(0,0,0,.45); pointer-events: none;
}
.crop-handle {
  position: absolute; width: 26px; height: 26px; margin: -13px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--accent-text);
  cursor: grab; touch-action: none;
}
.scan-actions { display: flex; gap: 10px; margin-top: 12px; }
.scan-actions .primary-btn, .scan-actions .secondary-btn { flex: 1; }
#scanStepFilter .filter-row { margin-top: 10px; flex-wrap: wrap; }
#scanCanvas.hidden { display: none; }

@media (min-width: 640px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ---------- JURISPRUDENCIA ---------- */
.jur-subtitle { font-size: 12px; color: var(--text-dim); margin: -6px 0 14px; }
.jur-loading { text-align: center; padding: 40px 20px; color: var(--text-dim); font-size: 13.5px; }
.jur-loading.hidden { display: none; }
#jurApp.hidden { display: none; }
.jur-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.jur-filters input, .jur-filters select {
  flex: 1 1 calc(50% - 4px); min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px;
  font-family: inherit;
}
.jur-actions { display: flex; gap: 10px; margin-top: 10px; }
.jur-actions .primary-btn, .jur-actions .secondary-btn { flex: 1; }
.jur-info { font-size: 11.5px; color: var(--text-dim); margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .03em; }
.jur-card .jur-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.jur-card .jur-tipo-tag {
  display: inline-block; padding: 1px 8px; border-radius: 20px; border: 1px solid var(--accent);
  color: var(--accent); font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.jur-pagination { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.jur-pagination button {
  padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 700; cursor: pointer; font-size: 13px;
}
.jur-pagination button:disabled { opacity: .35; cursor: default; }
.jur-pagination button.current { background: var(--accent-grad); color: var(--accent-text); border-color: var(--accent); }
.jur-meta-grid { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--text-dim); margin: 10px 0 16px; }
.jur-meta-grid b { color: var(--text); }
.jur-resumen { font-size: 13.5px; font-style: italic; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5; }
mark { background: var(--accent); color: var(--accent-text); padding: 0 2px; border-radius: 2px; }

/* ---------- IMPRESIÓN: solo el artículo, sin chrome de la app ---------- */
@media print {
  body, #app, main { background: #fff !important; color: #000 !important; height: auto !important; overflow: visible !important; }
  main { padding: 0 !important; }
  .topbar, .side-menu, .overlay, .bottom-nav, .back-btn,
  .view:not(#view-detail):not(#view-jurdetail),
  .detail-actions, .detail-section-head, #detailNotes,
  .placeholder-card, .boletin-note {
    display: none !important;
  }
  .detail-body h2 { font-size: 12pt; color: #555 !important; margin-bottom: 2pt; }
  .detail-body h1 { font-size: 16pt; color: #000 !important; margin-bottom: 10pt; }
  .detail-text { font-size: 11pt; line-height: 1.5; color: #000 !important; white-space: pre-wrap; }
  .reform-note, .historica-note, .vacante-banner {
    border: 1px solid #999; background: #f5f5f5 !important; color: #000 !important;
    padding: 8pt; margin-top: 10pt; font-size: 10pt;
  }
  .reform-note strong, .historica-note strong, .vacante-banner-label { color: #000 !important; }
  .concordancia-note { margin-top: 10pt; }
  .concordancia-chip { border: 1px solid #999; color: #000 !important; background: none !important; }
}
