:root {
    --primary-color: #3B82F6;
    --primary-hover: #2563EB;
    --background-color: #F3F4F6;
    --card-background: #ffffff;
    --text-color: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --sidebar-width: 250px;
    --bottom-nav-height: calc(60px + env(safe-area-inset-bottom));
    --mobile-header-height: calc(56px + env(safe-area-inset-top));
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-bottom: var(--bottom-nav-height);
    padding-bottom: var(--bottom-nav-height);
    /* For mobile */
    -webkit-tap-highlight-color: transparent;
    /* Remove default tap highlight */
}

/* --- Mobile Interactions --- */
.btn:active,
.card:active,
.nav-item:active,
.bottom-nav-item:active {
    transform: scale(0.98);
    transition: transform 0.1s;
}

/* --- Form Optimization for Mobile --- */
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    font-size: 16px;
    /* Prevent iOS zoom */
    min-height: 48px;
    /* Touch target size */
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .question-text {
        font-size: 1.05rem;
        line-height: 1.6;
    }
}

/* --- Layout Structure --- */
:root {
    --top-header-height: 64px;
}

/* Top Header - Unified for Desktop & Mobile */
.top-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-header-height);
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    z-index: 50;
    transition: transform 0.3s ease;
}

.top-header.hide {
    transform: translateY(-100%);
}

.top-header-container {
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    gap: 1rem;
    position: relative;
    /* Context for absolute logo */
}

/* Desktop Navigation */
.top-nav {
    display: none;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    margin-left: 2rem;
}

.top-nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.top-nav-item:hover {
    background-color: #F3F4F6;
    color: var(--primary-color);
}

.top-nav-item.active {
    background-color: #EFF6FF;
    color: var(--primary-color);
}

.top-nav-item svg {
    flex-shrink: 0;
}

/* Top Header Right Section */
.top-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Right Navigation Items (학습 현황, 이어서 공부하기) */
.top-nav-right {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

/* CTA Button - Apple SF Style */
.top-nav-cta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: #007AFF;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 2rem;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: none;
}

.top-nav-cta:hover {
    background: #0066D6;
    transform: none;
    box-shadow: none;
}

.top-nav-cta svg {
    flex-shrink: 0;
}

/* Desktop Auth Buttons */
.top-auth-buttons {
    display: none;
    align-items: center;
    gap: 0.75rem;
}

.btn-top-login {
    padding: 0.5rem 1.25rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-top-login:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.btn-top-signup {
    padding: 0.5rem 1.25rem;
    background: linear-gradient(135deg, #38bdf8, #3b82f6);
    color: white;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-top-signup:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

/* User Dropdown */
.user-dropdown {
    display: none;
    position: relative;
}

.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    background: #F9FAFB;
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.user-dropdown-btn:hover {
    background: #F3F4F6;
    border-color: var(--primary-color);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 180px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 100;
    overflow: hidden;
}

.user-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s;
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.dropdown-item:hover {
    background-color: #F9FAFB;
}

.dropdown-item.logout-item {
    color: #EF4444;
    border-top: 1px solid var(--border-color);
}

.dropdown-item.logout-item:hover {
    background-color: #FEF2F2;
}

/* Mobile User Greeting (visible only on mobile) */
.mobile-user-greeting {
    font-size: 0.9rem;
    font-weight: 500;
    /* Prevent overlap with centered logo */
    max-width: 30vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

/* Main Wrapper */
.main-wrapper {
    margin-top: 1rem;
    padding: 0 16px;
    min-height: calc(100vh - var(--top-header-height) - var(--bottom-nav-height));
}

/* --- Desktop Styles (Media Query) --- */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    .mobile-hamburger-btn,
    .mobile-user-greeting,
    .bottom-nav {
        display: none !important;
    }

    .top-nav {
        display: flex;
    }

    .top-auth-buttons {
        display: flex;
    }

    .top-nav-right {
        display: flex;
    }

    .user-dropdown {
        display: block;
    }

    .main-wrapper {
        margin-top: 2rem;
        padding: 0 2rem;
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
        min-height: calc(100vh - var(--top-header-height));
    }
}

/* --- Sidebar Components --- */
.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.sidebar-header .logo {
    position: static;
    transform: none;
    left: auto;
}


/* Base Logo Style (Mobile Centered) */
.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Desktop Logo Reset */
@media (min-width: 768px) {
    .logo {
        position: static;
        transform: none;
        left: auto;
    }
}

.logo img {
    height: 22px;
    width: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-label {
    padding: 0 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    transition: background-color 0.2s;
}

.nav-item:hover {
    background-color: #F9FAFB;
    color: var(--primary-color);
}

.nav-item.active {
    background-color: #EFF6FF;
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

.nav-item .icon {
    margin-right: 0.75rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
    /* Remove text height influence */
}

.nav-item .icon svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
    margin: auto;
    /* Ensure centering in flex container */
}

.nav-item:hover .icon svg {
    transform: scale(1.1);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #F9FAFB;
}

.sidebar-footer .copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

/* --- Bottom Nav (Mobile) --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background-color: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    flex: 1;
    height: 100%;
    gap: 2px;
    transition: color 0.2s ease;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

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

.bottom-nav-item .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.bottom-nav-item .nav-icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.75;
    transition: all 0.2s ease;
}

.bottom-nav-item.active .nav-icon svg {
    stroke: var(--primary-color);
    stroke-width: 2.25;
}

.bottom-nav-item .icon {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

/* Mobile Hamburger Button */
.mobile-hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-right: 8px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    color: var(--text-color);
}

.mobile-hamburger-btn:hover,
.mobile-hamburger-btn:active {
    background-color: rgba(0, 0, 0, 0.05);
}

.mobile-hamburger-btn svg {
    width: 20px;
    height: 20px;
}

/* --- Mobile Menu Overlay --- */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s;
    backdrop-filter: blur(4px);
}

.mobile-menu-overlay.active {
    visibility: visible;
    opacity: 1;
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    background-color: white;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.mobile-menu-overlay.active .mobile-menu-content {
    transform: translateX(0);
}

.mobile-menu-header {
    height: var(--mobile-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: env(safe-area-inset-top) 1.5rem 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-menu-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-muted);
}

.mobile-menu-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.user-profile-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.avatar-circle {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: bold;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details .username {
    font-weight: 600;
    font-size: 1rem;
}

.user-details .email {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.menu-section {
    margin-bottom: 2rem;
}

.menu-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    color: var(--text-color);
    text-decoration: none;
    font-size: 1rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.menu-item .icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    line-height: 0;
    /* Remove text height influence */
}

.menu-item .icon svg {
    width: 20px;
    height: 20px;
    margin: auto;
    /* Ensure centering in flex container */
}

.menu-item:active {
    background-color: #F3F4F6;
}

.menu-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.menu-footer a {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
}

.logout-btn {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: #EF4444;
}

.logout-btn .icon {
    color: #EF4444;
}

/* --- Common UI Components --- */
.container {
    max-width: 1024px;
    margin: 0 auto;
}

h1,
h2,
h3 {
    margin-bottom: 1rem;
}

.page-header {
    margin-bottom: 2rem;
}

.breadcrumb {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.card {
    background-color: var(--card-background);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.btn {
    display: inline-block;
    background: linear-gradient(135deg, #38bdf8, #3b82f6);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
    background-color: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

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

.grid {
    display: grid;
    /* Improved grid for responsiveness */
    grid-template-columns: repeat(1, 1fr);
    /* Default mobile 1 column */
    gap: 1.5rem;
}

@media (min-width: 640px) {

    /* Tablet Portrait */
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {

    /* Desktop */
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* --- Hero Section --- */
.hero {
    background-color: white;
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 3rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.hero h1 {
    font-size: 2rem;
    color: #111827;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.hero p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1.1rem;
    word-break: keep-all;
    /* Improve Korean text wrapping */
}

/* --- Forms --- */
input[type="text"],
input[type="password"],
input[type="email"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 1rem;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #F9FAFB;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* --- Practice Mode & Question Layouts --- */
.question-block {
    background-color: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.choices {
    list-style: none;
}

.choice-item {
    margin-bottom: 0.75rem;
}

.choice-label {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.choice-label:hover {
    background-color: #F9FAFB;
    border-color: var(--primary-color);
}

.choice-label input[type="radio"] {
    margin-right: 0.75rem;
}

/* Feedback Styles */
.result-feedback {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    background-color: #F9FAFB;
    border: 1px solid var(--border-color);
}

.result-feedback.correct {
    background-color: #ECFDF5;
    /* Green-50 */
    border-color: #10B981;
}

.result-feedback.incorrect {
    background-color: #FEF2F2;
    /* Red-50 */
    border-color: #EF4444;
}

.explanation {
    margin-top: 0.5rem;
    color: var(--text-color);
}

/* Score Card */
.score-card {
    text-align: center;
    padding: 3rem 1rem;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.score-display {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 1.5rem 0;
}

/* Mobile User Greeting */
.mobile-user-greeting {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Auth Buttons Sidebar */
.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-login {
    background: rgba(59, 130, 246, 0.08);
    background-image: none;
    color: var(--primary-color);
    border: 1px solid rgba(59, 130, 246, 0.3);
    text-align: center;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-login:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary-color);
    transform: none;
    box-shadow: none;
}

.btn-signup {
    background: white;
    background-image: none;
    color: var(--primary-color);
    border: 1px solid rgba(59, 130, 246, 0.3);
    text-align: center;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-signup:hover {
    background: rgba(59, 130, 246, 0.05);
    border-color: var(--primary-color);
    transform: none;
    box-shadow: none;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.875rem;
}

/* ================================================================
   DARK MODE - Global Theme Override
   Applied when html tag has class="dark"
   ================================================================ */

html.dark {
    --primary-color: #60a5fa;
    --primary-hover: #93c5fd;
    --background-color: #121218;
    --card-background: #1e1e2e;
    --text-color: #e0e0e0;
    --text-muted: #9ca3af;
    --border-color: #2d2d3d;
}

/* Body */
html.dark body {
    background-color: var(--background-color);
    color: var(--text-color);
}

/* --- Top Header --- */
html.dark .top-header {
    background-color: #1a1a2e;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

html.dark .top-nav-item {
    color: #c0c0d0;
}

html.dark .top-nav-item:hover {
    background-color: #2a2a3a;
    color: var(--primary-color);
}

html.dark .top-nav-item.active {
    background-color: rgba(96, 165, 250, 0.12);
    color: var(--primary-color);
}

html.dark .top-nav-cta {
    background: #3b82f6;
}

html.dark .top-nav-cta:hover {
    background: #2563eb;
}

/* --- User Dropdown --- */
html.dark .user-dropdown-btn {
    background: #2a2a3a;
    border-color: #3d3d4d;
}

html.dark .user-dropdown-btn:hover {
    background: #333344;
    border-color: var(--primary-color);
}

html.dark .user-name {
    color: #e0e0e0;
}

html.dark .user-dropdown-menu {
    background: #1e1e2e;
    border-color: #2d2d3d;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

html.dark .dropdown-item {
    color: #d0d0e0;
}

html.dark .dropdown-item:hover {
    background-color: #2a2a3a;
}

html.dark .dropdown-item.logout-item {
    color: #f87171;
    border-top-color: #2d2d3d;
}

html.dark .dropdown-item.logout-item:hover {
    background-color: #2a1a1a;
}

/* --- Auth Buttons --- */
html.dark .btn-top-login {
    color: var(--primary-color);
}

html.dark .btn-top-login:hover {
    background-color: rgba(96, 165, 250, 0.1);
}

html.dark .btn-top-signup {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

/* --- Logo --- */
html.dark .logo img {
    filter: brightness(1.2);
}

/* --- Bottom Nav (Mobile) --- */
html.dark .bottom-nav {
    background-color: #1a1a2e;
    border-top-color: #2d2d3d;
}

html.dark .bottom-nav-item {
    color: #7a7a8a;
}

html.dark .bottom-nav-item.active {
    color: var(--primary-color);
}

/* --- Mobile Menu --- */
html.dark .mobile-menu-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

html.dark .mobile-menu-content {
    background-color: #1a1a2e;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
}

html.dark .mobile-menu-header {
    border-bottom-color: #2d2d3d;
}

html.dark .mobile-menu-header h2 {
    color: #e0e0e0;
}

html.dark .close-btn {
    color: #9ca3af;
}

html.dark .avatar-circle {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

html.dark .user-profile-summary {
    border-bottom-color: #2d2d3d;
}

html.dark .user-details .username {
    color: #e0e0e0;
}

html.dark .user-details .email {
    color: #7a7a8a;
}

html.dark .menu-section h3 {
    color: #7a7a8a;
}

html.dark .menu-item {
    color: #d0d0e0;
}

html.dark .menu-item:active {
    background-color: #2a2a3a;
}

html.dark .logout-btn {
    color: #f87171;
}

html.dark .logout-btn .icon {
    color: #f87171;
}

html.dark .menu-footer {
    border-top-color: #2d2d3d;
}

html.dark .menu-footer a {
    color: #7a7a8a;
}

/* --- Mobile Hamburger --- */
html.dark .mobile-hamburger-btn {
    color: #d0d0e0;
}

html.dark .mobile-hamburger-btn:hover,
html.dark .mobile-hamburger-btn:active {
    background-color: rgba(255, 255, 255, 0.08);
}

/* --- Mobile User Greeting --- */
html.dark .mobile-user-greeting {
    color: #d0d0e0;
}

html.dark .mobile-user-greeting a {
    color: #d0d0e0 !important;
}

/* --- Cards --- */
html.dark .card {
    background-color: var(--card-background);
    border-color: var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* --- Forms --- */
html.dark input[type="text"],
html.dark input[type="password"],
html.dark input[type="email"],
html.dark select,
html.dark textarea {
    background-color: #2a2a3a;
    border-color: #3d3d4d;
    color: #e0e0e0;
}

html.dark input[type="text"]:focus,
html.dark input[type="password"]:focus,
html.dark input[type="email"]:focus,
html.dark select:focus,
html.dark textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

html.dark input::placeholder,
html.dark textarea::placeholder {
    color: #6a6a7a;
}

/* --- Headings --- */
html.dark h1,
html.dark h2,
html.dark h3 {
    color: #e0e0e0;
}

/* --- Links --- */
html.dark a {
    color: var(--primary-color);
}

html.dark .breadcrumb,
html.dark .breadcrumb a {
    color: #7a7a8a;
}

/* --- Sidebar --- */
html.dark .sidebar-footer {
    border-top-color: #2d2d3d;
    background-color: #1a1a28;
}

html.dark .sidebar-footer .copyright {
    color: #7a7a8a;
}

html.dark .nav-item:hover {
    background-color: #2a2a3a;
}

html.dark .nav-item.active {
    background-color: rgba(96, 165, 250, 0.12);
    border-right-color: var(--primary-color);
}

/* --- Toast --- */
html.dark .simple-toast {
    background-color: #2a2a3a;
    color: #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* --- Common UI sections --- */
html.dark .page-header {
    color: #e0e0e0;
}

/* --- Section titles often used across pages --- */
html.dark .section-title {
    color: #e0e0e0;
}

/* --- Empty states --- */
html.dark .empty-state-page {
    background: #1e1e2e;
    border-color: #2d2d3d;
    color: #9ca3af;
}

/* --- Auth pages --- */
html.dark .btn-login {
    background: var(--primary-color);
}

html.dark .btn-signup {
    color: var(--primary-color);
    border-color: #3d3d4d;
}

html.dark .btn-signup:hover {
    border-color: var(--primary-color);
}

/* --- Desktop Footer --- */
.desktop-footer {
    display: none;
    background-color: #F9FAFB;
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 3rem;
}

@media (min-width: 768px) {
    .desktop-footer {
        display: block;
    }
}

.desktop-footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Dark Mode Footer */
html.dark .desktop-footer {
    background-color: #1a1a2e;
    border-top-color: #2d2d3d;
}

html.dark .desktop-footer-container {
    color: #7a7a8a;
}

html.dark .footer-links a {
    color: #7a7a8a;
}

html.dark .footer-links a:hover {
    color: var(--primary-color);
}

/* --- Policy Pages (Terms & Privacy) --- */
.policy-content {
    line-height: 1.8;
    color: var(--text-color);
}

.policy-content h1 {
    margin-bottom: 2rem;
    font-size: 1.75rem;
    font-weight: 700;
}

.policy-content h2 {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.policy-content p {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.policy-content ul {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
    list-style-type: disc;
}

.policy-content li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.policy-content .last-updated {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    text-align: right;
}

/* Dark Mode Overrides for Policy Pages */
html.dark .policy-content h2 {
    border-bottom-color: #2d2d3d;
    color: #e0e0e0;
}

html.dark .policy-content p,
html.dark .policy-content li {
    color: #d0d0e0;
}

html.dark .policy-content .last-updated {
    color: #7a7a8a;
}

/* Ensure question-block has dark mode background */
html.dark .question-block {
    background-color: #1e1e2e;
    /* Darker card background */
    border: 1px solid #2d2d3d;
    color: #e0e0e0;
}