:root {
    --primary-emerald: #000033;
    --primary-light: #4710EB;
    --accent-gold: #0055EF;
    --bg-mint: #f0ecfd;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-dark: #000033;
    --text-muted: #6c757d;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 15px 35px rgba(71, 16, 235, 0.15);
}

/* Premium Navigation Bar */
.premium-nav-container {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    padding: 10px 15px;
    margin: -10px -15px 20px -15px;
}

.premium-nav-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: white;
    border-radius: 20px;
    padding: 8px;
    box-shadow: var(--shadow-soft);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 8px 12px;
    border-radius: 15px;
    position: relative;
    flex: 1;
}

.nav-item i {
    font-size: 20px;
    color: var(--text-muted);
    transition: inherit;
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item.active {
    background: var(--bg-mint);
}

.nav-item.active i {
    color: var(--primary-emerald);
    transform: scale(1.1);
}

.nav-item.active span {
    color: var(--primary-emerald);
}

.nav-item.selected {
    border-bottom: 2px solid var(--accent-gold);
}

/* Options Drawer */
.options-drawer {
    background: white;
    border-radius: 0 0 25px 25px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.options-drawer.open {
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    border-top: 1px solid #f0f0f0;
    margin-top: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-emerald) #f0f0f0;
}

.options-drawer.open::-webkit-scrollbar {
    width: 6px;
}

.options-drawer.open::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.options-drawer.open::-webkit-scrollbar-thumb {
    background-color: var(--primary-emerald);
    border-radius: 10px;
}

.option-pill {
    padding: 10px 15px;
    margin: 5px;
    border-radius: 12px;
    background: #f8faf8;
    display: inline-block;
    font-size: 14px;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.option-pill:hover {
    background: var(--bg-mint);
    border-color: var(--primary-light);
}

.option-pill.active {
    background: var(--primary-emerald);
    color: white;
}

/* Student Cards */
.student-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
    padding-bottom: 120px;
    /* Safe Zone for Sticky Footer */
}

.student-card {
    background: white;
    border-radius: 20px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.student-card:focus-within {
    transform: translateY(-5px);
    box-shadow: var(--shadow-premium);
    border-color: var(--primary-light);
}

.student-avatar {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
}

.student-info {
    flex: 1;
}

.student-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-dark);
}

.student-id {
    font-size: 11px;
    color: var(--text-muted);
}

.score-input-wrapper {
    width: 70px;
}

.score-input {
    width: 100%;
    padding: 10px;
    border-radius: 12px;
    border: 2px solid #f0f0f0;
    text-align: center;
    font-weight: 700;
    font-size: 16px;
    transition: all 0.3s ease;
}

.score-input:focus {
    border-color: var(--primary-emerald);
    background: var(--bg-mint);
    outline: none;
}

/* Sticky Footer */
.premium-footer-bar {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--primary-emerald);
    color: white;
    border-radius: 20px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 30px rgba(71, 16, 235, 0.4);
    z-index: 2000;
    transform: translateY(200%);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.premium-footer-bar.visible {
    transform: translateY(0);
}

.footer-summary {
    display: flex;
    flex-direction: column;
}

.footer-summary .main {
    font-weight: 700;
    font-size: 14px;
}

.footer-summary .sub {
    font-size: 10px;
    opacity: 0.8;
}

.footer-action-btn {
    background: var(--accent-gold);
    color: var(--primary-emerald);
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

/* PWA Install Button */
#installPwaBtn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: var(--accent-gold);
    color: var(--primary-emerald);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: none;
    /* Hidden until beforeinstallprompt */
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: bounceIn 0.8s;
}

#installPwaBtn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

#installPwaBtn i {
    font-size: 24px;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }

    70% {
        transform: scale(0.9);
        opacity: 0.9;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.insights-carousel {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 5px 25px 5px;
    margin: 0 -15px 10px -15px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap;
    /* Prevent wrapping */
    cursor: grab;
}

.insights-carousel:active {
    cursor: grabbing;
}

.insights-carousel::-webkit-scrollbar {
    display: none;
}

.insight-card {
    min-width: 140px;
    background: white;
    border-radius: 20px;
    padding: 15px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    border: 1px solid var(--glass-border);
}

.insight-card i {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.insight-card .value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-dark);
}

.insight-card .label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

/* Result Tiles */
.results-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 150px;
    /* Safe zone for navigation */
}

.result-tile {
    background: white;
    border-radius: 20px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--glass-border);
}

.result-tile:active {
    transform: scale(0.98);
    background: var(--bg-mint);
}

.grade-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    border-radius: 0 4px 4px 0;
}

.grade-A {
    background-color: #000033;
}

.grade-B {
    background-color: #4710EB;
}

.grade-C {
    background-color: #d4af37;
}

.grade-D {
    background-color: #e67e22;
}

.grade-F {
    background-color: #c0392b;
}

.grade-A1 {
    background-color: #000033;
}

.grade-B2,
.grade-B3 {
    background-color: #4710EB;
}

.grade-C4,
.grade-C5,
.grade-C6 {
    background-color: #d4af37;
}

.grade-D7 {
    background-color: #e67e22;
}

.grade-E8 {
    background-color: #f39c12;
}

.grade-F9 {
    background-color: #c0392b;
}

.result-main {
    flex: 1;
}

.result-student {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.result-sub {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

.result-score-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.total-score {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-emerald);
}

.grade-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    color: white;
}

/* Result Detail Drawer */
.result-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 25px 25px 0 0;
    z-index: 3000;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    padding: 20px;
}

.result-drawer.open {
    transform: translateY(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.drawer-handle {
    width: 40px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin: -10px auto 20px auto;
}

.ca-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.ca-item {
    background: var(--bg-mint);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
}

.ca-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    display: block;
    margin-bottom: 5px;
}

.ca-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-emerald);
}

.exam-section {
    background: #fff8e1;
    padding: 20px;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* E-Note Premium Overhaul */
.enote-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
    padding-bottom: 150px;
}

.enote-tile {
    background: white;
    border-radius: 20px;
    padding: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.enote-tile:hover {
    transform: translateY(-5px);
    box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-emerald);
}

.enote-icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.enote-tile:hover .enote-icon-wrapper {
    transform: scale(1.1);
}

/* File Type Colors */
.file-pdf {
    background: #fee2e2;
    color: #ef4444;
}

.file-doc {
    background: #e0f2fe;
    color: #0ea5e9;
}

.file-img {
    background: #f0fdf4;
    color: #22c55e;
}

.file-other {
    background: #f3f4f6;
    color: #6b7280;
}

.enote-info {
    width: 100%;
}

.enote-subject {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-dark);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.enote-meta {
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    gap: 8px;
}

/* Tactile Upload Form */
.premium-upload-form {
    background: white;
    padding: 20px;
    border-radius: 25px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--glass-border);
    margin-top: 10px;
}

.liquid-dropzone {
    border: 2px dashed #e0e0e0;
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-top: 15px;
    background: #fafafa;
}

.liquid-dropzone.dragover {
    border-color: var(--primary-emerald);
    background: var(--bg-mint);
    transform: scale(0.98);
}

.liquid-dropzone i {
    font-size: 40px;
    color: var(--primary-emerald);
    margin-bottom: 15px;
    display: block;
}

.liquid-dropzone p {
    font-size: 13px;
    color: var(--text-muted);
}

.liquid-dropzone span {
    color: var(--primary-emerald);
    font-weight: 600;
}

/* Selection Drawers Context */
.enote-selection-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.enote-select-item {
    flex: 1;
    background: white;
    padding: 12px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.enote-select-item.selected {
    background: var(--bg-mint);
    border-color: var(--primary-emerald);
}

.enote-select-item i {
    font-size: 16px;
    color: var(--text-muted);
}

.enote-select-item.selected i {
    color: var(--primary-emerald);
}

.enote-select-item span {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Staggered Grid Animation */
@keyframes enoteAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.enote-tile {
    animation: enoteAppear 0.4s ease forwards;
}

/* Video Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #f7f0fc;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    max-width: 90%;
    animation: splashPulse 2s ease-in-out infinite;
}

.splash-logo {
    max-width: 280px;
    height: auto;
    filter: drop-shadow(0 0 15px rgba(71, 16, 235, 0.5));
}

.splash-loader {
    width: 180px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.splash-loader-bar {
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, #4710EB, #0055EF);
    border-radius: 2px;
    position: absolute;
    animation: splashLoading 1.5s ease-in-out infinite;
}

.splash-tagline {
    font-family: 'Sora', sans-serif;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-align: center;
}

.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

@keyframes splashPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes splashLoading {
    0% { left: -60%; }
    50% { left: 40%; }
    100% { left: 100%; }
}

/* Hide main content initially to ensure smooth transition */
#mainBody {
    overflow: hidden;
}

/* Allow scrolling once splash is gone */
#mainBody.splash-gone {
    overflow: auto;
}

/* Info Modal Styles */
.info-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 5000;
    display: none;
    /* Hidden by default */
    justify-content: center;
    align-items: center;
    opacity: 1;
}

.info-modal-backdrop.show {
    display: flex;
    opacity: 1;
}

.info-modal-content {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 25px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

.info-modal-backdrop.show .info-modal-content {
    transform: scale(1);
}

.info-modal-icon {
    width: 60px;
    height: 60px;
    background: var(--bg-mint);
    color: var(--primary-emerald);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 20px auto;
}

.info-modal-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.info-modal-body {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 25px;
}

.info-modal-body strong {
    color: var(--primary-emerald);
}

.info-modal-btn {
    background: var(--primary-emerald);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: 15px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-premium);
}

.info-modal-btn:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
}

.highlight-box {
    background: #f8fafc;
    border-radius: 15px;
    padding: 15px;
    margin: 15px 0;
    border-left: 4px solid var(--primary-emerald);
    text-align: left;
}

.highlight-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    margin-bottom: 8px;
}

.highlight-item:last-child {
    margin-bottom: 0;
}

.highlight-item i {
    font-size: 12px;
    width: 15px;
    color: var(--primary-emerald);
}

@keyframes scroll-right-to-left {
    0% {
        transform: translateX(100%);
    }

    100% {
        transform: translateX(-100%);
    }
}

.drawer-scrolling-container {
    overflow: hidden;
    white-space: nowrap;
    background: #fff8e1;
    border-bottom: 1px solid #ffeeba;
    padding: 8px 0;
    margin: 0 -20px 15px -20px;
}

.drawer-scrolling-advisory {
    display: inline-block;
    animation: scroll-right-to-left 25s linear infinite;
    font-size: 13px;
    font-weight: 600;
    color: #856404;
}

/* Glassmorphism Card */
.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
}

/* Premium Switch Button */
.premium-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.premium-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.premium-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ddd;
    transition: .4s;
    border-radius: 34px;
}

.premium-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.premium-switch input:checked+.premium-slider {
    background-color: var(--primary-emerald);
}

.premium-switch input:checked+.premium-slider:before {
    transform: translateX(22px);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Quill Editor Overrides for Premium Theme */
.ql-toolbar.ql-snow {
    border: none !important;
    border-bottom: 1px solid #f0f0f0 !important;
    background: #f9fdf9 !important;
    padding: 10px 15px !important;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.ql-container.ql-snow {
    border: none !important;
    font-family: inherit !important;
    font-size: 14px !important;
}

.ql-editor {
    padding: 15px 20px !important;
    min-height: 120px;
}
.ql-editor.ql-blank::before {
    font-style: normal !important;
    color: #999 !important;
    left: 20px !important;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Library Styles */
.lib-action-btn {
    border: none;
    border-radius: 20px;
    padding: 20px 10px;
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
}

.lib-action-btn:active {
    transform: scale(0.95);
}

.lib-action-btn .icon-wrap {
    width: 45px;
    height: 45px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.lib-action-btn span {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #f5f5f5;
    animation: fadeIn 0.4s ease;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.activity-details {
    flex: 1;
}

.activity-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.activity-meta {
    font-size: 10px;
    color: #999;
    margin: 2px 0 0 0;
}

.activity-status {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 700;
}

.status-borrow { background: #f0ecfd; color: #4710EB; }
.status-study { background: #e3f2fd; color: #1976d2; }
.status-return { background: #f3e5f5; color: #7b1fa2; }

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Workflow — expired (past-deadline) task states */
.wf-task-card {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    padding: 15px;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
}

.wf-task-card.wf-task-card-expired {
    position: relative;
    background: #fffbfb;
    box-shadow: 0 0 0 1px #fecaca, var(--shadow-soft);
    border-color: #fca5a5;
}

.wf-tn-node {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #2563eb;
    border-radius: 14px;
    padding: 12px;
}

.wf-tn-node.wf-tn-node-completed {
    border-left-color: #16a34a;
}

.wf-tn-node.wf-tn-node-expired {
    background: #fff7f7;
    border-color: #fecaca;
    border-left-color: #dc2626;
}

.wf-expired-chip {
    background: #dc2626;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}

.wf-expired-note {
    margin-top: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 8px;
    font-size: 11px;
    color: #b91c1c;
}

/* Hover tooltip on expired cards — explains the query/review path and
   links to the chain view. */
.wf-card-tip {
    display: none;
    position: absolute;
    top: 40px;
    right: 12px;
    width: min(300px, calc(100% - 24px));
    z-index: 50;
    background: #fff;
    border: 1px solid #fca5a5;
    border-radius: 12px;
    padding: 10px;
    font-size: 11px;
    line-height: 1.5;
    color: #7f1d1d;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
}

.wf-task-card.wf-task-card-expired:hover .wf-card-tip { display: block; }
.wf-tip-link { margin-top: 6px; }
.wf-tip-link a { font-weight: 700; color: #b91c1c; text-decoration: none; }
.wf-tip-link a:hover { text-decoration: underline; }

/* Dark-mode variants: keep the red states readable when the OS prefers dark. */
@media (prefers-color-scheme: dark) {
    .wf-task-card.wf-task-card-expired {
        background: #1f1213;
        box-shadow: 0 0 0 1px #7f1d1d, var(--shadow-soft);
        border-color: #b91c1c;
    }

    .wf-tn-node.wf-tn-node-expired {
        background: #1f1213;
        border-color: #7f1d1d;
        border-left-color: #ef4444;
    }

    .wf-expired-chip {
        background: #ef4444;
    }

    .wf-expired-note {
        background: #2b1414;
        border-color: #7f1d1d;
        color: #fca5a5;
    }

    .wf-card-tip {
        background: #1f1213;
        border-color: #7f1d1d;
        color: #fca5a5;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    }

    .wf-tip-link a { color: #f87171; }

    .wf-verdict-info {
        background: #2b1414;
        border-color: #7f1d1d;
        color: #fca5a5;
    }

    .wf-verdict-info.wf-verdict-pardoned {
        background: #10231a;
        border-color: #14532d;
        color: #86efac;
    }
}

/* Workflow — per-task query history timeline */
.wf-qh {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
}

.wf-qh-title {
    font-weight: 800;
    font-size: 12px;
    color: #92400e;
    margin-bottom: 8px;
}

.wf-qh-event {
    border-left: 3px solid #f59e0b;
    padding: 2px 0 6px 10px;
    margin: 0 0 10px 0;
    font-size: 11px;
    line-height: 1.5;
}

/* Workflow — shared component styles (extracted from inline styles) */
.wf-row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wf-row-between-g8 { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.wf-badge-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.wf-actions { display: flex; gap: 10px; margin-top: 12px; }
.wf-actions-g8 { display: flex; gap: 8px; margin-top: 10px; }

.wf-card-title { font-weight: 800; font-size: 13px; color: #0f172a; }
.wf-card-title-lg { font-weight: 800; font-size: 14px; }
.wf-card-meta { font-size: 10px; color: #94a3b8; margin-top: 2px; }
.wf-card-sub { font-size: 11px; color: #64748b; margin-top: 4px; }
.wf-card-desc { font-size: 12px; margin-top: 6px; }
.wf-card-deadline { font-size: 11px; color: #64748b; margin-top: 8px; }
.wf-overdue-label { color: #dc2626; font-weight: 700; }

/* Status badge pills (mirrors the admin's wf-badge-* pattern). */
.wf-badge { padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; }
.wf-badge-assigned, .wf-badge-in_progress { background: #2563eb22; color: #2563eb; }
.wf-badge-forwarded { background: #7c3aed22; color: #7c3aed; }
.wf-badge-completed, .wf-badge-pardoned { background: #16a34a22; color: #16a34a; }
.wf-badge-expired, .wf-badge-penalized { background: #dc262622; color: #dc2626; }
.wf-badge-queried, .wf-badge-responded { background: #d9770622; color: #d97706; }
.wf-badge-created, .wf-badge-closed, .wf-badge-default { background: #64748b22; color: #64748b; }

.wf-deadline-overdue { color: #dc2626; font-weight: 600; animation: wfPulse 2s ease-in-out infinite; }
.wf-deadline-soon { color: #d97706; font-weight: 600; }
.wf-overdue-label { animation: wfPulse 2s ease-in-out infinite; }
@keyframes wfPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* "2/3" delegated-progress pill. */
.wf-child-progress { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; border-radius: 999px; padding: 2px 8px; margin-left: 6px; }
.wf-child-progress.wf-child-progress-all { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }

/* Completion box on COMPLETED cards/nodes. */
.wf-completion-info { margin-top: 10px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 10px; font-size: 11px; color: #166534; }
.wf-completion-note { margin-top: 4px; white-space: pre-wrap; }

/* Verdict summary on resolved (PARDONED/PENALIZED) cards. */
.wf-verdict-info {
    margin-top: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 10px;
    font-size: 11px;
    color: #7f1d1d;
}

.wf-verdict-info.wf-verdict-pardoned {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.wf-verdict-note { margin-top: 4px; white-space: pre-wrap; }

/* Progress bar on created-task cards (My Tasks tab). */
.wf-progress-wrap { margin-top: 10px; }
.wf-progress-track { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.wf-progress-fill { height: 100%; background: #2563eb; border-radius: 999px; transition: width .3s ease; }
.wf-progress-fill.wf-progress-done { background: #16a34a; }
.wf-progress-fill.wf-progress-partial { background: #f59e0b; }
.wf-progress-label { font-size: 10px; color: #64748b; margin-top: 5px; font-weight: 600; }

/* Per-assignee breakdown on created-task cards: name + status + deadline for
   every person a task was assigned to, so the creator can track progress. */
.wf-assignee-list { margin-top: 10px; border-top: 1px dashed #e2e8f0; padding-top: 2px; }
.wf-assignee-row { padding: 8px 0 10px; border-bottom: 1px dashed #e2e8f0; }
.wf-assignee-row:last-child { border-bottom: none; padding-bottom: 2px; }
.wf-assignee-name { font-size: 11px; font-weight: 700; color: #0f172a; }
.wf-assignee-role { font-size: 9px; font-weight: 600; color: #94a3b8; margin-left: 6px; }
.wf-assignee-meta { font-size: 10px; color: #64748b; margin-top: 3px; }
.wf-assignee-row .wf-completion-info,
.wf-assignee-row .wf-verdict-info { margin-top: 6px; padding: 8px; }

/* Expandable assignee rows — click to reveal per-assignment query history */
.wf-assignee-expandable { cursor: pointer; }
.wf-assignee-expandable:hover { background: #f8fafc; }
.wf-assignee-chevron { font-size: 9px; color: #94a3b8; transition: transform 0.2s ease; margin-left: 4px; }
.wf-assignee-chevron.wf-chevron-open { transform: rotate(180deg); color: #d97706; }
.wf-assignee-history {
    display: none;
    margin-top: 8px;
    padding: 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.5;
}

/* Chain node internals. */
.wf-tn-wrap { margin: 8px 0; }
.wf-tn-name { font-weight: 700; font-size: 12px; }
.wf-tn-role { color: #94a3b8; font-weight: 400; }
.wf-tn-meta { font-size: 10px; color: #64748b; margin-top: 2px; }

/* Action-button layout/color variants. */
.wf-btn-flex { flex: 1; justify-content: center; }
.wf-btn-sm { font-size: 11px; }
.wf-btn-muted { opacity: 0.5; cursor: not-allowed; }
.wf-btn-respond { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.wf-btn-review { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.wf-btn-query { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.wf-remind-btn { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.wf-remind-btn:hover { background: #fde68a; }
.wf-back-btn { margin-bottom: 12px; justify-content: center; }

/* Query box inside chain nodes (wf-tq-* mirrors the admin naming). */
.wf-tq-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px; font-size: 11px; }
.wf-tq-line { margin-top: 4px; }
.wf-tq-wait { margin-top: 4px; color: #b45309; }
.wf-tq-evidence { margin-top: 4px; color: #475569; }
.wf-tq-pdf-row { margin-top: 6px; }
.wf-tq-pdf { font-size: 10px; padding: 2px 10px; justify-content: center; }

/* My Queries (awaiting-verdict) cards. */
.wf-verdict-card { background: white; border-radius: 20px; box-shadow: var(--shadow-soft); padding: 15px; margin-bottom: 12px; border: 1px solid #fde68a; }
.wf-verdict-code { font-weight: 800; font-size: 13px; }
.wf-verdict-meta { font-size: 11px; color: #64748b; margin-top: 2px; }
.wf-q-reason { font-size: 11px; color: #475569; margin-top: 8px; background: #fffbeb; border-radius: 10px; padding: 8px; }

/* Query-history event internals. */
.wf-qh-line { margin-top: 2px; }
.wf-qh-awaiting { margin-top: 2px; color: #b45309; }
.wf-qh-reason { margin-top: 2px; color: #475569; }

/* Empty / error / muted list states. */
.wf-list-empty { text-align: center; padding: 30px; color: #94a3b8; }
.wf-list-error { text-align: center; padding: 30px; color: #dc2626; }
.wf-muted { color: #94a3b8; font-size: 12px; }
.wf-muted-pad { padding: 8px 0; }

/* Picker labels in forward / attach modals. */
.wf-pick-label { display: flex; gap: 8px; align-items: center; padding: 5px 0; font-size: 12px; cursor: pointer; }
