:root {
    --bg-base: #090d16;
    --bg-surface: #111827;
    --bg-surface-elevated: #1f2937;
    --bg-input: #0b1120;
    --border: #374151;
    --border-focus: #3b82f6;
    
    --primary: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.35);
    
    --accent: #8b5cf6;
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-subtle: #6b7280;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.25);
    
    --font-main: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
    background-attachment: fixed;
}

/* Header & Navbar */
.app-header {
    background: rgba(17, 24, 39, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 24px;
}

.header-container {
    max-width: 1300px;
    height: 72px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: var(--shadow-glow);
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    border-radius: var(--radius-full);
    font-weight: 600;
    margin-left: 6px;
}

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

.credit-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    color: #93c5fd;
}

.credit-val {
    color: #fff;
    font-weight: 700;
}

/* Main Container */
.main-wrapper {
    flex: 1;
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

/* Mode Switcher Tabs */
.mode-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}

.mode-tabs-container {
    background: var(--bg-surface);
    padding: 6px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    display: flex;
    gap: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.mode-tab {
    padding: 10px 22px;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

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

.mode-tab.active {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* Workspace Grid */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
}

@media (max-width: 960px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

/* Glass Card */
.glass-card {
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    position: relative;
}

.card-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-heading {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Controls Toolbar */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(11, 17, 32, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
}

.control-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.select-control {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.select-control:focus {
    border-color: var(--primary);
}

/* Text Editor Input */
.editor-textarea {
    width: 100%;
    min-height: 280px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: all 0.2s ease;
}

.editor-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.editor-textarea::placeholder {
    color: #4b5563;
}

.action-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.word-count {
    font-size: 0.85rem;
    color: var(--text-subtle);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    color: #e2e8f0;
}

.btn-secondary:hover {
    background: #374151;
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* Progress Bar (HawkHost Safe Chunking) */
.progress-box {
    margin-top: 16px;
    display: none;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: #93c5fd;
}

.progress-bar-track {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

/* Output Display */
.output-pane {
    min-height: 280px;
    max-height: 520px;
    overflow-y: auto;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    font-size: 1rem;
    line-height: 1.8;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    text-align: center;
    color: var(--text-subtle);
    gap: 12px;
}

.empty-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

/* In-Text Citation Badges */
.cite-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    padding: 1px 7px;
    border-radius: 6px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 2px;
}

.cite-badge:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Bibliography Section */
.bib-section {
    margin-top: 24px;
    border-top: 1px solid var(--border);
    padding-top: 18px;
}

.bib-heading {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #93c5fd;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bib-item {
    font-size: 0.9rem;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: rgba(31, 41, 55, 0.4);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.5;
}

.bib-item a {
    color: #60a5fa;
    text-decoration: none;
}

.bib-item a:hover {
    text-decoration: underline;
}

/* Modal Popup for Citation Details & Evidence Snippet */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    position: relative;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover { color: #fff; }

.evidence-box {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin: 16px 0;
}

.evidence-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.evidence-quote {
    font-style: italic;
    font-size: 0.95rem;
    color: #e2e8f0;
}

.match-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--success-bg);
    color: var(--success);
}

.oa-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: #fff;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

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

/* Form controls & Utilities */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Footer */
.app-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 24px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-subtle);
    margin-top: auto;
}

/* Journal Prestige & Metric Badges */
.prestige-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
}

.prestige-q1 {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.prestige-q2 {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.prestige-sinta {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

