/* * LIQUID GLASS OS 4.0 - OPTIMIZED FINAL
 * Cleaned & Merged by Gemini
 */

/* =========================================
   1. VARIABLES & CONFIGURATION
   ========================================= */
:root {
    --hue: 210;
    --primary: hsl(var(--hue), 90%, 55%);
    --primary-bg: hsl(var(--hue), 90%, 96%);
    --primary-glow: #00000033;

    --bg-gradient: linear-gradient(135deg, hsl(var(--hue), 20%, 96%) 0%, hsl(var(--hue), 20%, 85%) 100%);

    --glass-surface: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --modal-bg: rgba(255, 255, 255, 0.90);

    --tab-bg: rgba(120, 120, 128, 0.12);
    --tab-indicator-bg: #ffffff;
    --tab-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

    --text-main: #1d1d1f;
    --text-sec: #6e6e73;

    --ease-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    --ease-squish: cubic-bezier(0.25, 1, 0.3, 1);
    --blur-val: 20px;

    --app-width: 480px;
    --header-height: 60px;
    --radius-md: 18px;
}

/* --- BASIC COLOR THEMES (Nâng cấp) --- */
/* Mặc định (Blue) */
body.theme-blue {
    --hue: 210;
    --bg-gradient: linear-gradient(135deg, hsl(210, 30%, 96%) 0%, hsl(210, 30%, 85%) 100%);
    --primary-rgb: 79, 172, 254;
}

/* Hồng cá tính (Pink) */
body.theme-pink {
    --hue: 340;
    --primary: hsl(340, 95%, 60%);
    /* Hồng đậm hơn chút cho dễ đọc */
    --primary-bg: hsl(340, 100%, 96%);
    --bg-gradient: linear-gradient(135deg, #fff0f6 0%, #ffd6e7 100%);
    --primary-rgb: 255, 71, 133;
}

/* Xanh lá dịu mắt (Green) */
body.theme-green {
    --hue: 150;
    --primary: hsl(150, 90%, 40%);
    /* Xanh lá đậm hơn để rõ chữ */
    --primary-bg: hsl(150, 80%, 96%);
    --bg-gradient: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
    --primary-rgb: 0, 184, 148;
}

/* Tím mộng mơ (Purple) */
body.theme-purple {
    --hue: 260;
    --primary: hsl(260, 80%, 60%);
    --bg-gradient: linear-gradient(135deg, #f3f0ff 0%, #e9d8fd 100%);
    --primary-rgb: 155, 89, 182;
}

/* Luxury Theme (New) */
body.theme-luxury {
    --hue: 45;
    --primary: #d4af37;
    /* Gold */
    --primary-bg: #fffbf0;
    --text-main: #3e2723;
    --bg-gradient: linear-gradient(135deg, #FFEFBA 0%, #FFFFFF 100%);
    --glass-surface: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(212, 175, 55, 0.3);
    --primary-rgb: 212, 175, 55;
}

/* Dark Mode Overrides cho từng màu (để màu không bị chói khi tắt đèn) */
body.dark.theme-pink {
    --primary: hsl(340, 90%, 65%);
    --bg-gradient: linear-gradient(135deg, #2d1b24 0%, #451d2e 100%);
}

body.dark.theme-green {
    --primary: hsl(150, 70%, 50%);
    --bg-gradient: linear-gradient(135deg, #1b2d24 0%, #1d4532 100%);
}

body.dark.theme-purple {
    --primary: hsl(260, 80%, 65%);
    --bg-gradient: linear-gradient(135deg, #241b2d 0%, #321d45 100%);
}

body.dark.theme-luxury {
    --primary: #ffd700;
    --bg-gradient: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    --glass-border: rgba(255, 215, 0, 0.2);
    --text-main: #fff8e1;
}

body.dark.theme-blue {
    --bg-gradient: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
}

/* =========================================
   2. CORE LAYOUT & RESET
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: color 0.3s, background 0.3s;
}

/* Background Effects Layers */
#sky,
#fireworks-container,
#particles-js,
.particles,
.event-patterns {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* =========================================
   3. APP CONTAINER (PHONE UI)
   ========================================= */
.app-container {
    width: 100%;
    max-width: var(--app-width);
    height: 100%;
    background: var(--glass-surface);
    border: 1px solid var(--glass-border);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    transition: background 0.3s;
    z-index: 10;
}

@media (min-width: 520px) {
    .app-container {
        height: 88%;
        border-radius: 24px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.2);
    }
}

/* Loading Screen (Premium) */
#loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-gradient);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease-in-out;
    backdrop-filter: blur(10px);
}

.spinner {
    width: 50px;
    height: 50px;
    position: relative;
    border: none;
    animation: none;
}

.spinner::before,
.spinner::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}

.spinner::after {
    border-top-color: transparent;
    border-bottom-color: var(--primary);
    animation-direction: reverse;
    animation-duration: 2s;
    inset: 6px;
}

.loading-text {
    margin-top: 20px;
    font-weight: 600;
    letter-spacing: 1px;
    animation: pulse-op 1.5s infinite ease-in-out;
}

@keyframes pulse-op {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* =========================================
   4. HEADER & NAVIGATION TABS
   ========================================= */
.window-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
}

.header-title {
    font-weight: 800;
    font-size: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.digital-clock {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.7;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    color: var(--text-main);
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
    background: rgba(var(--primary-rgb), 0.1);
    transform: scale(1.1);
}

.header-actions {
    position: relative;
    z-index: 30;
}

/* App transition and orientation styles */
.app-container {
    transition: transform 420ms var(--ease-squish), width 420ms var(--ease-squish), height 420ms var(--ease-squish), border-radius 420ms var(--ease-squish), box-shadow 420ms ease;
    animation: page-fade-in 0.8s ease-out forwards;
}

@keyframes page-fade-in {
    0% {
        opacity: 0;
        transform: scale(0.98) translateY(10px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Fullscreen "app" mode (smoothly expand to fill viewport) */
.app-container.app-mode {
    position: fixed;
    inset: 0;
    /* top:0; right:0; bottom:0; left:0; */
    width: 100%;
    max-width: none;
    height: 100dvh;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    transform: translateY(0) scale(1);
    z-index: 9999;
}

/* Small visual hint when app-mode enters */
.app-container.app-mode .window-header {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

/* Landscape handling for phones: make layout wider and remove big rounded edges */
body.landscape .app-container {
    max-width: 100%;
    width: calc(100% - 36px);
    height: calc(100dvh - 24px);
    margin: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

/* When in landscape and app-mode, use edge-to-edge layout */
body.landscape .app-container.app-mode {
    border-radius: 0;
    margin: 0;
    width: 100%;
    height: 100dvh;
}

/* Minor performance hint for mobile */
@media (max-width: 520px) {
    .app-container {
        will-change: transform, width, height;
    }
}

.tab-navigation {
    display: flex;
    position: relative;
    padding: 4px;
    background: var(--tab-bg);
    border-radius: 100px;
    margin: 0 16px;
    flex-shrink: 0;
    z-index: 10;
}

.tab-item {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-sec);
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: color 0.2s;
}

.tab-item.active {
    color: var(--primary);
}

.tab-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    background: var(--tab-indicator-bg);
    border-radius: 30px;
    box-shadow: var(--tab-shadow);
    z-index: 1;
    transition: transform 0.4s var(--ease-squish), width 0.4s var(--ease-squish);
}

/* =========================================
   5. CONTENT PANELS & CARDS
   ========================================= */
.content-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    margin-top: 10px;
}

.tab-panel {
    position: absolute;
    inset: 0;
    padding: 0 16px 100px 16px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(30px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.tab-panel.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transform: translateX(0);
    transition: opacity 0.4s, transform 0.4s var(--ease-squish);
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding-top: 5px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* GPU acceleration for smooth scrolling */
    transform: translateZ(0);
}

.panel-scroll::-webkit-scrollbar {
    display: none;
}

/* Card Styles */
.card,
.subject-card,
.week-day-card {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.subject-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.btvn-item {
    margin-left: 24px;
    padding: 4px 0;
    font-size: 14px;
    line-height: 1.4;
    list-style-type: disc;
}

/* 3D Tilt Effect */
body:not(.no-liquid):not(.touch-device) .subject-card:hover,
body:not(.no-liquid):not(.touch-device) .week-day-card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05), 0 0 0 1px var(--primary-glow);
}

/* On touch devices, disable hover for better UX */
body.touch-device .subject-card:hover,
body.touch-device .week-day-card:hover {
    transform: none;
    box-shadow: none;
}

/* Highlight Tomorrow */
.subject-card.highlight-tomorrow {
    border: 1.5px solid var(--primary);
    background: linear-gradient(to right, var(--primary-bg), rgba(255, 255, 255, 0.8));
    /* Use both an ambient glow and a colored shadow derived from theme RGB */
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.12), 0 0 20px var(--primary-glow);
    z-index: 5;
    margin-bottom: 16px;
    animation: pulse-border 2.5s infinite;
    transition: transform 0.35s var(--ease-squish), box-shadow 0.35s ease, border-color 0.25s ease;
}

/* Card entrance & subtle motion - Optimized */
.card,
.subject-card,
.week-day-card {
    transform-origin: center bottom;
    animation: card-pop 350ms ease-out;
    backface-visibility: hidden;
}

@keyframes card-pop {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}



/* Staggered animation delay for list items */
.subject-card:nth-child(1) {
    animation-delay: 0.05s;
}

.subject-card:nth-child(2) {
    animation-delay: 0.1s;
}

.subject-card:nth-child(3) {
    animation-delay: 0.15s;
}

.subject-card:nth-child(4) {
    animation-delay: 0.2s;
}

.subject-card:nth-child(5) {
    animation-delay: 0.25s;
}

.subject-card:nth-child(n+6) {
    animation-delay: 0.3s;
}

/* Enhanced Hover Effects */
.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.icon-btn:active {
    transform: rotate(15deg) scale(0.9);
}


/* Subtle hover lift for touch & pointer devices (not on touch-device) */
@media (hover: hover) and (pointer: fine) {

    body:not(.no-liquid):not(.touch-device) .subject-card:hover,
    body:not(.no-liquid):not(.touch-device) .week-day-card:hover {
        transform: translateY(-6px) scale(1.02);
        box-shadow: 0 18px 40px rgba(var(--primary-rgb), 0.10), 0 0 30px var(--primary-glow);
    }
}

/* Respect user reduced motion */
@media (prefers-reduced-motion: reduce) {

    .card,
    .subject-card,
    .week-day-card,
    .tab-indicator {
        animation: none !important;
        transition: none !important;
    }

    .event-pattern,
    .particle,
    .firework {
        animation: none !important;
    }
}

/* Mobile performance optimizations */
@media (max-width: 520px) {
    :root {
        --blur-val: 12px;
    }

    .card,
    .subject-card,
    .week-day-card {
        transition: transform 0.25s ease, box-shadow 0.25s ease;
    }

    #sky,
    #fireworks-container,
    .event-pattern,
    .particles {
        display: none;
    }

    .glass-dock {
        height: 54px;
    }
}

/* TKB Rows */
.tkb-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.tkb-time {
    width: 45px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-sec);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tkb-line {
    width: 3px;
    background: var(--primary);
    opacity: 0.3;
    margin: 0 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.tkb-info {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    gap: 10px;
    align-items: center;
}

.tkb-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.duty-badge {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 10px;
}

.tomorrow-badge {
    position: absolute;
    top: -8px;
    right: 10px;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
}

/* =========================================
   6. CONTROLS, DOCK & BUTTONS
   ========================================= */
/* Dock */
.dock-wrapper {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 100;
}

.glass-dock {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    height: 60px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    transition: all 0.4s var(--ease-elastic);
}

/* --- SỬA LỖI ẨN DOCK ICON --- */

/* Biến Dock thành hình tròn nhỏ */
.glass-dock.single-mode {
    width: 60px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
}

/* Ẩn nút Refresh (Thêm !important để ép ẩn tuyệt đối) */
.glass-dock.single-mode .dock-icon[data-action="refresh"] {
    display: none !important;
}

/* Ẩn dấu gạch ngăn cách */
.glass-dock.single-mode .separator {
    display: none !important;
}

.dock-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    color: #444;
}

.dock-icon:active {
    transform: scale(0.9);
}

.separator {
    width: 1px;
    height: 20px;
    background: currentColor;
    opacity: 0.2;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 12px;
    width: 100%;
    font-weight: 600;
    margin-top: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 5px 15px var(--primary-glow);
    transition: transform 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-close,
.btn-close-abs,
.btn-dismiss {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-text-only {
    background: none;
    border: none;
    color: var(--primary);
    margin-top: 10px;
    cursor: pointer;
}

.full-width {
    width: 100%;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.hidden {
    display: none !important;
}

/* Settings Controls */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.disabled-control {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(120, 120, 128, 0.2);
    border-radius: 34px;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: .3s var(--ease-elastic);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.color-picker-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 10px;
}

.color-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.color-dot.active {
    transform: scale(1.15);
    border-color: var(--text-main);
}

.color-dot.blue {
    background: #4facfe;
}

.color-dot.pink {
    background: #ff4785;
}

.color-dot.green {
    background: #00b894;
}

.color-dot.purple {
    background: #9b59b6;
}

/* =========================================
   7. MODALS & POPUPS (Unified)
   ========================================= */
/* Shared Overlay Styles */
.modal-overlay,
.event-popup,
.popup-overlay,
.popup-guide {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open,
.event-popup.open,
.popup-overlay.active,
.popup-guide.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Shared Card/Content Styles */
.modal-glass,
.event-popup-card,
.install-card,
.selector-card,
.guide-card {
    background: var(--modal-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: 0.4s var(--ease-elastic);
}

/* Active State for Cards */
.modal-overlay.open .modal-glass,
.event-popup.open .event-popup-card,
.popup-overlay.active .install-card,
.popup-overlay.active .selector-card,
.popup-guide.open .guide-card {
    transform: scale(1) translateY(0);
}

/* Specific Modal Sizes */
.modal-glass.small {
    max-width: 360px;
}

.modal-glass.large {
    max-width: 600px;
    height: 70vh;
}

.modal-header {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* --- SPECIFIC POPUPS CONTENT --- */

/* Event Popup */
.event-popup-card {
    padding: 28px;
    max-width: 540px;
    position: relative;
}

.event-popup-card h3 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--primary);
}

.event-popup-card .close {
    position: absolute;
    right: 16px;
    top: 16px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-sec);
}

/* Selector Card (Android/iOS) */
.selector-card {
    max-width: 360px;
    position: relative;
}

.selector-header {
    padding: 25px 20px 10px;
    text-align: center;
}

.selector-header h3 {
    margin: 0 0 5px;
    font-size: 1.3rem;
    color: var(--text-main);
}

.btn-close-abs {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--tab-bg);
}

.platform-options {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.platform-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
}

.platform-option.android {
    background: var(--primary-bg);
    color: var(--primary);
}

.platform-option.ios {
    background: var(--tab-bg);
    color: var(--text-main);
}

.platform-option:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.plat-icon {
    font-size: 1.8rem;
}

.plat-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.plat-text b {
    font-size: 1rem;
    margin-bottom: 2px;
}

.plat-text span {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Install Card */
.install-card {
    max-width: 320px;
    padding: 30px 20px;
    text-align: center;
}

.install-icon img {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    box-shadow: 0 10px 25px rgba(10, 132, 255, 0.3);
    margin-bottom: 15px;
}

.install-content h3 {
    font-size: 1.4rem;
    margin: 0 0 10px 0;
    color: var(--text-main);
}

.install-content p {
    font-size: 0.95rem;
    color: var(--text-sec);
    line-height: 1.5;
    margin-bottom: 25px;
}

.btn-install-primary {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #007AFF, #0051a8);
    color: white;
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 122, 255, 0.3);
    margin-bottom: 10px;
}

/* IOS Guide & Steps */
.guide-card.ios-mode {
    max-width: 360px;
}

.guide-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.guide-body {
    padding: 20px;
}

/* Close button for iOS guide popup */
.btn-close-guide {
    background: var(--tab-bg);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
}

.btn-close-guide:hover {
    opacity: 0.95;
}

/* iOS guide steps styling */
.guide-body .ios-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    border-radius: 12px;
    background: var(--tab-bg);
    margin-bottom: 12px;
}

.guide-body .ios-step .step-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--tab-indicator-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 18px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.guide-body .ios-step .step-info b {
    display: block;
    margin-bottom: 6px;
}

.guide-body .ios-step .step-info p {
    margin: 0;
    color: var(--text-sec);
    font-size: 14px;
    line-height: 1.4;
}

.ios-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
    text-align: left;
    background: var(--tab-bg);
    padding: 12px;
    border-radius: 12px;
}

.step-icon {
    width: 36px;
    height: 36px;
    background: var(--tab-indicator-bg);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    font-size: 1.2rem;
}

.step-info b {
    display: block;
    margin-bottom: 3px;
    color: var(--text-main);
}

.step-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-sec);
}

/* App Banner (Bottom PWA Prompt) */
.app-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    width: 90%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.27), opacity 0.3s;
    opacity: 0;
    pointer-events: none;
}

.app-banner.open {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-icon-small {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.banner-text {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    line-height: 1.3;
    color: #333;
}

.banner-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-install {
    flex: 1;
    border: none;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-install.android {
    background: #e8f5e9;
    color: #2e7d32;
}

.btn-install.ios {
    background: #e3f2fd;
    color: #1565c0;
}

/* =========================================
   8. DARK MODE & NO-LIQUID OVERRIDES
   ========================================= */
body.dark {
    --bg-gradient: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
    --glass-surface: rgba(30, 30, 35, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --modal-bg: rgba(35, 35, 40, 0.95);
    --tab-bg: rgba(255, 255, 255, 0.1);
    --tab-indicator-bg: #636366;
    --tab-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    --text-main: #f5f5f7;
    --text-sec: #98989d;
    --primary-bg: hsla(var(--hue), 90%, 55%, 0.15);
}

body.dark .card,
body.dark .subject-card,
body.dark .week-day-card {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark .dock-icon {
    color: #eee;
}

body.dark .glass-dock {
    background: rgba(30, 30, 35, 0.85);
    border-color: rgba(255, 255, 255, 0.15);
}

body.dark .app-banner {
    background: rgba(40, 40, 45, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

body.dark .banner-text {
    color: white;
}

/* No Liquid Mode */
body.no-liquid {
    --glass-surface: #ffffff;
    --glass-border: #e5e5e5;
    --modal-bg: #f2f2f7;
    --blur-val: 0px;
    --ease-elastic: ease-out;
    --ease-squish: ease-out;
    --tab-bg: #e5e5ea;
    --tab-indicator-bg: #ffffff;
    --tab-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.dark.no-liquid {
    --bg-gradient: linear-gradient(135deg, #000 0%, #1c1c1e 100%);
    --glass-surface: #1c1c1e;
    --glass-border: #3a3a3c;
    --modal-bg: #1c1c1e;
    --tab-bg: #2c2c2e;
    --tab-indicator-bg: #636366;
    --tab-shadow: none;
}

/* =========================================
   9. EVENT THEMES (TET, HALLOWEEN, CHRISTMAS)
   ========================================= */

/* --- TẾT THEME --- */
body.event-tet {
    background: linear-gradient(135deg, #d32f2f 0%, #8e0000 100%) !important;
    --tab-bg: rgba(255, 255, 255, 0.15) !important;
    --tab-indicator-bg: #fffbe6;
    --primary: #ffd700;
    --primary-bg: rgba(255, 215, 0, 0.15);
    --text-main: #ffffff;
    --text-sec: #ffdbdb;
    --glass-border: rgba(255, 215, 0, 0.3);
}

body.event-tet .app-container,
body.event-tet .modal-glass {
    background: rgba(145, 15, 15, 0.9) !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
}

body.event-tet .subject-title,
body.event-tet h3,
body.event-tet .header-title {
    color: #ffd700 !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.event-tet .btn-primary {
    background: linear-gradient(to right, #ffd700, #ffb900);
    color: #8e0000;
    box-shadow: 0 4px 15px rgba(255, 185, 0, 0.3);
}

body.event-tet .glass-dock {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.event-tet .dock-icon {
    color: #ffd700;
}

body.event-tet .tab-item.active {
    color: #b71c1c !important;
}

body.event-tet .card,
body.event-tet .subject-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.15);
}

body.event-tet .tomorrow-badge {
    background: #ffd700;
    color: #8e0000;
}

/* --- TẾT LIGHT MODE FIXES (RED THEME) --- */
/* Fix App Banner not showing theme */
body.event-tet .app-banner {
    background: rgba(142, 0, 0, 0.95) !important;
    /* Red background */
    border: 1px solid #ffd700 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body.event-tet .app-banner .banner-text {
    color: #ffd700 !important;
    /* Gold text */
}

body.event-tet .app-banner .banner-text div:last-child {
    color: rgba(255, 255, 255, 0.8) !important;
    /* Subtext white */
}

body.event-tet .app-banner .app-icon-small {
    background: #ffd700 !important;
    color: #8e0000 !important;
}

/* Fix TKB Popup Visibility (Keep Red Theme) */
body.event-tet .modal-glass.large {
    background: rgba(145, 15, 15, 0.95) !important;
    /* Red background */
    color: #ffffff !important;
    border: 1px solid #ffd700;
}

body.event-tet .modal-header h3 {
    color: #ffd700 !important;
    /* Gold Header */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

body.event-tet .modal-header .btn-close {
    color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.1);
}

body.event-tet #content-full-week {
    color: #ffffff !important;
}

/* Ensure timeline rows in TKB popup are readable on Red */
body.event-tet .modal-glass .tkb-row {
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

body.event-tet .modal-glass .tkb-time {
    color: #ffd700 !important;
    /* Gold Time */
}

body.event-tet .modal-glass .tkb-name {
    color: #ffffff !important;
    font-weight: 500;
}

body.event-tet .modal-glass .tkb-name {
    color: #ffffff !important;
    font-weight: 500;
}

body.event-tet .week-day-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

body.event-tet .day-header-badge {
    background: #ffd700;
    color: #8e0000;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
}

/* Fix Greeting Modal (Happy New Year) */
body.event-tet .tet-greeting-modal {
    background: rgba(210, 10, 10, 0.95) !important;
    /* Vivid Red */
    border: 2px solid #ffff00 !important;
    box-shadow: 0 0 50px rgba(255, 234, 0, 0.5);
    color: #ffff00 !important;
}

body.event-tet .tet-greeting-content h1 {
    color: #ffff00 !important;
    text-shadow: 0 4px 10px rgba(183, 28, 28, 0.5);
}

body.event-tet .tet-greeting-content p {
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

body.event-tet .tet-greeting-close {
    background: #ffff00 !important;
    color: #d50000 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* --- TẾT THEME DARK MODE (NEW) --- */
/* --- TẾT THEME DARK MODE (NEW UI) --- */
/* --- TẾT THEME DARK MODE (SYNC WITH LIGHT MODE) --- */
/* --- TẾT THEME DARK MODE (SYNCED WITH LIGHT MODE) --- */
body.event-tet.dark {
    background: linear-gradient(135deg, #d32f2f 0%, #8e0000 100%) !important;
    --tab-bg: rgba(255, 255, 255, 0.15) !important;
    --tab-indicator-bg: #fffbe6;
    --primary: #ffd700;
    --primary-bg: rgba(255, 215, 0, 0.15);
    --text-main: #ffffff;
    --text-sec: #ffdbdb;
    --glass-border: rgba(255, 215, 0, 0.3);
}

body.event-tet.dark .event-patterns {
    display: none !important;
}

body.event-tet.dark .app-container,
body.event-tet.dark .modal-glass {
    background: rgba(145, 15, 15, 0.9) !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border) !important;
}

body.event-tet.dark .btn-close {
    color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.1) !important;
    border: none;
}

@media (max-width: 520px) {
    body.event-tet.dark .app-container {
        background: rgba(145, 15, 15, 0.9) !important;
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
        border: 1px solid var(--glass-border) !important;
    }
}

body.event-tet.dark .card,
body.event-tet.dark .subject-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.15);
}

body.event-tet.dark .glass-dock {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.event-tet.dark .dock-icon {
    color: #ffd700;
}

body.event-tet.dark .btn-primary {
    background: linear-gradient(to right, #ffd700, #ffb900);
    color: #8e0000;
    box-shadow: 0 4px 15px rgba(255, 185, 0, 0.3);
    border: none;
}

body.event-tet.dark .tab-item.active {
    color: #b71c1c !important;
}

body.event-tet.dark h3,
body.event-tet.dark .header-title,
body.event-tet.dark .subject-title {
    color: #ffd700 !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.event-tet.dark .tkb-row {
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

body.event-tet.dark .tkb-time {
    color: #ffd700 !important;
}

body.event-tet.dark .tkb-name {
    color: #ffffff !important;
}

/* --- TẾT POPUP OPTIMIZATIONS (UNIFIED LIGHT/DARK) --- */
body.event-tet .selector-card,
body.event-tet .guide-card,
body.event-tet .event-popup-card,
body.event-tet.dark .selector-card,
body.event-tet.dark .guide-card,
body.event-tet.dark .event-popup-card {
    background: rgba(145, 15, 15, 0.95) !important;
    border: 2px solid #ffd700 !important;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

body.event-tet .selector-header h3,
body.event-tet .guide-header h3,
body.event-tet .event-popup-card h3,
body.event-tet.dark .selector-header h3,
body.event-tet.dark .guide-header h3,
body.event-tet.dark .event-popup-card h3 {
    color: #ffd700 !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.event-tet .selector-header p,
body.event-tet .guide-header div div,
body.event-tet .event-popup-card #eventPopupContent,
body.event-tet.dark .selector-header p,
body.event-tet.dark .guide-header div div,
body.event-tet.dark .event-popup-card #eventPopupContent {
    color: rgba(255, 255, 255, 0.9) !important;
}

body.event-tet .event-popup-card .close,
body.event-tet.dark .event-popup-card .close {
    color: #ffd700 !important;
    opacity: 1 !important;
}



body.event-tet .platform-option.ios,
body.event-tet.dark .platform-option.ios {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 215, 0, 0.3) !important;
    color: #ffffff !important;
}

body.event-tet .platform-option.android,
body.event-tet.dark .platform-option.android {
    background: rgba(255, 215, 0, 0.15) !important;
    border: 1px solid #ffd700 !important;
    color: #ffd700 !important;
}

body.event-tet .plat-text b,
body.event-tet.dark .plat-text b {
    color: #ffd700 !important;
}

body.event-tet .plat-text span,
body.event-tet.dark .plat-text span {
    color: rgba(255, 255, 255, 0.7) !important;
}

body.event-tet .ios-step,
body.event-tet .guide-body .ios-step,
body.event-tet.dark .ios-step,
body.event-tet.dark .guide-body .ios-step {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 215, 0, 0.2) !important;
}

body.event-tet .step-icon,
body.event-tet .guide-body .ios-step .step-icon,
body.event-tet.dark .step-icon,
body.event-tet.dark .guide-body .ios-step .step-icon {
    background: #ffd700 !important;
    color: #8e0000 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

body.event-tet .step-info b,
body.event-tet.dark .step-info b {
    color: #ffd700 !important;
}

body.event-tet .step-info p,
body.event-tet.dark .step-info p {
    color: #ffffff !important;
}

body.event-tet .btn-close-abs,
body.event-tet .btn-close-guide,
body.event-tet.dark .btn-close-abs,
body.event-tet.dark .btn-close-guide {
    background: rgba(255, 215, 0, 0.15) !important;
    color: #ffd700 !important;
}

body.event-tet .guide-header,
body.event-tet.dark .guide-header {
    border-bottom: 1px solid rgba(255, 215, 0, 0.3) !important;
}

body.event-tet .btn-text-only,
body.event-tet.dark .btn-text-only {
    color: #ffd700 !important;
}

/* --- TẾT GRADE CALCULATOR (TAB ĐIỂM) --- */
body.event-tet .grade-input-group,
body.event-tet.dark .grade-input-group {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 215, 0, 0.3) !important;
}

body.event-tet .grade-input,
body.event-tet.dark .grade-input {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1.5px solid rgba(255, 215, 0, 0.4) !important;
    color: #ffffff !important;
}

body.event-tet .grade-input::placeholder,
body.event-tet.dark .grade-input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

body.event-tet .grade-input:focus,
body.event-tet.dark .grade-input:focus {
    border-color: #ffd700 !important;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2) !important;
}

body.event-tet .grade-formula-info,
body.event-tet .grade-source-info,
body.event-tet .classification-table-wrapper,
body.event-tet.dark .grade-formula-info,
body.event-tet.dark .grade-source-info,
body.event-tet.dark .classification-table-wrapper {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 215, 0, 0.3) !important;
}

body.event-tet .formula-header,
body.event-tet .source-header,
body.event-tet .classification-header,
body.event-tet.dark .formula-header,
body.event-tet.dark .source-header,
body.event-tet.dark .classification-header {
    color: #ffd700 !important;
}

body.event-tet .formula-content,
body.event-tet .source-content,
body.event-tet .classification-content,
body.event-tet.dark .formula-content,
body.event-tet.dark .source-content,
body.event-tet.dark .classification-content {
    color: rgba(255, 255, 255, 0.9) !important;
}

body.event-tet .formula-step code,
body.event-tet.dark .formula-step code {
    background: rgba(255, 215, 0, 0.15) !important;
    color: #ffd700 !important;
}

body.event-tet .grade-result-container,
body.event-tet.dark .grade-result-container {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(0, 0, 0, 0.2)) !important;
    border: 1.5px solid #ffd700 !important;
}

body.event-tet .result-header,
body.event-tet.dark .result-header {
    background: #ffd700 !important;
    color: #8e0000 !important;
}

body.event-tet .result-body,
body.event-tet.dark .result-body {
    color: #ffffff !important;
}

body.event-tet .result-label,
body.event-tet.dark .result-label {
    color: rgba(255, 255, 255, 0.8) !important;
}

body.event-tet .result-value,
body.event-tet .result-tbm,
body.event-tet.dark .result-value,
body.event-tet.dark .result-tbm {
    color: #ffd700 !important;
}

body.event-tet .result-main,
body.event-tet.dark .result-main {
    background: rgba(255, 215, 0, 0.15) !important;
}

body.event-tet .result-breakdown,
body.event-tet.dark .result-breakdown {
    border-top-color: rgba(255, 215, 0, 0.3) !important;
    color: rgba(255, 255, 255, 0.8) !important;
}

body.event-tet .btn-secondary,
body.event-tet.dark .btn-secondary {
    background: rgba(255, 215, 0, 0.15) !important;
    color: #ffd700 !important;
    border: 1px solid rgba(255, 215, 0, 0.3) !important;
}

body.event-tet .btn-secondary:hover,
body.event-tet.dark .btn-secondary:hover {
    background: rgba(255, 215, 0, 0.25) !important;
}

body.event-tet .source-item,
body.event-tet.dark .source-item {
    background: rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(255, 215, 0, 0.2) !important;
}

body.event-tet .source-icon,
body.event-tet.dark .source-icon {
    background: #ffd700 !important;
    color: #8e0000 !important;
}

body.event-tet .source-link,
body.event-tet.dark .source-link {
    color: #ffd700 !important;
}

body.event-tet .source-note,
body.event-tet .classification-warning,
body.event-tet.dark .source-note,
body.event-tet.dark .classification-warning {
    background: rgba(255, 215, 0, 0.1) !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

body.event-tet .classification-table,
body.event-tet.dark .classification-table {
    color: #ffffff !important;
}

body.event-tet .classification-table th,
body.event-tet.dark .classification-table th {
    background: rgba(255, 215, 0, 0.2) !important;
    color: #ffd700 !important;
}

body.event-tet .classification-table td,
body.event-tet.dark .classification-table td {
    border-color: rgba(255, 215, 0, 0.2) !important;
}

body.event-tet .input-guide,
body.event-tet .grade-subtitle,
body.event-tet .label-hint,
body.event-tet.dark .input-guide,
body.event-tet.dark .grade-subtitle,
body.event-tet.dark .label-hint {
    color: rgba(255, 255, 255, 0.7) !important;
}

body.event-tet .label-text,
body.event-tet.dark .label-text {
    color: #ffffff !important;
}

body.event-tet .label-text i,
body.event-tet.dark .label-text i {
    color: #ffd700 !important;
}

/* --- HALLOWEEN THEME --- */
body.event-halloween {
    background: linear-gradient(135deg, #240b36 0%, #c31432 100%) !important;
    --tab-bg: rgba(255, 255, 255, 0.12) !important;
    --tab-indicator-bg: #ff9f43;
    --primary: #ff9f43;
    --primary-bg: rgba(255, 159, 67, 0.2);
    --text-main: #ffffff;
    --text-sec: #e0d2ff;
    --glass-border: rgba(255, 159, 67, 0.3);
}

body.event-halloween .app-container,
body.event-halloween .modal-glass {
    background: rgba(45, 10, 60, 0.85) !important;
}

body.event-halloween .subject-title,
body.event-halloween h3 {
    color: #ff9f43 !important;
    text-shadow: 0 0 10px rgba(255, 159, 67, 0.4);
}

body.event-halloween .btn-primary {
    background: linear-gradient(135deg, #ff9f43 0%, #ff6b6b 100%);
    color: #2e003e;
}

body.event-halloween .tab-item.active {
    color: #ff9f43 !important;
}

/* --- CHRISTMAS THEME --- */
body.event-christmas {
    background: linear-gradient(135deg, #0f3443 0%, #34e89e 100%) !important;
    --tab-bg: rgba(255, 255, 255, 0.2) !important;
    --tab-indicator-bg: #ffffff;
    --primary: #ff4757;
    --primary-bg: rgba(255, 71, 87, 0.2);
    --text-main: #ffffff;
    --text-sec: #d1f2eb;
    --glass-border: rgba(255, 255, 255, 0.4);
}

body.event-christmas .app-container,
body.event-christmas .modal-glass {
    background: rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(15px);
}

body.event-christmas .subject-title,
body.event-christmas h3 {
    color: #ff4757 !important;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

body.event-christmas .btn-primary {
    background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
    color: white;
}

body.event-christmas .tab-item.active {
    color: #0f3443 !important;
}

body.event-christmas .dock-icon {
    color: #ffffff;
}

/* =========================================
   10. ANIMATIONS & PARTICLES
   ========================================= */
@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 8px var(--primary-glow);
    }

    50% {
        box-shadow: 0 0 18px var(--primary-glow);
    }

    100% {
        box-shadow: 0 0 8px var(--primary-glow);
    }
}

@keyframes firework-explode {
    0% {
        transform: translate(-50%, -50%);
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes float {
    0% {
        transform: translateY(100vh);
        opacity: 0;
    }

    50% {
        opacity: 0.2;
    }

    100% {
        transform: translateY(-100vh);
        opacity: 0;
    }
}

@keyframes float-pattern {
    0% {
        transform: translateY(100vh) rotate(0deg);
    }

    100% {
        transform: translateY(-100vh) rotate(360deg);
    }
}

.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
}

.firework-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.particle {
    position: absolute;
    background-color: var(--primary);
    border-radius: 50%;
    opacity: 0.2;
    animation: float 15s infinite linear;
}

.event-pattern {
    position: absolute;
    opacity: 0.1;
    animation: float-pattern 20s infinite linear;
    font-size: 40px;
}

.pattern-hoa-mai::before {
    content: "🌸";
}

.pattern-hoa-dao::before {
    content: "🌺";
}

.pattern-pumpkin::before {
    content: "🎃";
}

.pattern-ghost::before {
    content: "👻";
}

.pattern-snow::before {
    content: "❄️";
}

.pattern-tree::before {
    content: "🎄";
}

/* =========================================
   11. SCROLL TO TOP BUTTON
   ========================================= */
.scroll-to-top-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s var(--ease-elastic);
}

.scroll-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.scroll-to-top-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.scroll-to-top-btn:active {
    transform: scale(0.95);
}

body.dark .scroll-to-top-btn {
    background: var(--primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* Hide scroll button when setting is off */
.scroll-to-top-btn.disabled {
    display: none !important;
}

/* =========================================
   GRADE CALCULATOR STYLES
   ========================================= */
.grade-calculator {
    padding: 15px;
    max-width: 100%;
}

.grade-header {
    text-align: center;
    margin-bottom: 20px;
}

.grade-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.grade-subtitle {
    font-size: 13px;
    color: var(--text-sec);
    margin: 0;
}

.grade-input-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.grade-input-group {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.grade-input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.grade-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.label-text {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.label-text i {
    color: var(--primary);
    font-size: 16px;
}

.label-hint {
    font-size: 12px;
    color: var(--text-sec);
    margin-left: 24px;
}

.grade-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    font-family: inherit;
}

.grade-input::placeholder {
    color: var(--text-sec);
    opacity: 0.6;
}

.grade-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.input-guide {
    font-size: 11px;
    color: var(--text-sec);
    margin-top: 6px;
    opacity: 0.8;
}

/* Calculate Button */
/* Calculate Button - Optimized (removed infinite animation) */
.btn-calculate {
    font-size: 16px;
    padding: 14px;
    margin-bottom: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-calculate:active {
    transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
    background: var(--tab-bg);
    color: var(--text-main);
    border: none;
    padding: 12px;
    border-radius: 12px;
    width: 100%;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, background 0.2s;
    margin-top: 10px;
}

.btn-secondary:hover {
    background: rgba(120, 120, 128, 0.2);
}

.btn-secondary:active {
    transform: scale(0.98);
}

/* Result Container */
.grade-result-container {
    background: linear-gradient(135deg, var(--primary-bg), rgba(255, 255, 255, 0.9));
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    transition: all 0.4s var(--ease-squish);
}

.grade-result-container.visible {
    opacity: 1;
    transform: translateY(0);
    max-height: 400px;
}

.result-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-body {
    padding: 16px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.result-row:last-of-type {
    border-bottom: none;
}

.result-label {
    font-size: 14px;
    color: var(--text-sec);
}

.result-value {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
}

.result-main {
    background: rgba(var(--primary-rgb), 0.1);
    margin: 10px -16px -16px;
    padding: 16px;
    border-radius: 0 0 calc(var(--radius-md) - 2px) calc(var(--radius-md) - 2px);
}

.result-tbm {
    font-size: 28px;
    color: var(--primary);
    font-weight: 800;
}

.result-breakdown {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
    font-size: 12px;
    color: var(--text-sec);
    line-height: 1.6;
}

.result-breakdown strong {
    color: var(--text-main);
}

/* Formula Info Section */
.grade-formula-info {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    overflow: hidden;
}

.formula-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.formula-header:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

.toggle-icon {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.3s;
}

.formula-header.active .toggle-icon {
    transform: rotate(180deg);
}

.formula-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding: 0 16px;
}

.formula-content.visible {
    max-height: 300px;
    padding: 0 16px 16px;
}

.formula-step {
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 13px;
    line-height: 1.5;
}

.formula-step:last-child {
    border-bottom: none;
}

.formula-step code {
    display: block;
    background: rgba(var(--primary-rgb), 0.1);
    padding: 10px 12px;
    border-radius: 8px;
    margin-top: 6px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
    color: var(--primary);
}

.formula-step ul {
    margin: 6px 0 0 20px;
    padding: 0;
}

.formula-step li {
    margin-bottom: 4px;
}

.formula-step small {
    opacity: 0.8;
}

/* Error State */
.grade-input.error {
    border-color: #ff3b30;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15);
}

.grade-error-message {
    color: #ff3b30;
    font-size: 12px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Dark Mode Overrides */
body.dark .grade-input-group {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark .grade-input {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
}

body.dark .grade-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

body.dark .grade-result-container {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.15), rgba(255, 255, 255, 0.05));
    border-color: var(--primary);
}

body.dark .grade-formula-info {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark .formula-step code {
    background: rgba(var(--primary-rgb), 0.2);
}

body.dark .result-main {
    background: rgba(var(--primary-rgb), 0.2);
}

body.dark .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
}

body.dark .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* =========================================
   BOTTOM NAVIGATION DOCK MODE
   ========================================= */

/* Hide new dock by default */
.dock-nav-mode {
    display: none !important;
}

/* When dock-nav-enabled class is on body, switch docks */
body.dock-nav-enabled #dock-original {
    display: none !important;
}

body.dock-nav-enabled .dock-nav-mode {
    display: flex !important;
}

/* Hide refresh button in new dock navigation when in single-mode */
.dock-nav-mode.single-mode .dock-nav-icon[data-action="refresh"] {
    display: none !important;
}

.dock-nav-mode.single-mode .dock-nav-separator {
    display: none !important;
}

/* Hide top tab navigation when dock mode is enabled */
body.dock-nav-enabled .tab-navigation {
    display: none !important;
}

/* Adjust content area when no top tabs */
body.dock-nav-enabled .content-area {
    margin-top: 0;
}

/* New Navigation Dock Styles */
.glass-dock-nav {
    width: auto;
    max-width: calc(100% - 32px);
    height: auto;
    padding: 8px 12px;
    gap: 4px;
    border-radius: 20px;
}

.dock-nav-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s var(--ease-squish);
    color: var(--text-sec);
    gap: 3px;
    min-width: 48px;
    position: relative;
}

.dock-nav-icon i {
    font-size: 18px;
    transition: transform 0.2s, color 0.2s;
}

.dock-nav-icon span {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.9;
    transition: color 0.2s;
}

.dock-nav-icon:hover {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.dock-nav-icon:hover i {
    transform: scale(1.1);
}

.dock-nav-icon:active {
    transform: scale(0.95);
}

.dock-nav-icon.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.35);
}

.dock-nav-icon.active i,
.dock-nav-icon.active span {
    color: white;
}

/* Action icons (settings, refresh) - smaller, no label */
.dock-nav-action {
    min-width: 40px;
    padding: 10px;
}

.dock-nav-action span {
    display: none;
}

.dock-nav-action i {
    font-size: 16px;
}

/* Separator */
.dock-nav-separator {
    width: 1px;
    height: 28px;
    background: currentColor;
    opacity: 0.15;
    margin: 0 4px;
    flex-shrink: 0;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 420px) {
    .glass-dock-nav {
        padding: 6px 8px;
        gap: 2px;
    }

    .dock-nav-icon {
        padding: 6px 8px;
        min-width: 40px;
    }

    .dock-nav-icon i {
        font-size: 16px;
    }

    .dock-nav-icon span {
        font-size: 9px;
    }

    .dock-nav-action {
        min-width: 36px;
        padding: 8px;
    }
}

/* Very small screens - hide labels */
@media (max-width: 360px) {
    .dock-nav-icon span {
        display: none;
    }

    .dock-nav-icon {
        min-width: 36px;
        padding: 8px 10px;
    }
}

/* Dark mode adjustments */
body.dark .glass-dock-nav {
    background: rgba(30, 30, 30, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark .dock-nav-icon:hover {
    background: rgba(var(--primary-rgb), 0.2);
}

body.dark .dock-nav-separator {
    opacity: 0.2;
}

/* =========================================
   SOURCE CITATION STYLES
   ========================================= */
.grade-source-info {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    overflow: hidden;
}

.source-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 14px;
    color: #e67e22;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.source-header:hover {
    background: rgba(230, 126, 34, 0.08);
}

.source-header .toggle-icon {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.3s;
}

.source-header.active .toggle-icon {
    transform: rotate(180deg);
}

.source-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding: 0 16px;
}

.source-content.visible {
    max-height: 600px;
    padding: 0 16px 16px;
}

.source-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.source-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.source-item.source-main {
    background: linear-gradient(135deg, rgba(230, 126, 34, 0.1), rgba(255, 255, 255, 0.8));
    border-color: rgba(230, 126, 34, 0.2);
}

.source-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(230, 126, 34, 0.15);
    color: #e67e22;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.source-text {
    flex: 1;
}

.source-text strong {
    display: block;
    font-size: 14px;
    color: var(--text-main);
    margin-bottom: 4px;
}

.source-text p {
    font-size: 12px;
    color: var(--text-sec);
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.source-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.source-link:hover {
    color: #e67e22;
    text-decoration: underline;
}

.source-link i {
    font-size: 10px;
}

.source-note {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 10px;
    font-size: 11px;
    color: var(--text-sec);
    line-height: 1.5;
    border-left: 3px solid #3498db;
}

.source-note i {
    color: #3498db;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Dark Mode */
body.dark .grade-source-info {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark .source-item {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.05);
}

body.dark .source-item.source-main {
    background: linear-gradient(135deg, rgba(230, 126, 34, 0.15), rgba(255, 255, 255, 0.05));
}

body.dark .source-note {
    background: rgba(52, 152, 219, 0.15);
}

/* =========================================
   YEAR AVERAGE CALCULATOR
   ========================================= */
.year-calculator {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px dashed var(--glass-border);
}

/* Classification Table Wrapper */
.classification-table-wrapper {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    overflow: hidden;
}

.classification-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 14px;
    color: #8e44ad;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.classification-header:hover {
    background: rgba(142, 68, 173, 0.08);
}

.classification-header .toggle-icon {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.3s;
}

.classification-header.active .toggle-icon {
    transform: rotate(180deg);
}

.classification-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding: 0 16px;
}

.classification-content.visible {
    max-height: 500px;
    padding: 0 16px 16px;
}

/* Warning Box */
.classification-warning {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: rgba(241, 196, 15, 0.15);
    border-radius: 10px;
    font-size: 12px;
    color: #7d6608;
    line-height: 1.5;
    border-left: 3px solid #f1c40f;
    margin-bottom: 12px;
}

.classification-warning i {
    color: #f1c40f;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Classification Table */
.classification-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.classification-table th,
.classification-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.classification-table th {
    background: rgba(var(--primary-rgb), 0.1);
    font-weight: 600;
    color: var(--text-main);
}

.classification-table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

/* Level Badges */
.level-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.level-badge.gioi {
    background: linear-gradient(135deg, #f39c12, #e74c3c);
    color: white;
}

.level-badge.kha {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.level-badge.dat {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.level-badge.chuadat {
    background: linear-gradient(135deg, #7f8c8d, #95a5a6);
    color: white;
}

/* Dark Mode for Year Calculator */
body.dark .year-calculator {
    border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark .classification-table-wrapper {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark .classification-warning {
    background: rgba(241, 196, 15, 0.1);
    color: #f1c40f;
}

body.dark .classification-table th {
    background: rgba(var(--primary-rgb), 0.15);
}

body.dark .classification-table td {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.dark .classification-table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.1);
}