:root {
    --bg-dark: #080c14;
    --bg-card: #0f172a;
    --bg-card-hover: #1e293b;
    --border-glass: rgba(255, 255, 255, 0.08);
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.25);
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
    --accent-blue: #3b82f6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header Nav */
header {
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
    color: inherit;
}

.brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 0.72rem;
    color: var(--accent-green);
    font-weight: 600;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--text-main);
}

.engine-status-pill {
    padding: 0.4rem 0.85rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.engine-status-pill.offline {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-amber);
    border-color: rgba(245, 158, 11, 0.3);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
}

.engine-status-pill.offline .status-dot {
    background: var(--accent-amber);
}

/* Main Container */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1700px;
    margin: 0 auto;
    width: 100%;
}

/* Banner */
.notice-banner {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(16, 185, 129, 0.08));
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 1.25rem 1.75rem;
    margin-bottom: 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notice-banner.offline {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.08));
    border-color: rgba(245, 158, 11, 0.3);
}

.notice-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.notice-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Controls Grid */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 340px;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.upload-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.upload-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.dropzone-icon {
    font-size: 1.8rem;
    margin-bottom: 0.4rem;
}

.dropzone-text {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.dropzone-file-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-green);
    word-break: break-all;
    margin-top: 0.3rem;
}

.hidden-file-input {
    display: none;
}

.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

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

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-preset {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-preset:hover {
    background: rgba(16, 185, 129, 0.22);
}

/* Results Section */
.results-workspace {
    display: grid;
    grid-template-columns: 1fr 480px;
    gap: 1.5rem;
    min-height: 600px;
}

.annotated-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.img-container {
    flex: 1;
    background: #050810;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    max-height: 800px;
}

.annotated-img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.7);
}

/* Breakdown Panel */
.breakdown-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.breakdown-body {
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: 800px;
}

.score-hero {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(16, 185, 129, 0.1));
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
}

.score-main-val {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--accent-green);
    line-height: 1.1;
    margin: 0.3rem 0;
}

.score-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.q-item-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1rem;

}

.q-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.q-label {
    font-weight: 800;
    font-size: 1rem;
}

.q-score-pill {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.85rem;
}

.rubric-list {
    margin: 0.6rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.rubric-item {
    font-size: 0.78rem;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
}

.rubric-item.matched {
    color: var(--text-main);
}

.rubric-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 5px;
    background: var(--text-muted);
}

.rubric-item.matched .rubric-dot {
    background: var(--accent-green);
}

.q-reason {
    font-size: 0.82rem;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.1);
    padding: 0.6rem;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
    margin-top: 0.5rem;
}

.override-box {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.override-input {
    width: 80px;
    padding: 0.4rem 0.6rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
}

.card-markdown {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--accent-green);
    color: white;
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}
