@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Oswald:wght@500;600;700&display=swap');

:root {
    --bg: #f7f6f3;
    --panel: #ffffff;
    --panel-soft: #f3f1ec;
    --text: #171a18;
    --muted: #65706a;
    --subtle: #8a928e;
    --line: #dedfdc;
    --gold: #d78d0d;
    --gold-dark: #a96800;
    --gold-soft: #fff7e7;
    --green: #147a43;
    --green-soft: #eaf8ef;
    --danger: #b42318;
    --shadow: 0 3px 12px rgba(18, 24, 21, 0.06);
    --radius: 10px;
    --font-heading: 'Oswald', sans-serif;
    --font-body: 'Inter', sans-serif;
}

[data-theme="dark"] {
    --bg: #0d0f0e;
    --panel: #151816;
    --panel-soft: #1d211f;
    --text: #f5f7f6;
    --muted: #a9b0ac;
    --subtle: #7d8681;
    --line: #303633;
    --gold: #eca72c;
    --gold-dark: #f3bb55;
    --gold-soft: #2a2317;
    --green: #4bd184;
    --green-soft: #172a20;
    --danger: #ff766e;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
}

button, input { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-heading); line-height: 1.15; }

.hidden { display: none !important; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.header-inner {
    width: min(1080px, calc(100% - 32px));
    min-height: 62px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-logo img {
    display: block;
    width: 116px;
    height: auto;
    filter: none;
}

[data-theme="dark"] .brand-logo img { filter: brightness(0) invert(1); }

.nav-actions { display: flex; gap: 8px; }

.btn {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px 16px;
    background: var(--panel);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.btn:hover { border-color: var(--gold); }
.btn:focus-visible, .text-button:focus-visible, summary:focus-visible, input:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--gold) 35%, transparent);
    outline-offset: 2px;
}

.btn-small { padding: 7px 12px; font-size: 0.8rem; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #111; }
.btn-primary:hover { background: var(--gold-dark); color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { cursor: wait; opacity: 0.65; }

.text-button {
    appearance: none;
    border: 0;
    padding: 7px 0;
    background: transparent;
    color: var(--gold-dark);
    cursor: pointer;
    font-weight: 600;
}

.page-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    flex: 1;
    padding: 28px 0 48px;
}

.auth-wrapper {
    min-height: calc(100vh - 190px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(100%, 420px);
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.eyebrow {
    color: var(--gold-dark);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.auth-card h1 { margin-top: 5px; font-size: 2rem; }
.auth-copy, .section-copy, .hero-copy { color: var(--muted); }
.auth-copy { margin-top: 8px; margin-bottom: 24px; }

.field-label {
    display: block;
    margin: 14px 0 6px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.field-input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel-soft);
    color: var(--text);
}

.auth-card .btn-primary { margin-top: 20px; }
.auth-card #magicLinkButton { margin-top: 8px; background: var(--panel-soft); }
.auth-card .text-button { display: block; margin: 8px auto 0; }
.access-note { margin-top: 16px; color: var(--subtle); font-size: 0.76rem; text-align: center; }
.status-message { min-height: 22px; margin-top: 10px; font-size: 0.82rem; text-align: center; }
.status-message.error { color: var(--danger); }
.status-message.success { color: var(--green); }
.back-link { display: block; margin-top: 12px; color: var(--muted); font-size: 0.78rem; text-align: center; }

.loading-view { padding: 90px 20px; text-align: center; }
.tree-loader { font-size: 2.7rem; animation: pulse 1.4s ease-in-out infinite; }
.loading-view h2 { margin-top: 12px; }
.loading-view p { margin-top: 6px; color: var(--muted); }
@keyframes pulse { 50% { transform: scale(1.08); opacity: 0.7; } }

.dashboard { display: grid; gap: 18px; }
.panel {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.teacher-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.teacher-hero h1 { margin-top: 4px; font-size: 2.1rem; }
.hero-copy { margin-top: 5px; }
.period-badge {
    flex: 0 0 auto;
    padding: 8px 12px;
    border: 1px solid color-mix(in srgb, var(--green) 30%, var(--line));
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 700;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 { margin-top: 4px; font-size: 1.55rem; }
.section-copy { margin-top: 6px; font-size: 0.84rem; }
.compact-heading { padding-bottom: 14px; }

.summary-metrics { display: flex; gap: 10px; }
.metric {
    min-width: 88px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    text-align: center;
}
.metric strong { display: block; font-family: var(--font-heading); font-size: 1.5rem; line-height: 1; }
.metric span { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; }

.accordion-stack { display: grid; gap: 10px; margin-top: 16px; }
.accordion {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: clip;
}

.accordion > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    font-weight: 700;
}

.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::before {
    content: '›';
    width: 18px;
    color: var(--gold-dark);
    font-size: 1.35rem;
    line-height: 1;
    transform-origin: center;
    transition: transform 0.16s ease;
}
.accordion[open] > summary::before { transform: rotate(90deg); }
.accordion[open] > summary { border-bottom: 1px solid var(--line); }
.summary-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-meta { margin-left: auto; color: var(--muted); font-size: 0.74rem; font-weight: 600; white-space: nowrap; }

.accordion-body { padding: 10px 14px 14px; }
.month-stack { display: grid; gap: 8px; }
.month-accordion { background: var(--panel-soft); }
.month-accordion > summary { min-height: 46px; padding-block: 9px; }
.month-accordion .accordion-body { padding: 0; }

.class-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.class-table th {
    padding: 9px 10px;
    color: var(--subtle);
    font-size: 0.67rem;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}
.class-table td {
    padding: 10px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
    vertical-align: middle;
}
.class-table td:first-child { color: var(--text); font-weight: 700; }
.class-table th:last-child, .class-table td:last-child { text-align: right; }
.day-count { color: var(--gold-dark); font-weight: 700; }
.instrument-chip {
    display: inline-block;
    padding: 3px 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--muted);
    font-size: 0.72rem;
}

.empty-state {
    padding: 26px 16px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
}

.app-footer {
    min-height: 66px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    color: var(--subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    font-size: 0.76rem;
}
.footer-account { display: flex; align-items: center; gap: 10px; }
.footer-account .text-button { font-size: 0.76rem; padding: 0; }

@media (max-width: 700px) {
    .header-inner, .page-shell { width: min(100% - 20px, 1080px); }
    .header-inner { min-height: 58px; }
    .brand-logo img { width: 102px; }
    .btn-small { padding: 6px 9px; font-size: 0.72rem; }
    .page-shell { padding-top: 14px; }
    .auth-card, .panel { padding: 18px 15px; }
    .teacher-hero { align-items: flex-start; flex-direction: column; }
    .teacher-hero h1 { font-size: 1.75rem; }
    .period-badge { white-space: normal; }
    .section-heading { flex-direction: column; gap: 14px; }
    .summary-metrics { width: 100%; }
    .metric { flex: 1; }
    .accordion > summary { padding-inline: 10px; }
    .accordion-body { padding: 8px 8px 10px; }
    .summary-title { white-space: normal; }
    .class-table th:nth-child(2), .class-table td:nth-child(2) { display: none; }
    .class-table th, .class-table td { padding-inline: 7px; }
    .class-table th:first-child { width: 34%; }
    .class-table th:last-child { width: 45%; }
    .app-footer { flex-direction: column; gap: 5px; text-align: center; }
    .footer-account { flex-direction: column; gap: 3px; }
}

@media (max-width: 390px) {
    .brand-logo img { width: 96px; }
    .nav-actions { gap: 5px; }
    .btn-small { padding-inline: 7px; }
    .summary-meta { font-size: 0.68rem; }
    .class-table td { font-size: 0.76rem; }
}
