﻿/* ============================================================
   LTG — Fresh UI 2026
   Design tokens
   ============================================================ */
:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f5f5f7;
    --surface-3: #ececee;
    --text: #1d1d1f;
    --text-2: #6e6e73;
    --text-3: #8e8e93;
    --border: #e5e5e7;
    --border-2: #d2d2d7;
    --accent: #3F7652;
    --accent-hover: #2e5a3e;
    --accent-soft: rgba(63, 118, 82, 0.08);
    --danger: #d70015;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.10);
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --nav-h: 60px;
    --app-height: 100vh;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

@supports (height: 100dvh) {
    :root {
        --app-height: 100dvh;
    }
}

    :root.dark-theme {
        --bg: #000000;
        --surface: #1c1c1e;
        --surface-2: #2c2c2e;
        --surface-3: #38383a;
        --text: #f5f5f7;
        --text-2: #a1a1a6;
        --text-3: #8e8e93;
        --border: #38383a;
        --border-2: #48484a;
        --accent: #3F7652;
        --accent-hover: #2e5a3e;
        --accent-soft: rgba(63, 118, 82, 0.08);
        --danger: #ff453a;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.30);
        --shadow-md: 0 4px 16px rgba(0,0,0,0.40);
        --shadow-lg: 0 12px 40px rgba(0,0,0,0.50);
    }

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

html {
    background: var(--bg);
    transition: background-color 0.15s ease;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
}

/* ============================================================
   Navbar
   ============================================================ */
.ltg-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    z-index: 100;
    background: transparent;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
}

.dark-theme .ltg-navbar {
    background: rgba(0, 0, 0, 0.72);
}

.ltg-navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.ltg-brand img {
    height: 26px;
    width: auto;
    display: block;
}

.ltg-nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ltg-nav-link {
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    border-radius: var(--r-sm);
    transition: background 0.15s, color 0.15s;
}

    .ltg-nav-link:hover {
        color: var(--text);
        background: var(--surface-2);
    }

    .ltg-nav-link.active {
        color: var(--text);
        background: var(--surface-2);
    }

.ltg-nav-logout {
    color: var(--danger);
}

    .ltg-nav-logout:hover {
        color: var(--danger);
        background: rgba(215, 0, 21, 0.08);
    }

.dark-theme .ltg-nav-logout:hover {
    background: rgba(255, 69, 58, 0.12);
}

/* Mobile hamburger */
.ltg-nav-toggle {
    display: none;
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--r-sm);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

    .ltg-nav-toggle span {
        display: block;
        width: 20px;
        height: 1.5px;
        background: var(--text);
        border-radius: 2px;
        transition: background 0.2s;
    }

/* Mobile drawer */
.ltg-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

    .ltg-drawer-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

.ltg-nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--surface);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.30s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: -8px 0 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    padding: 76px 16px calc(20px + var(--safe-bottom));
    gap: 2px;
    max-height: var(--app-height);
    overflow-y: auto;
}

    .ltg-nav-drawer.open {
        transform: translateX(0);
    }

    .ltg-nav-drawer a {
        padding: 14px 16px;
        font-size: 16px;
        font-weight: 500;
        color: var(--text);
        border-radius: var(--r-sm);
        transition: background 0.15s;
    }

        .ltg-nav-drawer a:hover {
            background: var(--surface-2);
        }

        .ltg-nav-drawer a.active {
            background: var(--surface-2);
        }

        .ltg-nav-drawer a.logout {
            color: var(--danger);
        }
/* ============================================================
   Mobile drawer scroll fix
   ============================================================ */

/* The drawer itself is fixed, but its flex column needs an
   explicit height so its child (body) knows how much room it has. */
.spec-mobile-drawer {
    display: flex;
    height: var(--app-height);
    max-height: var(--app-height);
    overflow: hidden; /* drawer itself never scrolls */
}

/* The body is the only scrolling region. */
.spec-mobile-drawer-body {
    flex: 1 1 0; /* grow + allow shrink */
    min-height: 0; /* CRITICAL — flex child won't shrink otherwise */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    max-height: 100%; /* bounded by parent */
}

/* Prevent outer page from swallowing the touch scroll */
.spec-mobile-drawer.open {
    touch-action: pan-y;
}
/* ============================================================
   Main layout wrapper
   ============================================================ */
.ltg-main {
    height: var(--app-height);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

    .ltg-main.with-navbar {
        height: calc(var(--app-height) - var(--nav-h));
        margin-top: var(--nav-h);
    }
/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.2;
}

    .btn:active {
        transform: scale(0.985);
    }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

    .btn-primary:hover {
        background: var(--accent-hover);
        border-color: var(--accent-hover);
    }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-2);
}

    .btn-secondary:hover {
        background: var(--surface-3);
    }

.btn-ghost {
    color: var(--text-2);
}

    .btn-ghost:hover {
        background: var(--surface-2);
        color: var(--text);
    }

.btn-block {
    width: 100%;
}

/* ============================================================
   Shared page-topbar + back button
   Used on: Citation, Profile, ChangePassword, Document,
            Results, SpecificSearch
   Rule: topbar always spans a 1200px container, back button
         always sits at the left edge with 24px inset — matching
         .ltg-navbar-inner so the back button aligns with the logo.
   ============================================================ */

.page-topbar {
    flex-shrink: 0;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    /* Stays above the content of each page's own scroll region */
    position: relative;
    z-index: 5;
}

/* Optional right-aligned slot (e.g. Results map label) */
.page-topbar-right {
    margin-left: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The back link itself */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    padding: 6px 10px;
    /* Anchor to the left edge of the grid cell — the negative margin
       on the left keeps the SVG aligned with the 24px container inset,
       and the padding on both sides preserves the tap target. */
    margin-left: -10px;
    border-radius: var(--r-sm);
    text-decoration: none;
    transition: background 0.15s;
}

    .back-link:hover {
        background: var(--accent-soft);
    }

.back-link-icon {
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
}

/* ============================================================
   Forms
   ============================================================ */
.form-control,
.form-select {
    width: 100%;
    padding: 6px 10px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

    .form-control:focus,
    .form-select:focus {
        background: var(--surface);
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
    }

    .form-control::placeholder {
        color: var(--text-3);
    }

.form-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 34px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

.dark-theme .form-select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a6' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
}

/* Fix native date-picker calendar icon in dark mode */
.dark-theme input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.75;
}

    .dark-theme input[type="date"]::-webkit-calendar-picker-indicator:hover {
        opacity: 1;
    }

/* ============================================================
   Loading overlay
   ============================================================ */
.ltg-load-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

    .ltg-load-overlay.active {
        display: flex;
    }

.ltg-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ltg-spin 0.8s linear infinite;
}
.ltg-load-overlay[data-msg]:not([data-msg=""])::after {
    content: attr(data-msg);
    position: absolute;
    top: calc(50% + 34px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    background: var(--surface);
    padding: 6px 16px;
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
}
@keyframes ltg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-bottom: calc(24px + var(--safe-bottom));
    background: var(--bg);
    height: var(--app-height);
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 40px 32px;
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

    .login-logo img {
        height: 56px;
        width: auto;
    }

.login-card h1 {
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
}

.login-sub {
    text-align: center;
    color: var(--text-2);
    font-size: 13px;
    margin: 0 0 26px 0;
}

.login-field {
    margin-bottom: 16px;
}

    .login-field label {
        display: block;
        font-size: 13px;
        font-weight: 500;
        color: var(--text-2);
        margin-bottom: 6px;
    }

.login-box-btn {
    padding: 11px 14px;
    font-size: 15px;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    display: none;
}

/* ============================================================
   HOME PAGE
   ============================================================ */
.home-page {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-bottom);
}
.home-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 24px;
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
}

.home-ticker {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 8px 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.home-ticker-label {
    background: var(--accent);
    color: #fff;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.home-ticker-viewport {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    height: 24px;
    display: flex;
    align-items: center;
    mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}

.home-ticker-track {
    display: inline-flex;
    white-space: nowrap;
    animation: ltg-ticker linear infinite;
    animation-duration: 90s; /* safe fallback; JS recalculates per track width */
    will-change: transform;
}

.home-ticker:hover .home-ticker-track {
    animation-play-state: paused;
}

@keyframes ltg-ticker {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }
}

.home-ticker-item {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    margin-right: 48px; /* replaces parent gap so translateX(-50%) loops perfectly */
    color: var(--text-2);
    font-size: 13px;
}

    .home-ticker-item:hover {
        color: var(--accent);
    }

    .home-ticker-item strong {
        color: var(--text);
        font-weight: 600;
    }

    .home-ticker-item .date {
        color: var(--text-3);
        font-size: 11.5px;
    }

.home-ticker-view-all {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
}

    .home-ticker-view-all:hover {
        background: var(--accent-soft);
    }

.home-hero {
    text-align: center;
}

    .home-hero img {
        height: 76px;
        width: auto;
        margin-bottom: 6px;
    }

.home-hero-sub {
    font-size: 13px;
    color: var(--text-2);
    margin: 0;
    letter-spacing: 0.02em;
}

/* In the HOME PAGE section, replace the .home-search-card rule */
.home-search-card {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
    overflow: visible; /* ← allow the dropdown to escape */
    position: relative; /* ← anchor for absolutely-positioned child if ever needed */
    z-index: 1;
}

.home-search-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    position: relative; /* ← keep the panel z-index relative to the row */
    z-index: 2; /* ← beats the actions row below it */
}

.home-search-input {
    flex: 1;
    padding: 6px 10px;
    font-size: 16px;
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    transition: all 0.15s ease;
    min-width: 0;
}

    .home-search-input:focus {
        background: var(--surface);
        border-color: var(--accent);
        box-shadow: 0 0 0 4px var(--accent-soft);
    }


.dark-theme .home-search-tax {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a6' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
}

.home-search-btn {
    padding: 6px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 500;
    flex-shrink: 0;
    transition: background 0.15s;
}

    .home-search-btn:hover {
        background: var(--accent-hover);
    }

.home-search-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

    .home-search-options label {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        color: var(--text-2);
        cursor: pointer;
        user-select: none;
    }

    .home-search-options input[type="radio"] {
        accent-color: var(--accent);
        margin: 0;
    }

.home-search-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-3);
    min-height: 1.2em;
    text-align: center;
}

.home-search-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 10px;
    display: none;
    text-align: center;
}

.home-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.home-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
}

    .home-action-btn:hover {
        border-color: var(--accent);
        background: var(--accent-soft);
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }

.home-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-3);
    padding-top: 8px;
}

    .home-footer a {
        color: var(--text-2);
    }

        .home-footer a:hover {
            color: var(--accent);
        }

    .home-footer p {
        margin: 6px 0 0 0;
    }

    .home-footer .sep {
        margin: 0 8px;
        color: var(--border-2);
    }

.home-theme-toggle {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-md);
    z-index: 50;
    transition: all 0.15s ease;
}

    .home-theme-toggle:hover {
        transform: scale(1.05);
        box-shadow: var(--shadow-lg);
    }

/* Home tax combobox — replace the old rule with this */
.home-search-tax.ct-select {
    width: 160px;
    flex-shrink: 0;
}

    .home-search-tax.ct-select .ct-select-trigger {
        height: 100%;
        min-height: 40px;
        font-size: 14px;
        padding: 0 12px 0 14px;
        background: var(--surface-2);
        border-color: var(--border-2);
    }

/* ============================================================
   RESULTS PAGE
   ============================================================ */
.results-page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0px 24px calc(20px + var(--safe-bottom));
    gap: 12px;
    overflow: hidden;
}

/* ── Query banner ── */
.results-query-banner {
    font-size: 13px;
    color: var(--text-2);
    padding: 8px 12px;
    background: var(--accent-soft);
    border-radius: var(--r-sm);
    border-left: 3px solid var(--accent);
    flex-shrink: 0;
}

/* ── Body layout ── */
.results-body {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

/* ── Filter sidebar ── */
.results-filter-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 240;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

    .results-filter-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

.results-filter-sidebar {
    position: relative;
    width: 260px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: var(--shadow-sm);
    display: none;
}

    .results-filter-sidebar.open {
        display: block;
    }

.results-filter-inner {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.results-filter-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}

.results-filter-close {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-2);
    padding: 2px 6px;
    border-radius: 6px;
    line-height: 1;
    cursor: pointer;
}

    .results-filter-close:hover {
        background: var(--surface-2);
    }

.results-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .results-filter-group label {
        font-size: 12px;
        font-weight: 500;
        color: var(--text-2);
    }

    .results-filter-group select {
        width: 100%;
        padding: 7px 28px 7px 10px;
        font-size: 13px;
        color: var(--text);
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        border-radius: var(--r-sm);
        outline: none;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 8px center;
        background-size: 12px;
    }

.dark-theme .results-filter-group select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a6' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
}

.results-filter-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.results-filter-actions {
    margin-top: 4px;
}

.results-filter-count {
    font-size: 12px;
    color: var(--text-3);
    text-align: center;
}

/* ── Scroll container ── */
.results-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
}

    .results-scroll::-webkit-scrollbar {
        width: 8px;
    }

    .results-scroll::-webkit-scrollbar-thumb {
        background: var(--border-2);
        border-radius: 4px;
    }

/* ── Column header (desktop only) ── */
.results-head-row {
    display: none;
    grid-template-columns: 200px 130px 1fr;
    gap: 20px;
    padding: 0 18px 5px 18px;
    margin-bottom: 2px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 2;
}

.results-head-ref,
.results-head-date,
.results-head-content {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Row (mobile base = card) ── */
.result-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 18px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 6px;
    outline: none;
}

    .result-item:hover {
        border-color: var(--accent);
        box-shadow: var(--shadow-sm);
    }

    .result-item:focus-visible {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
    }

.result-ref {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-2);
    line-height: 1.35;
    word-break: break-word;
    text-transform: none;
    margin-bottom: 2px;
}

    .result-ref .result-court {
        font-weight: 600;
    }

/* Citation: Court + Sections rendered as two stacked rows */
.result-sections {
    display: block;
    margin-top: 8px;
    font-weight: 500;
    color: var(--text-2);
    line-height: 1.4;
    word-break: break-word;
}

    .result-sections .result-sections-label {
        font-weight: 600;
        color: var(--text);
    }
.result-date-col {
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-3);
    line-height: 1.35;
    margin-bottom: 4px;
}

    .result-ref:empty,
    .result-date-col:empty {
        display: none;
    }

.result-ref-empty,
.result-date-empty {
    color: var(--text-3);
}

.result-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

    .result-content b,
    .result-content strong {
        font-weight: 600;
    }

.result-court {
    font-weight: 500;
}

.result-date {
    color: var(--text-3);
}

@media (min-width: 900px) {
    .result-sections {
        margin-top: 10px;
        font-size: 13px;
    }
    .results-head-row {
        display: grid;
        grid-template-columns: 200px 130px 1fr;
    }

        .results-head-row.citation-2col {
            grid-template-columns: 240px 1fr;
        }

    .result-item {
        display: grid;
        grid-template-columns: 200px 130px 1fr;
        gap: 20px;
        align-items: start;
        padding: 14px 18px;
        border-radius: var(--r-sm);
    }

        /* Citation rows: no middle column at all (date-col is not rendered) */
        .result-item:not(:has(.result-date-col)) {
            grid-template-columns: 240px 1fr;
        }

    /* Every grid child MUST have min-width:0 — otherwise the column
       grows to fit unbroken strings like "2, 3, 4, 4B, 4C, 28A, 37A, ..." */
    .result-ref,
    .result-date-col,
    .result-content {
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .result-ref {
        font-size: 13px;
        color: var(--text);
        font-weight: 500;
        line-height: 1.5;
        margin-bottom: 0;
        letter-spacing: 0;
    }

        .result-ref .result-court br {
            display: block;
            content: "";
            margin: 3px 0;
        }

    .result-date-col {
        font-size: 13px;
        color: var(--text-2);
        font-weight: 400;
        line-height: 1.5;
        margin-bottom: 0;
        white-space: normal;
    }

    .result-content {
        font-size: 13.5px;
        line-height: 1.6;
    }
}

/* ── No results ── */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-2);
    font-size: 15px;
}

/* ── Hidden / filtered ── */
.result-item.filtered-out {
    display: none !important;
}
.result-item.search-hidden {
    display: none;
}

.result-item.group-collapsed {
    display: none;
}
/* ============================================================
   RESULTS TOPBAR — v3
   Desktop :  [ criteria row — full width ]
              [ Back · Filters · Search · Find · Group · Sort · Count ]
   Mobile  :  [ Back · criteria ]
              [ Find · Filters · Group · Sort · Count ]   (Find = popup)
   ============================================================ */

.rbar {
    flex-shrink: 0;
    display: grid;
    align-items: center;
    gap: 10px 12px;
    padding: 8px 0 10px;
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

/* ── Criteria row (map label) ── */
.rbar-criteria {
    grid-area: criteria;
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    font-size: 13px;
    color: var(--text-2);
    padding: 2px 0;
}

.rbar-criteria-label {
    flex-shrink: 0;
    font-weight: 600;
    color: var(--text-3);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.rbar-criteria-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 500;
}

/* ── Zone wrappers (thin — just glue + min-width reset) ── */
.rbar-zone {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.rbar-zone--back {
    grid-area: back;
}

.rbar-zone--filters {
    grid-area: filters;
}

.rbar-zone--search {
    grid-area: search;
}

.rbar-zone--group {
    grid-area: group;
}

.rbar-zone--sort {
    grid-area: sort;
}

.rbar-zone--count {
    grid-area: count;
}

/* ── Search field (shared by desktop inline + mobile popup) ── */
.rbar-search-field {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
}

.rbar-input {
    width: 100%;
    padding: 6px 34px 6px 12px;
    font-size: 14px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    outline: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    min-width: 0;
}

    .rbar-input:focus {
        background: var(--surface);
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
    }

    .rbar-input::placeholder {
        color: var(--text-3);
    }

.rbar-reset {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-3);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

    .rbar-reset:hover {
        background: var(--surface-3);
        color: var(--text);
    }

.rbar-find {
    flex-shrink: 0;
    padding: 6px 18px;
}

/* Mobile-only Find trigger — hidden on desktop */
.rbar-find-toggle {
    grid-area: find-mobile;
    display: none;
    padding: 6px 18px;
}

/* ── Group ── */
.rbar-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}

    .rbar-group input[type="checkbox"] {
        accent-color: var(--accent);
        margin: 0;
    }

/* ── Sort ── */
.rbar-sort {
    flex-shrink: 0;
}

    .rbar-sort select {
        padding: 6px 28px 6px 10px;
        font-size: 13px;
        color: var(--text);
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        border-radius: var(--r-sm);
        outline: none;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 8px center;
        background-size: 12px;
    }

.dark-theme .rbar-sort select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a6' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
}

.rbar-sort select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.rbar-filters {
    flex-shrink: 0;
}

/* ── Count ── */
.rbar-count {
    font-size: 13px;
    color: var(--text-2);
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

    .rbar-count strong {
        color: var(--text);
        font-weight: 600;
    }

/* ============================================================
   Desktop ≥ 901px
   Row 1: criteria (full width)
   Row 2: back · filters · search · find · group · sort · count
   ============================================================ */
@media (min-width: 901px) {
    .rbar {
        grid-template-columns: auto auto minmax(0, 1fr) auto auto auto auto;
        grid-template-areas:
            "criteria criteria criteria criteria criteria criteria criteria"
            "back     filters  search   search   group    sort     count";
    }

    /* Search + Find side by side in row 2; grid-area 'search' spans two cols */
    .rbar-zone--search {
        gap: 8px;
    }

    .rbar-zone--count {
        justify-content: flex-end;
    }
}

/* ============================================================
   Tablet / Mobile ≤ 900px
   Row 1: back · criteria
   Row 2: Find(mobile) · Filters · Group · Sort · Count
   Inline search zone is hidden — replaced by popup.
   ============================================================ */
@media (max-width: 900px) {
    .rbar {
        grid-template-columns: auto minmax(0, 1fr) auto auto auto auto;
        grid-template-areas:
            "back      criteria criteria criteria criteria criteria"
            "find-mobile filters group    sort     count    count";
        gap: 8px 10px;
        padding: 10px 0;
    }

    /* Hide the desktop inline search zone — popup replaces it */
    .rbar-zone--search {
        display: none;
    }

    /* Show the mobile Find trigger */
    .rbar-find-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .rbar-zone--filters,
    .rbar-zone--group,
    .rbar-zone--sort {
        justify-content: flex-start;
    }

    .rbar-zone--count {
        justify-content: flex-end;
    }

    .rbar-criteria-label {
        display: none; /* "Search:" label only helps on desktop */
    }
}

/* ============================================================
   Phone ≤ 640px — tighter spacing; controls stay on ONE row
   ============================================================ */
@media (max-width: 640px) {
    .rbar {
        grid-template-columns: auto auto auto minmax(0, 1fr) auto;
        grid-template-areas:
            "back      criteria criteria criteria criteria"
            "find-mobile filters group   sort     count";
        gap: 8px;
    }

    .rbar-find-toggle {
        padding: 6px 14px;
    }

    /* Sort sits inline — shrink it so it doesn't force a wrap */
    .rbar-sort select {
        font-size: 12.5px;
        padding: 5px 24px 5px 9px;
        max-width: 118px;
    }

    .rbar-count {
        justify-self: end;
    }
}

/* ============================================================
   Very narrow ≤ 400px — trim labels, keep tap targets
   ============================================================ */
@media (max-width: 400px) {
    .rbar-zone--back .back-link span {
        display: none; /* chevron only */
    }

    .rbar-criteria-text {
        font-size: 12px;
    }

    .rbar-group span {
        display: none; /* checkbox only */
    }

    .rbar-find-toggle {
        padding: 6px 12px;
        font-size: 13px;
    }
}
.back-link:hover {
    background: var(--accent-soft);
}

.dark-theme .back-link:hover {
    background: rgba(63, 118, 82, 0.18);
    color: #6ee7a0; /* brighter accent for legibility on dark bg */
}

    .dark-theme .back-link:hover .back-link-icon {
        color: #6ee7a0;
    }
.rbar-popup-clear {
    flex-shrink: 0;
    min-height: 40px;
    padding: 0 14px;
    background: transparent;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

    .rbar-popup-clear:hover {
        background: var(--surface-2);
        border-color: var(--border-2);
        color: var(--text);
    }

/* ============================================================
   Mobile search popup — full-width overlay for the inline search
   field when the user taps the mobile Find button.
   ============================================================ */
.rbar-search-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 300;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: calc(70px + var(--safe-top)) 16px 16px;
}

    .rbar-search-popup.show {
        display: flex;
    }

.rbar-search-popup-inner {
    width: 100%;
    max-width: 520px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    display: flex;
    gap: 8px;
    align-items: stretch;
}

    .rbar-search-popup-inner .rbar-search-field {
        flex: 1 1 auto;
        min-width: 0;
    }

    .rbar-search-popup-inner .rbar-input {
        min-height: 40px;
        font-size: 15px;
    }

    .rbar-search-popup-inner .rbar-find,
    .rbar-search-popup-inner .rbar-popup-close {
        flex-shrink: 0;
        min-height: 40px;
    }

.rbar-popup-close {
    background: transparent;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    color: var(--text-2);
    padding: 0 14px;
    font-size: 14px;
    cursor: pointer;
}

    .rbar-popup-close:hover {
        background: var(--surface-2);
        color: var(--text);
    }

/* Popup markup is injected by JS — see section 3 */

/* ============================================================
   Grouping headers
   ============================================================ */
.results-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    cursor: pointer;
    line-height: 1.3;
    transition: background 0.15s, border-color 0.15s;
}

.gh-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gh-count {
    flex-shrink: 0;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.toggle-sign {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}

/* Level 1 — Tax */
.results-group-header.tax-header {
    margin: 12px 0 4px;
    padding: 11px 16px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

    .results-group-header.tax-header:first-of-type {
        margin-top: 4px;
    }

    .results-group-header.tax-header:hover {
        background: var(--surface-2);
    }

    .results-group-header.tax-header .toggle-sign {
        width: 22px;
        height: 22px;
        font-size: 14px;
        background: var(--accent-soft);
        color: var(--accent);
    }

    .results-group-header.tax-header:hover .toggle-sign {
        background: var(--accent);
        color: #fff;
    }

    .results-group-header.tax-header .gh-count {
        font-size: 11.5px;
        color: var(--text-3);
        font-weight: 500;
        letter-spacing: 0;
        text-transform: none;
    }

/* Level 2 — DocType */
.results-group-header.doctype-header {
    margin: 2px 0 2px 22px;
    padding: 8px 14px;
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-2);
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 600;
}

    .results-group-header.doctype-header:hover {
        background: var(--surface-3);
        color: var(--text);
        border-left-color: var(--accent);
    }

    .results-group-header.doctype-header .toggle-sign {
        width: 16px;
        height: 16px;
        font-size: 12px;
        color: var(--text-3);
        background: transparent;
    }

    .results-group-header.doctype-header:hover .toggle-sign {
        color: var(--accent);
    }

    .results-group-header.doctype-header .gh-count {
        font-size: 11px;
        color: var(--text-3);
    }

.results-group-header.collapsed .toggle-sign {
    color: var(--text-3);
}

.results-scroll .result-item.group-child {
    margin-left: 40px;
    border-left: 2px solid var(--border);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* On mobile, drop the indent — cards read better full-width */
@media (max-width: 900px) {
    .results-scroll .result-item.group-child {
        margin-left: 0;
        border-left-width: 1px;
        border-top-left-radius: var(--r-md);
        border-bottom-left-radius: var(--r-md);
    }
}

.dark-theme .results-group-header.tax-header {
    background: var(--surface-2);
    border-color: var(--border);
}

    .dark-theme .results-group-header.tax-header:hover {
        background: var(--surface-3);
    }

.dark-theme .results-group-header.doctype-header {
    background: var(--surface-3);
    border-color: var(--border-2);
}

/* ── Filter sidebar drawer — LEFT side ── */
@media (max-width: 1023px) {
    .results-filter-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 300px;
        max-width: 88vw;
        z-index: 250;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
        box-shadow: 8px 0 40px rgba(0, 0, 0, 0.18);
        display: block;
        max-height: var(--app-height);
        padding-bottom: var(--safe-bottom);
    }

        .results-filter-sidebar.open {
            transform: translateX(0);
        }

    .results-filter-backdrop {
        display: block;
    }

        .results-filter-backdrop.show {
            display: block;
        }
}

@media (min-width: 1024px) {
    .results-filter-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 340px;
        z-index: 250;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
        box-shadow: 8px 8px 40px rgba(0, 0, 0, 0.15);
        display: block;
        max-height: var(--app-height);
        padding-bottom: var(--safe-bottom);
    }

        .results-filter-sidebar.open {
            transform: translateX(0);
        }

    .results-filter-backdrop {
        display: block;
    }

        .results-filter-backdrop.show {
            display: block;
        }
}

@media (max-width: 480px) {
    .result-item {
        padding: 12px 14px;
    }

    .result-content {
        font-size: 13px;
    }
}
/* ============================================================
   DOCUMENT PAGE
   ============================================================ */
.doc-page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 16px 24px calc(24px + var(--safe-bottom));
    gap: 12px;
    overflow: hidden;
}

.doc-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.doc-btn {
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

    .doc-btn:hover {
        background: var(--surface-2);
        border-color: var(--border-2);
    }

    .doc-btn.active {
        background: var(--accent-soft);
        border-color: var(--accent);
        color: var(--accent);
    }

    .doc-btn.primary {
        background: var(--accent);
        color: #fff;
        border-color: var(--accent);
    }

.doc-findbar {
    display: none;
    gap: 8px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 8px 12px;
    flex-shrink: 0;
}

    .doc-findbar.show {
        display: flex;
    }

    .doc-findbar input {
        flex: 1;
        border: none;
        background: transparent;
        font-size: 14px;
        color: var(--text);
        outline: none;
        min-width: 0;
    }

    .doc-findbar button {
        background: none;
        border: none;
        padding: 4px 8px;
        font-size: 14px;
        color: var(--text-2);
        border-radius: 6px;
    }

        .doc-findbar button:hover {
            background: var(--surface-2);
        }

.doc-findcount {
    font-size: 12px;
    color: var(--text-3);
    white-space: nowrap;
    padding: 0 6px;
}

.doc-body-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    -webkit-overflow-scrolling: touch;
}

    .doc-body-wrap::-webkit-scrollbar {
        width: 8px;
    }

    .doc-body-wrap::-webkit-scrollbar-thumb {
        background: var(--border-2);
        border-radius: 4px;
    }

.doc-body {
    padding: 32px 40px;
    line-height: 1.7;
    font-size: 15px;
    color: var(--text);
}

    .doc-body a {
        color: var(--accent);
        text-decoration: underline;
        cursor: pointer;
    }

    .doc-body table {
        border-collapse: collapse;
        max-width: 100%;
    }

    .doc-body img {
        max-width: 100%;
        height: auto;
    }

.doc-error {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-2);
}

/* Find highlights */
.find-hl {
    background: #ffe066;
    color: #000;
    border-radius: 2px;
}

.find-hl-current {
    background: #ff922b;
    color: #fff;
}

.dark-theme .find-hl {
    background: #b8952e;
    color: #000;
}

.dark-theme .find-hl-current {
    background: #ff922b;
    color: #000;
}

/* ============================================================
   MODAL (used by Home / Document)
   ============================================================ */
.ltg-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}

    .ltg-modal.show {
        display: flex;
    }

.ltg-modal-content {
    background: var(--surface);
    border-radius: var(--r-lg);
    width: 100%;
    max-width: 700px;
    max-height: 82dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.ltg-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

    .ltg-modal-head h2 {
        margin: 0;
        font-size: 17px;
        font-weight: 600;
    }

.ltg-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-2);
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
}

    .ltg-modal-close:hover {
        background: var(--surface-2);
    }

.ltg-modal-body {
    overflow-y: auto;
    padding: 8px;
}

    .ltg-modal-body .list-item {
        padding: 12px 16px;
        border-radius: var(--r-sm);
        cursor: pointer;
        transition: background 0.15s;
    }

        .ltg-modal-body .list-item:hover {
            background: var(--surface-2);
        }

        .ltg-modal-body .list-item .meta {
            font-size: 12px;
            color: var(--text-3);
            margin-bottom: 4px;
        }

        .ltg-modal-body .list-item .content {
            font-size: 13px;
            line-height: 1.55;
        }

.ltg-modal-preview {
    max-width: 1100px;
    height: 88dvh;
    padding: 0;
}

    .ltg-modal-preview iframe {
        width: 100%;
        height: 100%;
        border: none;
    }

.ltg-modal-body-loading {
    padding: 24px;
    text-align: center;
    color: var(--text-2);
    font-size: 14px;
}

/* News list in home modal */
.news-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    border-radius: var(--r-sm);
}

    .news-item:last-child {
        border-bottom: none;
    }

    .news-item:hover {
        background: var(--surface-2);
    }

.news-meta {
    font-size: 11.5px;
    color: var(--text-3);
    margin-bottom: 4px;
}

.news-title {
    font-size: 14px;
    margin-bottom: 4px;
    font-weight: 500;
}

.news-subj {
    font-size: 12.5px;
    color: var(--text-2);
    line-height: 1.5;
}

/* ============================================================
   Toast
   ============================================================ */
.ltg-toast {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: var(--bg);
    padding: 10px 20px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 9999;
}

    .ltg-toast.show {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

/* ============================================================
   SPECIFIC SEARCH PAGE
   ============================================================ */
.spec-page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
    padding: 0px 24px calc(24px + var(--safe-bottom));
    gap: 14px;
    overflow: hidden;
}

/* ============================================================
   Page topbar with centered title (3-col grid)
   Used by: SpecificSearch, Citation, Results, etc.
   ============================================================ */
.page-topbar-title-wrap {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    justify-items: start;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px 0;
    gap: 12px;
}
.page-topbar-title-wrap--flush {
    padding-left: 0;
    padding-right: 0;
}
.page-topbar-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    justify-self: center;
    max-width: 100%;
}

.page-topbar-spacer {
    display: block;
    justify-self: end;
}

/* ---- Layout (desktop) ---- */
.spec-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    overflow: hidden;
}

/* ---- Sidebar ---- */
.spec-sidebar {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    box-shadow: var(--shadow-sm);
}

    .spec-sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .spec-sidebar::-webkit-scrollbar-thumb {
        background: var(--border-2);
        border-radius: 3px;
    }

.spec-sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
}

    .spec-sidebar-header h3 {
        margin: 0 0 3px 0;
        font-size: 15px;
        font-weight: 600;
        color: var(--text);
        letter-spacing: -0.01em;
    }

    .spec-sidebar-header p {
        margin: 0;
        font-size: 12px;
        color: var(--text-3);
    }

/* Group */
.spec-group {
    border-bottom: 1px solid var(--border);
    background-color: var(--surface);
}

    .spec-group:last-child {
        border-bottom: none;
    }

.spec-group-toggle {
    width: 100%;
    padding: 8px 20px;
    background: transparent;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-align: left;
    text-transform: uppercase;
    transition: background 0.15s;
}

/* Dark mode: expanded groups use the light surface for the accent background */
:root.dark-theme .spec-group.expanded > .spec-group-toggle {
    color: #fff;
}
    .spec-group-toggle:hover {
        background: var(--surface-2);
    }

.spec-group.expanded > .spec-group-toggle {
    background: var(--accent);
    color: var(--surface-2);
}

.spec-group-name {
    flex: 1;
    min-width: 0;
}

.spec-group-chevron {
    transition: transform 0.2s;
    color: var(--text-3);
    font-size: 18px;
    line-height: 1;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.spec-group.expanded .spec-group-chevron {
    transform: rotate(90deg);
    color: #fff; /* white on the green accent background, both modes */
}

/* Items container — visibly recessed from the group header */
.spec-group-items {
    display: none;
    padding: 6px 8px 10px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
}

.spec-group.expanded .spec-group-items {
    display: block;
}

/* Item */
.spec-item {
    display: block;
    padding: 6px 10px;
    margin: 2px 0;
    font-size: 12px;
    transition: background 0.12s, color 0.12s;
    position: relative;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
}

    .spec-item:hover {
        border-color: var(--accent);
        background: var(--accent-soft);
        box-shadow: var(--shadow-md);
    }

    .spec-item.selected {
        border-color: var(--accent);
        background: var(--accent-soft);
        box-shadow: var(--shadow-md);
    }

        .spec-item.selected:hover {
            border-color: var(--accent);
            background: var(--accent-soft);
            transform: translateY(0);
            box-shadow: var(--shadow-md);
        }

/* Separator label */
.spec-separator {
    padding: 10px 14px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.10em;
    color: var(--text-3);
    text-transform: uppercase;
}

/* ---- Content (form area) ---- */
.spec-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.spec-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    background-color: var(--surface-2);
}

    .spec-scroll::-webkit-scrollbar {
        width: 8px;
    }

    .spec-scroll::-webkit-scrollbar-thumb {
        background: var(--border-2);
        border-radius: 4px;
    }

.spec-form-title {
    display: block;
    width: 100%;
    margin: 0;
    padding: 8px 20px;
    background: var(--accent);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.35;
    word-break: break-word;
}

/* Field */
.spec-field {
    margin-bottom: 5px;
}

    .spec-field label {
        display: block;
        font-size: 12.5px;
        font-weight: 500;
        color: var(--text-2);
    }

/* Two-column row for compact pairs (Year + Issue Date) */
.spec-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 5px;
}

    .spec-field-row .spec-field {
        margin-bottom: 0;
    }

@media (max-width: 480px) {
    .spec-field-row {
        grid-template-columns: 1fr;
    }
}

.tree-row-nonleaf {
    cursor: default;
}

    .tree-row-nonleaf .tree-label {
        font-weight: 600;
    }

    .tree-row-nonleaf:hover {
        background: var(--surface-2);
    }

    .tree-row-nonleaf.selected {
        /* ensure a non-leaf never shows the selected style */
        background: transparent;
        color: var(--text);
    }

/* ============================================================
   Judgments form — desktop grid layout (matches original ASPX)
   ============================================================ */
@media (min-width: 641px) {

    /* 3-column rows */
    .judg-row-3 {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 12px;
        margin-bottom: 14px;
    }

        .judg-row-3 .spec-field {
            margin-bottom: 0;
        }

    /* 2-column rows */
    .judg-row-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 14px;
    }

        .judg-row-2 .spec-field {
            margin-bottom: 0;
        }

    /* Full-width single-field rows still keep the normal margin */
    .judg-row-1 .spec-field {
        margin-bottom: 14px;
    }
}

/* Actions */
.spec-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap; /* allow wrapping on small screens */
    align-items: center; /* keep buttons vertically aligned */
}

    .spec-form-actions .btn {
        min-width: 120px;
    }

    /* Shortcut button — pushed to the far right of the actions bar */
    .spec-form-actions .spec-citation-shortcut {
        margin-left: auto; /* ← pushes to the right end */
    }

/* Wrap the inner form fields in a soft recessed panel */
.spec-form {
    background: transparent;
}

    .spec-form > form {
        padding: 10px 20px;
    }

/* Radios */
.spec-radio-row {
    display: flex;
    gap: 16px;
    padding: 4px 0;
    flex-wrap: wrap;
}

    .spec-radio-row label {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        color: var(--text-2);
    }

    .spec-radio-row input[type="radio"] {
        accent-color: var(--accent);
        margin: 0;
    }

/* Circular Type — card-style radio group */
.spec-radio-card {
    background: var(--surface-2);
    border: 0.1px solid #0202022b;
    border-radius: var(--r-md);
    padding: 10px 14px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

    .spec-radio-card > label.spec-radio-card-label {
        font-size: 12.5px;
        font-weight: 600;
        color: var(--text-2);
        letter-spacing: 0.02em;
        margin: 0;
        flex-shrink: 0;
        white-space: nowrap;
    }

    .spec-radio-card .spec-radio-row {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
        padding: 0;
        margin: 0;
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

        .spec-radio-card .spec-radio-row::-webkit-scrollbar {
            display: none;
        }

        .spec-radio-card .spec-radio-row label {
            flex: 0 0 auto;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            white-space: nowrap;
            font-size: 13px;
            color: var(--text);
            padding: 4px 12px;
            border-radius: 999px;
            background: var(--surface);
            border: 1px solid var(--border);
            transition: background 0.15s, border-color 0.15s, color 0.15s;
            cursor: pointer;
            margin: 0;
            line-height: 1.3;
        }

            .spec-radio-card .spec-radio-row label:hover {
                border-color: var(--accent);
                background: var(--accent-soft);
            }

            .spec-radio-card .spec-radio-row label:has(input[type="radio"]:checked) {
                border-color: var(--accent);
                background: var(--accent);
                color: #fff;
                font-weight: 500;
            }

                .spec-radio-card .spec-radio-row label:has(input[type="radio"]:checked) input[type="radio"] {
                    accent-color: #fff;
                }

        .spec-radio-card .spec-radio-row input[type="radio"] {
            margin: 0;
            flex-shrink: 0;
        }

.dark-theme .spec-radio-card {
    background: var(--surface-3);
}

/* Empty / denied state */
.spec-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-2);
}

    .spec-placeholder h4 {
        font-size: 17px;
        margin: 0 0 6px 0;
        color: var(--text);
    }

.spec-placeholder-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
}

    .spec-placeholder-icon svg {
        width: 32px;
        height: 32px;
        display: block;
    }

.dark-theme .spec-placeholder-icon {
    background: rgba(63, 118, 82, 0.18);
}

.spec-placeholder p {
    margin: 6px auto 0;
    max-width: 340px;
    line-height: 1.55;
    font-size: 14px;
}

/* ============================================================
   Mobile sidebar dropdown (only shows on small screens)
   ============================================================ */
.spec-mobile-nav {
    display: none;
    flex-shrink: 0;
    position: relative;
}

.spec-mobile-nav-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-weight: 500;
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.spec-mobile-nav-menu-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--text);
}

.spec-mobile-nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

    .spec-mobile-nav-label.muted {
        color: var(--text-2);
    }

    .spec-mobile-nav-trigger:hover {
        border-color: var(--border-2);
    }

.spec-mobile-nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

    .spec-mobile-nav-label.muted {
        color: var(--text-2);
    }

.spec-mobile-nav-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--text-3);
    transition: transform 0.2s;
}

.spec-mobile-nav.open .spec-mobile-nav-chevron {
    transform: rotate(180deg);
}

/* Backdrop */
.spec-mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

    .spec-mobile-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

/* Drawer */
.spec-mobile-drawer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    max-width: 88vw;
    background: var(--surface-2);
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.18);
    flex-direction: column;
    overflow: hidden;
    max-height: var(--app-height);
}

    .spec-mobile-drawer.open {
        transform: translateX(0);
    }

.spec-mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

    .spec-mobile-drawer-header h3 {
        margin: 0;
        font-size: 15px;
        font-weight: 600;
        color: var(--text);
    }

.spec-mobile-drawer-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-2);
    padding: 4px 8px;
    border-radius: 6px;
}

    .spec-mobile-drawer-close:hover {
        background: var(--surface-2);
    }

.spec-mobile-drawer-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(20px + var(--safe-bottom));
    background: var(--surface);
}

    .spec-mobile-drawer-body::-webkit-scrollbar {
        width: 6px;
    }

    .spec-mobile-drawer-body::-webkit-scrollbar-thumb {
        background: var(--border-2);
        border-radius: 3px;
    }

    .spec-mobile-drawer-body .spec-group-items {
        padding: 6px 8px 10px;
    }


/* ============================================================
   Tree dropdown
   ============================================================ */
.tree-dropdown {
    position: relative;
    width: 100%;
}

.tree-dropdown-chevron {
    color: var(--text-3);
    margin-left: 8px;
}

.tree-dropdown-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
    z-index: 120;
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
}

    .tree-dropdown-panel::-webkit-scrollbar {
        width: 6px;
    }

    .tree-dropdown-panel::-webkit-scrollbar-thumb {
        background: var(--border-2);
        border-radius: 3px;
    }

.tree-list {
    padding: 6px 0;
}

.tree-loading, .tree-empty, .tree-error {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-3);
}

.tree-error {
    color: var(--danger);
}

.tree-root, .tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-children {
    padding-left: 18px;
    display: none;
}

li.expanded > .tree-children {
    display: block;
}

.tree-row {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    margin: 1px 4px;
}

    .tree-row:hover {
        background: var(--surface-2);
    }

    .tree-row.selected {
        background: var(--accent);
        color: #fff;
    }

.tree-chevron {
    display: inline-block;
    width: 16px;
    text-align: center;
    margin-right: 4px;
    color: var(--text-3);
    font-size: 12px;
    user-select: none;
    flex-shrink: 0;
}

.tree-row.selected .tree-chevron {
    color: #fff;
}

.tree-label {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .spec-layout {
        grid-template-columns: 1fr;
    }

    .spec-sidebar {
        display: none;
    }

    .spec-mobile-nav {
        display: block;
    }

    .spec-mobile-backdrop,
    .spec-mobile-drawer {
        display: block;
    }
}

@media (max-width: 768px) {
    .spec-form-title {
        font-size: 12.5px;
        padding: 7px 12px;
    }

    .spec-form-actions {
        flex-wrap: wrap;
    }

        .spec-form-actions .btn {
            flex: 1;
/*            min-width: 0;
*/        }
}

@media (max-width: 480px) {


    .spec-mobile-drawer {
        width: 88vw;
    }
}
/* ============================================================
   SHARED PAGE SHELL
   ============================================================ */

.page-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
    padding-bottom: var(--safe-bottom);
}

/* Grid layout: Perfectly centers the card without stretching it */
.page-body {
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center; /* Centers horizontally and vertically */
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Base Card */
.page-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    padding: 15px;
    width: 100%;
}

/* Citation Card */
.page-card--narrow {
    max-width: 440px;
    background: var(--surface-2);
}

/* Profile & ChangePassword Card */
.page-card--medium {
    max-width: 540px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

/* Optional help line above the body */
.page-help {
    flex-shrink: 0;
    width: 100%;
    max-width: 1200px;
    margin: 4px auto 0;
    padding: 0 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-2);
}

    .page-help a {
        color: var(--accent);
    }

/* TABS (Restored for Profile) */
.page-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border-radius: var(--r-md);
    padding: 4px;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 540px;
    width: calc(100% - 48px);
    margin: 24px auto 0;
    align-self: center;
}

    .page-tabs::-webkit-scrollbar {
        display: none;
    }

.page-tab {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    text-align: center;
    border-radius: var(--r-sm);
    background: none;
    border: none;
    white-space: nowrap;
    transition: all 0.15s;
    cursor: pointer;
}

    .page-tab:hover {
        color: var(--text);
    }

    .page-tab.active {
        background: var(--surface);
        color: var(--text);
        box-shadow: var(--shadow-sm);
    }

/* Mobile tweaks */
@media (max-width: 480px) {
    .page-body {
        padding: 16px;
    }

    .page-card {
        padding: 22px 20px 20px;
    }

    .page-tabs {
        width: calc(100% - 32px);
        margin-top: 16px;
    }

    .page-tab {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ============================================================
   PAGE-SPECIFIC BITS (all inherited from .page-shell / .page-card)
   ============================================================ */

/* --- Citation: breadcrumb (only shows when ?from= is present) --- */
.citation-breadcrumb {
    flex-shrink: 0;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 24px 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 10px;
    color: var(--text-3);
    line-height: 1.4;
}

    .citation-breadcrumb a {
        color: var(--text-2);
        font-weight: 500;
        padding: 2px 4px;
        border-radius: 4px;
        transition: background 0.15s, color 0.15s;
    }

        .citation-breadcrumb a:hover {
            color: var(--accent);
            background: var(--accent-soft);
        }

    .citation-breadcrumb .bc-sep {
        color: var(--border-2);
        user-select: none;
    }

    .citation-breadcrumb .bc-current {
        color: var(--text);
        font-weight: 600;
    }

@media (max-width: 480px) {
    .citation-breadcrumb {
        padding: 8px 16px 0;
        font-size: 11.5px;
    }
}

/* --- Profile: card content (list, features, password CTA) --- */
.profile-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

    .profile-list li {
        display: flex;
        justify-content: space-between;
        gap: 20px;
        padding: 6px 0;
        border-bottom: 1px solid var(--border);
        font-size: 14px;
    }

        .profile-list li:last-child {
            border-bottom: none;
        }

    .profile-list b {
        font-weight: 500;
        color: var(--text-2);
    }

    .profile-list span {
        color: var(--text);
        text-align: right;
        word-break: break-word;
    }

.profile-expiry {
    color: var(--danger) !important;
    font-weight: 500;
}

.profile-trial {
    background: rgba(255, 179, 0, 0.10);
    color: #b45309;
    padding: 10px 16px;
    border-radius: var(--r-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border-left: 3px solid #ffb300;
}

.dark-theme .profile-trial {
    background: rgba(255, 179, 0, 0.12);
    color: #fbbf24;
}

.feature-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.feature-item {
    padding: 6px 16px;
    background: var(--accent-soft);
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .feature-item::before {
        content: "";
        width: 6px;
        height: 6px;
        background: var(--accent);
        border-radius: 50%;
        flex-shrink: 0;
    }

.feature-empty {
    color: var(--text-3);
    font-style: italic;
    padding: 20px 0;
    text-align: center;
    font-size: 13px;
}

.feature-intro {
    font-size: 13px;
    color: var(--text-2);
    margin: 0 0 14px 0;
}

.profile-password-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
    padding: 12px 0;
}

.profile-password-cta-text {
    margin: 0;
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.5;
}

.profile-password-cta .btn {
    min-width: 180px;
    height: 42px;
    padding: 0 22px;
    font-size: 14.5px;
    font-weight: 500;
}

/* --- ChangePassword: form pieces (inherit everything else from .page-card) --- */
.cp-user {
    text-align: center;
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.cp-input-wrap {
    position: relative;
}

    .cp-input-wrap input {
        padding-right: 44px;
    }

.cp-eye {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 6px 8px;
    font-size: 14px;
    color: var(--text-3);
    border-radius: 6px;
    line-height: 1;
}

    .cp-eye:hover {
        color: var(--text);
        background: var(--surface-2);
    }

.cp-strength {
    margin-top: 8px;
}

.cp-strength-bar {
    height: 4px;
    background: var(--surface-2);
    border-radius: 2px;
    overflow: hidden;
}

.cp-strength-fill {
    height: 100%;
    width: 0;
    transition: width 0.2s, background 0.2s;
    border-radius: 2px;
}

.cp-strength-text {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 4px;
}

.cp-submit {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-sm);
    font-size: 15px;
    font-weight: 500;
    margin-top: 8px;
    transition: background 0.15s;
}

    .cp-submit:hover {
        background: var(--accent-hover);
    }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .spec-layout {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .spec-sidebar {
        max-height: 240px;
    }
}

@media (max-width: 768px) {
    :root {
        --nav-h: 56px;
    }

    .ltg-nav-links {
        display: none;
    }

    .ltg-nav-toggle {
        display: flex;
    }

    .ltg-navbar-inner {
        padding: 0 16px;
    }

    .ltg-brand img {
        height: 22px;
    }

    .home-inner {
        padding: 16px;
        gap: 18px;
    }

    .home-hero img {
        height: 56px;
    }

    .home-search-card {
        padding: 16px;
    }

    .home-search-row {
        flex-wrap: wrap;
    }

    .home-search-input {
        flex: 1 1 100%;
        order: 1;
        padding: 11px 14px;
        font-size: 15px;
    }

    .home-search-tax {
        order: 2;
        flex: 1;
        width: auto;
        height: 44px;
    }

    .home-search-btn {
        order: 3;
        height: 44px;
        padding: 0 18px;
    }

    .home-actions {
        flex-direction: column;
    }

    .home-search-options {
        gap: 12px;
    }

    .doc-body {
        padding: 20px;
    }

    .doc-toolbar {
        gap: 6px;
    }

    .doc-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .home-theme-toggle {
        bottom: calc(16px + var(--safe-bottom));
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .ltg-modal {
        padding: 12px;
    }

    .ltg-modal-content {
        max-height: 90dvh;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 32px 22px;
    }

        .login-card h1 {
            font-size: 20px;
        }

    .login-logo img {
        height: 48px;
    }

    .home-inner {
        gap: 14px;
    }

    .home-hero img {
        height: 48px;
    }

    .home-ticker {
        padding: 6px 8px;
    }

    .home-ticker-item {
        font-size: 12px;
    }

    .home-search-options label {
        font-size: 12px;
    }

    .profile-list li {
        font-size: 13px;
    }

    .feature-list {
        grid-template-columns: 1fr;
    }
}

/* Inline SVG sizing */
.home-theme-toggle svg,
.home-action-btn svg,
.cp-eye svg {
    display: block;
    flex-shrink: 0;
}

.home-theme-toggle svg {
    width: 20px;
    height: 20px;
}

.home-action-btn svg {
    width: 16px;
    height: 16px;
    color: var(--text-2);
}

.cp-eye svg {
    width: 16px;
    height: 16px;
}

.home-action-btn:hover svg {
    color: var(--accent);
}

/* ============================================================
   Dark-mode override for legacy inline <font color="…">
   Many documents ship body text as <font color="#000000">…
   which is invisible on the dark surface. Only dark hex values
   are overridden; green/red/blue headings keep their color.
   ============================================================ */
.dark-theme .result-content font[color="#000000"],
.dark-theme .result-content font[color="#000"],
.dark-theme .result-content font[color="#111111"],
.dark-theme .result-content font[color="#111"],
.dark-theme .result-content font[color="#222222"],
.dark-theme .result-content font[color="#222"],
.dark-theme .result-content font[color="#333333"],
.dark-theme .result-content font[color="#333"],
.dark-theme .result-content font[color="#444444"],
.dark-theme .result-content font[color="#444"],
.dark-theme .result-content font[color="#555555"],
.dark-theme .result-content font[color="#555"] {
    color: var(--text) !important;
}

/* ============================================================
   Dark-mode override for legacy inline <font color="…">
   used in the Linked Judgments / History modals and the
   document body. Same rule as .result-content — the content
   is raw HTML from the DB and many rows embed black body text
   that disappears on the dark surface.
   ============================================================ */
.dark-theme .doc-body font[color="#000000"],
.dark-theme .doc-body font[color="#000"],
.dark-theme .doc-body font[color="#111111"],
.dark-theme .doc-body font[color="#111"],
.dark-theme .doc-body font[color="#222222"],
.dark-theme .doc-body font[color="#222"],
.dark-theme .doc-body font[color="#333333"],
.dark-theme .doc-body font[color="#333"],
.dark-theme .doc-body font[color="#444444"],
.dark-theme .doc-body font[color="#444"],
.dark-theme .doc-body font[color="#555555"],
.dark-theme .doc-body font[color="#555"],
.dark-theme .ltg-modal-body .list-item .content font[color="#000000"],
.dark-theme .ltg-modal-body .list-item .content font[color="#000"],
.dark-theme .ltg-modal-body .list-item .content font[color="#111111"],
.dark-theme .ltg-modal-body .list-item .content font[color="#111"],
.dark-theme .ltg-modal-body .list-item .content font[color="#222222"],
.dark-theme .ltg-modal-body .list-item .content font[color="#222"],
.dark-theme .ltg-modal-body .list-item .content font[color="#333333"],
.dark-theme .ltg-modal-body .list-item .content font[color="#333"],
.dark-theme .ltg-modal-body .list-item .content font[color="#444444"],
.dark-theme .ltg-modal-body .list-item .content font[color="#444"],
.dark-theme .ltg-modal-body .list-item .content font[color="#555555"],
.dark-theme .ltg-modal-body .list-item .content font[color="#555"] {
    color: var(--text) !important;
}

.dark-theme .doc-body a,
.dark-theme .doc-body a:visited,
.dark-theme .doc-body a:hover,
.dark-theme .doc-body a:active {
    color: #6EE7A0 !important;
}

    .dark-theme .doc-body a:hover {
        color: #8FF0B8 !important;
    }

.dark-theme .ltg-modal-body .list-item .content a,
.dark-theme .ltg-modal-body .list-item .content a:visited,
.dark-theme .ltg-modal-body .list-item .content a:hover,
.dark-theme .ltg-modal-body .list-item .content a:active {
    color: #6EE7A0 !important;
}

    .dark-theme .ltg-modal-body .list-item .content a:hover {
        color: #8FF0B8 !important;
    }

/* Light mode — force blue */
html:not(.dark-theme) .doc-body a,
html:not(.dark-theme) .doc-body a:visited,
html:not(.dark-theme) .doc-body a:hover,
html:not(.dark-theme) .doc-body a:active,
html:not(.dark-theme) .ltg-modal-body .list-item .content a,
html:not(.dark-theme) .ltg-modal-body .list-item .content a:visited,
html:not(.dark-theme) .ltg-modal-body .list-item .content a:hover,
html:not(.dark-theme) .ltg-modal-body .list-item .content a:active {
    color: #0000FF !important;
}

/* --- Citation form fields (page-specific) --- */
.citation-field {
    margin-bottom: 14px;
}

    .citation-field label {
        display: block;
        font-size: 13px;
        font-weight: 500;
        color: var(--text-2);
        margin-bottom: 6px;
    }

.citation-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

    .citation-actions .btn {
        flex: 1;
        height: 40px;
    }

@media (max-height: 620px) {
    .citation-field {
        margin-bottom: 12px;
    }

    .citation-actions {
        margin-top: 14px;
        padding-top: 12px;
    }

        .citation-actions .btn {
            height: 36px;
        }
}

/* ============================================================
   Custom combobox — .ct-select
   Used by: Citation (Book), Home (Tax), Specific Search (all selects)
   ============================================================ */
.ct-select {
    position: relative;
    width: 100%;
}

.ct-select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    outline: none;
    line-height: 1.4;
}

    .ct-select-trigger:hover {
        border-color: var(--border-2);
    }

    .ct-select.open .ct-select-trigger,
    .ct-select-trigger:focus-visible,
    .ct-select-trigger:hover {
        background: var(--surface);
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
    }

.ct-select-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .ct-select-value.placeholder {
        color: var(--text-3);
    }

.ct-select-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--text-3);
    transition: transform 0.2s ease;
}

.ct-select.open .ct-select-chevron {
    transform: rotate(180deg);
}

.ct-select-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
    z-index: 40;
    max-height: min(280px, calc(50dvh - 40px));
    overflow-y: auto;
    padding: 4px;
    display: none;
    -webkit-overflow-scrolling: touch;
}

.ct-select.open .ct-select-panel {
    display: block;
}

.ct-select-panel::-webkit-scrollbar {
    width: 6px;
}

.ct-select-panel::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 3px;
}

.ct-option {
    padding: 9px 12px;
    font-size: 14px;
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.35;
    word-break: break-word;
}

    .ct-option:hover {
        background: var(--surface-2);
    }

    .ct-option.selected {
        background: var(--accent-soft);
        color: var(--accent);
        font-weight: 500;
    }

    .ct-option.empty {
        color: var(--text-3);
        cursor: default;
        font-style: italic;
    }

        .ct-option.empty:hover {
            background: transparent;
        }

/* Short screens */
@media (max-height: 620px) {
    .ct-select-panel {
        max-height: min(200px, calc(40dvh - 30px));
    }
}

/* Mobile */
@media (max-width: 480px) {
    .ct-select-trigger {
        padding: 5px 12px;
        font-size: 14px;
        min-height: 32px;
    }

    .ct-select-panel {
        max-height: min(220px, 40dvh);
    }

    .ct-option {
        padding: 10px 12px;
        font-size: 14px;
    }
}