/* ==========================================================================
   DNB Emergency Medicine Question Bank — Design System
   Warm, glassy aesthetic inspired by Notion
   ========================================================================== */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Text — opacity variants of #37352f */
    --text-primary: #37352f;
    --text-secondary: rgba(55, 53, 47, 0.65);
    --text-muted: rgba(55, 53, 47, 0.45);
    --text-inverse: #f7f6f3;

    /* Backgrounds */
    --bg-page: #f7f6f3;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-glass-heavy: rgba(255, 255, 255, 0.8);
    --bg-sidebar: rgba(255, 255, 255, 0.45);
    --bg-hover: rgba(255, 255, 255, 0.7);
    --bg-active: rgba(55, 53, 47, 0.08);
    --bg-active-sidebar: rgba(55, 53, 47, 0.92);

    /* Borders */
    --border: rgba(55, 53, 47, 0.1);

    /* Accent — warm dark, no blue */
    --accent: #37352f;
    --accent-bg: rgba(55, 53, 47, 0.04);
    --accent-badge: rgba(55, 53, 47, 0.1);

    /* Warm shadows */
    --shadow-xs: 0 1px 2px rgba(55, 53, 47, 0.03);
    --shadow-sm: 0 2px 8px rgba(55, 53, 47, 0.04);
    --shadow-md: 0 8px 30px rgba(55, 53, 47, 0.05);
    --shadow-lg: 0 8px 30px rgba(55, 53, 47, 0.08);

    /* Sizing */
    --sidebar-width: 280px;
    --content-max-width: 900px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 28px;
    --radius-full: 999px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
    /* Text — light on dark */
    --text-primary: #ebebeb;
    --text-secondary: rgba(235, 235, 235, 0.6);
    --text-muted: rgba(235, 235, 235, 0.38);
    --text-inverse: #191919;

    /* Backgrounds */
    --bg-page: #191919;
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-heavy: rgba(255, 255, 255, 0.08);
    --bg-sidebar: rgba(255, 255, 255, 0.03);
    --bg-hover: rgba(255, 255, 255, 0.08);
    --bg-active: rgba(255, 255, 255, 0.08);
    --bg-active-sidebar: rgba(255, 255, 255, 0.9);

    /* Borders */
    --border: rgba(255, 255, 255, 0.1);

    /* Accent — warm light */
    --accent: #ebebeb;
    --accent-bg: rgba(255, 255, 255, 0.04);
    --accent-badge: rgba(255, 255, 255, 0.1);

    /* Shadows — subtle on dark */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* Dark theme overrides for hardcoded colors */
[data-theme="dark"] .sidebar-link {
    color: rgba(235, 235, 235, 0.6);
}

[data-theme="dark"] .sidebar-link.active {
    color: var(--text-inverse);
}

[data-theme="dark"] .sidebar-link.active .sidebar-link-count {
    color: rgba(25, 25, 25, 0.5);
}

[data-theme="dark"] .database-row:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .question-card-header {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .sub-part.highlighted {
    background-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .marks-badge {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .tag {
    background-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .search-input:focus {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .search-page-input:focus {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] mark {
    background-color: rgba(255, 212, 0, 0.2);
}

[data-theme="dark"] .sidebar-overlay {
    background-color: rgba(0, 0, 0, 0.6);
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
    display: none;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-page);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
}

img, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ==========================================================================
   LAYOUT
   ========================================================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR — frosted glass, inverted active state
   ========================================================================== */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal),
                min-width var(--transition-normal);
    z-index: 50;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
}

/* -- Sidebar Header ---------------------------------------------------- */

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 16px;
    white-space: nowrap;
    gap: 12px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background-color: var(--text-primary);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.sidebar-logo {
    width: 160px;
    height: auto;
    display: block;
}

[data-theme="dark"] .sidebar-logo {
    content: url('/static/logo-dark.png');
}

.login-logo {
    height: 72px;
    width: auto;
    margin: 0 auto 16px;
    display: block;
}

[data-theme="dark"] .login-logo {
    content: url('/static/logo-dark.png');
}

.sidebar-brand-text {
    min-width: 0;
}

.sidebar-workspace {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    line-height: 1.3;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    display: block;
    line-height: 1.3;
}

.sidebar-collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background-color var(--transition-fast),
                color var(--transition-fast);
}

.sidebar-collapse:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-expand {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
    cursor: pointer;
}

.sidebar-expand:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.app-layout.sidebar-collapsed .sidebar-expand {
    display: flex;
}

/* -- Sidebar Navigation ------------------------------------------------ */

.sidebar-nav {
    flex: 1;
    padding: 0 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 16px 12px 6px;
    white-space: nowrap;
    user-select: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 400;
    color: rgba(55, 53, 47, 0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all var(--transition-fast);
    gap: 8px;
}

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

/* Inverted active state — dark bg, light text */
.sidebar-link.active {
    background-color: var(--bg-active-sidebar);
    color: var(--text-inverse);
    font-weight: 500;
    box-shadow: var(--shadow-xs);
}

.sidebar-link.active .sidebar-link-count {
    color: rgba(247, 246, 243, 0.6);
}

.sidebar-link-name,
.sidebar-link-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-link-count {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.sidebar-divider {
    height: 1px;
    background-color: var(--border);
    margin: 8px 0;
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */

.main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.content-area {
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
    padding: 28px 32px 48px;
    flex: 1;
}

/* ==========================================================================
   TOP BAR — floating glass card
   ========================================================================== */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    margin: 16px 24px 0;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 40;
    gap: 12px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

/* -- Breadcrumb -------------------------------------------------------- */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    flex-wrap: wrap;
    min-width: 0;
}

.breadcrumb a {
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.breadcrumb a:hover {
    color: var(--text-primary);
}

.breadcrumb .breadcrumb-sep {
    color: var(--text-muted);
    font-size: 12px;
    user-select: none;
    margin: 0 2px;
}

/* -- Search (top bar) -------------------------------------------------- */

.search-form {
    display: flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.search-input {
    width: 200px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--bg-page);
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: width var(--transition-normal),
                border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

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

.search-input:focus {
    width: 260px;
    border-color: rgba(55, 53, 47, 0.25);
    box-shadow: 0 0 0 3px rgba(55, 53, 47, 0.06);
}

/* -- Mobile menu (hidden on desktop) ----------------------------------- */

.mobile-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.mobile-menu:hover {
    background-color: var(--bg-active);
}

/* -- Mobile search icon (hidden on desktop, shown on mobile) ----------- */

.mobile-search {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: color var(--transition-fast),
                background-color var(--transition-fast);
}

.mobile-search:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */

.page-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.page-title .text-secondary {
    font-weight: 400;
    font-size: 16px;
    margin-left: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.section-heading {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 16px;
}

/* ==========================================================================
   DATABASE TABLE — Home page section list (glass card)
   ========================================================================== */

.database-table {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
}

.database-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.database-row:last-child {
    border-bottom: none;
}

.database-row:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

.database-row-number {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 28px;
}

.database-row-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.database-row-bar-container {
    flex-shrink: 0;
    width: 120px;
    height: 6px;
    background-color: var(--bg-active);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.database-row-bar {
    height: 100%;
    background-color: var(--text-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.database-row-count {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    flex-shrink: 0;
    text-align: right;
    white-space: nowrap;
}

/* ==========================================================================
   QUESTION CARD — glass card with warm shadow
   ========================================================================== */

.question-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.question-card:hover {
    box-shadow: var(--shadow-md);
}

.question-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background-color: rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.question-card-header .question-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.question-card-header .question-meta {
    font-size: 12px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

a.question-meta:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.question-card-body {
    padding: 16px 20px;
}

/* -- Clinical Scenario ------------------------------------------------- */

.clinical-scenario {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px dashed var(--border);
}

/* -- Sub-parts --------------------------------------------------------- */

.sub-part {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

.sub-part-main {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.sub-part-text {
    flex: 1;
    line-height: 1.5;
    color: var(--text-primary);
}

.sub-part-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding-left: 24px;
}

.part-label {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Highlighted sub-part — warm dark left border */
.sub-part.highlighted {
    background-color: rgba(55, 53, 47, 0.04);
    border-left: 3px solid var(--text-primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 16px;
}

.sub-part.highlighted .part-label {
    color: var(--text-primary);
    font-weight: 700;
}

.sub-part.highlighted .sub-part-text {
    color: var(--text-primary);
}

/* Muted sub-part — softer sibling */
.sub-part.muted {
    opacity: 0.55;
    padding: 8px 14px;
}

.sub-part.muted .sub-part-text {
    color: var(--text-secondary);
    font-size: 13px;
}

.sub-part.muted .part-label {
    color: var(--text-secondary);
}

/* Section Label (on muted sub-parts) */
.section-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* Marks Badge */
.marks-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    background-color: rgba(55, 53, 47, 0.08);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    line-height: 1.4;
}

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.6);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    white-space: nowrap;
    line-height: 1.4;
    transition: background-color var(--transition-fast);
}

.tag:hover {
    background-color: var(--bg-hover);
}

/* ==========================================================================
   SUBSECTION TOGGLE — collapsible headings
   ========================================================================== */

.toggle-section {
    margin-bottom: 8px;
}

.toggle-heading {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    user-select: none;
    transition: background-color var(--transition-fast);
    gap: 10px;
}

.toggle-heading:hover {
    background-color: var(--bg-active);
}

.toggle-heading .toggle-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.toggle-heading .toggle-count {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.toggle-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition-normal);
    transform: rotate(90deg);
    flex-shrink: 0;
}

.toggle-heading.collapsed .toggle-arrow {
    transform: rotate(0deg);
}

.toggle-content {
    padding: 8px 0;
}

.toggle-content.collapsed {
    display: none;
}

/* ==========================================================================
   FILTER PILLS — inverted active state
   ========================================================================== */

/* ── Section bookmarks button + modal ───────────────────────────────── */

.section-bookmarks-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #d4a017;
    background-color: rgba(255, 212, 0, 0.08);
    border: 1px solid rgba(212, 160, 23, 0.2);
    border-radius: var(--radius-full);
    cursor: pointer;
    margin-bottom: 20px;
    transition: background-color var(--transition-fast);
}

.section-bookmarks-btn:hover {
    background-color: rgba(255, 212, 0, 0.15);
}

.section-bookmarks-btn svg {
    color: #d4a017;
}

.section-bookmarks-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    padding: 24px;
}

.section-bookmarks-overlay.active {
    opacity: 1;
    visibility: visible;
}

.section-bookmarks-modal {
    background-color: var(--bg-page);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-bookmarks-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.section-bookmarks-modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-bookmarks-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.section-bookmarks-close:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.section-bookmarks-modal-body {
    overflow-y: auto;
    padding: 8px 0;
}

.section-bookmark-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 20px;
    color: var(--text-primary);
    transition: background-color var(--transition-fast);
}

.section-bookmark-item:hover {
    background-color: var(--bg-active);
}

.section-bookmark-label {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.section-bookmark-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
}

.section-bookmark-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 24px;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: transparent;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--transition-fast),
                color var(--transition-fast);
    white-space: nowrap;
    border: none;
}

.filter-pill:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.filter-pill.active {
    background-color: var(--text-primary);
    color: var(--text-inverse);
    font-weight: 600;
}

.filter-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

/* ==========================================================================
   PAPER TABS — session detail page
   ========================================================================== */

.paper-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.paper-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color var(--transition-fast),
                border-color var(--transition-fast);
    white-space: nowrap;
}

.paper-tab:hover {
    color: var(--text-primary);
}

.paper-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
    font-weight: 600;
}

.paper-content {
    display: none;
}

.paper-content.active {
    display: block;
}

/* ==========================================================================
   YEAR GROUPS — sessions list page
   ========================================================================== */

.year-group {
    margin-bottom: 32px;
}

.year-heading {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* ==========================================================================
   SEARCH PAGE
   ========================================================================== */

.search-page-form {
    margin-bottom: 24px;
}

.search-page-input {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.search-page-input::placeholder {
    color: var(--text-muted);
}

.search-page-input:focus {
    border-color: rgba(55, 53, 47, 0.25);
    box-shadow: 0 0 0 3px rgba(55, 53, 47, 0.06);
}

mark {
    background-color: rgba(255, 212, 0, 0.35);
    color: var(--text-primary);
    padding: 1px 3px;
    border-radius: 3px;
}

.search-result-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 8px;
    background: var(--bg-glass);
    transition: background-color var(--transition-fast);
}

.search-result-item:hover {
    background-color: var(--bg-glass-heavy);
}

/* ==========================================================================
   STATS PAGE
   ========================================================================== */

.stats-section {
    margin-bottom: 40px;
}

.stat-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-bar-label {
    font-size: 13px;
    color: var(--text-primary);
    flex-shrink: 0;
    min-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-bar-track {
    flex: 1;
    height: 8px;
    background-color: var(--bg-active);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    background-color: var(--text-primary);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
    min-width: 2px;
}

.stat-bar-count {
    font-size: 12px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    color: var(--text-secondary);
    flex-shrink: 0;
    width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Stats Table */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.stats-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
}

.stats-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table tr:hover td {
    background: var(--bg-active);
}

/* Tag list */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-count {
    font-weight: 600;
    margin-left: 4px;
    color: var(--text-muted);
}

/* ==========================================================================
   REVISION SUMMARY — collapsible, distinct styling
   ========================================================================== */

.revision-summary {
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.revision-summary-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    cursor: pointer;
    user-select: none;
    background-color: rgba(55, 53, 47, 0.04);
    transition: background-color var(--transition-fast);
}

[data-theme="dark"] .revision-summary-toggle {
    background-color: rgba(255, 255, 255, 0.04);
}

.revision-summary-toggle:hover {
    background-color: rgba(55, 53, 47, 0.08);
}

[data-theme="dark"] .revision-summary-toggle:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.revision-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition-normal);
    transform: rotate(90deg);
    flex-shrink: 0;
}

.revision-summary.collapsed .revision-arrow {
    transform: rotate(0deg);
}

.revision-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.revision-summary-body {
    padding: 16px 24px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: rgba(55, 53, 47, 0.02);
}

[data-theme="dark"] .revision-summary-body {
    background-color: rgba(255, 255, 255, 0.02);
}

.revision-summary.collapsed .revision-summary-body {
    display: none;
}

/* ==========================================================================
   BOOKMARKS & NOTES
   ========================================================================== */

.question-detail-part-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.bookmark-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.5);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

[data-theme="dark"] .bookmark-btn {
    color: rgba(235, 235, 235, 0.35);
}

.bookmark-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
}

[data-theme="dark"] .bookmark-btn:hover {
    color: rgba(235, 235, 235, 0.8);
}

.bookmark-btn.active {
    color: #f5c542;
}

.bookmark-btn.active svg {
    fill: #f5c542;
    stroke: #f5c542;
}

.note-block {
    border-top: 1px solid var(--border);
    padding: 12px 24px 16px;
}

.note-display {
    background-color: rgba(255, 212, 0, 0.08);
    border-left: 3px solid #f5c542;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 16px;
    margin-bottom: 8px;
}

[data-theme="dark"] .note-display {
    background-color: rgba(255, 212, 0, 0.06);
}

.note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.note-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #d4a017;
}

.note-edit-btn {
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.note-edit-btn:hover {
    color: var(--text-primary);
}

.note-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.note-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.note-form.hidden {
    display: none;
}

.note-input {
    width: 100%;
    min-height: 80px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

.note-input:focus {
    border-color: rgba(55, 53, 47, 0.25);
    box-shadow: 0 0 0 3px rgba(55, 53, 47, 0.06);
}

[data-theme="dark"] .note-input:focus {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.note-actions {
    display: flex;
    gap: 8px;
}

.note-save-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    background-color: var(--text-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.note-cancel-btn {
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.note-add-btn {
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 0;
}

.note-add-btn:hover {
    color: var(--text-primary);
}

/* ── Collapsible notes ─────────────────────────────────────────────────── */

.note-display.collapsed .note-text {
    max-height: 1.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-toggle-btn {
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.note-toggle-btn:hover {
    color: var(--text-primary);
}

.note-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.note-block-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Drawing display ───────────────────────────────────────────────────── */

.drawing-display {
    background-color: var(--accent-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 8px;
}

.drawing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.drawing-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.drawing-actions-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawing-edit-btn,
.drawing-delete-btn {
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.drawing-edit-btn:hover,
.drawing-delete-btn:hover {
    color: var(--text-primary);
}

.drawing-image {
    max-width: 100%;
    border-radius: 8px;
    background-color: #ffffff;
}

[data-theme="dark"] .drawing-image {
    filter: invert(1) hue-rotate(180deg);
}

.draw-btn {
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 0;
}

.draw-btn:hover {
    color: var(--text-primary);
}

/* ── Drawing canvas overlay ────────────────────────────────────────────── */

.canvas-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background-color: var(--bg-page);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.canvas-overlay.active {
    opacity: 1;
    visibility: visible;
}

.canvas-overlay-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.canvas-overlay-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 8px;
}

.canvas-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.canvas-separator {
    width: 1px;
    height: 20px;
    background-color: var(--border);
    margin: 0 4px;
}

.canvas-tool {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.canvas-tool:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.canvas-tool.active {
    background-color: var(--text-primary);
    color: var(--text-inverse);
}

.canvas-color {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.canvas-color:hover {
    transform: scale(1.15);
}

.canvas-color.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-page), 0 0 0 4px var(--text-primary);
}

.canvas-action {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
}

.canvas-action:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.canvas-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.canvas-save-btn {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    background-color: var(--text-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.canvas-close-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
}

.canvas-close-btn:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.canvas-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
}

[data-theme="dark"] .canvas-body {
    background-color: #2a2a2a;
}

#drawing-canvas {
    background-color: #ffffff;
    cursor: crosshair;
    touch-action: none;
}

/* ==========================================================================
   CLICKABLE QUESTION CARDS
   ========================================================================== */

.question-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.sub-part-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* ==========================================================================
   QUESTION DETAIL PAGE
   ========================================================================== */

.question-detail-part {
    scroll-margin-top: 80px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
}

.question-detail-part-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background-color: var(--text-primary);
    color: var(--text-inverse);
}

[data-theme="dark"] .question-detail-part-header {
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.question-detail-part-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.question-detail-part-label .part-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-inverse);
    flex-shrink: 0;
}

[data-theme="dark"] .question-detail-part-label .part-label {
    color: var(--text-primary);
}

.question-detail-part-label .sub-part-text {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-inverse);
}

[data-theme="dark"] .question-detail-part-label .sub-part-text {
    color: var(--text-primary);
}

.question-detail-part-header .sub-part-meta {
    padding-top: 4px;
}

.question-detail-part-header .marks-badge {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--text-inverse);
}

[data-theme="dark"] .question-detail-part-header .marks-badge {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.question-detail-part-header .tag {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] .question-detail-part-header .tag {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(235, 235, 235, 0.7);
}

.question-detail-part-header .section-label {
    color: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .question-detail-part-header .section-label {
    color: rgba(235, 235, 235, 0.45);
}

.answer-block {
    padding: 20px 24px;
}

.answer-empty {
    padding: 24px;
    text-align: center;
}

.answer-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

.answer-content h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 20px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.answer-content h3:first-child {
    margin-top: 0;
}

.answer-content p {
    margin-bottom: 8px;
}

.answer-content ul,
.answer-content ol {
    padding-left: 20px;
    margin-bottom: 10px;
    list-style: disc;
}

.answer-content ol {
    list-style: decimal;
}

.answer-content li {
    margin-bottom: 4px;
    line-height: 1.6;
}

.answer-content strong {
    font-weight: 700;
    color: var(--text-primary);
}

.answer-content em {
    font-style: italic;
    color: var(--text-secondary);
}

.answer-content .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.answer-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 400px;
}

.answer-content th {
    text-align: left;
    padding: 8px 12px;
    font-weight: 600;
    background-color: var(--bg-active);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    white-space: nowrap;
}

.answer-content th:last-child { border-right: none; }

.answer-content td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.answer-content td:last-child { border-right: none; }
.answer-content tr:last-child td { border-bottom: none; }

.mermaid-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--accent-bg);
    margin: 16px 0;
    position: relative;
}

.mermaid-wrapper .mermaid-hint {
    display: none;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding: 6px 0 0;
}

.answer-content pre.mermaid,
.answer-content .mermaid {
    background: transparent;
    border: none;
    padding: 20px 16px;
    min-width: max-content;
}

.answer-content .mermaid svg {
    height: auto;
}

@media (max-width: 768px) {
    .mermaid-wrapper .mermaid-hint {
        display: block;
    }
}

/* Fullscreen diagram overlay */
.diagram-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background-color: var(--bg-page);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.diagram-overlay.active {
    opacity: 1;
    visibility: visible;
}

.diagram-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.diagram-overlay-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.diagram-overlay-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.diagram-overlay-close:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.diagram-overlay-body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    touch-action: pinch-zoom pan-x pan-y;
}

.diagram-overlay-body svg {
    max-width: none;
    max-height: none;
    transform-origin: center center;
}

.mermaid-wrapper {
    cursor: pointer;
}

.answer-content pre:not(.mermaid) {
    background-color: var(--bg-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px;
    overflow-x: auto;
    margin: 12px 0;
}

.answer-content .ref-badge {
    display: none;
}

.answer-content blockquote {
    border-left: 3px solid var(--text-primary);
    padding: 8px 16px;
    margin: 12px 0;
    background-color: var(--accent-bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
}

/* ==========================================================================
   RESPONSIVE — max-width: 768px
   ========================================================================== */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        background-color: var(--bg-page);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
    }

    .mobile-menu {
        display: flex;
    }

    .sidebar-collapse {
        display: none;
    }

    .search-form {
        display: none;
    }

    .mobile-search {
        display: flex;
    }

    .content-area {
        padding: 16px;
    }

    .top-bar {
        margin: 8px 12px 0;
        padding: 10px 14px;
        border-radius: var(--radius-lg);
    }

    .database-row-bar-container {
        display: none;
    }

    .database-row-number {
        width: 22px;
        font-size: 11px;
    }

    .stat-bar-label {
        min-width: 100px;
        font-size: 12px;
    }
}

/* Sidebar overlay (mobile only, JS-controlled display) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 99;
    display: none;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.monospace { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ==========================================================================
   THEME TOGGLE
   ========================================================================== */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: color var(--transition-fast),
                background-color var(--transition-fast);
}

.theme-toggle:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }

/* Light mode: show moon (click to go dark) */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }

[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Smooth color transitions on theme change */
body,
.sidebar,
.top-bar,
.database-table,
.question-card,
.question-card-header,
.search-input,
.search-page-input,
.stat-bar-chart,
.search-result-item {
    transition: background-color 0.3s ease, color 0.3s ease,
                border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ==========================================================================
   PWA INSTALL BANNER
   ========================================================================== */

.pwa-install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: var(--text-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    font-size: 14px;
    max-width: calc(100% - 40px);
}

.pwa-install-text {
    flex: 1;
    font-weight: 500;
}

.pwa-install-btn {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    background-color: #ffffff;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
}

.pwa-install-dismiss {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    line-height: 1;
}

.pwa-install-dismiss:hover {
    color: #ffffff;
}

/* ==========================================================================
   COPY PROTECTION
   ========================================================================== */

.answer-content {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ==========================================================================
   SIDEBAR USER
   ========================================================================== */

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-logout:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-page);
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background-color: var(--bg-glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-brand {
    margin-bottom: 20px;
}

.login-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background-color: var(--text-primary);
    color: var(--text-inverse);
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.login-description {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.login-google-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.login-footer {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.login-dev-notice {
    background-color: var(--accent-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
}

.login-dev-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.login-dev-form {
    display: flex;
    gap: 8px;
}

.login-dev-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.login-dev-input:focus {
    border-color: rgba(55, 53, 47, 0.25);
}

.login-dev-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background-color: var(--text-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
}

/* ==========================================================================
   ONBOARDING
   ========================================================================== */

.onboarding-container {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 24px;
}

.onboarding-card {
    background-color: var(--bg-glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.onboarding-form {
    text-align: left;
    margin-top: 24px;
}

.onboarding-section {
    margin-bottom: 20px;
}

.onboarding-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.onboarding-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.onboarding-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

.onboarding-input:focus {
    border-color: rgba(55, 53, 47, 0.25);
    box-shadow: 0 0 0 3px rgba(55, 53, 47, 0.06);
}

.onboarding-textarea {
    resize: vertical;
    min-height: 80px;
}

.onboarding-radio-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.onboarding-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

.price-options {
    gap: 8px;
}

.price-pill {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 13px;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.price-pill:has(input:checked) {
    background-color: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
}

.price-pill input {
    display: none;
}

.onboarding-notice {
    background-color: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: left;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.onboarding-notice-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px;
}

.onboarding-notice p {
    margin: 0 0 8px;
}

.onboarding-notice p:last-child {
    margin: 0;
}

.onboarding-submit {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    background-color: var(--text-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 8px;
}

.onboarding-logout {
    display: inline-block;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.onboarding-logout:hover {
    color: var(--text-primary);
}

/* ==========================================================================
   WAITLIST
   ========================================================================== */

.waitlist-share {
    display: flex;
    gap: 8px;
}

.waitlist-share-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
}

.waitlist-share-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background-color: var(--text-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
}

.waitlist-highlight {
    background-color: rgba(37, 99, 235, 0.06);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    margin: -4px -8px;
}

.waitlist-highlight .stat-bar-label {
    font-weight: 700;
}

[data-theme="dark"] .onboarding-input:focus {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .login-dev-input:focus {
    border-color: rgba(255, 255, 255, 0.25);
}
