:root {
    --primary-start: #667eea;
    --primary-end:   #764ba2;
    --accent:        #667eea;
}

[data-theme="space"] {
    --primary-start: #0f2027;
    --primary-end:   #2980b9;
    --accent:        #00cfff;
}

[data-theme="video-games"] {
    --primary-start: #0d0d2b;
    --primary-end:   #1a0a4a;
    --accent:        #00ff88;
}

body[data-theme="video-games"] {
    background:
        url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 56' shape-rendering='crispEdges'><rect x='4' y='16' width='72' height='24' fill='%23222244'/><rect x='4' y='16' width='72' height='4' fill='%23333366'/><rect x='16' y='8' width='16' height='8' fill='%23222244'/><rect x='48' y='8' width='16' height='8' fill='%23222244'/><rect x='4' y='20' width='16' height='4' fill='%2300ff88'/><rect x='60' y='20' width='16' height='4' fill='%2300ff88'/><rect x='32' y='24' width='16' height='8' fill='%2300ff88'/><rect x='36' y='28' width='8' height='4' fill='%230d0d2b'/><rect x='28' y='40' width='8' height='8' fill='%23222244'/><rect x='44' y='40' width='8' height='8' fill='%23222244'/></svg>") bottom right 24px no-repeat,
        linear-gradient(135deg, #0d0d2b 0%, #1a0a4a 100%);
    background-size: 140px auto, auto;
}

body[data-theme="space"] {
    background:
        url("space-bg.png") center center / cover no-repeat fixed;
}

body[data-theme="martial-arts"] {
    background:
        url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 80' shape-rendering='crispEdges'><rect x='20' y='0' width='8' height='8' fill='%23cc3333'/><rect x='16' y='8' width='16' height='8' fill='%23cc3333'/><rect x='12' y='16' width='24' height='8' fill='%23f0e0d0'/><rect x='8' y='24' width='32' height='12' fill='%23f0e0d0'/><rect x='16' y='36' width='16' height='8' fill='%23f0e0d0'/><rect x='8' y='44' width='8' height='24' fill='%23f0e0d0'/><rect x='32' y='44' width='8' height='24' fill='%23f0e0d0'/><rect x='0' y='32' width='8' height='4' fill='%23cc3333'/><rect x='40' y='32' width='8' height='4' fill='%23cc3333'/></svg>") bottom right 24px no-repeat,
        linear-gradient(135deg, #1a0a0a 0%, #5c1010 100%);
    background-size: 100px auto, auto;
}

[data-theme="martial-arts"] {
    --primary-start: #1a0a0a;
    --primary-end:   #5c1010;
    --accent:        #e84040;
}

[data-theme="greek-myths"] {
    --primary-start: #0d2b5e;
    --primary-end:   #1a4a8a;
    --accent:        #f0c040;
}

body[data-theme="greek-myths"] {
    background:
        url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 80' shape-rendering='crispEdges'><rect x='8' y='0' width='48' height='4' fill='%23f0c040'/><rect x='8' y='4' width='8' height='48' fill='%23d4aa30'/><rect x='24' y='4' width='8' height='48' fill='%23d4aa30'/><rect x='40' y='4' width='8' height='48' fill='%23d4aa30'/><rect x='8' y='52' width='48' height='4' fill='%23f0c040'/><rect x='4' y='56' width='56' height='8' fill='%23f0c040'/><rect x='0' y='64' width='64' height='8' fill='%23c8922a'/></svg>") bottom right 32px no-repeat,
        linear-gradient(135deg, #0d2b5e 0%, #1a4a8a 100%);
    background-size: 96px auto, auto;
}

[data-theme="fairy-tales"] {
    --primary-start: #2d1b4e;
    --primary-end:   #6b3fa0;
    --accent:        #ff80c0;
}

body[data-theme="fairy-tales"] {
    background:
        url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 80' shape-rendering='crispEdges'><rect x='24' y='0' width='16' height='8' fill='%23ff80c0'/><rect x='20' y='8' width='24' height='4' fill='%23cc60a0'/><rect x='16' y='12' width='32' height='28' fill='%23cc60a0'/><rect x='20' y='40' width='8' height='32' fill='%23aa5090'/><rect x='36' y='40' width='8' height='32' fill='%23aa5090'/><rect x='28' y='48' width='8' height='8' fill='%23ff80c0'/><rect x='8' y='16' width='8' height='16' fill='%23cc60a0'/><rect x='48' y='16' width='8' height='16' fill='%23cc60a0'/><rect x='4' y='4' width='4' height='4' fill='%23ffe0ff'/><rect x='56' y='8' width='4' height='4' fill='%23ffe0ff'/><rect x='12' y='56' width='4' height='4' fill='%23ffe0ff'/><rect x='52' y='52' width='4' height='4' fill='%23ffe0ff'/></svg>") bottom center no-repeat,
        linear-gradient(135deg, #2d1b4e 0%, #6b3fa0 100%);
    background-size: 120px auto, auto;
}

[data-theme="anime"] {
    --primary-start: #1a0528;
    --primary-end:   #3d1060;
    --accent:        #ff6b9d;
}

body[data-theme="anime"] {
    background:
        url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' shape-rendering='crispEdges'><rect x='28' y='0' width='8' height='8' fill='%23ffb7d5'/><rect x='24' y='4' width='16' height='8' fill='%23ff6b9d'/><rect x='20' y='8' width='24' height='8' fill='%23ffb7d5'/><rect x='24' y='16' width='16' height='4' fill='%23ff6b9d'/><rect x='0' y='28' width='8' height='8' fill='%23ffb7d5'/><rect x='56' y='28' width='8' height='8' fill='%23ffb7d5'/><rect x='4' y='24' width='8' height='16' fill='%23ff6b9d'/><rect x='52' y='24' width='8' height='16' fill='%23ff6b9d'/><rect x='28' y='44' width='8' height='8' fill='%23ffb7d5'/><rect x='24' y='48' width='16' height='8' fill='%23ff6b9d'/><rect x='20' y='52' width='24' height='8' fill='%23ffb7d5'/><rect x='24' y='56' width='16' height='8' fill='%23ff6b9d'/></svg>") bottom right 16px no-repeat,
        linear-gradient(135deg, #1a0528 0%, #3d1060 100%);
    background-size: 80px auto, auto;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    color: white;
    padding: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
}

.student-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.student-name {
    font-size: 1.1em;
    min-width: 140px;
}

.progress-bar {
    flex: 1;
    height: 30px;
    background: rgba(255,255,255,0.2);
    border-radius: 15px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #4ade80;
    transition: width 0.5s ease;
    border-radius: 15px;
}

.star-display {
    font-size: 1.2em;
    font-weight: bold;
    min-width: 60px;
    text-align: right;
    transition: transform 0.2s;
}

.star-flash {
    animation: starPop 0.6s ease;
}

@keyframes starPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.6); color: #ffd700; }
    100% { transform: scale(1); }
}

/* Welcome modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.modal-box h2 {
    margin: 12px 0 8px;
    color: #1f2937;
}

.modal-box p {
    color: #6b7280;
    margin-bottom: 20px;
}

.modal-box input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.1em;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 16px;
    outline: none;
    text-align: center;
}

.modal-box input:focus {
    border-color: #667eea;
}

.modal-box button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s;
}

.modal-box button:hover {
    transform: translateY(-2px);
}

/* Celebration confetti */
#celebration-overlay {
    display: none;
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    overflow: hidden;
}

#celebration-overlay.active {
    display: block;
}

.confetti-piece {
    position: absolute;
    top: -2em;
    animation: confettiFall 2.5s ease-in forwards;
}

@keyframes confettiFall {
    0%   { transform: translateY(0) rotate(0deg);   opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

.progress-text {
    font-weight: bold;
    min-width: 100px;
    text-align: right;
}

.tabs {
    display: flex;
    background: #f3f4f6;
    padding: 0;
    border-bottom: 2px solid #e5e7eb;
}

.tab {
    flex: 1;
    padding: 20px;
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab:hover {
    background: #e5e7eb;
}

.tab.active {
    background: white;
    border-bottom: 3px solid var(--accent);
    font-weight: bold;
}

main {
    padding: 30px;
    min-height: 500px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.curriculum-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.topic-card {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 15px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    position: relative;
}

.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-color: var(--accent);
}

.topic-card.completed {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: #10b981;
}

.topic-card h3 {
    font-size: 1.3em;
    margin-bottom: 10px;
    color: #1f2937;
}

.topic-card p {
    color: #6b7280;
    font-size: 0.95em;
    line-height: 1.5;
}

.topic-status {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5em;
}

.resource-list {
    margin-top: 20px;
}

.resource-item {
    background: #f9fafb;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border-left: 4px solid var(--accent);
}

.resource-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.resource-item h4 {
    color: #667eea;
    margin: 0;
}

.resource-item a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.resource-item a:hover {
    text-decoration: underline;
}

.vote-btn {
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.vote-btn:hover {
    border-color: #667eea;
    background: #eef2ff;
}

.vote-btn.voted {
    background: #eef2ff;
    border-color: #667eea;
    color: #667eea;
    font-weight: bold;
}

.yt-embed-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin-top: 12px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}

.yt-embed-wrap iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
    border-radius: 10px;
}

.yt-open-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.82em;
    color: #6b7280;
    text-decoration: none;
}

.yt-open-link:hover { color: #374151; text-decoration: underline; }

.video-launch-btn {
    display: inline-block;
    margin-top: 12px;
    background: #ff0000;
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.95em;
    transition: background 0.2s, transform 0.2s;
}

.video-launch-btn:hover {
    background: #cc0000;
    transform: translateY(-2px);
    text-decoration: none;
    color: white;
}

.video-embed-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 10px;
    margin: 12px 0;
    background: #000;
}

.video-embed-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 10px;
}

.alt-video-link {
    display: inline-block;
    font-size: 0.9em;
    color: #6b7280;
    margin-top: 4px;
}

.alt-video-link:hover {
    color: #667eea;
}

.vote-hint {
    font-size: 0.9em;
    color: #9ca3af;
    font-style: italic;
}

.header-btn {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85em;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.header-btn:hover {
    background: rgba(255,255,255,0.25);
}

.back-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.3s;
}

.back-btn:hover {
    background: var(--primary-end);
    transform: translateY(-2px);
}

.quiz-container {
    max-width: 600px;
    margin: 0 auto;
}

.quiz-question {
    background: #f3f4f6;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.quiz-question h3 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #1f2937;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    background: white;
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.quiz-option:hover {
    border-color: #667eea;
    transform: translateX(5px);
}

.quiz-option.correct {
    background: #d1fae5;
    border-color: #10b981;
}

.quiz-option.incorrect {
    background: #fee2e2;
    border-color: #ef4444;
}

.knowledge-tree {
    padding: 20px;
}

.tree-node {
    background: #f3f4f6;
    padding: 15px 20px;
    border-radius: 10px;
    margin: 10px 0;
    border-left: 4px solid #667eea;
}

.tree-node.completed {
    background: #d1fae5;
    border-left-color: #10b981;
}

.tree-children {
    margin-left: 30px;
    border-left: 2px dashed #cbd5e1;
    padding-left: 20px;
}

.tree-description {
    color: #6b7280;
    margin-bottom: 30px;
    font-size: 1.1em;
}
.tree-section-label {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9ca3af;
    margin: 20px 0 10px;
}
.current-course-label {
    color: #667eea;
    font-size: 0.9em;
}
.tree-connector {
    text-align: center;
    font-size: 1.5em;
    color: #cbd5e1;
    margin: 4px 0;
}
.tree-course-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.tree-course-card {
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 18px;
    text-align: center;
    min-width: 140px;
    max-width: 180px;
    transition: all 0.2s;
}
.tree-course-card.enrolled {
    background: #d1fae5;
    border-color: #10b981;
}
.tree-course-card.available {
    background: #eff6ff;
    border-color: #667eea;
    cursor: pointer;
}
.tree-course-card.available:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.2);
}
.tree-course-card.locked {
    opacity: 0.5;
}
.tree-course-card-title {
    font-weight: 600;
    font-size: 0.9em;
    margin: 6px 0 4px;
    color: #374151;
}
.tree-course-card-status {
    font-size: 0.78em;
    color: #6b7280;
}
.tree-course-card-enrol {
    margin-top: 8px;
    font-size: 0.8em;
    font-weight: 700;
    color: #667eea;
}

#quiz-topic-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.quiz-topic-btn {
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    color: white;
    border: none;
    padding: 20px;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
}

.quiz-topic-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.quiz-result {
    background: #f3f4f6;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin-top: 20px;
}

.quiz-result.pass {
    background: #d1fae5;
}

.quiz-result h3 {
    font-size: 2em;
    margin-bottom: 15px;
}

.quiz-result p {
    font-size: 1.2em;
    color: #6b7280;
}

.parent-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
}

.parent-table th, .parent-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.parent-table th {
    background: #f3f4f6;
    font-weight: bold;
    color: #374151;
}

.modal-box.wide {
    max-width: 700px;
}

.next-question-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s;
}

/* Calendar */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 10px;
}

.cal-header {
    text-align: center;
    font-size: 0.8em;
    font-weight: bold;
    color: #6b7280;
    padding: 6px 0;
}

.cal-day {
    min-height: 56px;
    background: #f9fafb;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    position: relative;
}

.cal-day:hover { border-color: var(--accent); }
.cal-day.empty { background: none; cursor: default; }
.cal-day.today { border-color: var(--accent); background: #eef2ff; }
.cal-day.has-activity { background: #d1fae5; }

.cal-day-num {
    font-size: 0.9em;
    font-weight: bold;
    color: #374151;
}

.cal-dot {
    display: inline-block;
    background: #10b981;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    border-radius: 10px;
    padding: 1px 6px;
    margin-top: 4px;
}

/* Activity log entries */
.activity-entry {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.88em;
}

.activity-entry:last-child { border-bottom: none; }

.activity-time { color: #9ca3af; min-width: 110px; }

.activity-type {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
}

.activity-type.quiz    { background: #dbeafe; color: #1d4ed8; }
.activity-type.learn   { background: #fef3c7; color: #92400e; }
.activity-type.video   { background: #fee2e2; color: #991b1b; }

.activity-topic { font-weight: bold; color: #374151; }
.activity-detail { color: #6b7280; flex: 1; }
.activity-result { font-weight: bold; }

.next-question-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

/* ── Auth screen ─────────────────────────────────────────────────────────── */
.auth-tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 1em;
    font-weight: 600;
    color: #9ca3af;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.auth-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

#auth-login-panel input,
#auth-signup-panel input {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 1em;
    box-sizing: border-box;
}

#auth-login-panel input:focus,
#auth-signup-panel input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

.auth-submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    margin-top: 4px;
    transition: opacity 0.2s;
}

.auth-submit-btn:hover { opacity: 0.9; }

.auth-err {
    color: #ef4444;
    font-size: 0.88em;
    min-height: 1.2em;
    margin: 0 0 8px;
}

/* ── Home screen ──────────────────────────────────────────────────────────── */
.home-course-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.home-course-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102,126,234,0.15);
}

/* ── Progress report ──────────────────────────────────────────────────────── */
.report-course-block {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.report-course-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #f9fafb;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05em;
}

.report-course-header input[type=checkbox] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.report-pct {
    margin-left: auto;
    color: white;
    font-size: 0.85em;
    padding: 3px 10px;
    border-radius: 99px;
    font-weight: 700;
}

.report-course-body {
    padding: 12px 18px;
}

.report-topic-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.report-topic {
    padding: 5px 0;
    font-size: 0.95em;
    border-bottom: 1px solid #f3f4f6;
}

.report-topic.done     { color: #1f2937; }
.report-topic.remaining { color: #9ca3af; }

/* ── Course Selector ────────────────────────────────── */
.course-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.course-card {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.course-card:not(.locked):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102,126,234,0.2);
    border-color: #667eea;
}

.course-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.course-icon {
    font-size: 1.6em;
    flex-shrink: 0;
}

.course-card h3 {
    margin: 0 0 2px;
    font-size: 0.95em;
    color: #1f2937;
}

.course-card p {
    font-size: 0.78em;
    color: #6b7280;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-progress-bar {
    background: #e5e7eb;
    border-radius: 99px;
    height: 6px;
    margin: 8px 0 4px;
    overflow: hidden;
}

.course-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s;
}

.course-progress-label {
    font-size: 0.78em;
    color: #6b7280;
}

.course-lock {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.82em;
    color: #9ca3af;
    font-weight: 600;
}

/* ──────────────────────────────────────────────────────────────
   Schedule Modal
────────────────────────────────────────────────────────────── */

.schedule-modal-box {
    text-align: left;
    max-width: 560px;
}

.schedule-section {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.schedule-section-title {
    font-size: 0.95em;
    color: #374151;
    font-weight: 700;
    margin-bottom: 12px;
}

.schedule-days {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.schedule-day-label {
    display: flex;
    align-items: center;
    gap: 5px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.9em;
    cursor: pointer;
    transition: border-color 0.2s;
    user-select: none;
}

.schedule-day-label:has(input:checked) {
    border-color: #667eea;
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
}

.schedule-day-label input {
    display: none; /* hide raw checkbox; style the label */
}

/* Fallback for browsers without :has() — keep checkbox visible */
@supports not (selector(:has(*))) {
    .schedule-day-label input { display: inline; margin: 0; }
}

.schedule-radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    cursor: pointer;
    font-size: 0.95em;
    color: #374151;
}

.schedule-radio-label input[type="radio"] {
    accent-color: #667eea;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────────
   Calendar — baseline / reforecast / actual markers
────────────────────────────────────────────────────────────── */

.cal-dots-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 4px;
}

/* Override the old single cal-dot — now we have coloured variants */
.cal-dot {
    display: inline-block;
    font-size: 0.7em;
    font-weight: bold;
    border-radius: 10px;
    padding: 1px 6px;
}

/* Green — actual activities completed */
.cal-dot-actual {
    background: #10b981;
    color: white;
}

/* Light blue — baseline planned topics */
.cal-dot-baseline {
    background: #bfdbfe;
    color: #1d4ed8;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    padding: 0;
    flex-shrink: 0;
    align-self: center;
}

/* Amber — reforecast (differs from baseline) */
.cal-dot-reforecast {
    background: #fcd34d;
    color: #92400e;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    padding: 0;
    flex-shrink: 0;
    align-self: center;
}

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 8px;
    padding: 8px 4px;
    font-size: 0.8em;
    color: #6b7280;
    align-items: center;
}

.cal-legend span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ──────────────────────────────────────────────────────────────
   Calendar day-detail panel sections
────────────────────────────────────────────────────────────── */

.day-section {
    margin-bottom: 16px;
}

.day-section-label {
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.day-section-item {
    font-size: 0.9em;
    color: #374151;
    padding: 4px 0;
    border-bottom: 1px solid #f3f4f6;
}

/* ──────────────────────────────────────────────────────────────
   Progress report — schedule section
────────────────────────────────────────────────────────────── */

.schedule-report-section {
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.schedule-report-header {
    font-weight: 700;
    color: #1d4ed8;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.schedule-report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.85em;
    color: #374151;
}

.schedule-report-meta span {
    background: white;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    padding: 3px 10px;
}

/* Schedule status colours in progress report table */
.sched-status-early   { color: #059669; font-weight: 600; } /* completed on time / early — green */
.sched-status-late    { color: #f59e0b; font-weight: 600; } /* completed late — orange */
.sched-status-overdue { color: #ef4444; font-weight: 600; } /* not done, due date passed — red */
.sched-status-future  { color: #9ca3af; }                    /* not done, due in future — grey */

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤900px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 14px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.9em;
        margin-bottom: 14px;
    }

    /* Student info row — allow wrapping on tablet */
    .student-info {
        flex-wrap: wrap;
        gap: 10px;
    }

    .student-name {
        min-width: 120px;
    }

    /* Nav tabs — reduce padding so all 5 fit, allow wrap */
    .tab {
        padding: 14px 10px;
        font-size: 0.95em;
    }

    /* Curriculum grid — 2 columns on tablet */
    .curriculum-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    /* Modal boxes */
    .modal-box.wide {
        max-width: 96vw;
    }

    main {
        padding: 20px;
    }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤600px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        box-shadow: none;
        min-height: 100vh;
    }

    /* ── Header ── */
    header {
        padding: 16px;
    }

    header h1 {
        font-size: 1.4em;
        margin-bottom: 12px;
    }

    .student-info {
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }

    .student-name {
        font-size: 0.95em;
        min-width: 0;
        flex: 1 1 100%;        /* full row on its own */
    }

    .progress-bar {
        height: 22px;
        flex: 1 1 calc(100% - 70px);
    }

    .progress-text {
        font-size: 0.8em;
        min-width: auto;
    }

    .star-display {
        font-size: 1em;
        min-width: auto;
    }

    #current-course-label {
        display: none;          /* redundant on small screens */
    }

    .header-btn {
        font-size: 0.78em;
        padding: 6px 10px;
    }

    /* ── Nav tabs — wrap instead of overflow ── */
    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        flex: 1 1 auto;
        padding: 10px 6px;
        font-size: 0.82em;
        text-align: center;
    }

    /* ── Main content ── */
    main {
        padding: 14px;
    }

    /* ── Curriculum grid — single column on phones ── */
    .curriculum-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .topic-card {
        padding: 18px;
    }

    /* ── Modal boxes — near full-width ── */
    .modal-box,
    .modal-box.wide {
        width: calc(100% - 20px);
        max-width: none;
        padding: 24px 18px;
        border-radius: 14px;
        margin: 10px;
    }

    .schedule-modal-box {
        max-width: none;
    }

    /* ── Quiz options — touch-friendly tap targets ── */
    .quiz-option {
        min-height: 44px;
        padding: 12px 14px;
        font-size: 0.95em;
    }

    .quiz-option:hover {
        transform: none;        /* no hover on touch */
    }

    .quiz-question {
        padding: 18px;
    }

    .quiz-question h3 {
        font-size: 1.2em;
    }

    #quiz-topic-list {
        grid-template-columns: 1fr;
    }

    /* ── Calendar — compact cells on phones ── */
    .cal-grid {
        gap: 2px;
    }

    .cal-header {
        font-size: 0.65em;
        padding: 4px 0;
    }

    .cal-day {
        min-height: 36px;
        padding: 3px;
    }

    .cal-day-num {
        font-size: 0.72em;
    }

    .cal-dot {
        font-size: 0.58em;
        padding: 1px 4px;
    }

    .cal-dot-baseline,
    .cal-dot-reforecast {
        width: 7px;
        height: 7px;
    }

    /* ── Parent table — horizontal scroll wrapper ── */
    .parent-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        font-size: 0.82em;
    }

    /* ── Course selector — single column ── */
    .course-selector-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* ── Knowledge tree indent — reduce on small screens ── */
    .tree-children {
        margin-left: 14px;
        padding-left: 10px;
    }

    /* ── Home course cards ── */
    .home-course-card {
        padding: 12px 14px;
        gap: 10px;
    }

    /* ── Back / action buttons ── */
    .back-btn {
        padding: 10px 18px;
        font-size: 0.9em;
    }

    /* ── Calendar controls — stack vertically ── */
    #calendar-tab > div:first-child {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ─── AI Course Generation ──────────────────────────────────────────────────── */

/* Create with AI button on home screen */
.btn-ai-create {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 14px 28px;
    font-size: 1.05em;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.01em;
}
.btn-ai-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.55);
}

/* Generate button inside modal */
.btn-ai-generate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-ai-generate:hover { opacity: 0.88; }

/* Save button */
.btn-ai-save {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-ai-save:hover { opacity: 0.88; }

/* Field grid */
.ai-field-row {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}
.ai-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ai-field label {
    font-weight: 600;
    color: #374151;
    font-size: 0.9em;
}
.ai-field input {
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.95em;
    width: 100%;
    box-sizing: border-box;
}

/* Loading spinner */
@keyframes ai-spin {
    to { transform: rotate(360deg); }
}
.ai-spinner {
    width: 52px;
    height: 52px;
    border: 5px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
    margin: 0 auto;
}

/* Preview header */
.ai-preview-header {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, #f0f4ff 0%, #faf0ff 100%);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 4px;
}

/* Topic list in preview */
.ai-topic-preview-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
}
.ai-topic-preview-row:last-child { border-bottom: none; }
.ai-topic-num {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

@media (max-width: 600px) {
    .ai-field-row { flex-direction: column; }
    .btn-ai-create { width: 100%; justify-content: center; }
}

/* ─── Stage 3: Document Upload ──────────────────────────────────────────── */

.ai-create-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-doc-create {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 22px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.btn-doc-create:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Document upload modal tabs */
.doc-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
}
.doc-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 10px 18px;
    font-size: 0.95em;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: color 0.15s;
}
.doc-tab:hover { color: #374151; background: #f9fafb; }
.doc-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #f5f3ff;
}

/* Document upload panel */
.doc-panel {
    margin-bottom: 20px;
}

/* Dropzone */
.doc-dropzone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #fafafa;
}
.doc-dropzone:hover {
    border-color: #667eea;
    background: #f5f3ff;
}
.doc-dropzone-icon {
    font-size: 2.5em;
    margin-bottom: 8px;
}
.doc-dropzone-text {
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}
.doc-dropzone-hint {
    font-size: 0.85em;
    color: #9ca3af;
}

/* File preview */
.doc-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.doc-preview-box {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #f9fafb;
    padding: 12px 14px;
    font-size: 0.85em;
    color: #374151;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 160px;
    overflow-y: auto;
}
.doc-char-count {
    text-align: right;
    font-size: 0.8em;
    color: #9ca3af;
    margin-top: 4px;
}

/* Shared fields section */
.doc-shared-fields {
    border-top: 1px solid #f3f4f6;
    padding-top: 16px;
    margin-top: 4px;
}

@media (max-width: 600px) {
    .btn-doc-create { width: 100%; justify-content: center; }
    .ai-create-row { flex-direction: column; }
}
