:root {
    --bg-dark: #0a192f; /* Baseline Navy */
    --card-bg: #112240;
    --accent-blue: #004a80;
    --accent-teal: #00a8b5;
    --accent-gold: #eab308;
    --text-light: #ccd6f6;
    --text-muted: #8892b0;
    --border: rgba(100, 255, 218, 0.1);
    
    /* REFINED TYPOGRAPHY STACK */
    --font-heading: 'Lora', 'Georgia', serif;
    --font-ui: 'Inter', 'Roboto', sans-serif;
    --font-academic: 'Lora', 'Georgia', serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* PAPER-LIKE EDITOR DEFAULTS */
    --editor-bg: #f8fafc;
    --editor-text: #0f172a;
    --editor-border: #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 4px !important; }

/* --- CUSTOM SCROLLBAR (REFINED) --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px !important;
    border: 2px solid var(--bg-dark);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-teal);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-ui);
    font-size: 1rem;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Header - Academic Distinction */
header {
    padding: 0 6vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 25, 47, 0.95);
    backdrop-filter: blur(15px);
    height: 100px;
}

.logo-lockup {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    color: #fff !important;
}

.logo-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.6rem;
    letter-spacing: -0.01em;
    line-height: 1; /* Force vertical centering */
    display: flex;
    align-items: center;
}

.lab-tag {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 4px 10px;
    background: rgba(0, 168, 181, 0.1);
    color: var(--accent-teal);
    border: 1px solid rgba(0, 168, 181, 0.2);
    border-radius: 50px !important;
    text-transform: uppercase;
    margin-left: 10px;
}

.header-avatar-cta {
    width: 80px;
    height: 80px;
    border-radius: 50% !important;
    border: 2px solid var(--accent-blue);
    object-fit: cover;
    background: #fff;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
    display: block;
}

.header-avatar-cta:hover {
    transform: scale(1.05);
    border-color: var(--accent-teal);
}

/* Ensure buttons are properly aligned next to avatar */
#auth-ui {
    display: flex;
    align-items: center;
    gap: 20px;
}


/* Modals - Prestigious Document Style */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #ffffff;
    color: #1e293b;
    padding: 3.5rem;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.protocol-brief {
    background: #f1f5f9; 
    border-left: 4px solid var(--accent-blue); 
    padding: 20px; 
    margin-bottom: 2rem; 
    font-size: 0.85rem; 
    line-height: 1.6; 
    color: #475569;
}

.modal-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: #0f172a;
}

.modal-input {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    padding: 1rem;
    color: #0f172a;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus { border-color: var(--accent-blue); }

/* Portal Layout */
main {
    padding: 4rem 6vw;
    max-width: 1400px;
    margin: 0 auto;
}

.portal-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 5vw;
}

/* Typography & Section Headers */
.section-header {
    margin-bottom: 4rem;
}

.section-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 1.2;
    margin-bottom: 1rem;
    color: #fff;
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
}

/* Research Cards - Clean Journal Style */
.research-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 3rem;
    margin-bottom: 2.5rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.research-card:hover {
    border-color: var(--accent-teal);
    transform: translateY(-2px);
}

.card-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #fff;
}

/* Buttons - Sophisticated & Clean */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
}

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

.btn-primary:hover {
    background: #003a66;
}

.btn-outline {
    border: 1.5px solid var(--border);
    color: var(--text-light);
    background: transparent;
}

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

/* Registry Tabs */
.registry-nav {
    display: flex;
    gap: 32px;
    margin-bottom: 4rem;
    border-bottom: 1px solid var(--border);
}

.registry-tab {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 1rem 0;
    position: relative;
    transition: color 0.2s;
}

.registry-tab:hover { color: #fff; }

.registry-tab.active {
    color: var(--accent-teal);
}

.registry-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-teal);
}

/* Institutional R&D Card */
.institutional-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(0, 168, 181, 0.2);
    padding: 4rem;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}

.institutional-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent-blue);
}

.institutional-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: #fff;
}

/* Academic Ledger Card */
.academic-ledger-card {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    margin-bottom: 2.5rem;
    transition: box-shadow 0.3s ease;
}

.academic-ledger-card:hover {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e1;
}

.ledger-main {
    padding: 3rem;
    display: flex;
    gap: 3rem;
}

.ledger-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 1rem;
}

.author-pill {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Ticker - Static Academic Alert */
.audit-ticker-wrap {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 12px 24px;
    margin-bottom: 4rem;
    display: flex;
    align-items: center;
    gap: 20px;
}

.audit-ticker-label {
    background: var(--accent-blue);
    color: #fff;
    font-weight: 700;
    font-size: 0.7rem;
    padding: 4px 12px;
    text-transform: uppercase;
    border-radius: 20px !important;
}

.audit-ticker-content {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- ACADEMIC WORKSPACE THEMES --- */

/* 1. BLUE (Institutional Navy - Default) */
body.role-blue {
    /* Baseline already set in :root */
}
body.role-blue .workbench-header, 
body.role-blue .tab-nav,
body.role-blue .workbench-content {
    background: #0a192f;
}

/* 2. DARK (Academic Slate) */
body.role-dark {
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
}
body.role-dark .workbench-header, 
body.role-dark .tab-nav,
body.role-dark .workbench-content {
    background: #0f172a;
}

/* 3. WARM (Parchment) */
body.role-warm, body.role-student {
    --bg-dark: #fcfaf5;
    --card-bg: #ffffff;
    --text-light: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --accent-blue: #004a80;
    --editor-bg: #fff;
    --editor-border: #cbd5e1;
}
body.role-warm header, body.role-student header,
body.role-warm .workbench-header, body.role-student .workbench-header,
body.role-warm .tab-nav, body.role-student .tab-nav,
body.role-warm .workbench-content, body.role-student .workbench-content { 
    background: #fcfaf5; 
    border-color: #e2e8f0;
}
body.role-warm .section-title, body.role-warm .card-title, body.role-warm .logo-text,
body.role-student .section-title, body.role-student .card-title, body.role-student .logo-text { color: #0f172a !important; }
body.role-warm .lab-tag, body.role-student .lab-tag { 
    background: rgba(0, 74, 128, 0.05); 
    color: var(--accent-blue); 
    border-color: rgba(0, 74, 128, 0.2); 
}
body.role-warm .btn-outline, body.role-student .btn-outline { color: #0f172a; border-color: #cbd5e1; }
body.role-warm .modal-content, body.role-student .modal-content { background: #fff; border: 1px solid #e2e8f0; }

/* 4. WHITE (Crisp Academic) */
body.role-white {
    --bg-dark: #ffffff;
    --card-bg: #f8fafc;
    --text-light: #0f172a;
    --text-muted: #475569;
    --border: #e2e8f0;
    --accent-blue: #004a80;
    --editor-bg: #fff;
    --editor-border: #cbd5e1;
}
body.role-white header, 
body.role-white .workbench-header, 
body.role-white .tab-nav,
body.role-white .workbench-content { 
    background: #ffffff; 
    border-bottom: 1px solid #f1f5f9; 
}
body.role-white .section-title, body.role-white .card-title, body.role-white .logo-text { color: #0f172a !important; }
body.role-white .lab-tag { 
    background: rgba(0, 74, 128, 0.05); 
    color: var(--accent-blue); 
    border-color: rgba(0, 74, 128, 0.2); 
}
body.role-white .btn-outline { color: #0f172a; border-color: #cbd5e1; }
body.role-white .research-card, body.role-white .academic-ledger-card { border-color: #f1f5f9; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }

/* Global Academic Typography Refinement */
.digital-render, .ledger-excerpt-static, .profile-bio {
    font-family: var(--font-academic);
}

body.role-warm .digital-render, 
body.role-white .digital-render {
    color: #1e293b !important;
}

/* --- UNIVERSAL FORM STYLING --- */
.form-group {
    margin-bottom: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--accent-teal);
    text-transform: uppercase;
    letter-spacing: 2px;
    border-left: 2px solid var(--accent-teal);
    padding-left: 10px;
    line-height: 1;
}

.form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    padding: 14px 18px;
    color: var(--text-light);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
    border-radius: 6px !important;
    appearance: none;
}

select.form-input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238892b0'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

.form-input option {
    background-color: var(--card-bg);
    color: var(--text-light);
}

/* Light Theme Select Adjustments */
body.role-warm select.form-input, 
body.role-white select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23004a80'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

body.role-warm .form-input option, 
body.role-white .form-input option {
    background-color: #fff;
    color: #0f172a;
}


.form-input:focus {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--accent-teal);
    box-shadow: 0 0 0 1px var(--accent-teal);
}

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
    border-style: dashed;
}

/* Light Theme Adjustments */
body.role-warm .form-label, 
body.role-white .form-label {
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

body.role-warm .form-input, 
body.role-white .form-input {
    background: #fff;
    border-color: #cbd5e1;
    color: #0f172a;
}

body.role-warm .form-input:focus, 
body.role-white .form-input:focus {
    background: #fff;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue);
}

/* --- VALIDATION FEEDBACK --- */
.field-error .form-input {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.05) !important;
    box-shadow: 0 0 0 1px #ef4444 !important;
}

.field-error .form-label {
    color: #ef4444 !important;
    border-left-color: #ef4444 !important;
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Drafting Area Layout */
.drafting-area {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.themed-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px !important;
    padding: 3rem;
    transition: all 0.3s ease;
}

/* Workspace editor specifically */
textarea#edit-content {
    background: var(--editor-bg) !important;
    color: var(--editor-text) !important;
    border: 1px solid var(--editor-border) !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    font-family: var(--font-academic);
    font-size: 1.1rem;
    line-height: 1.8;
}


/* --- DASHBOARD WORKBENCH LAYOUT --- */
.workbench-header {
    padding: 0 8vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-dark);
    height: 100px;
}

.tab-nav {
    display: flex;
    gap: 2rem;
    padding: 0 8vw;
    border-bottom: 1px solid var(--border);
    background: var(--bg-dark);
}

.tab-link {
    padding: 1.5rem 0;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    text-decoration: none;
    transition: color 0.2s ease;
}

.tab-link.active { color: var(--accent-teal); }
.tab-link:hover { color: var(--text-light); }
.tab-link.active::after {
    content: ''; position: absolute; bottom: -1px; left: 0;
    width: 100%; height: 2px; background: var(--accent-teal);
}

main.workbench-content {
    flex: 1;
    padding: 3rem 8vw;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 4rem;
    background: var(--bg-dark);
}

.status-pipeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.pipeline-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.pipeline-card:hover { 
    border-color: var(--accent-teal);
    transform: translateY(-2px);
}

.pipeline-card.active {
    border-color: var(--accent-teal);
    background: rgba(255, 255, 255, 0.03);
}

.pipeline-status {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 1px;
    margin-bottom: 10px;
    display: block;
    font-weight: 700;
}

.status-draft { color: var(--text-muted); }
.status-audit { color: var(--accent-teal); }
.status-live { color: #22c55e; }

.drafting-area {
    background: transparent;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.btn-mini {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 12px;
    font-weight: 600;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* --- READER INTERFACE LAYOUT --- */
.reader-layout {
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    height: calc(100vh - 80px);
    overflow: hidden;
    background: var(--bg-dark);
}

.intel-sidebar, .peer-review-sidebar {
    background: var(--bg-dark);
    border-color: var(--border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.viewer-container {
    background: var(--bg-dark);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.viewer-header {
    height: 50px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}

.digital-content {
    height: calc(100vh - 130px);
    overflow-y: auto;
    padding: 4vw 8vw;
    display: none;
    background: var(--editor-bg);
    color: var(--editor-text);
    font-family: var(--font-academic);
    line-height: 1.8;
    position: relative;
}

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

.view-toggle {
    display: flex;
    background: rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.toggle-btn {
    padding: 6px 15px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: var(--accent-teal);
    color: #000;
}

.pdf-viewport {
    height: calc(100vh - 130px);
    display: flex;
    justify-content: center;
    background: rgba(0,0,0,0.1);
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

/* --- PROFILE PAGE LAYOUT --- */
.profile-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 8vw;
    background: var(--bg-dark);
}

.profile-header {
    display: flex;
    gap: 4rem;
    align-items: center;
    margin-bottom: 5rem;
    padding-bottom: 5rem;
    border-bottom: 1px solid var(--border);
}

.profile-avatar {
    width: 400px;
    height: 400px;
    border: 6px solid var(--accent-blue);
    object-fit: cover;
    border-radius: 50% !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.profile-info { flex: 1; }

.profile-name {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
    color: var(--text-light);
}

.profile-meta {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent-blue);
    letter-spacing: 0.5px;
    margin-bottom: 2rem;
    display: block;
}

.profile-bio {
    font-family: var(--font-academic);
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.8;
    max-width: 750px;
}

.publication-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 2rem;
}

@media (max-width: 800px) {
    .profile-header { flex-direction: column; text-align: center; gap: 2rem; }
    .profile-bio { margin: 0 auto; }
}
