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

:root {
    /* Surfaces — warmer, richer backgrounds */
    --bg: #f7f8fa;
    --bg-card: #ffffff;
    --bg-hover: #f4f6f9;
    --bg-elevated: #ffffff;
    --bg-inset: #f0f2f5;

    /* Borders — softer, more subtle */
    --border: #e0e4ea;
    --border-light: #eceef2;
    --border-focus: rgba(37, 99, 235, 0.35);

    /* Text — refined hierarchy */
    --text: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;

    /* Brand — richer primary palette */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-ghost: rgba(37, 99, 235, 0.06);

    /* Semantic */
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;

    /* Accent tones */
    --blue-light: #eff6ff;
    --yellow-light: #fffbeb;
    --green-light: #ecfdf5;
    --gray-light: #f3f4f6;

    /* Shape */
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows — layered depth system */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px -1px rgba(0,0,0,0.03);
    --shadow: 0 2px 6px -1px rgba(0,0,0,0.06), 0 1px 4px -2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px -2px rgba(0,0,0,0.08), 0 2px 6px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 24px -4px rgba(0,0,0,0.1), 0 4px 8px -2px rgba(0,0,0,0.04);
    --shadow-primary: 0 2px 8px -2px rgba(37, 99, 235, 0.25);
    --shadow-success: 0 2px 8px -2px rgba(5, 150, 105, 0.25);

    /* Motion */
    --transition: 0.18s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-slow: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* ===== Navbar ===== */
.navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 0 32px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-brand a {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.navbar-logo {
    flex-shrink: 0;
    display: block;
}
.navbar-links { display: flex; gap: 2px; align-items: center; }
.navbar-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all var(--transition);
}
.navbar-links a:hover { color: var(--text); background: var(--bg-hover); }
.nav-user {
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 12px;
    font-weight: 500;
    border-left: 1px solid var(--border-light);
    margin-left: 4px;
}
.nav-logout { color: var(--danger) !important; }
.nav-logout:hover { background: var(--danger-light) !important; }

/* ===== Container ===== */
.container { max-width: 1440px; margin: 0 auto; padding: 32px; }

/* ===== Login ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f4ff 0%, var(--bg) 50%, #f0fdf4 100%);
}
.login-card {
    background: var(--bg-card);
    padding: 48px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border-light);
}
.login-card h1 { font-size: 24px; margin-bottom: 6px; letter-spacing: -0.5px; font-weight: 800; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }

/* User selection grid (login step 2) */
.user-select-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    margin-bottom: 10px;
}
.user-select-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 14px;
    font-weight: 500;
}
.user-select-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.user-select-option input[type="radio"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
}
.user-select-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary);
}

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--text);
    letter-spacing: -0.1px;
}
.required { color: var(--danger); }
.optional-tag { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.section-divider { font-size: 16px; margin-top: 32px; margin-bottom: 20px; padding-top: 20px; border-top: 1px solid var(--border-light); color: var(--text-secondary); font-weight: 700; letter-spacing: -0.2px; }
.form-input, .form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text);
    transition: all var(--transition);
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}
.form-input::placeholder { color: var(--text-muted); }
textarea.form-input { resize: vertical; }
.radio-group { display: flex; gap: 16px; }
.radio-label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 20px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--bg-card);
    color: var(--text);
    transition: all var(--transition);
    font-family: inherit;
    line-height: 1.4;
    letter-spacing: -0.1px;
    gap: 6px;
    white-space: nowrap;
    position: relative;
}
.btn:hover {
    background: var(--gray-light);
    box-shadow: var(--shadow-sm);
    transform: translateY(-0.5px);
}
.btn:active {
    transform: translateY(0);
    box-shadow: none;
}
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-primary);
    transform: translateY(-0.5px);
}
.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
    box-shadow: var(--shadow-xs);
}
.btn-success:hover {
    background: #047857;
    border-color: #047857;
    box-shadow: var(--shadow-success);
    transform: translateY(-0.5px);
}
.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}
.btn-warning:hover { background: #b45309; border-color: #b45309; transform: translateY(-0.5px); }
.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; transform: translateY(-0.5px); }
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--gray-light); border-color: var(--border); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ===== Alerts ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
}
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.badge-gray { background: var(--gray-light); color: var(--text-muted); }
.badge-blue { background: var(--blue-light); color: #1e40af; }
.badge-yellow { background: var(--yellow-light); color: #92400e; }
.badge-green { background: var(--green-light); color: #065f46; }

/* ===== Dashboard ===== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}
.dashboard-header h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.6px; }

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat-number {
    display: block;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.stat-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-top: 4px;
}
.stat-blue .stat-number { color: var(--primary); }
.stat-blue { border-left: 3px solid var(--primary); }
.stat-yellow .stat-number { color: var(--warning); }
.stat-yellow { border-left: 3px solid var(--warning); }
.stat-green .stat-number { color: var(--success); }
.stat-green { border-left: 3px solid var(--success); }

/* ===== Activity Feed ===== */
.activity-feed {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}
.activity-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.activity-header::-webkit-details-marker { display: none; }
.activity-header::marker { display: none; content: ""; }
.activity-chevron {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.activity-feed[open] .activity-chevron { transform: rotate(180deg); }
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 24px 20px;
    max-height: 240px;
    overflow-y: auto;
}
.activity-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.activity-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.activity-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    margin-top: 7px;
    flex-shrink: 0;
}
.activity-content {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}
.activity-actor {
    font-weight: 600;
    color: var(--text);
}
.activity-action {
    color: var(--text-secondary);
}
.activity-topic {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.activity-topic:hover {
    text-decoration: underline;
}
.activity-time {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 4px;
}

/* Filter Bar */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}
.filter-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-group { min-width: 140px; }
.filter-group .form-input, .filter-group .form-select { font-size: 13px; padding: 8px 12px; }
.filter-search { position: relative; flex: 1; min-width: 180px; }
.filter-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.filter-search .form-input { padding-left: 36px; }

/* Question Cards */
.question-cards { display: flex; flex-direction: column; gap: 8px; }
.question-card {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 24px;
    align-items: center;
    padding: 18px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-xs);
}
.question-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.qcard-main { min-width: 0; }
.qcard-top-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.qcard-difficulty {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.qcard-topic {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qcard-subtopic {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qcard-meta-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.qcard-meta-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-inset);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Step Progress Indicator */
.qcard-progress { display: flex; align-items: center; flex-shrink: 0; }
.qcard-step { display: flex; align-items: center; }
.qcard-step-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    background: var(--gray-light);
    color: var(--text-muted);
    transition: all var(--transition);
    flex-shrink: 0;
}
.step-done .qcard-step-dot { background: var(--green-light); color: var(--success); }
.step-current .qcard-step-dot {
    background: var(--blue-light);
    color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.qcard-step-line {
    width: 12px;
    height: 2px;
    background: var(--border-light);
    transition: background var(--transition);
}
.line-done { background: var(--success); }
.spinner-xs {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--blue-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Right column: Score + meta */
.qcard-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 80px;
}
.qcard-score {
    font-size: 20px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}
.qcard-score-max { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.qcard-score-empty { color: var(--text-muted); font-size: 16px; }
.qcard-footer {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.qcard-author { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.qcard-time { font-size: 11px; color: var(--text-muted); }
.avatar-xs { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; flex-shrink: 0; margin-bottom: 2px; }

/* Score colors (shared) */
.score { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.score-good { color: var(--success); }
.score-ok { color: var(--warning); }
.score-low { color: var(--danger); }

.text-muted { color: var(--text-muted); font-size: 12px; }
.mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 12px; }

.avatar-sm { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

/* Empty State */
.empty-state { text-align: center; padding: 100px 20px; color: var(--text-muted); }
.empty-state p { margin-bottom: 20px; font-size: 15px; }
.empty-state-card {
    text-align: center;
    padding: 80px 20px;
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
}
.empty-state-icon { color: var(--text-muted); margin-bottom: 16px; opacity: 0.4; }
.empty-state-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.empty-state-card p { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

/* ===== Create Form ===== */
.create-form { max-width: 1000px; }
.create-form h1 { margin-bottom: 32px; font-size: 26px; font-weight: 800; letter-spacing: -0.6px; }
.create-form h2 { font-size: 16px; margin-bottom: 18px; color: var(--text-secondary); font-weight: 700; letter-spacing: -0.2px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; padding-top: 24px; border-top: 1px solid var(--border-light); }

/* ===== Detail Layout ===== */
.detail-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 28px;
    align-items: start;
    padding-right: 60px; /* space for side-panel toolbar */
}

/* Left sidebar */
.detail-sidebar { position: sticky; top: 80px; }
.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.sidebar-card:hover { box-shadow: var(--shadow); }
.sidebar-card h3 { font-size: 16px; margin-bottom: 4px; font-weight: 700; letter-spacing: -0.3px; }

/* Topic inline rename */
.topic-header { display: flex; align-items: flex-start; gap: 6px; }
.topic-header h3 { flex: 1; margin: 0; }
.topic-edit-btn {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius);
    transition: all var(--transition);
    flex-shrink: 0;
    margin-top: 2px;
    opacity: 0;
}
.topic-header:hover .topic-edit-btn { opacity: 1; }
.topic-edit-btn:hover { color: var(--text); background: var(--bg-hover); }
.topic-rename-form { margin-bottom: 8px; }
.topic-rename-input { font-size: 15px; font-weight: 700; padding: 6px 10px; }
.topic-rename-actions { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; }

.sidebar-card h4 {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.meta-list { margin-top: 16px; }
.meta-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border-light);
}
.meta-item:last-child { border-bottom: none; }
.meta-label { color: var(--text-muted); font-weight: 500; }
.meta-value { font-weight: 600; color: var(--text-secondary); }

.score-display {
    font-size: 32px;
    font-weight: 800;
    text-align: center;
    padding: 12px;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
}

.delete-form { margin-top: 20px; }

/* Stepper */
.stepper { margin-bottom: 16px; }
.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-left: 2px solid var(--border-light);
    margin-left: 13px;
    padding-left: 18px;
    position: relative;
}
.step-item::before { content: ''; position: absolute; left: -2px; top: 0; bottom: 0; width: 2px; }
.step-item.step-complete { border-left-color: var(--success); }
.step-item.step-complete::before { background: var(--success); }
.step-item.step-active { border-left-color: var(--primary); }
.step-item.step-active::before { background: var(--primary); }

.step-indicator {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--gray-light);
    color: var(--text-muted);
    transition: all var(--transition);
}
.step-complete .step-indicator { background: var(--green-light); color: var(--success); }
.step-active .step-indicator {
    background: var(--blue-light);
    color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.step-label { font-size: 13px; font-weight: 500; color: var(--text-muted); letter-spacing: -0.1px; }
.step-active .step-label { color: var(--primary); font-weight: 600; }
.step-complete .step-label { color: var(--success); font-weight: 500; }

/* Clickable completed steps (revert) */
.stepper { position: relative; }
.step-clickable { cursor: pointer; transition: all var(--transition); }
.step-clickable:hover .step-indicator {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}
.step-clickable:hover .step-label { color: var(--text); }
.step-clickable:focus-visible { outline: none; }
.step-clickable:focus-visible .step-indicator { box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.25); }

/* Revert Popover */
.revert-popover {
    position: absolute;
    left: calc(100% + 16px);
    width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 16px;
    z-index: 100;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.revert-popover.visible { opacity: 1; transform: translateX(0); }

.revert-popover-arrow {
    position: absolute;
    left: -6px;
    top: 18px;
    width: 10px;
    height: 10px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transform: rotate(45deg);
}

.revert-popover-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.revert-popover-desc { font-size: 12px; color: var(--text-secondary); margin: 0 0 14px; line-height: 1.5; }
.revert-popover-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.revert-confirm-btn {
    background: var(--text);
    color: var(--bg);
    border: 1px solid var(--text);
    font-weight: 600;
}
.revert-confirm-btn:hover { background: var(--text-secondary); border-color: var(--text-secondary); }

/* Main content */
.detail-main { min-width: 0; }

.step-section {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-slow);
}
.step-section:hover { box-shadow: var(--shadow); }

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
}
.step-header h2 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
}
.step-content { padding: 28px; }

.llm-output {
    background: var(--bg-inset);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px;
    font-size: 14px;
    line-height: 1.8;
    max-height: 600px;
    overflow-y: auto;
    word-wrap: break-word;
}

/* ===== Explanation Word Count ===== */
.explanation-word-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 5px 12px;
    background: var(--bg-inset);
    border: 1px solid var(--border-light);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.explanation-word-count svg { color: var(--text-muted); flex-shrink: 0; }
.word-count-warning {
    color: var(--warning);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.word-count-ok {
    color: var(--success);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ===== Step Actions — Feedback & Buttons ===== */
.step-actions {
    padding: 24px 28px;
    border-top: 1px solid var(--border-light);
    background: var(--bg);
}

.revision-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.revision-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.revision-form .form-input {
    width: 100%;
    font-size: 14px;
    padding: 14px 16px;
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
    border-radius: var(--radius);
}
.step-actions .action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}
.inline-form { display: inline; }

.edit-form .form-input { margin-bottom: 10px; }
.improvements-form .form-group { margin-bottom: 12px; }

/* Diff display */
.diff-section { border-top: 2px solid var(--primary); }
.diff-section h3 { margin-bottom: 16px; font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.diff-display {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    font-size: 14px;
    line-height: 1.8;
    max-height: 500px;
    overflow-y: auto;
}

/* Score banner */
.score-banner {
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 24px;
    letter-spacing: -0.5px;
}
.score-banner.score-good { background: var(--green-light); color: var(--success); }
.score-banner.score-ok { background: var(--yellow-light); color: var(--warning); }
.score-banner.score-low { background: var(--danger-light); color: var(--danger); }

/* Generating banner */
.generating-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 28px;
    background: linear-gradient(135deg, #eff6ff 0%, #e0eaff 100%);
    color: #1e40af;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid #bfdbfe;
    box-shadow: var(--shadow-sm);
}
.unstick-form { margin-left: auto; }
.btn-danger {
    background: var(--danger);
    color: white;
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.btn-danger:hover { opacity: 0.85; }

/* Complete banner */
.complete-banner {
    padding: 24px;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: var(--success);
    border-radius: var(--radius-lg);
    text-align: center;
    font-weight: 700;
    font-size: 15px;
    border: 1px solid #a7f3d0;
    box-shadow: var(--shadow-sm);
}

/* Right sidebar - History */
/* (History sidebar removed — now inside side panel) */

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 12px;
    transition: all var(--transition);
}
.history-item:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
.history-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.history-step { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }
.history-time { color: var(--text-muted); font-size: 11px; }
.history-meta { color: var(--text-muted); font-size: 11px; }
.history-feedback {
    color: #92400e;
    background: var(--yellow-light);
    padding: 6px 10px;
    border-radius: var(--radius);
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.4;
}
.history-score { color: var(--success); font-weight: 700; margin-top: 4px; }
.history-current-label {
    display: inline-block;
    background: var(--success-light);
    color: var(--success);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
}
.history-item-current { border-color: var(--success-light); }
.history-restore-form { margin-top: 6px; }
.history-restore-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    cursor: pointer;
    transition: all var(--transition);
}
.history-restore-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Output Toolbar & Edit Mode ===== */
.output-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.output-toolbar .mode-btn {
    font-size: 12px;
    padding: 5px 14px;
    gap: 4px;
    display: inline-flex;
    align-items: center;
}
.output-toolbar .mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.toolbar-hint { font-size: 12px; color: var(--text-muted); }
.step-save-btn {
    margin-left: auto;
    font-size: 12px;
    padding: 5px 16px;
}

.llm-edit-area {
    width: 100%;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.7;
    padding: 24px;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    resize: vertical;
    min-height: 200px;
    background: #fffef8;
}

/* Annotatable output */
.llm-output.annotatable {
    cursor: text;
    user-select: text;
}
.llm-output.annotatable::selection,
.llm-output.annotatable *::selection {
    background: #bfdbfe;
}

/* Inline editing state (contentEditable) */
.llm-output.editing {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), var(--shadow);
    background: var(--bg-card);
    cursor: text;
    max-height: none;
}
.llm-output.editing:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15), var(--shadow-md);
}

/* Editing mode toolbar button active state */
.mode-btn { display: inline-flex; align-items: center; gap: 5px; }
.mode-btn .edit-icon { flex-shrink: 0; }
.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Inline Annotations ===== */
.annotation-highlight {
    background: #fef9c3;
    border-bottom: 2px solid #eab308;
    padding: 0 2px;
    border-radius: 2px;
    cursor: pointer;
    transition: background var(--transition);
}
.annotation-highlight:hover {
    background: #fde68a;
}

/* Annotation hover tooltip */
.annotation-tooltip {
    position: absolute;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid #eab308;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    max-width: 320px;
    min-width: 200px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    pointer-events: auto;
}
.annotation-tooltip-read {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}
.annotation-tooltip-text {
    flex: 1;
    word-wrap: break-word;
}
.annotation-tooltip-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.annotation-tooltip-edit {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    border-radius: 3px;
    transition: all var(--transition);
}
.annotation-tooltip-edit:hover {
    color: var(--primary);
    background: var(--primary-light, #eff6ff);
}
.annotation-tooltip-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    border-radius: 3px;
    transition: all var(--transition);
}
.annotation-tooltip-remove:hover {
    color: var(--danger);
    background: var(--danger-light);
}
.annotation-tooltip-editview {
    width: 100%;
}
.annotation-tooltip-textarea {
    width: 100%;
    min-height: 48px;
    padding: 8px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    border: 1px solid var(--border);
    border-radius: 4px;
    resize: vertical;
    outline: none;
}
.annotation-tooltip-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light, #eff6ff);
}
.annotation-tooltip-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    justify-content: flex-end;
}
.annotation-tooltip-save,
.annotation-tooltip-cancel {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}
.annotation-tooltip-save {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.annotation-tooltip-save:hover {
    opacity: 0.9;
}
.annotation-tooltip-cancel {
    background: var(--bg-card);
    color: var(--text-muted);
}
.annotation-tooltip-cancel:hover {
    background: var(--bg-hover);
}

/* Floating highlight button */
.highlight-btn {
    position: absolute;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    user-select: none;
    transition: all var(--transition);
    font-family: inherit;
    letter-spacing: -0.1px;
}
.highlight-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px -4px rgba(37,99,235,0.35);
}
.highlight-btn svg {
    flex-shrink: 0;
}

/* Annotation popup */
.annotation-popup {
    position: absolute;
    z-index: 1000;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 18px;
    width: 360px;
}
.annotation-popup-selected {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    padding: 10px 12px;
    background: #fefce8;
    border-radius: var(--radius);
    margin-bottom: 12px;
    max-height: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid #fde68a;
    line-height: 1.4;
}
.annotation-popup .form-input {
    font-size: 13px;
    padding: 10px 12px;
    margin-bottom: 12px;
}
.annotation-popup-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* LLM output markdown improvements */
.llm-output h2, .llm-output h3, .llm-output h4, .llm-output h5 {
    margin-top: 20px;
    margin-bottom: 10px;
    letter-spacing: -0.3px;
}
.llm-output h2 { font-size: 18px; font-weight: 800; }
.llm-output h3 { font-size: 16px; font-weight: 700; }
.llm-output h4 { font-size: 15px; font-weight: 700; }
.llm-output h5 { font-size: 14px; font-weight: 600; }
.llm-output ul, .llm-output ol {
    margin: 8px 0;
    padding-left: 24px;
}
.llm-output li {
    margin-bottom: 4px;
    line-height: 1.7;
}
.llm-output ul li { list-style-type: disc; }
.llm-output ol li { list-style-type: decimal; }
.llm-output strong { font-weight: 700; }
.llm-output em { font-style: italic; }
.llm-output hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.llm-output a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.llm-output a:hover { color: var(--primary-hover); }
.llm-output .md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}
.llm-output .md-table th,
.llm-output .md-table td {
    border: 1px solid var(--border-light);
    padding: 10px 14px;
    text-align: left;
}
.llm-output .md-table thead th {
    background: var(--bg);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
}
.llm-output .md-table tbody tr:nth-child(even) {
    background: var(--bg);
}

/* Reference verification badge */
.ref-verification-badge {
    margin-top: 16px;
}

/* ===== Spinners ===== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--blue-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid var(--blue-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Resources Panel (Full-Width) ===== */
.resources-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 12px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-slow);
}
.resources-panel:hover { box-shadow: var(--shadow); }

.resources-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
}

.resources-panel-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.2px;
}

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

/* ===== Side Panel Toolbar + Drawer ===== */
.side-panel-toolbar {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 998;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.side-panel-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    border-radius: var(--radius);
    margin: 0 4px;
    min-width: 48px;
}
.side-panel-btn:hover {
    color: var(--primary);
    background: var(--bg-hover);
}
.side-panel-btn.active {
    color: var(--primary);
    background: var(--blue-light, #eff6ff);
}
.side-panel-btn svg {
    flex-shrink: 0;
}

.side-panel-btn-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    line-height: 1;
}

.side-panel-btn-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.side-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.12);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.side-panel-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.side-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 420px;
    max-width: 90vw;
    z-index: 1000;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.side-panel.open {
    transform: translateX(0);
}

.side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.side-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.side-panel-close {
    border: none;
    background: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.side-panel-close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.side-panel-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.side-panel-content {
    display: none;
}
.side-panel-content.active {
    display: block;
}

.side-panel-tab-actions {
    display: flex;
    justify-content: flex-end;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
}

/* Side panel context overrides */
.side-panel .resource-image-grid {
    grid-template-columns: repeat(2, 1fr);
}
.side-panel .resource-article-card {
    padding: 12px 16px 12px 20px;
}
.side-panel .history-list {
    padding: 8px;
}

/* Subsection headers (Images / Articles) */
.resources-subsection {
    border-top: 1px solid var(--border-light);
}
.resources-subsection:first-of-type {
    border-top: none;
}

.resources-subsection-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg);
    letter-spacing: -0.1px;
}
.resources-subsection-header svg {
    opacity: 0.5;
    flex-shrink: 0;
}

.resources-subsection-count {
    font-size: 11px;
    background: var(--gray-light);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 10px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* Article preview panel (metadata card) */
.article-preview-panel {
    position: fixed;
    width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.article-preview-panel.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.article-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.article-preview-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.article-preview-close {
    border: none;
    background: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.article-preview-close:hover { color: var(--text); }

.article-preview-body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.article-preview-type {
    align-self: flex-start;
}

.article-preview-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.45;
    letter-spacing: -0.2px;
}

.article-preview-authors {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.article-preview-citation {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
}

.article-preview-ids {
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.article-preview-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    padding: 6px 14px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    transition: all var(--transition);
}
.article-preview-link:hover {
    background: var(--primary);
    color: white;
}
.article-preview-link svg { flex-shrink: 0; }

/* --- Image Grid (full-width) --- */
.resource-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1px;
    background: var(--border-light);
}

.resource-image-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
    overflow: hidden;
}

.resource-image-card:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-md);
    z-index: 1;
}

.resource-image-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.resource-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.resource-image-card:hover .resource-image-thumb img {
    transform: scale(1.04);
}

.resource-image-info {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.resource-image-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.1px;
}

.resource-image-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.resource-image-dims {
    font-size: 10px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.license-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--green-light);
    color: #065f46;
    white-space: nowrap;
}

/* --- Article List (full-width) --- */
.resource-article-list {
    display: flex;
    flex-direction: column;
}

.resource-article-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px 16px 24px;
    background: var(--bg-card);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
    position: relative;
    border-bottom: 1px solid var(--border-light);
}

.resource-article-card:last-child { border-bottom: none; }
.resource-article-card:hover { background: var(--bg-hover); }

.resource-article-type-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    border-radius: 0 2px 2px 0;
}

.resource-article-type-bar.article-type-blue { background: #3b82f6; }
.resource-article-type-bar.article-type-purple { background: #8b5cf6; }
.resource-article-type-bar.article-type-orange { background: #f59e0b; }
.resource-article-type-bar.article-type-teal { background: #14b8a6; }
.resource-article-type-bar.article-type-green { background: #22c55e; }
.resource-article-type-bar.article-type-gray { background: #9ca3af; }
.resource-article-type-bar.article-type-default { background: var(--border); }

.resource-article-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.resource-article-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.resource-article-year {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.article-type-badge {
    display: inline-flex;
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.article-type-badge.article-type-blue { background: var(--blue-light); color: #1e40af; }
.article-type-badge.article-type-purple { background: #f3e8ff; color: #6b21a8; }
.article-type-badge.article-type-orange { background: var(--yellow-light); color: #92400e; }
.article-type-badge.article-type-teal { background: #ccfbf1; color: #115e59; }
.article-type-badge.article-type-green { background: var(--green-light); color: #065f46; }
.article-type-badge.article-type-gray { background: var(--gray-light); color: var(--text-muted); }
.article-type-badge.article-type-default { background: var(--gray-light); color: var(--text-secondary); }

.resource-article-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.45;
    letter-spacing: -0.1px;
}

.resource-article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.resource-article-authors {
    color: var(--text-secondary);
}

.resource-article-journal {
    font-style: italic;
}

.resource-article-pmid {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
}

.resource-article-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0;
    transition: all var(--transition);
    padding-top: 2px;
}

.resource-article-card:hover .resource-article-arrow {
    opacity: 0.7;
    transform: translateX(2px);
}

/* ===== Cite Button (Articles & Images) ===== */
.cite-btn {
    position: relative;
    z-index: 2;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.cite-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.cite-btn.cited {
    background: var(--green-bg, #ecfdf5);
    color: var(--green-text, #059669);
    border-color: var(--green-text, #059669);
    cursor: default;
    pointer-events: none;
}
.cite-btn.cite-error {
    background: var(--red-bg, #fef2f2);
    color: var(--red-text, #dc2626);
    border-color: var(--red-text, #dc2626);
}
/* Position cite button within article cards */
.resource-article-card .cite-btn {
    align-self: center;
    margin-right: 4px;
}
/* Position cite button within image cards */
.resource-image-card {
    position: relative;
}
.resource-image-card .cite-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity var(--transition);
}
.resource-image-card:hover .cite-btn {
    opacity: 1;
}
.resource-image-card .cite-btn.cited {
    opacity: 1;
}

/* ===== Illustration Cards (Google Drive) ===== */
.resource-illustration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1px;
    background: var(--border-light);
}
.resource-illustration-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
    overflow: hidden;
}
.resource-illustration-card:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-md);
    z-index: 1;
}
.resource-illustration-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: center;
}
.resource-illustration-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}
.resource-illustration-card:hover .resource-illustration-thumb img {
    transform: scale(1.04);
}
.resource-illustration-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}
.resource-illustration-info {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.resource-illustration-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.1px;
}
.resource-illustration-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}
.resource-illustration-folder {
    font-size: 11px;
    color: var(--text-secondary);
}
.relevance-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}
.relevance-high { background: #ecfdf5; color: #065f46; }
.relevance-med { background: #fffbeb; color: #92400e; }
.relevance-low { background: #f3f4f6; color: var(--text-secondary); }

/* ===== Step 4: Illustration Selection ===== */
.illustration-selection-section {
    margin-bottom: 20px;
}
.illustration-selection-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}
.illustration-selection-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}
.illustration-selectable-grid {
    gap: 2px;
}
.illustration-select-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition);
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    text-decoration: none;
    color: inherit;
}
.illustration-select-card:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-md);
    z-index: 1;
}
.illustration-select-card.selected {
    border-color: var(--primary);
    background: #f0f7ff;
}
.illustration-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.illustration-check-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.illustration-select-card.selected .illustration-check-indicator {
    display: flex;
}
.illustration-drive-link {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 4px 6px;
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity var(--transition);
    z-index: 2;
    text-decoration: none;
}
.illustration-drive-link:hover {
    color: var(--primary);
}
.illustration-select-card:hover .illustration-drive-link {
    opacity: 1;
}
.no-illustrations-notice {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.no-illustrations-notice p {
    margin: 0;
}
.illustration-step-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}
.illustration-step-actions .action-buttons {
    display: flex;
    gap: 8px;
}
.illustration-recs-toggle {
    margin-top: 20px;
}
.illustration-recs-toggle > summary {
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
}
.illustration-recs-toggle > summary::-webkit-details-marker {
    display: none;
}
.illustration-recs-toggle > summary::before {
    content: '\25B6';
    font-size: 10px;
    transition: transform 0.2s;
}
.illustration-recs-toggle[open] > summary::before {
    transform: rotate(90deg);
}

/* Illustration Ideas (AI-generated recommendations) */
.illustration-ideas-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}
.illustration-ideas-content h4,
.illustration-ideas-content h5 {
    margin: 20px 0 4px 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}
.illustration-ideas-content h4:first-child,
.illustration-ideas-content h5:first-child,
.illustration-ideas-content strong:first-child {
    margin-top: 0;
}
.illustration-ideas-content strong {
    color: var(--text);
}
.illustration-ideas-content ul,
.illustration-ideas-content ol {
    margin: 4px 0;
    padding-left: 20px;
}
.illustration-ideas-content li {
    margin-bottom: 2px;
}
.illustration-ideas-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* ===== Score Dashboard ===== */
.score-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 28px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
}
.score-dashboard.score-tier-good { background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%); border-color: #a7f3d0; }
.score-dashboard.score-tier-ok { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); border-color: #fde68a; }
.score-dashboard.score-tier-low { background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%); border-color: #fca5a5; }

.score-dashboard-main {
    display: flex;
    align-items: center;
    gap: 28px;
}

.score-gauge-container {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}
.score-gauge {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.score-gauge-bg {
    fill: none;
    stroke: rgba(0,0,0,0.06);
    stroke-width: 8;
}
.score-gauge-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.score-tier-good .score-gauge-fill { stroke: var(--success); }
.score-tier-ok .score-gauge-fill { stroke: var(--warning); }
.score-tier-low .score-gauge-fill { stroke: var(--danger); }

.score-gauge-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    line-height: 1;
}
.score-gauge-number {
    display: block;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
}
.score-gauge-max {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
.score-tier-good .score-gauge-number { color: var(--success); }
.score-tier-ok .score-gauge-number { color: var(--warning); }
.score-tier-low .score-gauge-number { color: var(--danger); }

.score-dashboard-meta { flex: 1; }
.score-tier-label {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.4px;
    margin-bottom: 4px;
}
.score-tier-good .score-tier-label { color: var(--success); }
.score-tier-ok .score-tier-label { color: var(--warning); }
.score-tier-low .score-tier-label { color: var(--danger); }

.score-summary-text {
    font-size: 13px;
    color: var(--text-muted);
}

.score-domain-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.domain-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: rgba(255,255,255,0.8);
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}
.domain-chip:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.domain-chip:active {
    transform: translateY(0);
}
.domain-chip-score {
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}
.domain-chip-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.2;
}
.domain-chip.chip-good .domain-chip-score { color: var(--success); }
.domain-chip.chip-ok .domain-chip-score { color: var(--warning); }
.domain-chip.chip-low .domain-chip-score { color: var(--danger); }

/* Student Success Prediction */
.prediction-subsection {
    margin-top: 16px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}
.prediction-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.prediction-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.1px;
}
.prediction-pct {
    font-size: 18px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.prediction-good { color: var(--success); }
.prediction-ok { color: var(--warning); }
.prediction-low { color: var(--danger); }
.prediction-reasoning {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 8px;
}
.prediction-ideal-note {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
    font-style: italic;
}

/* Domain Detail Modal */
.domain-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.domain-detail-overlay.domain-detail-visible {
    opacity: 1;
}

.domain-detail-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 420px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    transform: translateY(12px) scale(0.97);
    transition: transform 0.2s ease;
}
.domain-detail-visible .domain-detail-modal {
    transform: translateY(0) scale(1);
}

.domain-detail-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.domain-detail-score-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--bg-inset);
    border: 2px solid var(--border-light);
}
.domain-detail-score-badge.badge-good {
    background: #ecfdf5;
    border-color: var(--success);
}
.domain-detail-score-badge.badge-ok {
    background: #fffbeb;
    border-color: var(--warning);
}
.domain-detail-score-badge.badge-low {
    background: #fef2f2;
    border-color: var(--danger);
}

.domain-detail-score-num {
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.badge-good .domain-detail-score-num { color: var(--success); }
.badge-ok .domain-detail-score-num { color: var(--warning); }
.badge-low .domain-detail-score-num { color: var(--danger); }

.domain-detail-score-max {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 1px;
}

.domain-detail-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    flex: 1;
    margin: 0;
}

.domain-detail-close {
    border: none;
    background: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: var(--radius);
    transition: all var(--transition);
    margin-left: auto;
}
.domain-detail-close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.domain-detail-body {
    padding: 20px 24px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}
.domain-detail-body p {
    margin: 0 0 12px;
}
.domain-detail-body p:last-child {
    margin-bottom: 0;
}

/* ===== Question Preview (Step 3 inline highlights) ===== */
.step3-question-preview {
    margin-bottom: 24px;
}
.step3-question-preview .preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.step3-question-preview .preview-header h3 {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.2px;
}
.step3-question-preview .preview-hint {
    font-size: 12px;
}
.step3-annotated-question {
    max-height: 500px;
    overflow-y: auto;
    padding: 20px 24px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-card);
}

/* Suggestion highlights on question text */
.suggestion-highlight {
    padding: 0;
    border-radius: 0;
    border-bottom: none;
    background: none !important;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.suggestion-highlight:hover,
.suggestion-highlight.suggestion-highlight-hover {
    filter: brightness(0.92);
}

/* Original text inside the highlight */
.suggestion-original {
    text-decoration: none;
    color: var(--text);
}

/* Replacement text — floating tooltip, never disrupts inline flow */
.suggestion-replacement {
    display: none;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    background: #bbf7d0;
    border: 1px solid #86efac;
    border-radius: 4px;
    padding: 4px 8px;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    z-index: 50;
    white-space: normal;
    max-width: 400px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    pointer-events: none;
    font-size: 13px;
    line-height: 1.45;
}
/* Arrow pointing down to the highlighted text */
.suggestion-replacement::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 16px;
    border: 5px solid transparent;
    border-top-color: #86efac;
}

/* ACCEPTED state: pink bg + red strikethrough on original, replacement shows on hover */
.suggestion-highlight-accepted .suggestion-original {
    background: #fecdd3;
    border-radius: 2px;
    padding: 1px 2px;
    text-decoration: line-through;
    text-decoration-color: #dc2626;
    text-decoration-thickness: 1.5px;
    color: var(--text);
    opacity: 1;
}
/* Show replacement tooltip on hover */
.suggestion-highlight-accepted:hover .suggestion-replacement {
    display: block;
}

/* REJECTED state: no diff, just dim the highlight */
.suggestion-highlight-rejected {
    opacity: 0.35;
}
.suggestion-highlight-rejected .suggestion-original {
    text-decoration: none;
    background: none;
    padding: 0;
}
.suggestion-highlight-rejected .suggestion-replacement {
    display: none;
}

/* Suggestion popover */
.suggestion-popover {
    position: absolute;
    z-index: 1100;
    width: 360px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.suggestion-popover-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
}
.suggestion-popover-number {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: var(--blue-light);
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}
.suggestion-popover-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.suggestion-popover-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color var(--transition);
}
.suggestion-popover-close:hover { color: var(--danger); }
.suggestion-popover-body {
    padding: 14px 18px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 120px;
    overflow-y: auto;
}
.suggestion-popover-diff {
    padding: 8px 18px 0;
}
.popover-diff-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.popover-diff-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background: #bbf7d0;
    border-radius: 4px;
    padding: 6px 10px;
    max-height: 100px;
    overflow-y: auto;
}
.suggestion-popover-actions {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-light);
    justify-content: flex-end;
}

/* Card pulse animation (bidirectional linking) */
@keyframes cardPulse {
    0% { box-shadow: 0 0 0 0 rgba(37,99,235,0.3); }
    50% { box-shadow: 0 0 0 6px rgba(37,99,235,0.1); }
    100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}
.suggestion-card.card-pulse {
    animation: cardPulse 0.8s ease-out;
}

/* ===== Suggestion Cards ===== */
.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.suggestions-header h3 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    margin: 0;
}

.select-all-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.select-all-toggle input[type="checkbox"] {
    accent-color: var(--primary);
    width: 15px;
    height: 15px;
}

.suggestion-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 18px;
}

.suggestion-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}
.suggestion-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    transform: translateY(-0.5px);
}
.suggestion-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary);
}

.suggestion-checkbox {
    margin-top: 2px;
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.suggestion-card-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.suggestion-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.suggestion-number {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: var(--blue-light);
    padding: 2px 7px;
    border-radius: 4px;
    flex-shrink: 0;
}

.suggestion-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.1px;
}

.suggestion-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Raw analysis toggle */
.raw-analysis-toggle {
    margin-top: 18px;
}
.raw-analysis-toggle > summary {
    cursor: pointer;
    list-style: none;
}
.raw-analysis-toggle > summary::-webkit-details-marker {
    display: none;
}

/* No suggestions state */
.no-suggestions {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

/* ===== Suggestion Card Animation ===== */
@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.suggestion-card.card-enter {
    animation: cardSlideIn 0.3s var(--ease-spring) forwards;
    opacity: 0;
}

/* ===== Scrollbar Refinement ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.2); }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .detail-layout { grid-template-columns: 200px 1fr; }
    .resource-image-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .resource-illustration-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (max-width: 768px) {
    .detail-layout { grid-template-columns: 1fr; }
    .detail-sidebar { position: static; }
    .form-grid { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; }
    .container { padding: 16px; }
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .question-card { grid-template-columns: 1fr; gap: 12px; }
    .qcard-progress { justify-content: flex-start; }
    .qcard-right {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    .qcard-footer { flex-direction: row; gap: 8px; }
    .score-domain-grid { grid-template-columns: repeat(2, 1fr); }
    .score-dashboard-main { flex-direction: column; text-align: center; }
    .score-dashboard-meta { text-align: center; }
    .suggestion-popover { width: calc(100vw - 20px); max-width: 360px; }
    .resource-image-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .resource-illustration-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .article-preview-panel { width: 300px; }
}
