:root {
    --accent: #315cff;
    --accent-rgb: 49, 92, 255;
    --sidebar-width: 340px;
    --font-scale: 1;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --surface-3: #eef1f7;
    --text: #182033;
    --muted: #687086;
    --faint: #8d95a7;
    --line: #dfe3ed;
    --line-strong: #cdd3e0;
    --danger: #c8324a;
    --success: #087c5b;
    --warning: #95620b;
    --shadow: 0 18px 50px rgba(24, 32, 51, 0.10);
    --shadow-soft: 0 8px 25px rgba(24, 32, 51, 0.07);
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 9px;
    --transition: 160ms ease;
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #0d111b;
    --surface: #151b28;
    --surface-2: #1b2231;
    --surface-3: #242c3d;
    --text: #f2f4fa;
    --muted: #a8b0c2;
    --faint: #818ba0;
    --line: #2b3446;
    --line-strong: #3a455a;
    --danger: #ff6e82;
    --success: #53d8ad;
    --warning: #ffc76a;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
    --shadow-soft: 0 8px 25px rgba(0, 0, 0, 0.22);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        --bg: #0d111b;
        --surface: #151b28;
        --surface-2: #1b2231;
        --surface-3: #242c3d;
        --text: #f2f4fa;
        --muted: #a8b0c2;
        --faint: #818ba0;
        --line: #2b3446;
        --line-strong: #3a455a;
        --danger: #ff6e82;
        --success: #53d8ad;
        --warning: #ffc76a;
        --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
        --shadow-soft: 0 8px 25px rgba(0, 0, 0, 0.22);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: calc(16px * var(--font-scale));
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }

.hidden { display: none !important; }
.mobile-only { display: none !important; }
.spacer { flex: 1; }

/* Login */
.login-page {
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 12% 10%, rgba(49, 92, 255, .15), transparent 28rem),
        radial-gradient(circle at 92% 85%, rgba(119, 87, 255, .13), transparent 28rem),
        var(--bg);
}

.login-shell {
    width: min(1180px, calc(100% - 40px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(360px, .85fr) minmax(480px, 1.15fr);
    align-items: center;
    gap: 72px;
    padding: 64px 0;
}

.login-card {
    max-width: 520px;
}

.brand-mark {
    width: 64px;
    height: 64px;
    border-radius: 19px;
    display: inline-grid;
    place-items: center;
    background: var(--accent);
    color: white;
    font-family: Georgia, serif;
    font-size: 36px;
    box-shadow: 0 16px 36px rgba(var(--accent-rgb), .28);
}

.brand-mark.small {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 25px;
    flex: 0 0 auto;
}

.eyebrow {
    margin: 22px 0 8px;
    color: var(--accent);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.login-card h1 {
    margin: 0;
    max-width: 600px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.65rem, 5vw, 4.7rem);
    line-height: .98;
    letter-spacing: -.045em;
}

.login-copy {
    margin: 26px 0 30px;
    max-width: 540px;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.7;
}

.google-button-wrap {
    min-height: 46px;
    display: flex;
    align-items: center;
}

.fine-print {
    max-width: 460px;
    margin: 18px 0 0;
    color: var(--faint);
    font-size: .78rem;
    line-height: 1.55;
}

.alert {
    margin: 20px 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    line-height: 1.5;
}
.alert-error { border-color: rgba(200, 50, 74, .45); color: var(--danger); }
.alert-warning { border-color: rgba(149, 98, 11, .35); color: var(--warning); }

.login-preview {
    perspective: 1200px;
}

.preview-window {
    min-height: 550px;
    display: grid;
    grid-template-columns: 210px 1fr;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 28px;
    background: var(--surface);
    box-shadow: 0 40px 90px rgba(26, 34, 59, .22);
    transform: rotateY(-4deg) rotateX(1deg);
}

.preview-sidebar {
    padding: 34px 24px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #141b2c;
    color: #eff3ff;
}
.preview-sidebar strong { margin-top: 18px; font-size: .9rem; }
.preview-sidebar small { color: #aeb9d6; line-height: 1.4; }
.preview-pill { width: 92px; height: 12px; border-radius: 99px; background: #315cff; margin-bottom: 34px; }

.preview-document {
    padding: 82px 55px;
    background:
        linear-gradient(rgba(255,255,255,.96), rgba(255,255,255,.96)),
        repeating-linear-gradient(0deg, transparent 0 31px, #eef1f7 32px);
    color: #182033;
}
.preview-kicker { color: #315cff; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.preview-document h2 { margin: 22px 0 16px; font-family: Georgia, serif; font-size: 3.3rem; }
.preview-document p { color: #5d667b; line-height: 1.8; }
.preview-note { margin-top: 46px; padding: 22px; border-left: 5px solid #e8b83f; border-radius: 4px 14px 14px 4px; background: #fff3bd; color: #5f4b14; box-shadow: var(--shadow-soft); }

/* Main application */
.app-page { overflow: hidden; }
.app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) 0;
    transition: grid-template-columns var(--transition);
}
.app-shell.notes-open { grid-template-columns: var(--sidebar-width) minmax(0, 1fr) minmax(320px, 390px); }

.sidebar {
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--line);
    background: var(--surface);
    z-index: 20;
}

.sidebar-header {
    min-height: 78px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong { font-size: .98rem; }
.brand-copy small { margin-top: 3px; color: var(--muted); font-size: .68rem; }

.profile-card {
    margin: 15px 16px 10px;
    padding: 11px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}
.profile-card img { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.profile-card div { min-width: 0; display: flex; flex-direction: column; }
.profile-card strong, .profile-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-card strong { font-size: .82rem; }
.profile-card small { margin-top: 2px; color: var(--muted); font-size: .65rem; }

.sidebar-search, .article-search {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--muted);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.sidebar-search:focus-within, .article-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .1); }
.sidebar-search { margin: 0 16px 13px; padding: 9px 11px; }
.sidebar-search input, .article-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.sidebar-search input { font-size: .78rem; }

.sidebar-section { padding: 0 10px; min-height: 0; }
.sidebar-section.grow { flex: 1; overflow: auto; }
.law-library-section { max-height: 32vh; overflow: auto; padding-bottom: 10px; border-top: 1px solid var(--line); }
.section-heading {
    position: sticky;
    top: 0;
    z-index: 2;
    min-height: 43px;
    padding: 12px 7px 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    color: var(--muted);
    font-size: .69rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.mini-button, .icon-button {
    border: 0;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    background: transparent;
    color: var(--muted);
    transition: background var(--transition), color var(--transition), transform var(--transition);
}
.mini-button { width: 27px; height: 27px; border-radius: 8px; font-size: 1.1rem; }
.icon-button { width: 38px; height: 38px; border-radius: 10px; font-size: 1.35rem; }
.mini-button:hover, .icon-button:hover { background: var(--surface-3); color: var(--text); }
.mini-button:active, .icon-button:active { transform: scale(.95); }

.category-tree, .law-list { display: flex; flex-direction: column; gap: 4px; }
.category-group { border-radius: var(--radius-md); }
.category-header {
    width: 100%;
    padding: 9px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    text-align: left;
}
.category-header:hover { background: var(--surface-2); }
.category-chevron { color: var(--faint); font-size: .75rem; transition: transform var(--transition); }
.category-group.collapsed .category-chevron { transform: rotate(-90deg); }
.category-color { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.category-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .79rem; font-weight: 700; }
.category-count { color: var(--faint); font-size: .68rem; }
.category-edit { opacity: 0; }
.category-header:hover .category-edit { opacity: 1; }
.category-items { padding: 2px 0 7px 22px; display: flex; flex-direction: column; gap: 2px; }
.category-group.collapsed .category-items { display: none; }

.bookmark-item {
    position: relative;
    width: 100%;
    padding: 8px 9px 8px 12px;
    display: grid;
    grid-template-columns: 4px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
    text-align: left;
}
.bookmark-item:hover { background: var(--surface-2); }
.bookmark-stripe { width: 4px; height: 31px; border-radius: 99px; }
.bookmark-copy { min-width: 0; display: flex; flex-direction: column; }
.bookmark-copy strong, .bookmark-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-copy strong { font-size: .73rem; }
.bookmark-copy small { margin-top: 2px; color: var(--muted); font-size: .62rem; }
.bookmark-menu { opacity: 0; }
.bookmark-item:hover .bookmark-menu { opacity: 1; }

.uncategorized-label { padding: 12px 8px 5px 27px; color: var(--faint); font-size: .64rem; font-weight: 700; text-transform: uppercase; }

.law-item {
    width: 100%;
    padding: 9px 8px;
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    text-align: left;
}
.law-item:hover { background: var(--surface-2); }
.law-item.active { border-color: rgba(var(--accent-rgb), .22); background: rgba(var(--accent-rgb), .08); }
.law-item.hidden-law { opacity: .55; }
.law-color { width: 9px; height: 30px; border-radius: 99px; }
.law-copy { min-width: 0; display: flex; flex-direction: column; }
.law-copy strong, .law-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.law-copy strong { font-size: .75rem; }
.law-copy small { margin-top: 3px; color: var(--muted); font-size: .61rem; }
.law-edit { opacity: 0; }
.law-item:hover .law-edit { opacity: 1; }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.logout-form { margin: 0; }
.sidebar-action { width: 100%; padding: 9px 10px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: .73rem; text-align: left; }
.sidebar-action:hover { background: var(--surface-2); color: var(--text); }

.workspace { min-width: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
    min-height: 92px;
    padding: 16px 27px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(16px);
}
.law-heading { min-width: 0; flex: 1; display: flex; align-items: center; gap: 13px; }
.law-dot { width: 11px; height: 42px; border-radius: 99px; background: var(--accent); flex: 0 0 auto; }
.law-heading .eyebrow { margin: 0 0 4px; font-size: .63rem; }
.law-heading h1 { margin: 0; max-width: 600px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.35rem, 2.1vw, 2rem); letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.article-search { width: min(300px, 25vw); padding: 9px 12px; }
.article-search input { font-size: .78rem; }

.button {
    min-height: 40px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--accent);
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: .75rem;
    font-weight: 750;
    transition: transform var(--transition), filter var(--transition), background var(--transition), border-color var(--transition);
}
.button:hover { filter: brightness(1.04); }
.button:active { transform: translateY(1px); }
.button.secondary { border-color: var(--line); background: var(--surface); color: var(--text); }
.button.secondary:hover { background: var(--surface-2); }
.button.ghost { background: transparent; }
.button.danger { border-color: rgba(200, 50, 74, .35); color: var(--danger); }
.button.full { width: 100%; }
.button:disabled { opacity: .5; cursor: not-allowed; }

.document-toolbar { min-height: 54px; padding: 10px 28px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.document-toolbar > div:first-child { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.document-toolbar strong { font-size: .76rem; }
.document-toolbar span { color: var(--muted); font-size: .69rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-toggle { padding: 3px; display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.view-toggle button { padding: 5px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: .66rem; }
.view-toggle button.active { background: var(--surface-3); color: var(--text); font-weight: 700; }

.article-list { flex: 1; min-height: 0; overflow: auto; padding: 28px clamp(22px, 5vw, 80px) 100px; scroll-behavior: smooth; }
.article-card {
    position: relative;
    max-width: 980px;
    margin: 0 auto 16px;
    padding: 28px 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 1px 0 rgba(24, 32, 51, .02);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.article-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-soft); }
.article-card.focused { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .09), var(--shadow-soft); }
.article-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.article-number { display: flex; align-items: center; gap: 12px; }
.article-number .number-box { min-width: 64px; height: 42px; padding: 0 12px; display: inline-grid; place-items: center; border-radius: 11px; background: rgba(var(--accent-rgb), .09); color: var(--accent); font-family: Georgia, serif; font-size: 1.08rem; font-weight: 700; }
.article-number h2 { margin: 0; font-family: Georgia, serif; font-size: 1.24rem; }
.article-actions { display: flex; align-items: center; gap: 5px; }
.article-action { min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: .68rem; }
.article-action:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--text); }
.article-action.primary { border-color: rgba(var(--accent-rgb), .2); background: rgba(var(--accent-rgb), .07); color: var(--accent); }
.article-body { margin-top: 21px; color: color-mix(in srgb, var(--text) 88%, var(--muted)); font-family: Georgia, "Times New Roman", serif; font-size: 1.02rem; line-height: 1.85; white-space: normal; }
.article-body > :first-child { margin-top: 0; }
.article-body > :last-child { margin-bottom: 0; }
.article-body p { margin: 0 0 1em; }
.article-body h4 { margin: 1.35em 0 .65em; font-size: 1rem; }
.law-lid { margin: 0 0 1em; display: grid; grid-template-columns: minmax(28px, auto) minmax(0, 1fr); gap: 12px; align-items: start; }
.law-lid-number { min-width: 28px; padding-top: .08em; color: var(--muted); font-family: var(--font-sans, Inter, system-ui, sans-serif); font-size: .82rem; font-weight: 800; }
.law-lid-content { min-width: 0; }
.law-lid-content > :first-child { margin-top: 0; }
.law-lid-content > :last-child { margin-bottom: 0; }
.law-list-block { margin: .75em 0 1em 1.35em; padding: 0; }
.law-list-block li { margin: .35em 0; padding-left: .25em; }
.law-table-wrap { max-width: 100%; margin: 1em 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.law-table-wrap table { width: 100%; border-collapse: collapse; font-family: var(--font-sans, Inter, system-ui, sans-serif); font-size: .78rem; }
.law-table-wrap th, .law-table-wrap td { padding: 9px 11px; border: 1px solid var(--line); vertical-align: top; text-align: left; }
.law-table-wrap th { background: var(--surface-2); font-weight: 800; }
.article-meta { margin-top: 22px; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); }
.article-meta-group { display: flex; flex-wrap: wrap; gap: 7px; }
.meta-chip { padding: 5px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: .63rem; }
.meta-chip.note-chip { border: 1px solid color-mix(in srgb, var(--chip-color, #fff0a8) 75%, var(--line)); background: color-mix(in srgb, var(--chip-color, #fff0a8) 22%, var(--surface)); color: var(--text); cursor: pointer; }
.article-source { color: var(--muted); font-size: .63rem; }
.article-source:hover { color: var(--accent); }

.app-shell.compact .article-list { padding-top: 18px; }
.app-shell.compact .article-card { margin-bottom: 9px; padding: 17px 20px; }
.app-shell.compact .article-body { margin-top: 13px; font-size: .9rem; line-height: 1.62; }
.app-shell.compact .article-meta { margin-top: 13px; padding-top: 10px; }

.empty-state { min-height: 55vh; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-state .empty-icon { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 22px; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-soft); font-family: Georgia, serif; font-size: 36px; }
.empty-state h2 { margin: 20px 0 6px; color: var(--text); font-family: Georgia, serif; font-size: 1.6rem; }
.empty-state p { max-width: 450px; margin: 0; line-height: 1.6; }

.notes-panel { min-width: 0; height: 100vh; overflow: hidden; border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; transform: translateX(100%); opacity: 0; transition: transform var(--transition), opacity var(--transition); }
.app-shell.notes-open .notes-panel { transform: translateX(0); opacity: 1; }
.notes-panel > header { min-height: 92px; padding: 19px 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.notes-panel .eyebrow { margin: 0 0 5px; font-size: .6rem; }
.notes-panel h2 { margin: 0; font-family: Georgia, serif; font-size: 1.15rem; }
.notes-list { flex: 1; overflow: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
.notes-panel > .button { margin: 15px; width: calc(100% - 30px); }
.note-card { padding: 15px; border: 1px solid var(--line); border-left: 5px solid var(--note-color); border-radius: var(--radius-md); background: color-mix(in srgb, var(--note-color) 12%, var(--surface)); cursor: pointer; }
.note-card:hover { border-color: var(--line-strong); }
.note-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.note-card h3 { margin: 0; font-size: .81rem; }
.note-card small { color: var(--muted); font-size: .62rem; }
.note-card p { margin: 10px 0 0; color: var(--text); font-size: .72rem; line-height: 1.6; white-space: pre-wrap; }
.note-empty { padding: 30px 10px; color: var(--muted); text-align: center; font-size: .76rem; line-height: 1.6; }

.scrim { position: fixed; inset: 0; z-index: 15; background: rgba(5, 8, 14, .42); opacity: 0; pointer-events: none; transition: opacity var(--transition); }

/* Dialogs and forms */
.modal {
    width: min(520px, calc(100% - 28px));
    max-height: min(86vh, 850px);
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}
.modal.wide { width: min(690px, calc(100% - 28px)); }
.modal::backdrop { background: rgba(7, 10, 18, .58); backdrop-filter: blur(3px); }
.modal form { max-height: inherit; padding: 22px; overflow: auto; }
.modal-header { margin-bottom: 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.modal-header .eyebrow { margin: 0 0 5px; font-size: .61rem; }
.modal-header h2 { margin: 0; font-family: Georgia, serif; font-size: 1.45rem; }
.modal label { margin-bottom: 15px; display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.modal input:not([type="checkbox"]):not([type="range"]), .modal textarea, .modal select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: 0;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 400;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.modal textarea { resize: vertical; line-height: 1.55; }
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .1); }
.modal input[type="color"] { min-height: 43px; padding: 5px !important; cursor: pointer; }
.modal input[type="range"] { width: 100%; accent-color: var(--accent); }
.form-grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-help { margin: -3px 0 16px; color: var(--faint); font-size: .67rem; line-height: 1.5; }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 9px !important; }
.checkbox-row input { accent-color: var(--accent); }
.context-card { margin-bottom: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: .75rem; line-height: 1.5; }
.context-card strong { color: var(--accent); }
.modal-actions { margin-top: 20px; padding-top: 16px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }


.dialog-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: stretch; }
.dialog-search-row .button { min-height: 43px; }
.law-search-results { min-height: 130px; max-height: 48vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.law-search-result { width: 100%; padding: 13px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text); }
.law-search-result:hover { border-color: var(--line-strong); background: var(--surface-3); }
.law-search-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.law-search-copy strong { overflow: hidden; text-overflow: ellipsis; font-size: .78rem; line-height: 1.35; }
.law-search-copy small { color: var(--muted); font-size: .65rem; line-height: 1.4; }
.law-search-result .button { white-space: nowrap; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 9px; pointer-events: none; }
.toast { min-width: 260px; max-width: 420px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: .76rem; line-height: 1.45; animation: toast-in 180ms ease both; }
.toast.error { border-color: rgba(200, 50, 74, .4); color: var(--danger); }
.toast.success { border-color: rgba(8, 124, 91, .35); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.loading-line { height: 4px; position: fixed; top: 0; left: 0; z-index: 1001; background: var(--accent); animation: loading 1.2s ease-in-out infinite; }
@keyframes loading { 0% { width: 0; left: 0; } 50% { width: 50%; left: 25%; } 100% { width: 0; left: 100%; } }

@media (max-width: 1180px) {
    .app-shell, .app-shell.notes-open { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
    .notes-panel { position: fixed; top: 0; right: 0; z-index: 40; width: min(390px, 92vw); box-shadow: var(--shadow); }
    .app-shell.notes-open .scrim { opacity: 1; pointer-events: auto; }
    .topbar-actions .button.secondary { padding-inline: 10px; }
    #editLawButton { font-size: 0; }
    #editLawButton::after { content: 'Aanpassen'; font-size: .72rem; }
}

@media (max-width: 860px) {
    .mobile-only { display: inline-grid !important; }
    .app-shell, .app-shell.notes-open { display: block; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-width), 92vw); transform: translateX(-101%); transition: transform var(--transition); box-shadow: var(--shadow); }
    .app-shell.sidebar-open .sidebar { transform: translateX(0); }
    .app-shell.sidebar-open .scrim, .app-shell.notes-open .scrim { opacity: 1; pointer-events: auto; }
    .workspace { width: 100%; }
    .topbar { min-height: auto; padding: 13px 15px; flex-wrap: wrap; }
    .law-heading { order: 1; flex: 1; }
    #openSidebar { order: 0; }
    .topbar-actions { order: 2; width: 100%; }
    .article-search { flex: 1; width: auto; }
    #sourceLink, #editLawButton { min-width: 42px; padding: 8px 10px; }
    #sourceLink { font-size: 0; }
    #sourceLink::after { content: '↗'; font-size: 1rem; }
    #editLawButton::after { content: '⚙'; font-size: 1rem; }
    .document-toolbar { padding: 9px 15px; }
    .article-list { padding: 18px 13px 90px; }
    .article-card { padding: 20px 17px; }
    .article-card-header { flex-direction: column; }
    .article-actions { width: 100%; }
    .article-action { flex: 1; }
}

@media (max-width: 720px) {
    .login-shell { width: min(100% - 30px, 520px); display: block; padding: 40px 0; }
    .login-preview { display: none; }
    .login-card h1 { font-size: clamp(2.4rem, 13vw, 4rem); }
    .form-grid.two { grid-template-columns: 1fr; gap: 0; }
    .modal form { padding: 18px; }
    .dialog-search-row { grid-template-columns: 1fr; }
    .law-search-result { grid-template-columns: 1fr; }
    .law-search-result .button { width: 100%; }
}

/* Access, billing and note limits */
.alert-success {
    border-color: rgba(8, 124, 91, .35);
    color: var(--success);
}

.trial-chip {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(var(--accent-rgb), .28);
    border-radius: 999px;
    background: rgba(var(--accent-rgb), .09);
    color: var(--accent);
    font-size: .78rem;
    font-weight: 800;
    white-space: nowrap;
}

.character-counter {
    display: block;
    margin-top: 6px;
    color: var(--faint);
    font-size: .75rem;
    text-align: right;
}

.character-counter.limit-near { color: var(--warning); font-weight: 800; }

.billing-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 0%, rgba(var(--accent-rgb), .12), transparent 34rem),
        var(--bg);
}

.billing-shell {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 60px;
}

.billing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px 0 36px;
}

.billing-brand { display: inline-flex; align-items: center; gap: 12px; }
.billing-user { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .85rem; }
.billing-user form { margin: 0; }

.billing-hero {
    max-width: 850px;
    margin: 24px auto 42px;
    text-align: center;
}

.billing-hero .eyebrow { margin-top: 0; }
.billing-hero h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    line-height: 1;
    letter-spacing: -.045em;
}
.billing-hero > p:not(.eyebrow) { color: var(--muted); font-size: 1.04rem; line-height: 1.7; }
.billing-hero .alert { max-width: 720px; margin-left: auto; margin-right: auto; text-align: left; }
.billing-enter { margin-top: 8px; }

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: stretch;
}

.price-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.price-card.featured {
    border-color: rgba(var(--accent-rgb), .45);
    box-shadow: 0 24px 60px rgba(var(--accent-rgb), .16);
    transform: translateY(-10px);
}

.price-badge {
    position: absolute;
    top: -13px;
    left: 50%;
    transform: translateX(-50%);
    padding: 7px 13px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: .72rem;
    font-weight: 900;
    white-space: nowrap;
}

.price-kicker { margin: 0; color: var(--accent); font-size: .76rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.price-card h2 { margin: 0; font-family: Georgia, serif; font-size: 2.9rem; }
.price-card h2 small { margin-left: 8px; color: var(--muted); font-family: inherit; font-size: .86rem; font-weight: 500; }
.price-card > p:not(.price-kicker) { min-height: 54px; margin: 0; color: var(--muted); line-height: 1.55; }
.price-card form { margin-top: auto; }
.price-card > small { color: var(--faint); font-size: .74rem; text-align: center; }
.price-card button:disabled { opacity: .5; cursor: not-allowed; }

.billing-manage {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-top: 32px;
    padding: 22px 25px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}
.billing-manage p { margin: 5px 0 0; color: var(--muted); }

.billing-legal {
    max-width: 900px;
    margin: 38px auto 0;
    color: var(--faint);
    font-size: .76rem;
    line-height: 1.65;
    text-align: center;
}

@media (max-width: 880px) {
    .pricing-grid { grid-template-columns: 1fr; }
    .price-card.featured { transform: none; }
}

@media (max-width: 620px) {
    .billing-header, .billing-user, .billing-manage { align-items: flex-start; flex-direction: column; }
    .billing-shell { width: min(100% - 24px, 1180px); }
    .price-card { padding: 24px; }
}

.legal-shell {
    width: min(900px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 70px;
}
.legal-nav { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0 18px; }
.legal-nav a { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: .82rem; font-weight: 800; }
.legal-document { padding: clamp(25px, 5vw, 54px); border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-soft); }
.legal-document h1 { margin: 0 0 24px; font-family: Georgia, serif; font-size: clamp(2.2rem, 5vw, 4rem); }
.legal-document section { margin-top: 30px; }
.legal-document h2 { margin: 0 0 8px; font-size: 1.05rem; }
.legal-document p { color: var(--muted); line-height: 1.75; }

/* Registration waitlist */
.compact-login-shell { grid-template-columns: minmax(0, 680px); justify-content: center; }
.waitlist-form { display: grid; gap: 14px; margin-top: 24px; }
.waitlist-form label { display: grid; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.waitlist-form input {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}
.waitlist-form input:focus { outline: 3px solid rgba(var(--accent-rgb), .15); border-color: var(--accent); }

/* Category archives, deletion choices and one-minute undo */
.category-archive-section { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); }
.category-archive-heading {
    width: 100%;
    padding: 8px 9px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    text-align: left;
    font-size: .7rem;
    font-weight: 800;
}
.category-archive-heading:hover { background: var(--surface-2); color: var(--text); }
.category-archive-section.collapsed > .category-archive-heading .category-chevron { transform: rotate(-90deg); }
.category-archive-section.collapsed > .category-archive-items { display: none; }
.category-archive-items { padding-top: 3px; }
.category-group.archived { opacity: .82; }
.archive-badge {
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: .52rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.delete-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.delete-choice {
    min-height: 128px;
    padding: 17px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}
.delete-choice:hover { border-color: var(--accent); background: rgba(var(--accent-rgb), .07); }
.delete-choice strong { font-size: .84rem; }
.delete-choice span { color: var(--muted); font-size: .69rem; line-height: 1.55; }
.delete-choice.danger-choice:hover { border-color: rgba(200, 50, 74, .58); background: rgba(200, 50, 74, .07); }

.modal select:disabled { opacity: .58; cursor: not-allowed; }
.toast.has-action {
    min-width: min(430px, calc(100vw - 40px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    pointer-events: auto;
}
.toast-message { min-width: 0; }
.toast-action {
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid rgba(var(--accent-rgb), .35);
    border-radius: 8px;
    background: rgba(var(--accent-rgb), .1);
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}
.toast-action:hover { background: rgba(var(--accent-rgb), .17); }
.toast-action:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 620px) {
    .delete-choice-grid { grid-template-columns: 1fr; }
    .toast.has-action { align-items: stretch; flex-direction: column; }
    .toast-action { width: 100%; }
}
