:root {
    --primary: #0B2D4D;
    --accent: #2D7DD2;
    --page: #F4F7FB;
    --surface: #FFFFFF;
    --text: #172434;
    --muted: #66778A;
    --line: #DCE4EC;
    --danger: #B42318;
    --success: #138A4B;
    --warning: #9A6700;
    --radius: 18px;
    --shadow: 0 14px 35px rgba(11, 45, 77, .10);
    --topbar-h: 64px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--text); -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.topbar {
    position: fixed; z-index: 70; top: 0; left: 0; right: 0; height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 8px;
    background: var(--primary); color: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.16);
}
.hamburger { width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.hamburger span, .hamburger span::before, .hamburger span::after { width: 22px; height: 2px; background: #fff; border-radius: 4px; display: block; position: relative; }
.hamburger span::before, .hamburger span::after { content: ""; position: absolute; left: 0; }
.hamburger span::before { top: -7px; }
.hamburger span::after { top: 7px; }
.topbar-brand { text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; justify-self: start; }
.topbar-mark, .brand-mark, .auth-logo { display: grid; place-items: center; background: #fff; color: var(--primary); font-weight: 900; border-radius: 11px; }
.topbar-mark { width: 32px; height: 32px; }
.topbar-user { font-size: .9rem; font-weight: 700; opacity: .9; padding-right: 6px; }

.drawer-overlay { position: fixed; z-index: 79; inset: 0; background: rgba(4,17,30,.45); opacity: 0; visibility: hidden; transition: .2s ease; }
.drawer-overlay.open { opacity: 1; visibility: visible; }
.drawer {
    position: fixed; z-index: 80; top: 0; bottom: 0; left: 0; width: min(88vw, 340px);
    padding: max(20px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
    background: #fff; box-shadow: 20px 0 50px rgba(0,0,0,.22); transform: translateX(-105%); transition: transform .22s ease;
    display: flex; flex-direction: column; overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 44px; height: 44px; background: var(--primary); color: #fff; font-size: 1.35rem; }
.drawer-brand strong, .drawer-brand small { display: block; }
.drawer-brand small { color: var(--muted); margin-top: 2px; }
.drawer-nav { padding: 12px 0; flex: 1; }
.nav-section { margin: 16px 10px 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 800; }
.nav-link { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px; display: flex; align-items: center; text-decoration: none; border: 0; background: transparent; color: var(--text); font-weight: 700; text-align: left; }
.nav-link:hover, .nav-link:focus-visible, .nav-link.active { background: color-mix(in srgb, var(--accent) 12%, white); color: var(--primary); outline: none; }
.nav-button { cursor: pointer; }
.drawer-user { padding: 14px; border-radius: 14px; background: var(--page); }
.drawer-user strong, .drawer-user span { display: block; }
.drawer-user span { margin-top: 3px; color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }

.page-container { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 28px) 0 max(34px, env(safe-area-inset-bottom)); }
.app-page-container { width: min(1400px, calc(100% - 24px)); }
.content-section { display: grid; gap: 18px; }
.narrow-section { max-width: 720px; margin-inline: auto; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 1.08; margin-bottom: 10px; }
h2 { font-size: 1.25rem; margin-bottom: 8px; }
h3 { font-size: 1rem; margin: 0; }
.eyebrow { margin: 0 0 6px; color: var(--accent); text-transform: uppercase; letter-spacing: .09em; font-weight: 900; font-size: .74rem; }
.muted { color: var(--muted); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin: 8px 0 14px; }
.section-heading h1, .section-heading h2, .section-heading p { margin-bottom: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.btn { min-height: 44px; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: #EAF0F5; color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: #FDECEA; color: var(--danger); }
.btn-large { min-height: 52px; padding-inline: 22px; }
.btn-small { min-height: 38px; padding: 8px 12px; font-size: .88rem; }
.btn-full { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }

.flash { margin-bottom: 18px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font-weight: 700; }
.flash.success { border-color: #9BD5B6; background: #F0FBF5; }
.flash.error { border-color: #F1B5AF; background: #FEF3F2; color: #8A1C13; }
.flash.warning { border-color: #F0D38A; background: #FFFAEB; color: #7A5200; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.copy-row input { min-width: 0; }

.auth-shell { min-height: calc(100vh - 150px); display: grid; place-items: center; }
.auth-card { width: min(100%, 520px); background: #fff; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: clamp(22px, 5vw, 38px); }
.auth-logo { width: 58px; height: 58px; background: var(--primary); color: #fff; font-size: 1.7rem; margin-bottom: 22px; }
.text-link { display: inline-block; margin-top: 18px; color: var(--accent); font-weight: 800; }
.form-stack { display: grid; gap: 14px; }
.form-stack label, .app-dialog label { display: grid; gap: 7px; font-size: .86rem; font-weight: 800; color: var(--text); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input:not([type]) { width: 100%; min-height: 48px; border: 1px solid #C9D4DE; border-radius: 12px; padding: 10px 12px; background: #fff; color: var(--text); }
input:focus { outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
.form-hint { color: var(--muted); font-size: .82rem; margin: -4px 0 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.touch-choice { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.touch-choice legend { width: 100%; margin-bottom: 6px; font-size: .86rem; font-weight: 800; }
.touch-choice label { position: relative; }
.touch-choice input { position: absolute; opacity: 0; pointer-events: none; }
.touch-choice span, .category-choice-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 12px; padding: 9px 15px; background: #fff; font-weight: 800; }
.touch-choice input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }
.toggle-line { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 10px !important; }
.toggle-line input { width: 24px; height: 24px; accent-color: var(--primary); }
.admin-grid { display: grid; grid-template-columns: minmax(300px, .75fr) minmax(0, 1.5fr); gap: 18px; align-items: start; }
.user-list { display: grid; gap: 14px; }
.user-card { display: grid; gap: 16px; }
.card-title-row { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.card-title-row h2, .card-title-row p { margin-bottom: 2px; }
.status-pill { border-radius: 999px; padding: 6px 10px; font-size: .76rem; font-weight: 900; }
.status-pill.ok { background: #E8F7EF; color: var(--success); }
.status-pill.off { background: #F1F3F5; color: #667085; }
.compact-form { padding-top: 4px; border-top: 1px solid var(--line); }

.sync-banner { position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top) + 8px); z-index: 40; min-height: 42px; margin-bottom: 14px; padding: 8px 12px; border-radius: 13px; background: #ECF8F1; color: #17653A; border: 1px solid #B8E1C9; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.06); font-weight: 800; font-size: .82rem; }
.sync-banner.offline { background: #FFF7E6; color: #805A00; border-color: #EED18C; }
.sync-banner.pending { background: #EEF5FF; color: #245C99; border-color: #BFD5EE; }
.sync-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: currentColor; }
.syncing .sync-dot { animation: pulse 1s infinite; }
.sync-action { margin-left: auto; border: 0; background: transparent; color: inherit; font-weight: 900; padding: 6px 8px; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.72); } }

.gradebook-app { display: grid; gap: 10px; }
.app-view { min-width: 0; }
.hero-panel { border-radius: 24px; padding: clamp(22px, 4vw, 38px); background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 72%, var(--accent))); color: #fff; display: flex; align-items: end; justify-content: space-between; gap: 20px; box-shadow: var(--shadow); }
.hero-panel .eyebrow { color: #CDE6FF; }
.hero-panel h1 { max-width: 650px; }
.hero-panel p:not(.eyebrow) { margin: 0; opacity: .86; }
.hero-panel .btn-primary { background: #fff; color: var(--primary); flex: 0 0 auto; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0 22px; }
.metric-card { min-height: 100px; background: #fff; border: 1px solid var(--line); border-radius: 17px; padding: 18px; display: flex; flex-direction: column; justify-content: center; box-shadow: 0 8px 20px rgba(11,45,77,.06); }
.metric-card strong { font-size: 1.8rem; color: var(--primary); }
.metric-card span { color: var(--muted); font-weight: 700; }
.course-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.course-summary-card { min-height: 140px; text-align: left; border: 1px solid var(--line); border-radius: 18px; background: #fff; padding: 20px; box-shadow: 0 8px 20px rgba(11,45,77,.06); display: grid; align-content: center; gap: 8px; color: var(--text); }
.course-summary-card strong { font-size: 1.2rem; }
.course-summary-card span { color: var(--muted); }
.course-summary-card i { font-style: normal; color: var(--accent); font-weight: 900; margin-top: 7px; }

.course-tabs, .touch-selector { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: thin; }
.touch-chip { flex: 0 0 auto; min-height: 46px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 10px 16px; font-weight: 900; color: var(--text); }
.touch-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.course-workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.course-workspace-head h2, .course-workspace-head p { margin-bottom: 3px; }
.manage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.manage-panel { min-width: 0; }
.mini-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.mini-heading > div { display: flex; align-items: center; gap: 9px; }
.mini-heading span { color: var(--muted); font-size: .82rem; font-weight: 800; }
.weight-ok { color: var(--success) !important; }
.weight-warning { color: var(--warning) !important; }
.student-manage-list, .category-list { display: grid; gap: 7px; max-height: 460px; overflow-y: auto; }
.manage-row { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 6px 8px 10px; border-radius: 12px; background: #F7F9FB; }
.manage-row strong, .manage-row small { display: block; }
.manage-row small { color: var(--muted); margin-top: 2px; }
.manage-name-button { border: 0; background: transparent; text-align: left; padding: 0; color: inherit; flex: 1; }
.icon-action { width: 38px; height: 38px; flex: 0 0 auto; border: 0; border-radius: 11px; background: #EEF2F5; font-size: 1.25rem; font-weight: 800; }
.icon-action.danger { color: var(--danger); background: #FDECEA; }
.category-row { display: grid; grid-template-columns: 1fr 38px; gap: 7px; align-items: center; }
.category-card { min-height: 58px; width: 100%; display: grid; grid-template-columns: 9px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: #fff; padding: 8px 10px; text-align: left; color: var(--text); }
.category-card strong, .category-card small { display: block; }
.category-card small { color: var(--muted); margin-top: 2px; }
.category-card i { font-style: normal; color: var(--accent); font-size: .8rem; font-weight: 900; }
.category-swatch, .context-color { background: var(--category-color); border-radius: 999px; }
.category-swatch { width: 8px; height: 38px; }
.assessments-panel { margin-top: 14px; }
.assessment-grid { display: grid; gap: 9px; }
.assessment-card { min-height: 82px; border: 1px solid var(--line); border-radius: 15px; background: #fff; display: grid; grid-template-columns: 8px 1fr auto; overflow: hidden; }
.assessment-color { background: var(--category-color); }
.assessment-content { padding: 13px; display: grid; gap: 3px; }
.assessment-content small, .assessment-content span { color: var(--muted); }
.assessment-content strong { font-size: 1rem; }
.assessment-actions { display: flex; align-items: center; gap: 6px; padding: 10px; }
.notice-line { color: var(--warning); font-weight: 800; }
.inline-empty { padding: 18px; border: 1px dashed #C8D3DD; border-radius: 13px; color: var(--muted); text-align: center; }
.inline-empty.wide { min-width: min(420px, 90vw); }
.empty-state { min-height: 140px; border: 1px dashed #C8D3DD; border-radius: 17px; display: grid; place-content: center; gap: 5px; padding: 20px; text-align: center; color: var(--muted); background: rgba(255,255,255,.5); }
.empty-state strong { color: var(--text); }

.grade-heading { align-items: center; }
.grade-context { display: flex; align-items: center; gap: 9px; min-height: 48px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.grade-context strong, .grade-context small { display: block; }
.grade-context small { color: var(--muted); margin-top: 2px; }
.context-color { width: 8px; height: 34px; }
.assessment-selector { padding-bottom: 12px; }
.assessment-chip { flex: 0 0 auto; min-width: 190px; min-height: 60px; border: 1px solid var(--line); border-left: 7px solid var(--category-color); border-radius: 14px; background: #fff; text-align: left; padding: 9px 12px; color: var(--text); }
.assessment-chip span, .assessment-chip small { display: block; }
.assessment-chip span { font-weight: 900; }
.assessment-chip small { color: var(--muted); margin-top: 3px; }
.assessment-chip.active { box-shadow: inset 0 0 0 2px var(--primary); border-color: var(--primary); border-left-color: var(--category-color); }
.grade-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 14px; align-items: start; }
.student-grade-list { background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); min-height: 300px; }
.student-grade-row { width: 100%; min-height: 64px; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; display: grid; grid-template-columns: 34px 1fr 54px; align-items: center; gap: 10px; text-align: left; color: var(--text); }
.student-grade-row:last-child { border-bottom: 0; }
.student-grade-row.active { background: color-mix(in srgb, var(--accent) 10%, white); box-shadow: inset 5px 0 0 var(--accent); }
.student-index { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #EEF2F5; color: var(--muted); font-size: .78rem; font-weight: 900; }
.student-name strong, .student-name small { display: block; }
.student-name small { color: var(--muted); margin-top: 3px; }
.student-score { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: #EEF2F5; font-size: 1.25rem; font-weight: 900; color: var(--muted); }
.student-score.has-score { background: var(--category-color, var(--primary)); color: #fff; }
.score-pad { position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top) + 62px); background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 14px; }
.score-pad-head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 4px 4px 12px; }
.score-pad-head small, .score-pad-head strong { display: block; }
.score-pad-head small { color: var(--muted); margin-bottom: 2px; }
.current-score { min-width: 54px; height: 54px; display: grid; place-items: center; border-radius: 15px; background: var(--primary); color: #fff; font-size: 1.6rem; font-weight: 900; }
.score-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.score-button { aspect-ratio: 1.22 / 1; min-height: 54px; border: 1px solid #CBD5DF; border-radius: 13px; background: #F8FAFC; color: var(--primary); font-size: 1.2rem; font-weight: 900; }
.score-button.active { background: var(--accent); color: #fff; border-color: var(--accent); transform: scale(.97); }
.score-button:active { transform: scale(.95); }
.score-nav { display: grid; grid-template-columns: 58px 1fr 58px; gap: 8px; margin-top: 10px; }
.score-nav-btn, .score-clear { min-height: 52px; border: 0; border-radius: 13px; font-weight: 900; }
.score-nav-btn { background: var(--primary); color: #fff; font-size: 1.4rem; }
.score-clear { background: #EEF2F5; color: var(--text); }
.score-nav-btn:disabled, .score-clear:disabled { opacity: .35; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.theme-form { display: grid; gap: 12px; }
.color-row { min-height: 56px; display: flex !important; grid-template-columns: unset !important; align-items: center; justify-content: space-between; gap: 14px !important; padding: 8px 10px 8px 14px; border: 1px solid var(--line); border-radius: 13px; }
input[type="color"] { width: 72px; height: 40px; border: 0; padding: 0; border-radius: 10px; background: transparent; }
.offline-explainer { margin-top: 16px; padding: 14px; background: var(--page); border-radius: 13px; }
.offline-explainer strong, .offline-explainer span { display: block; }
.offline-explainer span { color: var(--muted); margin-top: 4px; }

.app-dialog, .confirm-dialog { width: min(92vw, 560px); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 30px 80px rgba(0,0,0,.28); color: var(--text); }
.app-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(4,17,30,.55); }
.app-dialog form, .confirm-dialog form { padding: 20px; display: grid; gap: 16px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-head h2 { margin: 0; }
.icon-close { width: 42px; height: 42px; border: 0; border-radius: 12px; background: #EEF2F5; font-size: 1.5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.stepper-field { display: grid; gap: 7px; font-size: .86rem; font-weight: 800; }
.weight-stepper { display: grid; grid-template-columns: 54px 1fr 54px; gap: 8px; }
.weight-stepper button, .weight-stepper output { min-height: 50px; border: 1px solid var(--line); border-radius: 13px; display: grid; place-items: center; background: #F8FAFC; color: var(--primary); font-weight: 900; font-size: 1.1rem; }
.weight-stepper button { font-size: 1.5rem; }
.category-choice { display: flex; flex-wrap: wrap; gap: 8px; }
.category-choice legend { width: 100%; }
.category-choice-button { gap: 8px; color: var(--text); }
.category-choice-button > span { width: 9px; height: 28px; border-radius: 999px; background: var(--category-color); padding: 0; min-height: 0; border: 0; }
.category-choice-button.active { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }

.toast { position: fixed; z-index: 120; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: min(90vw, 520px); padding: 12px 16px; border-radius: 13px; background: #172434; color: #fff; font-weight: 800; opacity: 0; visibility: hidden; transition: .18s ease; box-shadow: 0 12px 34px rgba(0,0,0,.25); text-align: center; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

@media (max-width: 900px) {
    .admin-grid, .manage-grid, .settings-grid { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .grade-layout { grid-template-columns: 1fr 340px; }
    .score-button { min-height: 50px; }
}

@media (max-width: 720px) {
    :root { --topbar-h: 58px; }
    .page-container, .app-page-container { width: min(100% - 16px, 1400px); padding-top: calc(var(--topbar-h) + env(safe-area-inset-top) + 18px); }
    .topbar { grid-template-columns: 46px 1fr auto; }
    .topbar-user { display: none; }
    .topbar-brand { font-size: .98rem; }
    .hero-panel { align-items: stretch; flex-direction: column; }
    .hero-panel .btn-primary { width: 100%; }
    .metric-grid { gap: 8px; }
    .metric-card { min-height: 84px; padding: 14px; }
    .metric-card strong { font-size: 1.5rem; }
    .section-heading { align-items: center; }
    .section-heading.grade-heading { align-items: stretch; flex-direction: column; }
    .grade-context { width: 100%; }
    .course-workspace-head { align-items: stretch; flex-direction: column; }
    .assessment-card { grid-template-columns: 7px 1fr; }
    .assessment-actions { grid-column: 2; padding-top: 0; flex-wrap: wrap; }
    .two-col { grid-template-columns: 1fr; }
    .copy-row { grid-template-columns: 1fr; }

    .grades-view { padding-bottom: 360px; }
    .grade-layout { display: block; }
    .student-grade-list { min-height: 180px; }
    .score-pad {
        position: fixed; z-index: 55; left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); top: auto;
        border-radius: 18px; padding: 10px; box-shadow: 0 -12px 40px rgba(7,30,53,.22);
    }
    .score-pad-head { padding-bottom: 8px; }
    .current-score { min-width: 46px; height: 46px; font-size: 1.35rem; }
    .score-grid { gap: 6px; }
    .score-button { min-height: 44px; aspect-ratio: auto; border-radius: 11px; font-size: 1.05rem; }
    .score-nav { margin-top: 7px; grid-template-columns: 52px 1fr 52px; gap: 6px; }
    .score-nav-btn, .score-clear { min-height: 46px; }
    .student-grade-row { min-height: 60px; padding-inline: 9px; }
    .sync-banner { top: calc(var(--topbar-h) + env(safe-area-inset-top) + 6px); }
}

@media (max-width: 430px) {
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .btn { padding-inline: 12px; }
    .section-heading > .btn { flex: 0 0 auto; }
    .assessment-actions .btn { flex: 1; }
    .grade-context { font-size: .9rem; }
    .student-name strong { font-size: .92rem; }
    .student-name small { font-size: .76rem; }
    .grades-view { padding-bottom: 344px; }
}

@media (orientation: landscape) and (min-width: 900px) {
    .score-pad { position: sticky; }
    .student-grade-list { max-height: calc(100vh - 260px); overflow-y: auto; }
}

.summary-panel { margin-top: 14px; }
.summary-scroll { overflow-x: auto; }
.grade-summary-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.grade-summary-table th, .grade-summary-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.grade-summary-table th:first-child, .grade-summary-table td:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.grade-summary-table th { color: var(--muted); font-size: .8rem; vertical-align: bottom; }
.grade-summary-table th small { display: block; margin-top: 3px; }
.grade-summary-table tbody tr:last-child td { border-bottom: 0; }
.summary-category-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--category-color); }
.summary-total { font-weight: 900; color: var(--primary); }

/* Kursarten & Schülerimport */
.button-row.compact { gap: 6px; }
.student-title-line, .selected-student-line { display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
.student-title-line strong { min-width: 0; }
.manage-name-button small { overflow-wrap: anywhere; }
.course-type-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: .68rem; line-height: 1; font-weight: 950; letter-spacing: .035em; white-space: nowrap; border: 1px solid transparent; vertical-align: middle; }
.course-type-badge.abi { background: #FCE7F3; color: #9D174D; border-color: #F9A8D4; }
.course-type-badge.lk { background: #E0F2FE; color: #075985; border-color: #7DD3FC; }
.course-type-badge.gk { background: #ECFDF3; color: #166534; border-color: #86EFAC; }
.course-type-badge.other { background: #F1F5F9; color: #475569; border-color: #CBD5E1; }
.course-type-choice button { min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 9px 15px; background: #fff; color: var(--text); font-weight: 900; }
.course-type-choice button.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.score-pad-head .selected-student-line { justify-content: flex-start; }
.grade-summary-table .student-title-line { flex-wrap: nowrap; }

@media (max-width: 430px) {
    .course-type-badge { min-height: 22px; padding: 3px 7px; font-size: .64rem; }
    .mini-heading .button-row.compact .btn { padding-inline: 10px; }
}

/* Benutzerverwaltung 0.3.0 */
.info-panel { margin-bottom: 18px; }
.info-panel p { margin: 6px 0 0; }
.user-admin-actions { display: grid; gap: 10px; }
.user-admin-actions form { margin: 0; }

/* Kategorienhierarchie, Schnellanlage & kompakter Sync-Status 0.4.0 */
.drawer-sync {
    margin: 14px 8px 4px;
    min-height: 34px;
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    padding: 7px 9px;
    border-radius: 10px;
    background: #F1F8F4;
    color: #17653A;
    font-size: .72rem;
    font-weight: 800;
    border: 1px solid #D5EBDD;
}
.drawer-sync.offline { background: #FFF8E8; color: #805A00; border-color: #F0DEAB; }
.drawer-sync.pending { background: #F2F6FC; color: #245C99; border-color: #D8E3F0; }
.drawer-sync button { border: 0; background: transparent; color: inherit; padding: 4px 3px; font-weight: 900; font-size: .7rem; }
.drawer-sync .sync-dot { width: 7px; height: 7px; }

.grade-create-bar {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.grade-create-bar strong, .grade-create-bar small { display: block; }
.grade-create-bar small { margin-top: 2px; color: var(--muted); font-size: .78rem; }

.structure-panel { margin-top: 14px; }
.structure-help { margin: -2px 0 14px; font-size: .85rem; }
.category-tree { display: grid; gap: 12px; }
.category-tree-node {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--category-color) 3%, white);
    overflow: hidden;
}
.category-tree-node .category-tree-node { box-shadow: none; }
.category-tree-head {
    min-height: 58px;
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-bottom: 1px solid color-mix(in srgb, var(--category-color) 18%, var(--line));
}
.category-tree-head > .category-swatch { width: 9px; height: 38px; border-radius: 999px; background: var(--category-color); }
.category-tree-title { border: 0; background: transparent; padding: 4px 2px; color: var(--text); text-align: left; min-width: 0; }
.category-tree-title strong, .category-tree-title small { display: block; }
.category-tree-title small { color: var(--muted); margin-top: 3px; font-size: .75rem; }
.category-tree-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.btn-tiny { min-height: 34px; padding: 6px 9px; border-radius: 10px; font-size: .76rem; }
.structure-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
    gap: 10px;
    padding: 10px;
    background: rgba(255,255,255,.68);
}
.structure-items > .category-tree-node { align-self: start; }
.structure-assessment {
    min-height: 76px;
    display: grid;
    grid-template-columns: 7px minmax(0, 1fr) auto;
    border: 1px solid var(--line);
    border-radius: 13px;
    overflow: hidden;
    background: #fff;
}
.structure-assessment .assessment-color { background: var(--category-color); }
.structure-assessment .assessment-content { padding: 10px; min-width: 0; }
.structure-assessment .assessment-content strong,
.structure-assessment .assessment-content small,
.structure-assessment .assessment-content span { display: block; }
.structure-assessment .assessment-content small,
.structure-assessment .assessment-content span { color: var(--muted); font-size: .76rem; }
.structure-assessment .assessment-content strong { margin: 2px 0 3px; overflow-wrap: anywhere; }
.structure-assessment .assessment-actions { padding: 8px; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
.inline-empty.compact { min-height: 50px; padding: 12px; }
.student-manage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 8px; }

.app-dialog-wide { width: min(94vw, 680px); }
.category-parent-choice, .category-choice { max-height: 245px; overflow-y: auto; align-content: start; padding: 2px 2px 4px; }
.category-parent-choice .category-choice-button,
.category-choice .category-choice-button { text-align: left; justify-content: flex-start; }
.dialog-hint { margin: -5px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }

@media (max-width: 720px) {
    .grade-create-bar { align-items: stretch; flex-direction: column; }
    .grade-create-bar .button-row { display: grid; grid-template-columns: 1fr 1fr; }
    .category-tree-head { grid-template-columns: 8px minmax(0, 1fr); }
    .category-tree-actions { grid-column: 2; justify-content: flex-start; }
    .structure-items { grid-template-columns: 1fr; }
    .structure-assessment { grid-template-columns: 6px minmax(0, 1fr); }
    .structure-assessment .assessment-actions { grid-column: 2; justify-content: flex-start; padding-top: 0; }
}
