/* ============================================================
   Design Tokens
   ============================================================ */
:root {
    /* Typography scale (6 sizes max) */
    --text-xs:   0.8rem;    /* ~13px — labels, captions (min readable) */
    --text-sm:   0.875rem;  /* 14px — secondary text, table cells */
    --text-base: 1rem;      /* 16px — body */
    --text-lg:   1.125rem;  /* 18px — emphasized body */
    --text-xl:   1.25rem;   /* 20px — section headings */
    --text-2xl:  1.5rem;    /* 24px — page headings (max for dense UI) */

    /* Font families */
    --font-display: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, sans-serif;
    --font-body:    "Figtree", "Inter", system-ui, -apple-system, sans-serif;
    --font-mono:    "JetBrains Mono", "SF Mono", "Fira Code", Consolas, monospace;

    /* Spacing (4-point grid) */
    --sp-1:  4px;
    --sp-2:  8px;
    --sp-3:  12px;
    --sp-4:  16px;
    --sp-5:  20px;
    --sp-6:  24px;
    --sp-8:  32px;
    --sp-10: 40px;
    --sp-12: 48px;

    /* Color palette — "Precision Instrument" identity */
    --color-primary:     #0c1222;
    --color-primary-hover: #1a2744;
    --color-accent:      #0891b2;
    --color-accent-hover: #0e7490;
    --color-accent-light: #ecfeff;
    --color-accent-glow:  rgba(8, 145, 178, 0.15);
    --color-success:     #16a34a;
    --color-success-bg:  #f0fdf4;
    --color-success-fg:  #166534;
    --color-danger:      #dc2626;
    --color-danger-bg:   #fef2f2;
    --color-danger-fg:   #991b1b;
    --color-warning:     #d97706;
    --color-warning-bg:  #fffbeb;
    --color-warning-fg:  #92400e;
    --color-info:        #0284c7;
    --color-info-bg:     #f0f9ff;
    --color-info-fg:     #075985;
    --color-purple:      #7c3aed;
    --color-purple-bg:   #f5f3ff;
    --color-case:        #059669;
    --color-case-bg:     #ecfdf5;
    --color-case-fg:     #065f46;
    --color-repair:      #ea580c;
    --color-repair-bg:   #fff7ed;

    --color-surface:     #ffffff;
    --color-surface-muted: #f8fafc;
    --color-bg:          #f4f6f8;
    --color-bg-soft:     #eef1f5;
    --color-border:      #dfe4ea;
    --color-border-light: #eef1f5;
    --color-text:        #0c1222;
    --color-text-secondary: #475569;
    --color-text-muted:  #5a6577;   /* improved contrast: ~5.5:1 on white */
    --color-text-faint:  #78859b;   /* improved contrast: ~4.5:1 on white (WCAG AA) */

    /* Derived interactive states */
    --color-success-hover: #15803d;
    --color-danger-hover:  #b91c1c;
    --color-success-border: #d1fae5;

    /* Nav (dark background context) */
    --color-nav-text:  #94a3b8;
    --color-nav-hover: #e2e8f0;

    /* Credits */
    --color-credit:    #0891b2;
    --color-credit-bg: #ecfeff;

    /* Difficulty semantic tokens */
    --color-difficulty-easy-bg:     #d1fae5;
    --color-difficulty-moderate-bg: #fef3c7;
    --color-difficulty-hard-bg:     #fee2e2;

    /* Log panel (terminal dark theme) */
    --log-bg:         #0c1222;
    --log-bg-alt:     #131d35;
    --log-border:     #1e2d4a;
    --log-text:       #e2e8f0;
    --log-text-muted: #8b949e;
    --log-text-faint: #484f58;
    --log-error:      #ff7b72;
    --log-warning:    #e3b341;
    --log-info:       #5eead4;
    --log-debug:      #6e7681;

    /* Shadows — deeper, more dimensional */
    --shadow-sm:  0 1px 3px rgba(12, 18, 34, 0.05), 0 1px 2px rgba(12, 18, 34, 0.03);
    --shadow-md:  0 2px 8px rgba(12, 18, 34, 0.08), 0 1px 3px rgba(12, 18, 34, 0.05);
    --shadow-lg:  0 8px 24px rgba(12, 18, 34, 0.1), 0 2px 8px rgba(12, 18, 34, 0.05);
    --shadow-xl:  0 16px 48px rgba(12, 18, 34, 0.12), 0 4px 12px rgba(12, 18, 34, 0.06);

    /* Radii — slightly rounder for modern feel */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-pill: 100px;

    /* Transitions — refined easing */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   Reset & Base
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

nav {
    background: linear-gradient(135deg, #0c1222 0%, #111b30 50%, #0f1728 100%);
    padding: 0 2rem;
    display: flex;
    gap: 0;
    align-items: center;
    height: 54px;
    border-bottom: 1px solid rgba(8, 145, 178, 0.1);
    overflow: visible;
    box-shadow: 0 1px 8px rgba(12, 18, 34, 0.25);
    position: relative;
    z-index: 5001;
}

nav a {
    color: var(--color-nav-text);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--text-sm);
    padding: 0 var(--sp-3);
    height: 54px;
    display: inline-flex;
    align-items: center;
    transition: color var(--transition-fast), background var(--transition-fast);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.01em;
}

nav a:hover {
    color: var(--color-nav-hover);
    background: rgba(255,255,255,0.05);
}

nav a.active-nav {
    color: #fff;
    border-bottom-color: var(--color-accent);
    font-weight: 600;
}

nav .brand {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    margin-right: var(--sp-4);
    letter-spacing: -0.03em;
    padding: 0;
    border: none;
}
nav .brand::first-letter {
    color: var(--color-accent);
}

.container {
    max-width: 1200px;
    margin: var(--sp-6) auto;
    padding: 0 var(--sp-6);
    line-height: 1.6;
    overflow-x: hidden; /* prevent horizontal page scroll from children */
}

h1, h2, h3 {
    font-family: var(--font-display);
    margin-top: 0;
    margin-bottom: var(--sp-4);
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: var(--color-text);
}

h1 { font-size: var(--text-2xl); font-weight: 700; }
h2 { font-size: var(--text-xl); font-weight: 600; }
h3 { font-size: var(--text-lg); font-weight: 600; }

/* ============================================================
   Utility Classes
   ============================================================ */
/* Typography */
.text-xs   { font-size: var(--text-xs) !important; }
.text-sm   { font-size: var(--text-sm) !important; }
.text-base { font-size: var(--text-base) !important; }
.text-lg   { font-size: var(--text-lg) !important; }
.text-xl   { font-size: var(--text-xl) !important; }
.text-2xl  { font-size: var(--text-2xl) !important; }
.font-semibold { font-weight: 600 !important; }
.font-bold     { font-weight: 700 !important; }
.font-mono     { font-family: var(--font-mono) !important; }
.text-center   { text-align: center !important; }
.text-right    { text-align: right !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.italic { font-style: italic; }
.no-margin { margin: 0 !important; }
.no-decoration { text-decoration: none !important; }

/* Colors */
.color-muted   { color: var(--color-text-muted) !important; }
.color-faint   { color: var(--color-text-faint) !important; }
.color-success { color: var(--color-success) !important; }
.color-danger  { color: var(--color-danger) !important; }
.color-warning { color: var(--color-warning-fg) !important; }
.color-info    { color: var(--color-info) !important; }
.color-accent  { color: var(--color-accent) !important; }
.color-purple  { color: var(--color-purple) !important; }
.color-credit  { color: var(--color-credit) !important; }

/* Credit cost hint - subtle indicator near action buttons */
.credit-hint {
    font-size: 0.7rem;
    color: var(--color-text-faint);
    font-weight: 400;
    white-space: nowrap;
}

/* Flexbox */
.flex          { display: flex !important; }
.inline-flex   { display: inline-flex !important; }
.flex-col      { flex-direction: column !important; }
.flex-wrap     { flex-wrap: wrap !important; }
.items-center  { align-items: center !important; }
.items-start   { align-items: flex-start !important; }
.justify-between { justify-content: space-between !important; }
.justify-center  { justify-content: center !important; }
.gap-1  { gap: var(--sp-1) !important; }
.gap-2  { gap: var(--sp-2) !important; }
.gap-3  { gap: var(--sp-3) !important; }
.gap-4  { gap: var(--sp-4) !important; }
.gap-6  { gap: var(--sp-6) !important; }
.flex-1 { flex: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

/* Spacing */
.m-0   { margin: 0 !important; }
.mt-0  { margin-top: 0 !important; }
.mt-1  { margin-top: var(--sp-1) !important; }
.mt-2  { margin-top: var(--sp-2) !important; }
.mt-3  { margin-top: var(--sp-3) !important; }
.mt-4  { margin-top: var(--sp-4) !important; }
.mt-6  { margin-top: var(--sp-6) !important; }
.mt-8  { margin-top: var(--sp-8) !important; }
.mt-10 { margin-top: var(--sp-10) !important; }
.mt-12 { margin-top: var(--sp-12) !important; }
.mb-0  { margin-bottom: 0 !important; }
.mb-1  { margin-bottom: var(--sp-1) !important; }
.mb-2  { margin-bottom: var(--sp-2) !important; }
.mb-3  { margin-bottom: var(--sp-3) !important; }
.mb-4  { margin-bottom: var(--sp-4) !important; }
.mb-6  { margin-bottom: var(--sp-6) !important; }
.mb-8  { margin-bottom: var(--sp-8) !important; }
.ml-1  { margin-left: var(--sp-1) !important; }
.ml-2  { margin-left: var(--sp-2) !important; }
.ml-3  { margin-left: var(--sp-3) !important; }
.ml-auto { margin-left: auto !important; }
.mr-2  { margin-right: var(--sp-2) !important; }
.p-0   { padding: 0 !important; }
.p-1   { padding: var(--sp-1) !important; }
.p-2   { padding: var(--sp-2) !important; }
.p-3   { padding: var(--sp-3) !important; }
.p-4   { padding: var(--sp-4) !important; }
.p-6   { padding: var(--sp-6) !important; }
.p-8   { padding: var(--sp-8) !important; }
.px-2  { padding-left: var(--sp-2) !important; padding-right: var(--sp-2) !important; }
.px-3  { padding-left: var(--sp-3) !important; padding-right: var(--sp-3) !important; }
.px-4  { padding-left: var(--sp-4) !important; padding-right: var(--sp-4) !important; }
.px-6  { padding-left: var(--sp-6) !important; padding-right: var(--sp-6) !important; }
.py-1  { padding-top: var(--sp-1) !important; padding-bottom: var(--sp-1) !important; }
.py-2  { padding-top: var(--sp-2) !important; padding-bottom: var(--sp-2) !important; }
.py-3  { padding-top: var(--sp-3) !important; padding-bottom: var(--sp-3) !important; }
.py-4  { padding-top: var(--sp-4) !important; padding-bottom: var(--sp-4) !important; }

/* Display & sizing */
.hidden  { display: none !important; }
.block   { display: block !important; }
.inline  { display: inline !important; }
.inline-block { display: inline-block !important; }
.w-full  { width: 100% !important; }
.overflow-x-auto { overflow-x: auto; }
.inline-form { display: inline; margin: 0; }
.color-white { color: #fff !important; }

/* Borders */
.border-0       { border: none !important; }
.border         { border: 1px solid var(--color-border) !important; }
.border-top     { border-top: 1px solid var(--color-border) !important; }
.border-bottom  { border-bottom: 1px solid var(--color-border) !important; }
.rounded-sm     { border-radius: var(--radius-sm) !important; }
.rounded-md     { border-radius: var(--radius-md) !important; }
.rounded-lg     { border-radius: var(--radius-lg) !important; }
.rounded-pill   { border-radius: var(--radius-pill) !important; }

/* Background */
.bg-surface       { background: var(--color-surface) !important; }
.bg-surface-muted { background: var(--color-surface-muted) !important; }
.bg-accent        { background: var(--color-accent) !important; }
.bg-success       { background: var(--color-success) !important; }
.bg-danger        { background: var(--color-danger) !important; }
.bg-warning       { background: var(--color-warning) !important; }

/* Section label — replaces the repeated uppercase pattern */
.section-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    letter-spacing: 0.01em;
    margin: 0;
    display: block;
}

/* Subtle callout box */
.callout {
    padding: var(--sp-3) var(--sp-4);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: var(--text-sm);
    line-height: 1.6;
    margin-bottom: var(--sp-4);
    overflow-wrap: break-word;
    word-break: break-word;
}
.callout-neutral {
    background: var(--color-surface-muted);
    border-left: 3px solid var(--color-text-faint);
    color: var(--color-text-secondary);
}
.callout-info {
    background: var(--color-info-bg);
    border-left: 3px solid var(--color-info);
    color: var(--color-info-fg);
}
.callout-success {
    background: var(--color-success-bg);
    border-left: 3px solid var(--color-success);
    color: var(--color-success-fg);
}
.callout-danger {
    background: var(--color-danger-bg);
    border-left: 3px solid var(--color-danger);
    color: var(--color-danger-fg);
}
.callout-warning {
    background: var(--color-warning-bg);
    border-left: 3px solid var(--color-warning);
    color: var(--color-warning-fg);
}
.callout-case {
    background: var(--color-case-bg);
    border-left: 3px solid var(--color-case);
    color: var(--color-case-fg);
}

/* Inline code / type signature tag */
.tag-mono {
    background: var(--color-surface-muted);
    color: var(--color-text-secondary);
    padding: 2px var(--sp-2);
    border-radius: 3px;
    font-size: var(--text-xs);
    font-family: var(--font-mono);
}

/* Curriculum / blueprint pill */
.tag-pill {
    display: inline-block;
    padding: 2px var(--sp-3);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.4;
}
.tag-pill-blue   { background: var(--color-info-bg); color: var(--color-info-fg); }
.tag-pill-green  { background: var(--color-success-bg); color: var(--color-success-fg); }
.tag-pill-purple { background: var(--color-purple-bg); color: var(--color-purple); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--sp-4) var(--sp-3);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.stat-card .number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .label {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-top: var(--sp-1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    margin-bottom: var(--sp-6);
}

th, td {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}

th {
    background: var(--color-surface-muted);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    white-space: nowrap;
}

td {
    overflow-wrap: break-word;
    word-break: break-word;
}

tr:hover {
    background: var(--color-surface-muted);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.badge-accepted    { background: var(--color-success-bg); color: var(--color-success-fg); }
.badge-published   { background: var(--color-accent);     color: #fff; }
.badge-pending     { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.badge-escalated   { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.badge-rejected    { background: var(--color-surface-muted); color: var(--color-text-muted); }
.badge-running     { background: var(--color-accent-light); color: var(--color-accent); }
.badge-paused      { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.badge-completed   { background: var(--color-success-bg); color: var(--color-success-fg); }
.badge-interrupted { background: var(--color-surface-muted); color: var(--color-text-muted); }
.badge-case        { background: var(--color-case-bg);    color: var(--color-case-fg); }
.badge-factual     { background: #f0f4f8;                 color: #475569; }
.badge-review      { background: var(--color-warning-bg); color: var(--color-warning-fg); }

/* Judge score mini-badge for item cards */
.judge-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.4rem;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 0 6px;
}
.judge-badge-good { background: var(--color-success-bg); color: var(--color-success-fg); }
.judge-badge-ok   { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.judge-badge-low  { background: var(--color-danger-bg);  color: var(--color-danger-fg); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 9px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
    line-height: 1.4;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn:hover {
    filter: brightness(0.95);
}

.btn:active {
    filter: brightness(0.9);
}

.btn-approve { background: var(--color-success); color: #fff; }
.btn-approve:hover { background: var(--color-success-hover); }

.btn-reject { background: var(--color-danger); color: #fff; }
.btn-reject:hover { background: var(--color-danger-hover); }

.btn-view { background: var(--color-accent); color: #fff; }
.btn-view:hover { background: var(--color-accent-hover); }

.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: var(--color-success-hover); }

.btn-accent { background: var(--color-accent); color: #fff; }
.btn-accent:hover { background: var(--color-accent-hover); }

.btn-warning-soft { background: var(--color-warning-bg); color: var(--color-warning-fg); border: 1px solid var(--color-warning); }

.btn-case { background: var(--color-case); color: #fff; }

.btn-repair { background: var(--color-repair); color: #fff; }

.item-detail {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    margin-bottom: var(--sp-6);
}

.item-detail h3 {
    margin-top: var(--sp-6);
    color: var(--color-text);
}

.options-list {
    list-style: none;
    margin: 1rem 0;
}

.options-list li {
    padding: 0.5rem 1rem;
    margin: 0.3rem 0;
    border-radius: var(--radius-sm);
    background: var(--color-surface-muted);
}

.options-list li.correct {
    background: var(--color-success-bg);
    border-left: 4px solid var(--color-success);
    font-weight: 600;
}

.filter-bar {
    margin-bottom: 0;
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

.filter-bar a {
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text-secondary);
    background: transparent;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.filter-bar a:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.filter-bar a.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.meta-info {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-top: 0.5rem;
}

pre {
    background: var(--color-surface-muted);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: var(--text-sm);
}

/* ============================================================
   New UI elements — qVault UI overhaul
   ============================================================ */

/* Page header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--sp-6);
    gap: var(--sp-4);
    flex-wrap: wrap;
}

.page-header h1 {
    margin-bottom: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-top: var(--sp-1);
    line-height: 1.5;
}

/* Alerts */
.alert {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--sp-4);
    font-weight: 500;
    font-size: var(--text-sm);
    line-height: 1.5;
}

.alert-error {
    background: var(--color-danger-bg);
    color: var(--color-danger-fg);
    border-left: 3px solid var(--color-danger);
}

.alert-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-fg);
    border-left: 3px solid var(--color-warning);
}

.alert-info {
    background: var(--color-info-bg);
    color: var(--color-info-fg);
    border-left: 3px solid var(--color-info);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-fg);
    border-left: 3px solid var(--color-success);
}

/* Generic white card */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--sp-6);
    border: 1px solid var(--color-border);
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Flat card — for nesting inside other cards (no shadow, lighter border) */
.card-flat {
    background: var(--color-surface-muted);
    border-radius: var(--radius-sm);
    padding: var(--sp-3);
    border: 1px solid var(--color-border-light);
    overflow-wrap: break-word;
    word-break: break-word;
}

.card h2 {
    margin-top: 0;
    margin-bottom: var(--sp-4);
}

/* Lightweight section divider — used instead of .card for non-interactive content */
.section-block {
    padding-top: var(--sp-4);
    margin-top: var(--sp-4);
    border-top: 1px solid var(--color-border-light);
}
.section-block:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}
details.card > summary {
    padding: 0;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 0; }

.card h3 {
    margin-top: var(--sp-4);
    margin-bottom: var(--sp-3);
}

.hint {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-top: var(--sp-2);
    line-height: 1.5;
}

/* Lead text — for question stems and vignettes */
.lead-text {
    font-size: var(--text-lg);
    line-height: 1.8;
    color: var(--color-text);
}

/* Surface muted — light background card variant */
.surface-muted {
    background: var(--color-surface-muted) !important;
}

/* Border left accents */
.border-left-case    { border-left: 3px solid var(--color-case) !important; }
.border-left-info    { border-left: 3px solid var(--color-info) !important; }
.border-left-warning { border-left: 3px solid var(--color-warning) !important; }
.border-left-danger  { border-left: 3px solid var(--color-danger) !important; }
.border-left-accent  { border-left: 3px solid var(--color-accent) !important; }

/* ── Explanation section ── */
.explanation-section {
    padding-top: var(--sp-2);
}
/* Key point block - prominent colored display before explanation */
.kp-block {
    font-weight: 600;
    font-size: var(--text-sm);
    line-height: 1.6;
    padding: 0.6rem 1rem;
    background: var(--color-accent-light);
    border-left: 3px solid var(--color-accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: var(--sp-4);
    color: var(--color-text);
}

/* Legacy classes kept for backward compat */
.explanation-kp-inline {
    font-size: var(--text-sm);
    line-height: 1.6;
    color: var(--color-text-secondary);
    margin-bottom: var(--sp-3);
}
.explanation-kp-tag {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-right: 6px;
}

/* ── Explanation Principle / Approach ── */
.explanation-principle {
    display: block;
    border-left: 2px solid var(--color-purple, #7c3aed);
    padding-left: 10px;
    margin: 6px 0;
    font-style: italic;
    color: var(--color-text-secondary);
}
.explanation-approach {
    display: block;
    border-left: 2px solid var(--color-warning, #d97706);
    padding-left: 10px;
    margin: 6px 0;
    color: var(--color-text-secondary);
}

/* ── Question Bank: Status pill bar ── */
.qb-status-bar {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}
.qb-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}
.qb-status-pill:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}
.qb-status-pill.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.qb-status-pill.qb-status-warning:not(.active) {
    color: var(--color-warning-fg);
}
.qb-pill-count {
    font-size: 0.8em;
    opacity: 0.75;
}

/* ── Question Bank: Secondary filter row ── */
.qb-filter-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
    flex-wrap: wrap;
}
.qb-filter-row-left {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
.qb-select {
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    background: var(--color-surface);
    cursor: pointer;
}
.qb-search-form {
    flex: 1;
    min-width: 140px;
    max-width: 280px;
}
.qb-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.qb-search-icon {
    position: absolute;
    left: 8px;
    pointer-events: none;
}
.qb-search-input {
    width: 100%;
    padding: 5px 10px 5px 30px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    background: var(--color-surface);
}
.qb-search-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* ── Question Bank: Results bar ── */
.qb-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
    flex-wrap: wrap;
}

/* ── Question Bank: Empty state ── */
.qb-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-8) var(--sp-4);
    color: var(--color-text-muted);
    text-align: center;
}
.qb-empty-state p {
    margin: 0;
    font-size: var(--text-sm);
}

/* Meta row — small grey metadata */
.meta-row {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

/* Button variants */
.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

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

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

.btn-large {
    padding: 10px 20px;
    font-size: var(--text-base);
}

.btn-sm {
    padding: 4px 10px;
    font-size: var(--text-xs);
}

/* Nav "New Run" button */
.btn-nav-new {
    background: var(--color-accent) !important;
    color: #fff !important;
    padding: 0 14px !important;
    height: 34px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: var(--sp-1) !important;
    border-radius: var(--radius-sm) !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    font-size: var(--text-sm) !important;
    border-bottom: none !important;
    margin-left: var(--sp-2);
    white-space: nowrap;
}

.btn-nav-new:hover {
    background: var(--color-accent-hover) !important;
}

/* Tab bar (paste / upload tabs on new_run page) */
.tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--color-border-light);
}

.tab {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

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

.tab:hover:not(.active) {
    color: var(--color-text-secondary);
}

/* File drop zone */
.file-drop {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    text-align: center;
    transition: border-color var(--transition-base);
}

.file-drop:hover {
    border-color: var(--color-primary);
}

.file-drop label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.file-drop input[type="file"] {
    display: none;
}

.upload-icon {
    font-size: 2.5rem;
}

/* Mode selector grid */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-3);
    margin-top: var(--sp-2);
}

.mode-card {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.mode-card:hover {
    border-color: var(--color-text-faint);
}

.mode-card:has(input:checked) {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
}

.mode-card input[type="radio"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--color-accent);
}

.mode-body {
    flex: 1;
}

.mode-title {
    font-weight: 600;
    margin-bottom: var(--sp-1);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
}

.mode-desc {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* Form footer */
.form-footer {
    margin-top: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.generate-footer {
    position: sticky;
    bottom: 0;
    background: var(--color-surface-muted);
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

/* KP selection toolbar */
.select-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pair-count {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-left: auto;
}

/* KP cards */
.kp-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    overflow-wrap: break-word;
    word-break: break-word;
}

.kp-sentence {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--color-text);
    line-height: 1.5;
}

/* Cloze-style sentence layout */
.kp-sentence.cloze-sentence {
    font-weight: 500;
    line-height: 1.7;
    padding: 0.75rem;
    background: var(--color-surface-muted);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
}

.cloze-anchor {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0 0.15rem;
    cursor: pointer;
    user-select: none;
}

.cloze-anchor input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.cloze-text {
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    border: 1px solid var(--color-border);
    transition: all var(--transition-fast);
}

.cloze-anchor:has(input:checked) .cloze-text {
    border-color: var(--color-success);
    background: var(--color-success-bg);
    color: var(--color-text);
}

.cloze-anchor .score-badge {
    font-size: 0.7rem;
    margin-left: 0.2rem;
}

.anchor-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Anchor checkboxes styled as pills */
.anchor-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    border: 2px solid var(--color-border);
    background: var(--color-surface-muted);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: border-color var(--transition-fast), background var(--transition-fast);
    user-select: none;
}

.anchor-tag:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-accent-light);
}

.anchor-tag input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.anchor-high { border-color: var(--color-success); }
.anchor-high:has(input:checked) { background: var(--color-success-bg); border-color: var(--color-success); }

.anchor-mid { border-color: var(--color-warning); }
.anchor-mid:has(input:checked) { background: var(--color-warning-bg); border-color: var(--color-warning); }

.anchor-low { border-color: var(--color-danger); }
.anchor-low:has(input:checked) { background: var(--color-danger-bg); border-color: var(--color-danger); }

.score-badge {
    font-size: var(--text-xs);
    background: rgba(0,0,0,0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: 600;
}

/* Progress page */
.progress-container {
    max-width: 720px;
    margin: var(--sp-6) auto;
    text-align: center;
}

.progress-container h1 {
    margin-bottom: var(--sp-2);
}

.progress-bar-wrap {
    background: var(--color-border);
    border-radius: var(--radius-pill);
    height: 10px;
    margin: var(--sp-4) 0 var(--sp-2);
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: var(--color-accent);
    border-radius: var(--radius-pill);
    transition: width 0.5s ease;
}

.bar-complete {
    background: var(--color-success);
}

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

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--sp-4);
}

.spinner.spinner-done {
    border-color: var(--color-success);
    border-top-color: var(--color-success);
    animation: none;
}

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

/* Inline spinner for buttons */
.spinner-inline {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;
}

.stage {
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
}

.stage.stage-active {
    background: var(--color-info-bg);
    color: var(--color-info-fg);
    font-weight: 600;
}

.stage.stage-done {
    background: var(--color-success-bg);
    color: var(--color-success-fg);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--sp-12) var(--sp-6);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    margin-bottom: var(--sp-6);
}

.empty-state h2 {
    margin: var(--sp-3) 0 0 0;
    font-size: var(--text-xl);
}

.empty-state p {
    color: var(--color-text-muted);
    margin: var(--sp-3) auto;
    max-width: 440px;
    font-size: var(--text-sm);
    line-height: 1.6;
}

.empty-state .btn {
    margin-top: var(--sp-6);
}

/* Legacy color utilities — prefer .color-success / .color-danger / .color-muted */
.text-green { color: var(--color-success); }
.text-red { color: var(--color-danger); }
.text-muted { color: var(--color-text-faint); }

/* ── Reason / status tags in run detail table ─────────────────────── */
.reason-cell { font-size: var(--text-sm); }

.reason-tag {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}

.reason-error  { background: var(--color-danger-bg); color: var(--color-danger-fg); }
.reason-judge  { background: var(--color-purple-bg); color: var(--color-purple); cursor: default; }
.reason-repair { background: var(--color-warning-bg); color: var(--color-warning-fg); }

/* ── Pipeline Logs panel ──────────────────────────────────────────── */
.log-section {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.log-header {
    background: var(--color-primary);
    color: var(--color-nav-text);
    padding: var(--sp-2) var(--sp-4);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: var(--text-sm);
    user-select: none;
    transition: background var(--transition-fast);
}

.log-header:hover { background: var(--color-primary-hover); }

.log-panel {
    background: var(--log-bg);
    border: 1px solid var(--log-border);
    border-top: none;
}

.log-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--log-bg-alt);
    border-bottom: 1px solid var(--log-border);
    font-size: var(--text-sm);
    color: var(--log-text-muted);
}

.log-toolbar label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.btn-log-clear {
    background: none;
    border: 1px solid var(--log-border);
    color: var(--log-text-muted);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-xs);
}
.btn-log-clear:hover { background: var(--log-bg-alt); color: var(--log-text); }

.log-status-text {
    margin-left: auto;
    font-size: var(--text-xs);
    color: var(--log-text-faint);
}

.log-output {
    background: transparent;
    padding: 0.75rem 1rem;
    height: 320px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.5;
    color: var(--log-text);
    white-space: pre-wrap;
    word-break: break-all;
    border-radius: 0;
    box-shadow: none;
    text-align: left;
}

.log-line.log-error   { color: var(--log-error); }
.log-line.log-warning { color: var(--log-warning); }
.log-line.log-info    { color: var(--log-info); }
.log-line.log-debug   { color: var(--log-debug); }

/* Textarea */
textarea {
    width: 100%;
    padding: var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: var(--text-sm);
    resize: vertical;
    color: var(--color-text);
    line-height: 1.6;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ============================================================
   Stage counters (progress page) — pipeline visualization
   ============================================================ */
.stage-counters {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-top: var(--sp-4);
    flex-wrap: wrap;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--sp-2);
    border: 1px solid var(--color-border);
}

.stage-counter {
    text-align: center;
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-faint);
    min-width: 72px;
    transition: all var(--transition-base);
    position: relative;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.stage-counter.sc-active {
    background: var(--color-accent-light);
    color: var(--color-accent);
    animation: pulse-glow 2s ease-in-out infinite;
}

.stage-counter.sc-complete {
    background: var(--color-success-bg);
    color: var(--color-success-fg);
}

.stage-counter.sc-done.sc-active {
    background: var(--color-success-bg);
    color: var(--color-success-fg);
}

.stage-counter.sc-error.sc-active {
    background: var(--color-danger-bg);
    color: var(--color-danger-fg);
}
.sc-error-badge {
    display: none;
    font-size: var(--text-xs);
    color: var(--color-danger-fg);
    background: var(--color-danger-bg);
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    margin-top: 2px;
}

.sc-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sc-count {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 1px;
}

/* Per-item progress table */
.item-progress-table {
    font-size: var(--text-sm);
    margin-top: 0.5rem;
    text-align: left;
}

.item-progress-table th {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.item-stage-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    font-size: var(--text-xs);
    font-weight: 600;
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
}

.item-stage-badge.stage-f1 { background: var(--color-info-bg); color: var(--color-info-fg); }
.item-stage-badge.stage-f2 { background: var(--color-purple-bg); color: var(--color-purple); }
.item-stage-badge.stage-judges { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.item-stage-badge.stage-f4 { background: var(--color-success-bg); color: var(--color-success-fg); }
.item-stage-badge.stage-done { background: var(--color-success-bg); color: var(--color-success-fg); }
.item-stage-badge.stage-err { background: var(--color-danger-bg); color: var(--color-danger-fg); }

/* ============================================================
   Audit trail table
   ============================================================ */
.audit-trail {
    margin-top: 0.5rem;
    overflow-x: auto;
}

.audit-table {
    font-size: var(--text-sm);
}

.audit-table th {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr.audit-error td {
    background: var(--color-danger-bg);
    color: var(--color-danger-fg);
}

/* ============================================================
   Escalation detail
   ============================================================ */
.escalation-detail {
    background: var(--color-warning-bg);
    padding: var(--sp-4);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--color-warning);
}

.escalation-detail p {
    margin-bottom: 0.5rem;
}

.escalation-detail details {
    margin-top: 0.5rem;
}

.escalation-detail summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text);
}

.escalation-actions {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface-muted);
    border-radius: var(--radius-sm);
}

/* ============================================================
   Item prev/next navigation bar (review page)
   ============================================================ */
/* ============================================================
   Edit mode toggle (review page)
   ============================================================ */
.review-main.edit-mode-off .edit-tools {
    display: none !important;
}

.review-main.edit-mode-off .btn-regen {
    display: none !important;
}

#edit-mode-toggle.active {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.item-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-4);
    padding: var(--sp-2) 0;
}

.item-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-accent);
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.item-nav-btn:hover {
    background: var(--color-info-bg);
}

.item-nav-disabled {
    color: var(--color-text-faint);
    pointer-events: none;
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    padding: var(--sp-4) 0;
    flex-wrap: wrap;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-text);
    text-decoration: none;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: background var(--transition-fast), border-color var(--transition-fast);
    min-width: 36px;
    justify-content: center;
}

.pagination-btn:hover {
    background: var(--color-info-bg);
    border-color: var(--color-accent);
}

.pagination-active {
    background: var(--color-accent) !important;
    color: #fff !important;
    border-color: var(--color-accent) !important;
    font-weight: 600;
}

.pagination-ellipsis {
    padding: var(--sp-2) var(--sp-1);
    color: var(--color-text-muted);
}

/* ============================================================
   Question card view (items page)
   ============================================================ */
.question-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    margin-bottom: var(--sp-2);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.question-card:hover {
    border-color: var(--color-text-faint);
    box-shadow: var(--shadow-sm);
}

.qc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.qc-header:hover {
    background: var(--color-surface-muted);
}

.qc-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.qc-chevron {
    color: var(--color-text-faint);
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.qc-body {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--color-border-light);
}

.qc-leadin {
    margin: 0.75rem 0;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.qc-explanation {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-info-bg);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    line-height: 1.5;
}

.qc-escalation {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-danger-bg);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    color: var(--color-danger-fg);
}

/* Inline preview row in table view */
.item-preview-row td {
    padding: 0 !important;
    border-top: none !important;
}

.item-preview-inner {
    background: var(--color-surface-muted);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 2px solid var(--color-border);
    animation: slideDown 0.15s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 400px; }
}

.item-preview-inner .preview-stem {
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text);
    margin-bottom: var(--sp-2);
}

.item-preview-inner .preview-options {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--sp-2);
}

.item-preview-inner .preview-options li {
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}

.item-preview-inner .preview-options li.correct {
    background: var(--color-success-bg);
    font-weight: 600;
}

.item-preview-inner .preview-actions {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}

/* ============================================================
   Interim output inspection on progress page
   ============================================================ */
.btn-interim {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: var(--text-xs);
    cursor: pointer;
    color: var(--color-text-muted);
}
.btn-interim:hover {
    background: var(--color-surface-muted);
    color: var(--color-text-secondary);
}
.interim-detail {
    background: var(--color-surface-muted);
    padding: 0.75rem 1rem !important;
    border-left: 3px solid var(--color-success);
    font-size: var(--text-sm);
}
.interim-stage {
    margin-bottom: var(--sp-3);
}
.interim-stage:last-child {
    margin-bottom: 0;
}
.interim-label {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: var(--sp-1);
}
.interim-text {
    margin: 0;
    line-height: 1.6;
    color: var(--color-text);
}
.interim-options {
    margin-top: var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.interim-option {
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}
.interim-judges {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
.interim-judge-score {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
}
.interim-judge-score.judge-good { background: var(--color-success-bg); color: var(--color-success-fg); }
.interim-judge-score.judge-ok   { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.interim-judge-score.judge-low  { background: var(--color-danger-bg); color: var(--color-danger-fg); }
.interim-judge-name {
    font-weight: 400;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}
.interim-failed {
    margin-top: var(--sp-1);
    font-size: var(--text-xs);
    color: var(--color-danger);
}
.interim-stage ul {
    list-style: disc;
}

/* ============================================================
   Delete button (items / runs)
   ============================================================ */
.btn-delete {
    background: transparent;
    color: var(--color-text-faint);
    border: 1px solid var(--color-border);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}
.btn-delete:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: var(--color-danger);
}
.btn-delete-sm {
    padding: 3px 6px;
    font-size: var(--text-xs);
}

/* ============================================================
   View toggle buttons
   ============================================================ */
.view-toggle {
    display: flex;
    gap: 0.25rem;
}

/* ============================================================
   Breadcrumbs
   ============================================================ */
.breadcrumbs {
    background: var(--color-surface);
    padding: 0 var(--sp-6);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--text-sm);
    margin-bottom: 0;
}

.breadcrumbs-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--sp-2) 0;
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

.breadcrumb-item {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

.breadcrumb-item.active {
    color: var(--color-text-secondary);
    font-weight: 500;
}

.breadcrumb-sep {
    color: var(--color-text-faint);
    margin: 0 2px;
    font-size: var(--text-xs);
}

/* ============================================================
   Workflow Progress Indicator
   ============================================================ */
.workflow-progress {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: var(--sp-6);
    background: var(--color-surface);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0 var(--sp-3);
    position: relative;
    flex: 1;
}

.workflow-step::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 1px;
    background: var(--color-border);
}

.workflow-step:last-child::after {
    display: none;
}

.workflow-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-border);
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: var(--text-xs);
    flex-shrink: 0;
}

.workflow-step.active .workflow-number {
    background: var(--color-accent);
    color: #fff;
}

.workflow-step.complete .workflow-number {
    background: var(--color-success);
    color: #fff;
}

.workflow-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-muted);
}

.workflow-step.active .workflow-label {
    color: var(--color-text);
    font-weight: 600;
}

/* ============================================================
   Run Sidebar (context panel)
   ============================================================ */
.run-detail-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem;
    align-items: start;
}
.run-detail-layout > :first-child {
    min-width: 0; /* prevent grid blowout from long content */
}

.run-sidebar {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    position: sticky;
    top: var(--sp-4);
}

.run-sidebar-section {
    margin-bottom: 1.5rem;
}

.run-sidebar-section:last-child {
    margin-bottom: 0;
}

.run-sidebar-title {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: var(--sp-3);
    display: block;
}

.run-sidebar-content {
    font-size: var(--text-sm);
}

.run-sidebar-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--color-border-light);
}

.run-sidebar-stat:last-child {
    border-bottom: none;
}

.run-sidebar-stat-label {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

.run-sidebar-stat-value {
    font-weight: 600;
    color: var(--color-text);
}

.run-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.run-sidebar-actions .btn {
    width: 100%;
    text-align: center;
    padding: 0.5rem 0.75rem;
    font-size: var(--text-sm);
    justify-content: center;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.run-export-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 50;
    padding: 4px 0;
    min-width: 200px;
}
.run-export-dropdown.open { display: block; }
.run-export-dropdown a {
    display: block;
    padding: 6px 12px;
    font-size: var(--text-xs);
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
}
.run-export-dropdown a:hover { background: var(--color-surface-muted); }

/* ============================================================
   Responsive Improvements
   ============================================================ */
@media (max-width: 1024px) {
    .run-detail-layout {
        grid-template-columns: 1fr;
    }

    .run-sidebar {
        position: static;
    }
}

@media (max-width: 768px) {
    .workflow-progress {
        padding: 0.75rem;
    }

    .workflow-step {
        padding: 0 0.5rem;
        min-width: 60px;
    }

    .workflow-label {
        font-size: var(--text-xs);
    }

    .workflow-number {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .breadcrumbs {
        padding: 0.4rem 0.75rem;
    }

    .breadcrumbs-inner {
        padding: 0 0.5rem;
        font-size: 0.8rem;
    }

    .page-header {
        margin-bottom: 1.5rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .number {
        font-size: 1.5rem;
    }
}

/* ============================================================
   Tooltip and Help Styles
   ============================================================ */
[data-tooltip] {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--color-text-faint);
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    font-size: var(--text-sm);
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.help-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
    border-radius: 50%;
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: help;
    margin-left: 0.25rem;
}

.help-icon:hover {
    background: var(--color-primary);
    color: white;
}

/* ============================================================
   Input and Form Improvements
   ============================================================ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select {
    font-size: var(--text-sm);
    padding: 7px var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    color: var(--color-text);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ============================================================
   Table Mobile Responsiveness
   ============================================================ */
@media (max-width: 1024px) {
    table {
        font-size: var(--text-sm);
    }

    th, td {
        padding: 0.6rem 0.8rem;
    }
}

@media (max-width: 768px) {
    table {
        font-size: var(--text-sm);
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    th, td {
        padding: 0.5rem 0.6rem;
    }
}

/* ============================================================
   Review Page — Two-Column Layout
   ============================================================ */
.review-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: var(--sp-6);
    align-items: start;
}

.review-main {
    min-width: 0; /* prevent grid blowout */
}

.review-sidebar {
    position: sticky;
    top: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-width: 0; /* prevent overflow */
    overflow-wrap: break-word;
    word-break: break-word;
}

.review-sidebar .card {
    margin-bottom: 0;
    padding: var(--sp-4);
    box-shadow: none;
    border-color: var(--color-border-light);
}

@media (max-width: 1024px) {
    .review-layout {
        grid-template-columns: 1fr;
    }
    .review-sidebar {
        position: static;
    }
}

/* Options table in review */
.options-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
}
.options-table td {
    padding: var(--sp-4);
    vertical-align: top;
    line-height: 1.6;
}
.options-table tr:last-child td {
    border-bottom: none;
}
.options-table .opt-letter {
    width: 40px;
    font-weight: 700;
    font-size: var(--text-base);
    white-space: nowrap;
    color: var(--color-text-muted);
    padding-right: var(--sp-2);
}
.options-table .opt-text {
    font-size: var(--text-base);
    overflow-wrap: break-word;
    word-break: break-word;
    width: 55%;
}
.options-table .opt-rationale {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: 1.5;
    width: 35%;
    overflow-wrap: break-word;
    word-break: break-word;
}
.options-table tr.opt-correct td:first-child {
    border-left: 3px solid var(--color-success);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.options-table tr.opt-correct .opt-letter {
    color: var(--color-success-fg);
}
.options-table tr:not(.opt-correct) td {
    border-bottom: 1px solid var(--color-border-light);
}
/* Explanation: correct-answer reference */
.expl-correct {
    color: var(--color-success-fg);
}

/* Inline edit panel */
.edit-panel {
    margin-top: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--color-border);
}
.edit-panel input[type="text"] {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-2);
}
.edit-panel .edit-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    flex-wrap: wrap;
}
.edit-status {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* Unified edit panel (tabbed Direct / AI) */
.unified-edit-panel {
    margin-top: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-muted);
}
.unified-edit-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--sp-3);
    border-bottom: 1px solid var(--color-border);
}
.unified-tab {
    padding: var(--sp-1) var(--sp-3);
    border: none;
    background: none;
    font-size: var(--text-sm);
    cursor: pointer;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.unified-tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    font-weight: 600;
}
.unified-tab-content input[type="text"] {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-2);
}
.unified-tab-content .edit-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    flex-wrap: wrap;
}

/* Ghost button (edit, regen) */
.btn-ghost {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px var(--sp-2);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-ghost:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-accent-light);
}
.btn-ghost:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

/* Judge orbs in sidebar */
.judge-orbs {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    flex-wrap: wrap;
}
.judge-orb {
    text-align: center;
}
.judge-orb-label {
    font-size: var(--text-xs);
    color: var(--color-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
}
.judge-orb-value {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
}
.judge-orb-good { background: var(--color-success-bg); color: var(--color-success-fg); }
.judge-orb-ok   { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.judge-orb-low  { background: var(--color-danger-bg); color: var(--color-danger-fg); }
.judge-mean {
    margin-left: var(--sp-3);
    padding-left: var(--sp-3);
    border-left: 1px solid var(--color-border);
}
.judge-mean-label {
    font-size: var(--text-xs);
    color: var(--color-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.judge-mean-value {
    font-size: var(--text-2xl);
    font-weight: 700;
}

/* ============================================================
   Button — Focus & Disabled States
   ============================================================ */
.btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================================
   Toast Notification System
   ============================================================ */
.toast-container {
    position: fixed;
    top: var(--sp-6);
    right: var(--sp-6);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
    font-size: var(--text-sm);
    max-width: 400px;
    animation: toast-in 0.25s ease;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.toast-out {
    opacity: 0;
    transform: translateX(16px);
}
.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}
.toast-message {
    flex: 1;
    line-height: 1.4;
}
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--color-text-muted);
    font-size: var(--text-lg);
    line-height: 1;
}
.toast-close:hover { color: var(--color-text); }

.toast-success { border-left: 4px solid var(--color-success); }
.toast-error   { border-left: 4px solid var(--color-danger); }
.toast-warning { border-left: 4px solid var(--color-warning); }
.toast-info    { border-left: 4px solid var(--color-accent); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   Confirm Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 0.15s ease;
}

.modal-box {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-8);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modal-pop 0.2s ease;
}
.modal-box h3 {
    margin-bottom: var(--sp-3);
}
.modal-box p {
    color: var(--color-text-secondary);
    margin-bottom: var(--sp-6);
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    gap: var(--sp-3);
    justify-content: flex-end;
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modal-pop {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   Export Modal
   ============================================================ */
.export-options {
    display: grid;
    gap: var(--sp-3);
}
.export-option {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: var(--color-text);
}
.export-option:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
}
.export-option-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-lg);
}
.export-option-text {
    flex: 1;
}
.export-option-title {
    font-weight: 600;
    font-size: var(--text-sm);
}
.export-option-desc {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ============================================================
   Student Preview — Clean exam-style view
   ============================================================ */
.student-preview {
    max-width: 800px;
    margin: 0 auto;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.8;
    color: var(--color-text);
}
.student-preview h1 {
    font-family: var(--font-display);
    text-align: center;
    margin-bottom: var(--sp-8);
    font-size: var(--text-xl);
    letter-spacing: 0;
}
.student-question {
    margin-bottom: var(--sp-10);
    page-break-inside: avoid;
}
.student-question-number {
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--sp-2);
    font-family: var(--font-body);
}
.student-stem {
    margin-bottom: var(--sp-4);
    font-size: var(--text-base);
}
.student-options {
    list-style: none;
    padding: 0;
    margin: 0;
}
.student-options li {
    padding: var(--sp-2) 0;
    padding-left: var(--sp-6);
    text-indent: -var(--sp-6);
}
.student-answer-key {
    page-break-before: always;
    margin-top: var(--sp-12);
    border-top: 2px solid var(--color-border);
    padding-top: var(--sp-8);
}
@media print {
    .no-print { display: none !important; }
    body { background: white; }
    .student-preview { max-width: none; }
}

/* ============================================================
   Auth Pages
   ============================================================ */
.auth-container {
    max-width: 400px;
    margin: var(--sp-12) auto;
}
.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--sp-10);
}
.auth-card h1 {
    text-align: center;
    margin-bottom: var(--sp-6);
}
.auth-card .brand-mark {
    text-align: center;
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: var(--sp-2);
}
.form-group {
    margin-bottom: var(--sp-4);
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: var(--sp-1);
    color: var(--color-text);
}
.form-group input {
    width: 100%;
    padding: var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    transition: border-color var(--transition-fast);
}
.form-group input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}
.form-error {
    color: var(--color-danger);
    font-size: var(--text-sm);
    margin-top: var(--sp-1);
}

/* Admin users table */
.admin-table { font-size: var(--text-sm); }
.admin-table th {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.role-badge {
    display: inline-block;
    padding: 2px var(--sp-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
}
.role-admin  { background: var(--color-danger-bg); color: var(--color-danger-fg); }
.role-editor { background: var(--color-info-bg); color: var(--color-info-fg); }
.role-viewer { background: var(--color-surface-muted); color: var(--color-text-secondary); }

/* ============================================================
   Lucide SVG Icon Sizing
   ============================================================ */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 18px; height: 18px; }
.icon-lg { width: 24px; height: 24px; }

/* ============================================================
   Nav Dropdown (user menu)
   ============================================================ */
.nav-user {
    position: relative;
    /* Spacing from preceding element (credit badge or spacer).
       margin-left: auto is intentionally removed — the flex:1 spacer div already
       pushes right-side items to the end; double auto-margin causes inconsistent
       gaps depending on what's visible. */
    margin-left: var(--sp-2);
    display: flex;
    align-items: center;
}
.nav-user-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    /* Use padding-only sizing so the button height is determined naturally,
       matching the parent's align-items: center alignment cleanly. */
    padding: 0 var(--sp-3);
    height: 34px;
    color: var(--color-nav-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}
.nav-user-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--color-nav-hover);
}
.nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 170px;
    z-index: 5000;
    padding: 4px 0;
}
.nav-dropdown.open { display: block; }
.nav-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    color: var(--color-text);
    text-decoration: none;
    font-size: var(--text-sm);
    transition: background var(--transition-fast);
}
.nav-dropdown a:hover {
    background: var(--color-surface-muted);
}
.nav-dropdown-sep {
    border-top: 1px solid var(--color-border);
    margin: 4px 0;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: var(--sp-8) var(--sp-4);
    color: var(--color-text-faint);
    font-size: var(--text-xs);
    border-top: 1px solid var(--color-border);
    margin-top: var(--sp-12);
}

/* ── Credit badge in nav ── */
.nav-credit-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.1);
    color: var(--color-nav-text);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-pill);
    /* Match the user-button height for visual consistency — use padding not
       magic pixel heights so it scales with font-size. */
    padding: 0 var(--sp-3);
    height: 34px;
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: default;
    white-space: nowrap;
    transition: background var(--transition-fast);
    /* Ensure badge sits flush with the spacer boundary */
    margin-left: var(--sp-2);
}
.nav-credit-badge:hover {
    background: rgba(255,255,255,0.15);
    color: var(--color-nav-hover);
}
.nav-credit-unlimited {
    background: rgba(22, 163, 74, 0.15);
    color: #86efac;
    border-color: rgba(22, 163, 74, 0.3);
}
.nav-credit-unlimited:hover {
    background: rgba(22, 163, 74, 0.25);
}

/* ── Segmented Control (quality preset, view toggles) ── */
.segmented-control {
    display: flex;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    max-width: 400px;
}
.segmented-control label {
    flex: 1;
    text-align: center;
    cursor: pointer;
}
.segmented-control input[type="radio"] {
    display: none;
}
.segmented-option {
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    font-weight: 500;
    background: var(--color-surface);
    color: var(--color-text-muted);
    border-right: 1px solid var(--color-border);
    transition: background var(--transition-fast), color var(--transition-fast);
}
.segmented-option:last-child,
.segmented-control label:last-child .segmented-option {
    border-right: none;
}
.segmented-option.selected {
    background: var(--color-accent);
    color: #fff;
}
.segmented-option:hover:not(.selected) {
    background: var(--color-surface-muted);
}

/* ── Settings Panel (judge selection, form groups) ── */
.settings-panel {
    padding: var(--sp-4);
    background: var(--color-surface-muted);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    margin-bottom: var(--sp-4);
}
.settings-panel-title {
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: var(--sp-1);
}
.settings-panel-hint {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: var(--sp-3);
}

/* ── Checkbox Chip (judge selection, settings) ── */
.checkbox-chip {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    cursor: pointer;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}
.checkbox-chip:hover {
    border-color: var(--color-text-faint);
}
.checkbox-chip:has(input:checked) {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
}
.checkbox-chip input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--color-accent);
}
.checkbox-chip-label {
    font-weight: 600;
}
.checkbox-chip-hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* ── Form Field Group ── */
.form-field {
    margin-bottom: var(--sp-4);
}
.form-field-label {
    font-weight: 600;
    font-size: var(--text-sm);
    display: block;
    margin-bottom: var(--sp-1);
}
.form-field-hint {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: var(--sp-2);
}
.form-select {
    width: 100%;
    padding: 0.5rem;
    font-size: var(--text-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
}

/* ── Stat Highlight (run detail cost/credit cards) ── */
.stat-highlight {
    padding: var(--sp-4);
    border-radius: var(--radius-sm);
}
.stat-highlight-label {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--sp-2);
}
.stat-highlight-value {
    font-size: 1.75rem;
    font-weight: 700;
}
.stat-highlight-note {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--sp-1);
}

/* ── Sidebar Action Button (consistent styling) ── */
.btn-sidebar {
    width: 100%;
    text-align: center;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    justify-content: center;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: filter var(--transition-fast);
}
.btn-sidebar:hover { filter: brightness(0.95); }
.btn-sidebar-accent  { background: var(--color-accent); color: #fff; }
.btn-sidebar-info    { background: var(--color-info); color: #fff; }
.btn-sidebar-purple  { background: var(--color-purple); color: #fff; }
.btn-sidebar-warning { background: var(--color-warning); color: #fff; }
.btn-sidebar-muted   { background: var(--color-text-muted); color: #fff; }
.btn-sidebar-success { background: var(--color-success); color: #fff; }
.btn-sidebar-outline { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }

/* ── Status callout (inline messages, subject creator) ── */
.status-message {
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    border-left: 3px solid;
}
.status-message-info    { background: var(--color-info-bg); border-color: var(--color-info); color: var(--color-info-fg); }
.status-message-success { background: var(--color-success-bg); border-color: var(--color-success); color: var(--color-success-fg); }
.status-message-error   { background: var(--color-danger-bg); border-color: var(--color-danger); color: var(--color-danger-fg); }

/* ── Escalation Card Components ── */
.escalation-item {
    padding: 0;
}
.escalation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: var(--sp-3);
    margin-bottom: var(--sp-4);
    border-bottom: 1px solid var(--color-border-light);
}
.escalation-header h3 {
    margin: 0 0 var(--sp-1);
}
.escalation-content {
    background: var(--color-surface-muted);
    padding: var(--sp-4);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-accent);
    margin-bottom: var(--sp-4);
    overflow-wrap: break-word;
    word-break: break-word;
}
.escalation-content.escalation-content-case {
    border-left-color: var(--color-case);
}
.escalation-content-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--sp-2);
}
.escalation-options {
    margin: var(--sp-2) 0;
    padding-left: var(--sp-6);
}
.escalation-options li {
    margin-bottom: var(--sp-2);
    line-height: 1.5;
}
.escalation-option-correct {
    color: var(--color-success-fg);
    font-weight: 600;
}
.escalation-judge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}
.escalation-judge-card {
    text-align: center;
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
    border-left: 3px solid;
}
.escalation-judge-card-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}
.escalation-judge-card-score {
    font-size: 1.25rem;
    font-weight: 700;
}
.escalation-actions-bar {
    display: flex;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--color-border-light);
    flex-wrap: wrap;
    align-items: stretch;
}
.escalation-actions-bar > * {
    flex: 1 1 0;
    min-width: 0;
}
.escalation-actions-bar .btn {
    width: 100%;
    justify-content: center;
}

/* ── Difficulty Badge (full word) ── */
.badge-difficulty-easy { background: var(--color-success-bg); color: var(--color-success-fg); }
.badge-difficulty-moderate, .badge-difficulty-mixed { background: var(--color-warning-bg); color: var(--color-warning-fg); }
.badge-difficulty-hard { background: var(--color-danger-bg); color: var(--color-danger-fg); }

/* ── Pipeline Enhancement toggles ── */
.enhance-group {
    margin-bottom: var(--sp-4);
}
.enhance-group-label {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--sp-2);
    padding-bottom: var(--sp-1);
    border-bottom: 1px solid var(--color-border-light);
}
.enhance-row {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-bottom: var(--sp-1);
}
.enhance-row:hover {
    background: var(--color-surface-muted);
}
.enhance-row input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--color-accent);
}
.enhance-row strong {
    font-size: var(--text-sm);
}
.enhance-desc {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-top: 2px;
}
.enhance-cost {
    font-size: var(--text-xs);
    color: var(--color-text-faint);
    margin-left: var(--sp-2);
    font-weight: 400;
}

/* ── Quality preset toggle ── */
.quality-opt {
    transition: background var(--transition-fast), color var(--transition-fast);
    font-weight: 500;
}
.quality-opt.selected {
    background: var(--color-accent);
    color: #fff;
}

/* ── Model Assignment grid ── */
.model-assignment-grid {
    display: grid;
    gap: var(--sp-2);
}
.model-assignment-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    background: var(--color-surface-muted);
}
.model-assignment-label {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.model-select {
    width: 220px;
    padding: 6px 10px;
    font-size: var(--text-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
}
.model-select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -1px;
}
@media (max-width: 640px) {
    .model-assignment-row {
        flex-direction: column;
        align-items: stretch;
    }
    .model-select {
        width: 100%;
    }
}

/* ── Admin credits page ── */
.credit-rate-row input[type=number] {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: var(--text-sm);
}
.balance-chip {
    display: inline-block;
    background: var(--color-credit-bg);
    color: var(--color-credit);
    border-radius: var(--radius-pill);
    padding: 2px 10px;
    font-weight: 700;
    font-size: var(--text-sm);
}
.balance-chip.unlimited {
    background: var(--color-success-bg);
    color: var(--color-success-hover);
}


/* ============================================================
   Dashboard redesign
   ============================================================ */

/* Page header: headline left, action right */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
    flex-wrap: wrap;
}
.dash-headline {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Stats cards row */
.dash-stats {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
    flex-wrap: wrap;
}
.dash-stat-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 100px;
    padding: var(--sp-3) var(--sp-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.dash-stat-card:hover {
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
}
/* Color differentiation via value text only — no left border */
.dash-stat-card.dash-stat-accent  { }
.dash-stat-card.dash-stat-success { }
.dash-stat-card.dash-stat-warning { }
.dash-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}
.dash-stat-accent  .dash-stat-value { color: var(--color-accent); }
.dash-stat-success .dash-stat-value { color: var(--color-success-fg); }
.dash-stat-warning .dash-stat-value { color: var(--color-warning-fg); }
.dash-stat-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

/* Battery-style credit card */
.dash-battery-card {
    min-width: 180px;
    gap: 4px;
}
.dash-battery-top {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.dash-battery-value {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text);
}
.battery-bar {
    width: 100%;
    height: 10px;
    background: var(--color-surface-muted);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--color-border-light);
}
.battery-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.8s ease;
    min-width: 2px;
}
.battery-green  { background: linear-gradient(90deg, #43a047, #66bb6a); }
.battery-yellow { background: linear-gradient(90deg, #f9a825, #fdd835); }
.battery-red    { background: linear-gradient(90deg, #e53935, #ef5350); }
.dash-battery-hint {
    font-size: 10px;
    color: var(--color-text-muted);
    letter-spacing: 0.01em;
}

/* Quick actions row */
.dash-quick-actions {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
}
.dash-action-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.dash-action-link:hover {
    color: var(--color-accent);
    background: var(--color-surface-muted);
}

/* Two-column grid: runs (wider) + recent q (narrower) */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: var(--sp-6);
    align-items: start;
}
.dash-col {
    min-width: 0; /* prevent grid blowout from long content */
}
@media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
}

.dash-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-3);
}
.dash-section-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* Run cards — replaces the dense table */
.run-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.run-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: var(--sp-3) var(--sp-4);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.run-card:hover {
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
}
.run-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
    flex-wrap: wrap;
}
.run-card-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
.run-card-id {
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.run-card-actions {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
}
.run-card-stats {
    display: flex;
    gap: var(--sp-4);
    flex-wrap: wrap;
}
.run-stat {
    font-size: var(--text-xs);
}

/* Recent questions list */
.recent-q-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.recent-q-item {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: var(--sp-3) var(--sp-3);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.recent-q-item:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-light);
}
.recent-q-top {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: 2px;
}
.recent-q-anchor {
    font-weight: 600;
    font-size: var(--text-sm);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recent-q-preview {
    margin: 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    line-height: 1.5;
    /* Two-line clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.badge-xs {
    font-size: 10px !important;
    padding: 1px 6px !important;
}

/* ============================================================
   DESIGN UPGRADE — Motion System
   ============================================================ */

/* Page-load entrance animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Apply entrance to major content blocks */
.card,
.stat-card,
.dash-stat-card,
.run-card,
.question-card,
.kp-card,
.item-detail,
.empty-state,
.auth-card {
    animation: fadeInUp 0.45s var(--ease-out-expo) both;
}

/* Stagger cards for orchestrated reveal */
.card:nth-child(1), .dash-stat-card:nth-child(1), .run-card:nth-child(1), .question-card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2), .dash-stat-card:nth-child(2), .run-card:nth-child(2), .question-card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3), .dash-stat-card:nth-child(3), .run-card:nth-child(3), .question-card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4), .dash-stat-card:nth-child(4), .run-card:nth-child(4), .question-card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5), .dash-stat-card:nth-child(5), .run-card:nth-child(5), .question-card:nth-child(5) { animation-delay: 0.16s; }
.card:nth-child(6), .dash-stat-card:nth-child(6), .run-card:nth-child(6), .question-card:nth-child(6) { animation-delay: 0.20s; }
.card:nth-child(7), .run-card:nth-child(7), .question-card:nth-child(7) { animation-delay: 0.24s; }
.card:nth-child(8), .run-card:nth-child(8), .question-card:nth-child(8) { animation-delay: 0.28s; }

/* Page header entrance */
.page-header,
.dash-header {
    animation: fadeIn 0.35s var(--ease-out-expo) both;
}

/* ============================================================
   DESIGN UPGRADE — Component Refinements
   ============================================================ */

/* Cards — no global hover (only interactive cards get hover effects) */
.card {
    transition: border-color var(--transition-base);
}

/* Run cards — interactive lift */
.run-card {
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-fast);
}
.run-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Question cards — interactive lift */
.question-card {
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-fast);
}
.question-card:hover {
    transform: translateY(-1px);
}

/* Dash stat cards — interactive lift (these are clickable <a> tags) */
.dash-stat-card {
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-fast);
}
.dash-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
/* Stat cards — display-only, no hover lift */

/* Buttons — refined press effect */
.btn {
    transition: all var(--transition-fast);
}
.btn:active {
    transform: scale(0.97);
    filter: brightness(0.92);
}

/* Primary accent button glow */
.btn-view:hover,
.btn-accent:hover {
    box-shadow: 0 2px 12px var(--color-accent-glow);
}

/* Nav new-run button glow */
.btn-nav-new:hover {
    box-shadow: 0 0 14px var(--color-accent-glow) !important;
}

/* Stat card numbers — display font */
.stat-card .number,
.dash-stat-value,
.stat-highlight-value,
.judge-mean-value {
    font-family: var(--font-display);
}

/* Progress bar — gradient */
.progress-bar {
    background: linear-gradient(90deg, var(--color-accent), #06b6d4);
}

/* Judge orbs — refined sizing and shadow */
.judge-orb-value {
    width: 38px;
    height: 38px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Badge refinement */
.badge {
    transition: background var(--transition-fast), color var(--transition-fast);
}
.badge-published {
    background: var(--color-accent);
}

/* Filter bar active state uses accent */
.filter-bar a.active,
.qb-status-pill.active {
    background: var(--color-primary);
}

/* Toast entrance — smoother */
.toast {
    border-radius: var(--radius-md);
}

/* Modal — glass background */
.modal-overlay {
    background: rgba(12, 18, 34, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.modal-box {
    box-shadow: var(--shadow-xl);
}

/* Breadcrumbs — subtle styling */
.breadcrumbs {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

/* Textarea and inputs — refined focus */
textarea:focus,
input:focus,
select:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-glow);
}

/* Auth card — accent top border */
.auth-card {
    border-top: 3px solid var(--color-accent);
    box-shadow: var(--shadow-lg);
}

/* Auth brand mark — display font */
.auth-card .brand-mark {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--color-primary);
}

/* Workflow progress — accent color for active */
.workflow-step.active .workflow-number {
    background: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-glow);
}

/* Stage counters — accent for active */
.stage-counter.sc-active {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

/* KP cards — subtle background tint on hover */
.kp-card {
    transition: background var(--transition-base), box-shadow var(--transition-base);
}
.kp-card:hover {
    background: var(--color-surface-muted);
}

/* Cloze anchors — smoother checked state */
.cloze-anchor:has(input:checked) .cloze-text {
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
}

/* Anchor tags — smoother transition */
.anchor-tag {
    transition: all var(--transition-fast);
}

/* Mode cards — accent border on checked */
.mode-card:has(input:checked) {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
    box-shadow: 0 0 0 1px var(--color-accent);
}

/* Log panel header — match nav gradient */
.log-header {
    background: var(--color-primary);
}

/* Settings panel — refined border */
.settings-panel {
    border-color: var(--color-border);
}

/* Segmented control — accent active */
.segmented-option.selected,
.quality-opt.selected {
    background: var(--color-accent);
}

/* Checkbox chip — accent checked */
.checkbox-chip:has(input:checked) {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
}

/* Export option — accent hover */
.export-option:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
}

/* Pagination — accent active */
.pagination-active {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
}

/* Pagination hover — accent */
.pagination-btn:hover {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
}

/* Ghost button — accent hover */
.btn-ghost:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-accent-light);
}

/* Credit badge — use accent teal */
.nav-credit-badge {
    border-color: rgba(8, 145, 178, 0.2);
}

/* ============================================================
   DESIGN UPGRADE — Reduced motion preference
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

