:root {
    --bg: #eef2ec;
    --panel: rgba(255, 255, 252, 0.93);
    --panel-strong: #ffffff;
    --ink: #17202b;
    --muted: #5c6876;
    --accent: #b95d35;
    --accent-deep: #7b351d;
    --accent-soft: rgba(185, 93, 53, 0.12);
    --blue: #285d8f;
    --green: #2d735a;
    --gold: #b3862f;
    --danger: #a6403a;
    --line: rgba(23, 32, 43, 0.14);
    --shadow: 0 18px 46px rgba(15, 23, 35, 0.16);
    --radius: 8px;
    --sidebar: rgba(15, 24, 36, 0.88);
    --input: rgba(255, 255, 255, 0.92);
}

html[data-theme="calm"] {
    --bg: #eef5f1;
    --panel: rgba(250, 255, 253, 0.94);
    --ink: #142622;
    --muted: #566a65;
    --accent: #327c6b;
    --accent-deep: #1f5247;
    --accent-soft: rgba(50, 124, 107, 0.14);
    --blue: #366f9c;
    --green: #2d735a;
    --gold: #a06d2a;
    --sidebar: rgba(16, 39, 35, 0.9);
}

html[data-theme="midnight"] {
    --bg: #111823;
    --panel: rgba(24, 33, 45, 0.94);
    --panel-strong: #202b39;
    --ink: #f1f5f4;
    --muted: #b7c2ce;
    --accent: #dd8b4d;
    --accent-deep: #ffc08c;
    --accent-soft: rgba(221, 139, 77, 0.16);
    --blue: #79a8d8;
    --green: #79c7a8;
    --gold: #e4bb66;
    --danger: #ff8f83;
    --line: rgba(255, 255, 255, 0.14);
    --sidebar: rgba(6, 10, 16, 0.92);
    --input: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(12, 20, 32, 0.76), rgba(38, 83, 86, 0.36)),
        var(--page-image, linear-gradient(135deg, #1a2634, #6a7b72));
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: rgba(8, 13, 20, 0.08);
}

a {
    color: inherit;
}

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

button {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    display: grid;
    grid-template-columns: 282px minmax(0, 1fr);
    min-height: 100vh;
    position: relative;
}

.sidebar {
    padding: 22px 18px;
    background: var(--sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 4;
    overflow-y: auto;
    backdrop-filter: blur(16px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    color: #fff9f2;
}

.brand img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.12);
    padding: 6px;
}

.brand-copy h1,
.brand-copy p {
    margin: 0;
}

.brand-copy h1 {
    font-size: 1.22rem;
    letter-spacing: 0;
}

.brand-copy p {
    color: rgba(255, 249, 242, 0.72);
    font-size: 0.9rem;
}

.nav-links {
    display: grid;
    gap: 7px;
}

.nav-links a,
.nav-feedback-button {
    text-decoration: none;
    padding: 12px 13px;
    border-radius: var(--radius);
    color: rgba(255, 249, 242, 0.87);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
    text-align: left;
    cursor: pointer;
}

.nav-links a:hover,
.nav-links a.active,
.nav-feedback-button:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateX(3px);
}

.sidebar-note {
    margin-top: 20px;
    padding: 14px;
    border-radius: var(--radius);
    color: rgba(255, 249, 242, 0.88);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-note p {
    margin: 6px 0 0;
}

.sidebar-toggle {
    display: none;
}

.main {
    width: min(1440px, 100%);
    padding: 26px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-title h2,
.page-title p {
    margin: 0;
}

.page-title h2 {
    font-size: clamp(2rem, 3vw, 3.25rem);
    color: #fff9f2;
    line-height: 1;
}

.page-title p {
    color: rgba(255, 249, 242, 0.88);
    margin-top: 9px;
    max-width: 760px;
    line-height: 1.5;
}

.topbar-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.badge,
.clock-chip {
    background: rgba(255, 255, 255, 0.13);
    color: #fff9f2;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius);
    padding: 10px 13px;
    backdrop-filter: blur(10px);
}

.dashboard-grid,
.two-column,
.three-column,
.resource-grid,
.settings-grid {
    display: grid;
    gap: 18px;
}

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

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

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

.settings-grid {
    grid-template-columns: 1.1fr 0.9fr;
}

.card,
.resource-card {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    padding: 20px;
}

.hero-card {
    grid-column: span 7;
}

.side-card {
    grid-column: span 5;
}

.wide-card {
    grid-column: span 12;
}

.half-card {
    grid-column: span 6;
}

.card h3,
.card p,
.resource-card h3,
.resource-card p {
    margin-top: 0;
}

.card-header,
.embed-header,
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    color: var(--accent-deep);
    margin-bottom: 7px;
    font-weight: 700;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.9rem;
}

.stack,
.list,
.subject-list,
.resource-list,
.ai-output,
.activity-list {
    display: grid;
    gap: 11px;
}

.button-row,
.inline-form,
.toolbar,
.chip-row,
.tab-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-form > * {
    flex: 1 1 170px;
}

.btn {
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 11px 14px;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    gap: 8px;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:focus-visible,
.field:focus,
.textarea:focus,
.select:focus,
.subject-button:focus-visible {
    outline: 3px solid rgba(40, 93, 143, 0.28);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent);
    color: #fff9f2;
}

.btn-secondary {
    background: var(--accent-soft);
    color: var(--accent-deep);
    border-color: rgba(185, 93, 53, 0.15);
}

.btn-danger {
    background: rgba(166, 64, 58, 0.12);
    color: var(--danger);
    border-color: rgba(166, 64, 58, 0.16);
}

.btn-ghost {
    background: rgba(23, 32, 43, 0.06);
    color: var(--ink);
    border-color: var(--line);
}

.btn[disabled] {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.field,
.textarea,
.select {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--input);
    border-radius: var(--radius);
    padding: 12px 13px;
    color: var(--ink);
    min-height: 44px;
}

.field-label {
    display: grid;
    align-content: center;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.field::placeholder,
.textarea::placeholder {
    color: rgba(92, 104, 118, 0.8);
}

.studyquest-footer {
    width: min(1440px, calc(100% - 282px));
    margin-left: 282px;
    padding: 18px 26px 28px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    color: rgba(255, 249, 242, 0.88);
    position: relative;
    z-index: 2;
}

.studyquest-footer button,
.studyquest-footer a {
    min-height: 40px;
    padding: 9px 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.12);
    color: #fff9f2;
    text-decoration: none;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.feedback-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(7, 12, 20, 0.56);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.feedback-backdrop.open {
    opacity: 1;
}

.feedback-modal {
    width: min(680px, 100%);
    display: grid;
    gap: 14px;
    padding: 22px;
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.36);
    box-shadow: var(--shadow);
    transform: translateY(16px) scale(0.98);
    animation: feedbackIn 0.2s ease forwards;
}

.feedback-modal.is-submitting {
    animation: feedbackSubmit 0.34s ease;
}

.feedback-modal-header,
.feedback-modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.feedback-modal-header h2 {
    margin: 0;
}

.feedback-close {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel-strong);
    color: var(--ink);
    cursor: pointer;
    font-size: 1.35rem;
}

.feedback-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
}

.feedback-rating {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 9px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel-strong);
}

.feedback-rating button {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: var(--radius);
    color: rgba(179, 134, 47, 0.42);
    background: transparent;
    cursor: pointer;
    font-size: 1.25rem;
    transition: transform 0.16s ease, color 0.16s ease;
}

.feedback-rating button.active,
.feedback-rating button:hover {
    color: var(--gold);
    transform: translateY(-1px);
}

.feedback-admin-list {
    display: grid;
    gap: 12px;
}

.feedback-admin-card {
    display: grid;
    gap: 10px;
    padding: 15px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.feedback-admin-card p {
    margin: 0;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.admin-content {
    display: block;
}

.admin-login-gate {
    min-height: calc(100vh - 70px);
    display: grid;
    place-items: center;
    padding: 24px;
}

.admin-login-card {
    width: min(420px, 100%);
    display: grid;
    gap: 13px;
    animation: feedbackIn 0.2s ease forwards;
}

.admin-login-card h2 {
    margin: 0;
}

.status-line.success {
    color: var(--green);
}

@keyframes feedbackIn {
    to {
        transform: translateY(0) scale(1);
    }
}

@keyframes feedbackSubmit {
    50% {
        transform: translateY(-2px) scale(1.01);
    }
}

.textarea {
    min-height: 210px;
    resize: vertical;
    line-height: 1.55;
}

.textarea.short {
    min-height: 120px;
}

.list-item,
.task-card,
.note-item,
.schedule-row,
.resource-link,
.stat-card,
.quiz-card,
.flashcard,
.activity-row {
    border-radius: var(--radius);
    padding: 14px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.task-card.done {
    opacity: 0.72;
}

.task-card.done .task-title {
    text-decoration: line-through;
}

.task-topline,
.subject-row,
.activity-row,
.stat-card {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.task-title,
.break-word {
    overflow-wrap: anywhere;
}

.task-meta,
.metadata-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.pill,
.priority-pill,
.urgency-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-size: 0.86rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.pill.success,
.priority-low {
    background: rgba(45, 115, 90, 0.14);
    color: var(--green);
}

.priority-medium,
.pill.warning {
    background: rgba(179, 134, 47, 0.16);
    color: var(--gold);
}

.priority-high,
.pill.danger {
    background: rgba(166, 64, 58, 0.13);
    color: var(--danger);
}

.empty {
    padding: 16px;
    border-radius: var(--radius);
    border: 1px dashed rgba(23, 32, 43, 0.24);
    color: var(--muted);
    text-align: center;
    background: rgba(255, 255, 255, 0.35);
}

.empty-state {
    padding: 18px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px dashed var(--line);
}

.reminder-list {
    display: grid;
    gap: 12px;
}

.reminder-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 15px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.reminder-card p {
    margin: 8px 0 0;
}

.muted-reminder {
    opacity: 0.62;
}

.metric-row,
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.metric,
.stat-card {
    padding: 14px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.metric strong,
.stat-card strong {
    display: block;
    font-size: 1.7rem;
    margin-bottom: 4px;
}

.focus-display {
    font-size: clamp(2.5rem, 6vw, 4.35rem);
    font-weight: 800;
    letter-spacing: 0;
    margin: 12px 0 16px;
    line-height: 1;
}

.progress-track {
    height: 10px;
    background: rgba(23, 32, 43, 0.1);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--blue), var(--accent));
}

.chart-bars {
    display: grid;
    gap: 10px;
}

.mini-chart {
    min-height: 150px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.mini-bar {
    min-height: 118px;
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 8px;
    align-items: end;
    text-align: center;
    color: var(--muted);
}

.mini-bar span {
    display: block;
    width: 100%;
    min-height: 6px;
    border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(180deg, var(--blue), var(--green));
}

.mini-bar small {
    font-size: 0.78rem;
}

.chart-row {
    display: grid;
    grid-template-columns: minmax(86px, 120px) 1fr minmax(42px, auto);
    align-items: center;
    gap: 10px;
}

.bar-shell {
    height: 10px;
    background: rgba(23, 32, 43, 0.1);
    border-radius: 99px;
    overflow: hidden;
}

.bar-shell span {
    display: block;
    height: 100%;
    background: var(--blue);
}

.quote-box {
    font-size: 1.04rem;
    line-height: 1.6;
}

.tips-list,
.schedule-list {
    padding-left: 18px;
    margin: 0;
}

.tips-list li,
.schedule-list li {
    margin-bottom: 10px;
}

.subject-button {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    color: var(--ink);
}

.subject-button.active {
    background: var(--accent-soft);
    border-color: rgba(185, 93, 53, 0.3);
}

.subject-button strong {
    display: block;
    margin-bottom: 6px;
}

.status-line {
    min-height: 24px;
    color: var(--green);
    font-size: 0.94rem;
}

.status-line.error {
    color: var(--danger);
}

.onboarding-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.onboarding-card {
    width: min(1060px, 100%);
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    background: rgba(9, 15, 23, 0.46);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(14px);
}

.onboarding-panel,
.onboarding-form {
    padding: 32px;
}

.onboarding-panel {
    color: #fff9f2;
    background: rgba(15, 24, 36, 0.72);
}

.onboarding-panel p {
    line-height: 1.6;
}

.onboarding-panel .list-item {
    background: rgba(255, 252, 247, 0.96);
    color: #17202b;
    border-color: rgba(23, 32, 43, 0.08);
    font-weight: 650;
}

.onboarding-panel h1 {
    font-size: clamp(2.3rem, 4vw, 4rem);
    margin: 18px 0 12px;
    line-height: 1.04;
}

.onboarding-form {
    background: rgba(255, 252, 247, 0.97);
}

.onboarding-form h2 {
    font-size: clamp(1.9rem, 4vw, 3.1rem);
    line-height: 1.05;
}

.onboarding-form form {
    display: grid;
    gap: 14px;
}

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

.form-grid .full {
    grid-column: span 2;
}

.footer-note {
    color: var(--muted);
    font-size: 0.92rem;
}

.embed-card {
    min-height: calc(100vh - 175px);
    display: flex;
    flex-direction: column;
}

.embed-frame-wrap {
    position: relative;
    flex: 1;
    min-height: 520px;
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(14, 22, 35, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.embed-frame {
    width: 100%;
    height: 100%;
    min-height: 520px;
    border: none;
    background: #fff;
}

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

.resource-list {
    margin-top: 12px;
}

.resource-link {
    display: block;
    text-decoration: none;
    background: rgba(23, 32, 43, 0.04);
}

.resource-link:hover {
    background: var(--accent-soft);
}

.ocr-preview-shell {
    min-height: 280px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: rgba(23, 32, 43, 0.08);
    border: 1px solid var(--line);
    overflow: hidden;
}

.ocr-preview {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    display: block;
    background: rgba(255, 255, 255, 0.45);
}

.ocr-progress {
    margin-top: 0;
}

.ocr-output {
    min-height: 320px;
}

.ocr-history-list {
    display: grid;
    gap: 11px;
}

.ocr-history-item {
    width: 100%;
    display: grid;
    gap: 7px;
    text-align: left;
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    color: var(--ink);
    background: var(--panel-strong);
    cursor: pointer;
}

.ocr-history-item:hover {
    border-color: rgba(185, 93, 53, 0.34);
    background: var(--accent-soft);
}

.search-results,
.search-facets {
    display: grid;
    gap: 11px;
}

.search-result-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 15px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.search-result-card p {
    margin: 8px 0 0;
}

.facet-button {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    width: 100%;
    min-height: 46px;
    padding: 12px 13px;
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--panel-strong);
    border: 1px solid var(--line);
    cursor: pointer;
}

.facet-button.active,
.facet-button:hover {
    border-color: rgba(185, 93, 53, 0.34);
    background: var(--accent-soft);
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.data-table th,
.data-table td {
    padding: 13px 12px;
    border-bottom: 1px solid rgba(23, 32, 43, 0.1);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--accent-deep);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

.flashcard button {
    justify-self: start;
}

.flashcard .answer {
    display: none;
}

.flashcard.open .answer {
    display: block;
}

.quiz-card textarea {
    min-height: 74px;
    margin-top: 10px;
}

.ai-tool-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.78fr);
    gap: 18px;
}

.split-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

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

.theme-choice button {
    border: 1px solid var(--line);
    background: var(--panel-strong);
    color: var(--ink);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
}

.theme-choice button.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-strong);
}

.toggle-row input {
    width: 18px;
    height: 18px;
}

.mobile-bottom-nav {
    display: none;
}

.video-quest-controls {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.8fr) minmax(140px, 0.7fr) auto auto;
    gap: 10px;
    align-items: center;
}

.video-quest-grid {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr);
    gap: 18px;
    margin-top: 22px;
    align-items: start;
}

.quest-video-pane,
.quest-evaluation-panel {
    min-height: 640px;
}

.video-frame {
    aspect-ratio: 16 / 9;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius);
    background: rgba(14, 22, 35, 0.92);
    border: 1px solid var(--line);
}

.video-frame iframe,
.video-frame #player {
    width: 100%;
    height: 100%;
}

.quest-evaluation-panel {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    padding: 20px;
    transform: translateX(16px);
    opacity: 0.82;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.quest-evaluation-panel.open {
    transform: translateX(0);
    opacity: 1;
}

.milestone-track {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.milestone-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--line);
    color: var(--muted);
}

.milestone-chip.active {
    border-color: var(--accent);
    color: var(--accent-deep);
}

.milestone-chip.complete {
    background: rgba(45, 115, 90, 0.14);
    color: var(--green);
}

.quest-terminal,
.quest-scratchpad {
    display: grid;
    gap: 10px;
}

.terminal-output {
    min-height: 88px;
    padding: 13px;
    border-radius: var(--radius);
    background: #111823;
    color: #d9f7ef;
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.tab-row .active {
    border-color: var(--accent);
}

.two-week-chart {
    grid-template-columns: repeat(14, minmax(0, 1fr));
}

.heatmap-list,
.skill-tree-grid {
    display: grid;
    gap: 12px;
}

.heatmap-row {
    display: grid;
    grid-template-columns: minmax(160px, 0.9fr) minmax(160px, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.heatmap-meter {
    height: 12px;
    border-radius: 99px;
    overflow: hidden;
    background: rgba(23, 32, 43, 0.1);
}

.heatmap-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--gold), var(--danger));
}

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

.skill-node {
    display: grid;
    gap: 12px;
    min-height: 250px;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--line);
    position: relative;
}

.skill-node h3 {
    margin: 10px 0 0;
}

.skill-node.locked {
    opacity: 0.72;
}

.skill-node.available {
    border-color: rgba(179, 134, 47, 0.42);
    box-shadow: 0 14px 34px rgba(179, 134, 47, 0.12);
}

.skill-node.unlocked {
    border-color: rgba(45, 115, 90, 0.36);
    background: linear-gradient(180deg, rgba(45, 115, 90, 0.12), var(--panel-strong));
}

.passport-profile,
.passport-metrics {
    display: grid;
    gap: 12px;
}

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

.compact-metric strong {
    font-size: 1.25rem;
    overflow-wrap: anywhere;
}

.passport-output {
    min-height: 360px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92rem;
    white-space: pre;
}

.hidden {
    display: none !important;
}

@media (max-width: 1100px) {
    .three-column,
    .ai-tool-grid,
    .settings-grid,
    .video-quest-grid,
    .video-quest-controls {
        grid-template-columns: 1fr;
    }

    .metric-row,
    .stat-grid,
    .skill-tree-grid,
    .passport-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    body {
        background-attachment: scroll;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(84vw, 300px);
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        height: 100vh;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 48px;
        height: 44px;
        border: none;
        border-radius: var(--radius);
        background: rgba(255, 255, 255, 0.16);
        color: #fff9f2;
        backdrop-filter: blur(10px);
        margin-bottom: 12px;
    }

    .main {
        padding: 18px 18px 86px;
    }

    .studyquest-footer {
        width: 100%;
        margin-left: 0;
        padding: 12px 18px 92px;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .dashboard-grid,
    .two-column,
    .resource-grid,
    .form-grid,
    .onboarding-card {
        grid-template-columns: 1fr;
    }

    .hero-card,
    .side-card,
    .wide-card,
    .half-card,
    .form-grid .full {
        grid-column: span 1;
    }

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

    .topbar-info {
        width: 100%;
        justify-content: flex-start;
    }

    .onboarding-shell {
        padding: 10px;
        align-items: start;
    }

    .onboarding-form {
        order: 1;
        padding: 23px 18px;
    }

    .onboarding-panel {
        order: 2;
        padding: 22px 18px;
    }

    .embed-card {
        min-height: auto;
    }

    .embed-header,
    .card-header {
        flex-direction: column;
    }

    .embed-frame-wrap,
    .embed-frame {
        min-height: 70vh;
    }
}

@media (max-width: 760px) {
    .mobile-bottom-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 10px;
        z-index: 10;
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 6px;
        padding: 8px;
        border-radius: 16px;
        background: rgba(14, 22, 35, 0.92);
        border: 1px solid rgba(255, 255, 255, 0.14);
        box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
        backdrop-filter: blur(16px);
    }

    .mobile-bottom-nav a {
        min-height: 46px;
        display: grid;
        place-items: center;
        color: rgba(255, 249, 242, 0.78);
        text-decoration: none;
        border-radius: 12px;
        font-size: 0.78rem;
        font-weight: 700;
    }

    .mobile-bottom-nav a.active {
        background: rgba(255, 255, 255, 0.14);
        color: #fff9f2;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 13px 13px 88px;
    }

    .page-title h2 {
        font-size: 2rem;
    }

    .focus-display {
        font-size: 2.55rem;
    }

    .field,
    .textarea,
    .select,
    .btn {
        font-size: 16px;
    }

    .card,
    .list-item,
    .task-card,
    .schedule-row,
    .resource-card {
        padding: 16px;
    }

    .metric-row,
    .stat-grid,
    .theme-choice,
    .feedback-form-grid {
        grid-template-columns: 1fr;
    }

    .feedback-modal {
        max-height: calc(100vh - 26px);
        overflow-y: auto;
        padding: 18px;
    }

    .admin-login-gate {
        min-height: calc(100vh - 128px);
        padding: 18px 0 96px;
    }

    .feedback-modal-header,
    .feedback-modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .task-topline,
    .subject-row,
    .activity-row,
    .stat-card,
    .split-actions,
    .heatmap-row,
    .reminder-card,
    .search-result-card {
        flex-direction: column;
        align-items: stretch;
    }

    .reminder-card,
    .search-result-card {
        display: grid;
        grid-template-columns: 1fr;
    }

    .heatmap-row,
    .skill-tree-grid,
    .two-week-chart,
    .passport-metrics {
        grid-template-columns: 1fr;
    }

    .toolbar .btn,
    .button-row .btn {
        flex: 1 1 100%;
    }

    .onboarding-panel img {
        width: 132px;
    }

    .onboarding-panel h1 {
        font-size: 1.85rem;
    }

    .onboarding-form h2 {
        font-size: 2rem;
    }
}
