﻿:root {
    --bg-top: #eef5ff;
    --bg-bottom: #fdf6ec;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --text: #1f2a44;
    --muted: #5f6b84;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --border: rgba(148, 163, 184, 0.35);
    --shadow: 0 18px 40px rgba(30, 64, 175, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 92% 10%, rgba(245, 158, 11, 0.22), transparent 46%),
        radial-gradient(circle at 10% 4%, rgba(37, 99, 235, 0.16), transparent 40%),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    min-height: 100vh;
}

.layout {
    max-width: 1220px;
    margin: 18px auto;
    padding: 0 16px 24px;
}

.auth-layout {
    max-width: 560px;
    margin: 46px auto;
    padding: 0 16px;
}

.auth-card {
    padding: 20px;
}

.auth-form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.tab {
    flex: 1;
    border-radius: 12px;
    background: #e8efff;
    color: #1e3a8a;
}

.tab.active {
    background: var(--primary);
    color: #fff;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
}

.top-nav {
    display: flex;
    gap: 8px;
    padding: 8px;
    margin-bottom: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f6ff;
    border: 1px solid #d9e3fb;
    border-radius: 12px;
    padding: 6px 8px;
    color: #1e3a8a;
    font-size: 13px;
}

.nav-item {
    padding: 10px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: #1e3a8a;
    background: #eaf1ff;
    font-weight: 700;
}

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

.hero {
    padding: 20px 24px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.kicker {
    margin: 0 0 6px;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.3px;
    font-size: 13px;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: clamp(1.2rem, 2.5vw, 2rem);
}

h2 {
    font-size: 1.2rem;
}

.subtitle {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.8;
}

.hero-badge {
    background: linear-gradient(140deg, #1d4ed8 0%, #0ea5e9 100%);
    color: #fff;
    border-radius: 16px;
    padding: 14px 18px;
    min-width: 130px;
    text-align: center;
}

.hero-badge span {
    display: block;
    font-size: 13px;
    opacity: 0.9;
}

.hero-badge strong {
    font-size: 20px;
}

.panel {
    padding: 18px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 14px;
    margin-top: 14px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}

.grid {
    display: grid;
    gap: 10px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

input,
textarea,
select,
button {
    font: inherit;
}

input,
textarea,
select {
    border: 1px solid #d4deec;
    background: var(--surface-strong);
    border-radius: 12px;
    padding: 10px 12px;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

textarea {
    resize: vertical;
    min-height: 120px;
}

#question_text,
#formula_compose_text {
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
}

.exam-answer-textarea {
    width: 100%;
    min-height: 240px;
    line-height: 1.9;
}

.input-box {
    margin-top: 10px;
    border: 1px dashed #c8d7ef;
    border-radius: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.75);
}

.input-box h3 {
    margin-bottom: 8px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.actions.tight {
    margin-top: 8px;
    align-items: center;
}

.align-end {
    align-items: end;
}

button,
.file-btn {
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.12s ease, background 0.2s ease;
}

button:hover,
.file-btn:hover {
    background: var(--primary-hover);
}

button:active,
.file-btn:active {
    transform: translateY(1px);
}

button.secondary,
.file-btn.secondary {
    background: #334155;
}

button.secondary:hover,
.file-btn.secondary:hover {
    background: #1e293b;
}

button.ghost {
    background: #eef2ff;
    color: #1e3a8a;
}

button.ghost:hover {
    background: #dbe7ff;
}

button.mode-active {
    background: #c7d8ff;
    color: #1e3a8a;
    box-shadow: inset 0 0 0 1px #7ea1f5;
}

button.accent {
    background: var(--accent);
}

button.accent:hover {
    background: var(--accent-hover);
}

button.danger {
    background: var(--danger);
}

button.danger:hover {
    background: var(--danger-hover);
}

.file-btn input {
    display: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    background: #e0ecff;
    color: #1e40af;
    font-size: 12px;
    font-weight: 700;
}

.badge.neutral {
    background: #fff8e8;
    color: #b45309;
}

.question-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
    max-height: 460px;
    overflow: auto;
}

.question-item {
    border: 1px solid #dce5f3;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.75);
    padding: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.12s ease, background 0.2s ease;
}

.question-item:hover {
    border-color: #93b2f5;
}

.question-item.active {
    border-color: var(--primary);
    background: #edf4ff;
    transform: translateY(-1px);
}

.question-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.question-meta {
    color: var(--muted);
    font-size: 12px;
}

.question-text {
    color: #273248;
    line-height: 1.7;
    font-size: 14px;
}

.question-text-large {
    margin: 8px 0 14px;
    line-height: 1.9;
}

.sticky-actions {
    padding-top: 12px;
    border-top: 1px solid #e1e8f5;
    margin-top: 12px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.item-card {
    border: 1px solid #dce5f3;
    border-radius: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.85);
    line-height: 1.8;
}

.item-card h3 {
    margin-bottom: 4px;
}

.question-stage {
    border: 1px solid #e3e8f5;
    border-radius: 16px;
    padding: 14px;
    margin-top: 10px;
    background: #fff;
}

.choice-row {
    border: 1px solid #dce5f3;
    border-radius: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 9px 10px;
    margin-bottom: 8px;
    cursor: pointer;
}

.grading-list {
    display: grid;
    gap: 10px;
    margin: 12px 0;
}

.grading-item {
    border: 1px solid #dce5f3;
    border-radius: 14px;
    background: #fff;
    padding: 12px;
    line-height: 1.9;
}

.status {
    margin: 14px 4px 0;
    font-size: 13px;
    color: #334155;
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.hidden {
    display: none !important;
}

.auth-layout {
    max-width: 700px;
}

.auth-card {
    padding: 24px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin: 14px 0;
}

.auth-tabs button {
    flex: 1;
    background: #e5e7eb;
    color: #1f2937;
}

.auth-tabs button.active {
    background: var(--primary);
    color: #fff;
}

.auth-form {
    display: grid;
    gap: 10px;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    color: var(--muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
}

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

.slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #cbd5e1;
    transition: 0.2s ease;
}

.slider::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    right: 3px;
    top: 3px;
    border-radius: 50%;
    background: #fff;
    transition: 0.2s ease;
}

.switch input:checked + .slider {
    background: #16a34a;
}

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

.danger-mark {
    background: #fee2e2;
    color: #b91c1c;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.modal-box {
    width: min(860px, 100%);
    max-height: 90vh;
    overflow: auto;
    padding: 16px;
}

.modal.liquid-glass-modal {
    background:
        radial-gradient(460px 220px at 80% 10%, rgba(56, 189, 248, 0.22), transparent 65%),
        radial-gradient(460px 220px at 15% 90%, rgba(59, 130, 246, 0.18), transparent 65%),
        rgba(2, 6, 23, 0.5);
    backdrop-filter: blur(4px);
}

.modal-box.liquid-glass-box {
    max-width: 520px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.36);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.14));
    box-shadow:
        0 24px 42px rgba(15, 23, 42, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.58);
    backdrop-filter: blur(14px) saturate(132%);
    -webkit-backdrop-filter: blur(14px) saturate(132%);
}

#global_app_modal .liquid-glass-btn {
    min-width: 150px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #123a7a;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2));
    box-shadow: 0 8px 20px rgba(30, 58, 138, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#global_app_modal .liquid-glass-btn:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.28));
    transform: translateY(-1px);
}

#global_app_modal .liquid-glass-btn-accent {
    color: #fff;
    border-color: rgba(14, 165, 233, 0.68);
    background: linear-gradient(145deg, rgba(56, 189, 248, 0.95), rgba(37, 99, 235, 0.88));
    box-shadow: 0 10px 24px rgba(14, 116, 144, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#global_app_modal .liquid-glass-btn-accent:hover {
    background: linear-gradient(145deg, rgba(14, 165, 233, 0.98), rgba(29, 78, 216, 0.92));
}

.formula-mathfield {
    width: 100%;
    min-height: 56px;
    border: 1px solid #d4deec;
    border-radius: 12px;
    background: #fff;
    padding: 10px 12px;
    margin-top: 8px;
}

.formula-tools {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 8px;
}

.formula-token-btn {
    width: 100%;
    padding: 8px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.formula-preview-wrap {
    margin-top: 12px;
    border: 1px dashed #c8d7ef;
    border-radius: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
}

.formula-preview {
    margin-top: 8px;
    min-height: 40px;
    line-height: 1.8;
    overflow-x: auto;
}

#formula_modal .formula-modal-box {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.12));
    border: 1px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(14px) saturate(130%);
    -webkit-backdrop-filter: blur(14px) saturate(130%);
}

#formula_modal button {
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.14));
    color: #163a79;
    box-shadow: 0 8px 22px rgba(30, 58, 138, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#formula_modal button:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.22));
}

#formula_modal button.mode-active {
    background: linear-gradient(145deg, rgba(56, 189, 248, 0.36), rgba(59, 130, 246, 0.28));
    border-color: rgba(56, 189, 248, 0.8);
    color: #0b2a5b;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.28), 0 8px 22px rgba(14, 116, 144, 0.25);
}

:root[data-theme="dark"] #formula_modal .formula-modal-box {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.45));
    border-color: rgba(148, 163, 184, 0.3);
}

:root[data-theme="dark"] #formula_modal button {
    color: #dbeafe;
    border-color: rgba(148, 163, 184, 0.3);
    background: linear-gradient(145deg, rgba(51, 65, 85, 0.62), rgba(30, 41, 59, 0.46));
    box-shadow: 0 8px 20px rgba(2, 6, 23, 0.35), inset 0 1px 0 rgba(203, 213, 225, 0.1);
}

:root[data-theme="dark"] #formula_modal button.mode-active {
    background: linear-gradient(145deg, rgba(14, 165, 233, 0.45), rgba(59, 130, 246, 0.35));
    border-color: rgba(125, 211, 252, 0.85);
    color: #eff6ff;
}

:root[data-theme="dark"] .modal {
    background: rgba(2, 6, 23, 0.65);
}

:root[data-theme="dark"] .formula-mathfield {
    background: #1f2a3d;
    border-color: #334155;
}

:root[data-theme="dark"] .formula-preview-wrap {
    background: rgba(15, 23, 42, 0.55);
    border-color: #334155;
}

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

    .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .grid-2,
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        flex-direction: column;
        align-items: flex-start;
    }

    button,
    .file-btn {
        width: 100%;
        text-align: center;
    }

    .actions.tight {
        flex-direction: column;
        align-items: stretch;
    }

    .formula-tools {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

:root[data-theme="dark"] {
    --bg-top: #0b1220;
    --bg-bottom: #121a2b;
    --surface: rgba(22, 30, 46, 0.92);
    --surface-strong: #1f2a3d;
    --text: #e5edf8;
    --muted: #98a9c3;
    --primary: #4f8dff;
    --primary-hover: #3f7ef3;
    --accent: #f59e0b;
    --accent-hover: #e28f09;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --border: rgba(88, 109, 142, 0.45);
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #dce5f3;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 999px;
    padding: 6px 10px;
}

.chip-remove {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #e2e8f0;
    color: #334155;
    cursor: pointer;
    padding: 0;
}

.soft {
    margin-top: 12px;
    padding: 12px;
}

:root[data-theme="dark"] .nav-item {
    background: #27344c;
    color: #dfe8f7;
}

:root[data-theme="dark"] .nav-item.active {
    background: var(--primary);
    color: #fff;
}

:root[data-theme="dark"] .item-card,
:root[data-theme="dark"] .question-item,
:root[data-theme="dark"] .question-stage,
:root[data-theme="dark"] .grading-item,
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .input-box {
    background: rgba(20, 28, 43, 0.9);
    border-color: #334865;
}

:root[data-theme="dark"] .badge {
    background: #1f3f77;
    color: #d8e6ff;
}

:root[data-theme="dark"] .badge.neutral {
    background: #4d3d1c;
    color: #ffe3a8;
}

:root[data-theme="dark"] .danger-mark {
    background: #51202a;
    color: #ffc2ca;
}

:root[data-theme="dark"] button.ghost {
    background: #1f2f47;
    color: #dbe8ff;
}

:root[data-theme="dark"] .choice-row {
    border-color: #38506f;
}

.site-footer {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 0.95rem;
}

.site-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.site-footer a:hover {
    text-decoration: underline;
}

.check-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.enamad-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    min-height: 40px;
    padding: 4px;
}

.grade-list-modal-box {
    width: min(980px, 100%);
}

.table-wrap {
    overflow-x: auto;
}

.gradebook-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    empty-cells: show;
    margin-top: 10px;
    font-size: 0.97rem;
    border: 1px solid #cbd5e1;
}

.gradebook-table .col-row {
    width: 70px;
}

.gradebook-table .col-name {
    width: auto;
}

.gradebook-table .col-score {
    width: 120px;
}

.gradebook-table th,
.gradebook-table td {
    border: 1px solid #cbd5e1;
    padding: 10px 12px;
    text-align: right;
    vertical-align: middle;
    word-break: break-word;
}

.gradebook-table td:nth-child(1),
.gradebook-table th:nth-child(1),
.gradebook-table td:nth-child(3),
.gradebook-table th:nth-child(3) {
    text-align: center;
}

.gradebook-table thead th {
    background: rgba(59, 130, 246, 0.1);
}

.gradebook-table tfoot td {
    font-weight: 800;
    background: rgba(16, 185, 129, 0.1);
}

:root[data-theme="dark"] .gradebook-table {
    border-color: #475569;
}

:root[data-theme="dark"] .gradebook-table th,
:root[data-theme="dark"] .gradebook-table td {
    border-color: #475569;
}

details {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.75);
}

details summary {
    cursor: pointer;
    margin-bottom: 10px;
}

.user-school-group {
    width: 100%;
    margin-bottom: 10px;
}

.user-school-group > .cards-grid {
    margin-top: 10px;
}

:root[data-theme="dark"] details {
    background: rgba(20, 28, 43, 0.9);
    border-color: #334865;
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 74px;
    justify-content: center;
}

.theme-switch-icon {
    font-size: 1rem;
}

.theme-switch-track {
    width: 34px;
    height: 18px;
    border-radius: 999px;
    background: #dbe4f3;
    position: relative;
}

.theme-switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.2s ease;
}

.theme-switch.is-dark .theme-switch-track {
    background: #4a5f82;
}

.theme-switch.is-dark .theme-switch-track::after {
    left: 18px;
}

.home-hero {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 18px;
}

.hero-media img {
    width: 100%;
    height: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 18px;
    border: 1px solid var(--line);
}

.receipt-thumb {
    width: 100%;
    max-width: 240px;
    border-radius: 14px;
    border: 1px solid var(--line);
}

@media (max-width: 900px) {
    .home-hero {
        grid-template-columns: 1fr;
    }
}

/* Global UI Refresh */
:root {
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --surface-soft: rgba(255, 255, 255, 0.74);
    --line: rgba(148, 163, 184, 0.25);
}

body {
    background:
        radial-gradient(900px 500px at 95% -10%, rgba(59, 130, 246, 0.12), transparent 60%),
        radial-gradient(900px 500px at -10% 5%, rgba(14, 165, 233, 0.08), transparent 60%),
        linear-gradient(180deg, #f8fbff 0%, #f5f7fb 100%);
    color: #182136;
}

.layout {
    max-width: 1280px;
    padding: 18px 18px 32px;
}

.card {
    border-radius: var(--radius-xl);
    border: 1px solid var(--line);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    background: var(--surface-soft);
    backdrop-filter: blur(10px);
}

.panel {
    padding: 22px;
}

.top-nav {
    position: sticky;
    top: 10px;
    z-index: 50;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(14px);
    border-radius: 18px;
    margin-bottom: 14px;
}

.nav-item {
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0;
}

.hero {
    border-radius: 26px;
}

.hero h1 {
    letter-spacing: -0.2px;
}

.subtitle {
    line-height: 1.95;
}

.grid,
.cards-grid,
.content-grid {
    gap: 14px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 320px));
    justify-content: start;
    align-items: start;
}

#plans_container.cards-grid,
#home_plans.cards-grid,
#subscription_plans_container.cards-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
}

.content-grid {
    grid-template-columns: 1.15fr 0.95fr;
}

label {
    font-weight: 500;
    color: #445170;
}

input,
textarea,
select {
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.38);
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 13px;
}

input::placeholder,
textarea::placeholder {
    color: #96a0b5;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(59, 130, 246, 0.55);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
}

button,
.file-btn {
    border-radius: 999px;
    font-weight: 700;
    padding: 10px 16px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}

button.secondary,
.file-btn.secondary {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
}

button.ghost {
    box-shadow: none;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.item-card,
.question-item,
.grading-item,
.question-stage,
.chip,
.input-box,
details {
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(255, 255, 255, 0.78);
}

.item-card,
.grading-item {
    padding: 14px;
}

.question-item {
    padding: 12px;
}

.question-item.active {
    border-color: rgba(37, 99, 235, 0.55);
}

.status {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    font-weight: 600;
}

.modal .modal-box {
    border-radius: 22px;
    width: min(560px, calc(100% - 24px));
}

.site-footer {
    border-radius: 16px;
    padding: 12px 14px;
    margin-top: 14px;
}

.site-footer a {
    font-weight: 700;
}

.auth-card {
    max-width: 760px;
    margin: 0 auto;
}

.auth-tabs button {
    border-radius: 999px;
}

.home-hero {
    align-items: stretch;
}

.hero-media img {
    border-radius: 20px;
    min-height: 260px;
}

.receipt-thumb {
    margin-top: 8px;
}

.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.switch {
    display: inline-flex;
    align-items: center;
}

.switch input {
    display: none;
}

.switch .slider {
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: #d5dbe9;
    position: relative;
    transition: 0.2s ease;
}

.switch .slider::before {
    content: none !important;
    display: none !important;
}

.switch .slider::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    transition: 0.2s ease;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.switch input:checked + .slider {
    background: #16a34a;
}

.switch input:checked + .slider::after {
    left: 23px;
}

.dot-badge {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    margin-right: 6px;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.16);
}

.upload-progress-wrap {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.upload-progress-wrap progress {
    width: 100%;
    height: 12px;
    accent-color: #16a34a;
}

.clickable-plan {
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.clickable-plan:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.55);
    box-shadow: 0 10px 26px rgba(59, 130, 246, 0.14);
}

:root[data-theme="dark"] body {
    background:
        radial-gradient(900px 500px at 95% -10%, rgba(96, 165, 250, 0.18), transparent 60%),
        radial-gradient(900px 500px at -10% 5%, rgba(56, 189, 248, 0.12), transparent 60%),
        linear-gradient(180deg, #0c1322 0%, #0b1220 100%);
    color: #e7edf9;
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .top-nav {
    background: rgba(18, 27, 43, 0.88);
    border-color: rgba(71, 92, 126, 0.5);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] label {
    color: #c0cbe3;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select {
    color: #e4ebf8;
    background: rgba(15, 23, 39, 0.9);
    border-color: rgba(88, 108, 140, 0.65);
}

:root[data-theme="dark"] .item-card,
:root[data-theme="dark"] .question-item,
:root[data-theme="dark"] .grading-item,
:root[data-theme="dark"] .question-stage,
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .input-box,
:root[data-theme="dark"] details {
    background: rgba(14, 22, 37, 0.88);
    border-color: rgba(73, 94, 128, 0.55);
}

:root[data-theme="dark"] .status {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    #plans_container.cards-grid,
    #home_plans.cards-grid,
    #subscription_plans_container.cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .layout {
        padding: 12px;
    }
    .panel {
        padding: 16px;
    }
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
    .hero {
        flex-direction: column;
        align-items: flex-start;
    }
    #plans_container.cards-grid,
    #home_plans.cards-grid,
    #subscription_plans_container.cards-grid {
        grid-template-columns: 1fr;
    }
}

/* Layout and hierarchy refinements */
.layout {
    max-width: 1140px;
}

h1 {
    font-size: clamp(1.8rem, 2.8vw, 2rem);
    font-weight: 800;
}

h2,
.panel > h2,
.section-head h2 {
    font-size: clamp(1.35rem, 2vw, 1.5rem);
    font-weight: 800;
}

.item-card h3,
.question-stage h3,
.modal-box h3 {
    font-size: 1.25rem;
    font-weight: 800;
}

.subtitle {
    font-size: 1rem;
}

.muted,
.question-meta {
    font-size: 13px;
}

.content-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

label {
    gap: 6px;
}

input,
select {
    min-height: 50px;
    border-radius: 16px;
    padding: 10px 12px;
}

textarea {
    border-radius: 16px;
    padding: 10px 12px;
}

.field-cluster {
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
}

.dense-grid {
    gap: 12px;
}

.cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 280px));
    gap: 12px;
}

.item-card {
    padding: 12px;
    display: grid;
    gap: 6px;
    line-height: 1.6;
}

.item-card .actions {
    margin-top: 8px;
}

/* Mobile header + drawer */
.mobile-nav-shell {
    display: none;
}

.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    margin-bottom: 10px;
}

.mobile-header-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
    text-align: center;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-menu-btn,
.mobile-header-action,
.mobile-drawer-item {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #eef2ff;
    color: #1e3a8a;
    text-decoration: none;
    font-weight: 700;
}

.mobile-menu-btn,
.mobile-header-action {
    min-height: 42px;
    padding: 8px 10px;
}

.mobile-header-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.mobile-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    border: none;
    background: rgba(2, 6, 23, 0.45);
    z-index: 210;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(88vw, 320px);
    padding: 12px;
    transform: translateX(104%);
    transition: transform 0.2s ease;
    z-index: 220;
    border-radius: 18px 0 0 18px;
    overflow-y: auto;
}

.mobile-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
}

.mobile-drawer-list {
    display: grid;
    gap: 8px;
}

.mobile-drawer-item {
    display: block;
    width: 100%;
    text-align: right;
    padding: 11px 12px;
}

.mobile-drawer-item.active {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
}

body.mobile-nav-open {
    overflow: hidden;
}

body.mobile-nav-open .mobile-drawer-backdrop {
    display: block;
}

body.mobile-nav-open .mobile-drawer {
    transform: translateX(0);
}

@media (max-width: 760px) {
    .top-nav {
        display: none;
    }

    .mobile-nav-shell {
        display: block;
        position: sticky;
        top: 8px;
        z-index: 60;
    }

    .hero {
        display: none;
    }

    .panel {
        padding: 14px;
    }

    .grid {
        gap: 14px;
    }

    .content-grid {
        grid-template-columns: 1fr !important;
    }

    .dense-grid {
        gap: 14px;
    }

    input,
    select,
    textarea {
        min-height: 48px;
        border-radius: 15px;
        padding: 9px 11px;
    }

    textarea {
        min-height: 108px;
    }

    .actions {
        gap: 8px;
    }

    .actions button,
    .actions .file-btn {
        width: auto;
        flex: 1 1 calc(50% - 8px);
        min-height: 46px;
        border-radius: 14px;
        padding: 9px 10px;
    }

    .sticky-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .sticky-actions button {
        margin: 0;
        width: 100%;
        min-height: 44px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .item-card {
        padding: 11px;
        gap: 5px;
    }
}

@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr !important;
    }
}

:root[data-theme="dark"] .mobile-menu-btn,
:root[data-theme="dark"] .mobile-header-action,
:root[data-theme="dark"] .mobile-drawer-item {
    background: #1f2f47;
    color: #dbe8ff;
    border-color: rgba(88, 108, 140, 0.65);
}

.org-teacher-pick-list {
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 16px;
    padding: 10px;
    max-height: 420px;
    overflow-y: auto;
    display: grid;
    gap: 8px;
}

.org-teacher-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.78);
}

.org-teacher-row p {
    margin-top: 3px;
    font-size: 0.92rem;
}

.org-teacher-row .check-row {
    justify-self: end;
}

:root[data-theme="dark"] .org-teacher-pick-list {
    border-color: rgba(88, 108, 140, 0.65);
}

:root[data-theme="dark"] .org-teacher-row {
    background: rgba(14, 22, 37, 0.88);
    border-color: rgba(73, 94, 128, 0.55);
}

.question-bank-modal-box {
  width: min(980px, 96vw);
}

.question-bank-course-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.question-bank-course-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.question-bank-question-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-bank-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.question-bank-meta {
  margin: 0;
  font-size: 0.86rem;
  opacity: 0.85;
}

.question-bank-text {
  margin: 0;
}

.question-bank-image {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.question-bank-option-list {
  margin: 0;
  padding-inline-start: 22px;
  display: grid;
  gap: 4px;
}

.question-bank-add-row {
  align-items: end;
}
