/* ==========================================================================
   LOST — Montana Case Law Research
   Design System: Modernist Legal
   Typography: Cormorant Garamond (display) + IBM Plex Sans (body)
   ========================================================================== */

/* --- Variables ---------------------------------------------------------- */
:root {
    --bg:             #f7f8fa;
    --bg-subtle:      #eef0f4;
    --surface:        #ffffff;
    --surface-raised: #f9fafb;
    --surface-hover:  #f1f3f7;
    --text:           #111827;
    --text-body:      #1f2937;
    --text-muted:     #6b7280;
    --text-faint:     #9ca3af;
    --border:         #e5e7eb;
    --border-strong:  #d1d5db;
    --accent:         #1a3c6e;
    --accent-hover:   #14305a;
    --accent-muted:   rgba(26, 60, 110, 0.10);
    --accent-subtle:  rgba(26, 60, 110, 0.04);
    --danger:         #dc2626;
    --danger-bg:      #fef2f2;
    --danger-border:  #fecaca;
    --danger-text:    #991b1b;
    --warning-bg:     #fffbeb;
    --warning-border: #fde68a;
    --warning-text:   #92400e;
    --highlight:      rgba(26, 60, 110, 0.06);
    --font-display:   'IBM Plex Sans', -apple-system, sans-serif;
    --font-body:      'IBM Plex Sans', -apple-system, sans-serif;
    --font-mono:      'IBM Plex Mono', 'Menlo', monospace;
    --max-width:      1040px;
    --radius:         6px;
}

/* --- Reset -------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --- Base --------------------------------------------------------------- */
html {
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.12s;
}

a:hover {
    color: var(--accent-hover);
}

::selection {
    background: var(--accent-muted);
    color: var(--text);
}

/* --- Layout ------------------------------------------------------------- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
    animation: fadeIn 0.35s ease-out;
}

/* --- Typography --------------------------------------------------------- */
h1, h2 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.25;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; }
h3 { font-weight: 600; }

/* --- Header ------------------------------------------------------------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 5%, var(--accent) 50%, transparent 95%);
    opacity: 0.25;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.site-title:hover {
    color: var(--accent);
}

.header-search {
    flex: 1;
    max-width: 400px;
}

.header-search form {
    display: flex;
    gap: 0.5rem;
}

.header-search input {
    flex: 1;
    padding: 0.45rem 0.75rem;
    font-size: 0.92rem;
    font-family: var(--font-body);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.header-search input::placeholder {
    color: var(--text-faint);
}

.header-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.header-search button {
    padding: 0.45rem 0.9rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: background 0.12s;
}

.header-search button:hover {
    background: var(--accent-hover);
}

.header-nav {
    display: flex;
    gap: 1.25rem;
}

.header-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.92rem;
    position: relative;
    padding-bottom: 2px;
}

.header-nav a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.2s;
}

.header-nav a:hover {
    color: var(--text);
}

.header-nav a:hover::after {
    transform: scaleX(1);
}

/* --- Hero / Home -------------------------------------------------------- */
.hero {
    text-align: center;
    padding: 4rem 0 2rem;
}

.hero h1 {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.hero p {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 2rem;
    font-weight: 300;
}

.hero-rule {
    width: 60px;
    height: 2px;
    background: var(--accent);
    margin: 0.75rem auto 1.25rem;
    opacity: 0.7;
}

.hero-search {
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-search form {
    display: flex;
    gap: 0.5rem;
}

.hero-search input {
    flex: 1;
    padding: 0.9rem 1.25rem;
    font-size: 1rem;
    font-family: var(--font-body);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.hero-search input::placeholder {
    color: var(--text-faint);
}

.hero-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.hero-search button {
    padding: 0.9rem 1.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: background 0.12s;
}

.hero-search button:hover {
    background: var(--accent-hover);
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 0.75rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

/* --- Recent Opinions ---------------------------------------------------- */
.recent-opinions {
    max-width: 700px;
    margin: 0 auto 2.5rem;
}

.recent-opinions > .section-label {
    padding-left: 0.25rem;
}

.recent-opinions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    animation: cardSlideIn 0.35s ease-out both;
}

@keyframes cardSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.recent-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(26, 60, 110, 0.08);
    transform: translateY(-1px);
}

.recent-card-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    padding: 0.35rem 0;
    border-right: 2px solid var(--accent);
    flex-shrink: 0;
}

.recent-card-month {
    display: block;
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent);
    line-height: 1;
}

.recent-card-day {
    display: block;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.15;
}

.recent-card-body {
    flex: 1;
    min-width: 0;
}

.recent-card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 0.15rem;
}

.recent-card:hover .recent-card-title {
    color: var(--accent);
}

.recent-card-cite {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    letter-spacing: 0.02em;
    margin-bottom: 0.4rem;
}

.recent-card-holding {
    font-size: 0.82rem;
    color: var(--text-body);
    line-height: 1.55;
}

@media (max-width: 600px) {
    .recent-card-date {
        min-width: 2.5rem;
    }
    .recent-card-day {
        font-size: 1.1rem;
    }
}

/* --- Breadcrumb --------------------------------------------------------- */
.breadcrumb {
    margin-bottom: 1.5rem;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    color: var(--text-muted);
}

/* --- Section Label ------------------------------------------------------ */
.section-label {
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
}

/* --- Answer Section ----------------------------------------------------- */
.answer-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.answer-text {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-body);
}

.answer-text p {
    margin-bottom: 1em;
}

.answer-text p:last-child {
    margin-bottom: 0;
}

.query-time {
    font-size: 0.82rem;
    color: var(--text-faint);
    text-align: right;
    margin-top: 0.75rem;
    font-family: var(--font-mono);
}

/* --- Source Cards -------------------------------------------------------- */
.source-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    position: relative;
    transition: border-color 0.12s, background 0.12s;
    animation: fadeUp 0.35s ease-out both;
}

.source-card:nth-child(2) { animation-delay: 0.04s; }
.source-card:nth-child(3) { animation-delay: 0.08s; }
.source-card:nth-child(4) { animation-delay: 0.12s; }
.source-card:nth-child(5) { animation-delay: 0.16s; }
.source-card:nth-child(6) { animation-delay: 0.20s; }
.source-card:nth-child(7) { animation-delay: 0.24s; }
.source-card:nth-child(8) { animation-delay: 0.28s; }

.source-card:hover {
    border-left-color: var(--accent);
    background: var(--surface-raised);
}

.source-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.source-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: var(--radius);
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.source-title {
    flex: 1;
}

.source-title h3 {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    color: var(--text);
}

.source-meta {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-family: var(--font-body);
}

.source-holding {
    font-size: 0.95rem;
    color: var(--text-body);
    line-height: 1.65;
    margin-bottom: 0.4rem;
}

.source-topics {
    font-size: 0.88rem;
    color: var(--accent);
    font-style: italic;
}

.source-excerpt {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.source-view {
    font-size: 0.85rem;
    color: var(--accent);
    text-align: right;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.source-card:hover .source-view {
    opacity: 1;
}

.cite-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.cite-link:hover {
    text-decoration: underline;
}

/* Direct match cards */
.direct-match {
    border-left: 3px solid var(--accent);
    background: var(--accent-subtle);
}

.direct-match:hover {
    background: var(--accent-muted);
}

/* Non-cite cards */
.source-card.non-cite {
    border-color: var(--danger-border);
    border-left-color: var(--danger-border);
    background: var(--danger-bg);
}

.source-card.non-cite:hover {
    border-left-color: var(--danger);
}

/* Ancestor cards */
.source-card.ancestor-card {
    border-left-color: var(--border-strong);
}

.source-card.ancestor-card:hover {
    border-left-color: var(--accent);
}

/* --- Badges ------------------------------------------------------------- */
.cited-badge {
    display: inline-block;
    background: var(--accent-muted);
    color: var(--accent);
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: var(--font-body);
}

.non-cite-badge {
    display: inline-block;
    background: var(--danger-bg);
    color: var(--danger-text);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 0.5rem;
    border: 1px solid var(--danger-border);
}

.ancestor-badge {
    display: inline-block;
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-left: 0.5rem;
    border: 1px solid var(--accent-muted);
}

/* --- Case Sticky Header ------------------------------------------------- */
.case-sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transform: translateY(-100%);
    transition: transform 0.25s ease;
    padding: 0.5rem 1.5rem;
}

.case-sticky-header.visible {
    transform: translateY(0);
}

.case-sticky-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.case-sticky-info {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    min-width: 0;
}

.case-sticky-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.case-sticky-citation {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Case Layout (sidebar + main) --------------------------------------- */
.case-layout {
    position: relative;
}

.case-main {
    /* main content stays at full container width */
}

.case-sidebar {
    display: none;
}

@media (min-width: 1300px) {
    .case-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 33%;
        transform: translateY(-33%);
        left: max(1rem, calc((100vw - var(--max-width)) / 2 - 160px));
        width: 130px;
        gap: 0.15rem;
        z-index: 50;
    }

    .sidebar-link {
        display: block;
        padding: 0.4rem 0.65rem;
        font-size: 0.82rem;
        color: var(--text-muted);
        text-decoration: none;
        border-left: 2px solid transparent;
        transition: color 0.15s, border-color 0.15s;
        line-height: 1.3;
    }

    .sidebar-link:hover {
        color: var(--text);
    }

    .sidebar-link.active {
        color: var(--accent);
        border-left-color: var(--accent);
        font-weight: 500;
    }
}

/* --- Case Detail -------------------------------------------------------- */
.case-header {
    margin-bottom: 1.5rem;
}

.case-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.case-header-top .btn-edit {
    flex-shrink: 0;
    margin-top: 0.3rem;
}

.case-header h1 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 0.35rem;
}

.case-meta {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

.case-meta span {
    display: inline-block;
    margin-right: 0.5rem;
}

.case-meta span:not(:last-child)::after {
    content: '\2022';
    margin-left: 0.5rem;
    color: var(--border-strong);
}

/* AI Summary */
.case-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.case-summary .holding {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-body);
    margin-bottom: 0.75rem;
}

.case-summary .topics {
    font-size: 0.92rem;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

.case-summary .outcome {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

/* Headnotes */
.case-headnotes {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.case-headnotes .section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.case-headnotes .toggle-icon {
    font-size: 0.65rem;
    transition: transform 0.2s;
    color: var(--text-muted);
}

.case-headnotes.collapsed .headnotes-list {
    display: none;
}

.case-headnotes.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.headnotes-list {
    margin: 0.75rem 0 0 0;
    padding-left: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-body);
}

.headnotes-list li {
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
}

.headnotes-list li.has-source {
    cursor: pointer;
    border-radius: 4px;
    padding: 0.15rem 0.35rem;
    margin-left: -0.35rem;
    transition: background 0.15s;
}

.headnotes-list li.has-source:hover {
    background: var(--accent-muted);
}

.headnotes-list li.has-source::after {
    content: ' \2197';
    font-size: 0.75em;
    color: var(--text-faint);
}

.headnotes-list li::marker {
    color: var(--accent);
    font-weight: 600;
}

/* Opinion structural markers: section titles, author attributions, signatures */
.case-content .section-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    margin: 2rem 0 1rem 0;
    color: var(--text-muted);
}

.case-content .author-attribution {
    font-style: italic;
    font-weight: 600;
    margin: 2rem 0 0.75rem 0;
    color: var(--text);
}

.case-content .signature {
    font-style: italic;
    text-align: right;
    margin: 1rem 0 0.5rem 0;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* Paragraph highlight from headnote click */
.para-highlight {
    background: #fef9c3;
    border-left: 3px solid var(--accent);
    padding-left: 0.75rem;
    animation: flashHighlight 1.5s ease;
}

@keyframes flashHighlight {
    0% { background: #fde68a; }
    100% { background: #fef9c3; }
}

/* Search context */
.search-context {
    background: var(--highlight);
    border: 1px solid var(--accent-muted);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
}

.search-context-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.search-context-text {
    font-size: 0.95rem;
    color: var(--text-body);
    line-height: 1.65;
}

/* Case actions */
.case-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Case body */
.case-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.case-content {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text-body);
}

.case-content p {
    margin-bottom: 1.25rem;
    text-align: justify;
    hyphens: auto;
}

.case-content p:last-child {
    margin-bottom: 0;
}

/* Footnotes */
.footnotes-section {
    margin-top: 2.5rem;
}

.footnotes-rule {
    border: none;
    border-top: 1px solid var(--border-strong);
    width: 40%;
    margin: 0 0 1.25rem 0;
}

.footnotes-section p.footnote {
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    text-align: justify;
    hyphens: auto;
    scroll-margin-top: 4rem;
}

.footnotes-section p.footnote .fn-num {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    margin-right: 0.3em;
}

.case-content .fn-ref {
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
    scroll-margin-top: 4rem;
}

.case-content .fn-ref a {
    color: var(--accent);
    text-decoration: none;
    padding: 0 0.1em;
}

.case-content .fn-ref a:hover,
.case-content p.footnote .fn-num:hover {
    text-decoration: underline;
}

/* Citations (inline links in opinion text) */
.citation-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent);
}

.citation-link:hover {
    border-bottom-style: solid;
}

/* --- Citation Network --------------------------------------------------- */
#citation-network {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

#citation-network > .section-label {
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

.cn-loading, .cn-empty {
    color: var(--text-muted);
    font-size: 0.92rem;
    padding: 1rem 0;
}

.cn-warning {
    background: var(--danger-bg);
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
    line-height: 1.6;
}

.cn-warning a {
    font-weight: 600;
}

.cn-treatment-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    gap: 2px;
}

.cn-bar-seg {
    border-radius: 3px;
    transition: opacity 0.15s;
}

.cn-bar-seg:hover {
    opacity: 0.7;
}

.cn-treatment-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.82rem;
}

.cn-legend-count {
    color: var(--text-muted);
    margin-right: 0.25rem;
}

.treatment-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border: 1px solid;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.cn-section {
    margin-bottom: 1.5rem;
}

.cn-section > .section-label {
    margin-bottom: 0.75rem;
}

.cn-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.cn-item {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    transition: background 0.12s;
}

.cn-item:hover {
    background: var(--surface-hover);
}

.cn-case {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}

.cn-case-name {
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.95rem;
}

.cn-case-name:hover {
    text-decoration: underline;
}

.cn-case-cite {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.cn-cited-count {
    font-size: 0.78rem;
    color: var(--text-faint);
}

.cn-holding {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 0.2rem;
    padding-left: 0.1rem;
}

/* --- Case Edit ---------------------------------------------------------- */
.edit-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 600px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.7rem 0.75rem;
    font-size: 1rem;
    font-family: var(--font-body);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.6;
}

.form-group .help-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.readonly-field {
    padding: 0.7rem 0.75rem;
    font-size: 0.92rem;
    font-family: var(--font-mono);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
}

.readonly-field .no-value {
    color: var(--text-faint);
    font-style: italic;
    font-family: var(--font-body);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.delete-section {
    margin-top: 3rem;
    padding: 1.5rem;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius);
}

.delete-section h3 {
    color: var(--danger-text);
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}

.delete-section p {
    color: var(--danger-text);
    font-size: 0.88rem;
    margin-bottom: 1rem;
    opacity: 0.85;
}

/* --- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid var(--border);
    transition: all 0.12s;
    letter-spacing: 0.01em;
}

.btn-edit {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-edit:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--text-muted);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #cc3b3b;
    border-color: #cc3b3b;
}

/* --- Browse ------------------------------------------------------------- */
.browse-year-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem;
}

.browse-year-card {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.12s, background 0.12s;
}

.browse-year-card:hover {
    border-color: var(--accent);
    background: var(--surface-raised);
}

.browse-year-card.unknown {
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

.browse-year-card.unknown:hover {
    border-color: var(--danger);
}

.browse-year-card.botched {
    border-color: var(--warning-border);
    background: var(--warning-bg);
}

.browse-year-card.botched:hover {
    border-color: var(--warning-text);
}

.browse-year-card.citation-prefixed {
    border-color: var(--warning-border);
    background: var(--warning-bg);
}

.browse-year-card.citation-prefixed:hover {
    border-color: var(--warning-text);
}

.year-name {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    color: var(--text);
}

.year-count {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.browse-section {
    margin-top: 2.5rem;
}

/* Case list (browse by year, unknown, botched, etc.) */
.case-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.case-row {
    display: grid;
    grid-template-columns: 140px 1fr 100px;
    gap: 1rem;
    padding: 0.65rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    align-items: center;
    transition: border-color 0.12s, background 0.12s;
}

.case-row:hover {
    border-color: var(--accent);
    background: var(--surface-raised);
}

.case-row.non-cite {
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

.case-row.non-cite:hover {
    border-color: var(--danger);
}

.case-citation {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    font-family: var(--font-mono);
    color: var(--text);
}

.case-name {
    font-size: 0.95rem;
    color: var(--text-body);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.case-date {
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: right;
    font-family: var(--font-mono);
}

.case-id {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.case-docket {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.year-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5rem;
}

.year-header h1 {
    margin: 0;
}

.case-count {
    font-size: 0.88rem;
    color: var(--text-muted);
}

/* Quality issue notes */
.unknown-header,
.botched-header,
.prefixed-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5rem;
}

.unknown-header h1,
.botched-header h1,
.prefixed-header h1 {
    margin: 0;
}

.unknown-note {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    color: var(--danger-text);
}

.botched-note {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    color: var(--warning-text);
}

.prefixed-note {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    color: var(--warning-text);
}

/* --- Statutes ----------------------------------------------------------- */
.statute-meta {
    margin-bottom: 1.5rem;
}

.statute-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    line-height: 1.8;
    color: var(--text-body);
}

.statute-body p {
    margin-bottom: 0.75rem;
}

.statute-body p:last-child {
    margin-bottom: 0;
}

.statute-history {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.statute-history-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.statute-xrefs {
    margin-top: 1.5rem;
}

.statute-citing {
    margin-top: 2rem;
}

/* Statute browse grids */
.statute-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.6rem;
}

.statute-title-card {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.12s, background 0.12s;
}

.statute-title-card:hover {
    border-color: var(--accent);
    background: var(--surface-raised);
}

.statute-title-card h3 {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.statute-title-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.statute-chapter-group {
    margin-bottom: 2rem;
}

.statute-chapter-group h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.statute-section-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.statute-section-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-body);
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: var(--radius);
    transition: background 0.12s;
}

.statute-section-link:hover {
    background: var(--surface-raised);
    color: var(--accent);
}

/* --- Tabs --------------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab {
    padding: 0.45rem 0.9rem;
    text-decoration: none;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-radius: var(--radius);
    transition: background 0.12s, color 0.12s;
}

.tab:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.tab.active {
    background: var(--accent);
    color: #fff;
}

/* --- Popular ------------------------------------------------------------ */
.popular-grid {
    display: grid;
    gap: 0.6rem;
}

.popular-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.12s;
}

.popular-card:hover {
    border-color: var(--accent);
}

.popular-rank {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-faint);
    width: 24px;
    font-family: var(--font-mono);
}

.popular-info {
    flex: 1;
}

.popular-info h4 {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
}

.popular-info p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.popular-cited {
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 500;
}

/* --- Login -------------------------------------------------------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
}

.login-box h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
    text-align: center;
    color: var(--text);
}

.login-rule {
    width: 40px;
    height: 2px;
    background: var(--accent);
    margin: 0 auto 1.5rem;
    opacity: 0.7;
}

.login-box label {
    display: block;
    font-size: 0.82rem;
    margin-bottom: 0.3rem;
    color: var(--text-muted);
    font-weight: 500;
}

.login-box input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    margin-bottom: 1rem;
    transition: border-color 0.15s;
}

.login-box input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.login-box button {
    width: 100%;
    padding: 0.6rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}

.login-box button:hover {
    background: var(--accent-hover);
}

.login-box .error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* --- Utilities ---------------------------------------------------------- */
.text-muted {
    color: var(--text-muted);
    font-size: 0.88rem;
}


.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 0.5rem;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* --- Animations --------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
    .header-search {
        display: none;
    }

    .container {
        padding: 1rem;
    }

    .hero {
        padding: 2.5rem 0 1.5rem;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .stats-bar {
        gap: 1.5rem;
    }

    .case-body {
        padding: 1.25rem;
    }

    .case-row {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .case-date {
        text-align: left;
    }

    .browse-year-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    .statute-grid {
        grid-template-columns: 1fr;
    }
}
