/* EdMat components. Tokens only: colours, spacing, radius, sizes and shadows come from tokens.css. */
body { margin: 0; font-family: var(--font-sans); font-size: 0.9375rem; line-height: 1.5; background: var(--surface); color: var(--ink); -webkit-font-smoothing: antialiased; }
*, *::before, *::after { box-sizing: border-box; }
.ed-num { font-variant-numeric: tabular-nums; }
.ed-mono { font-family: var(--font-mono); font-size: 0.875rem; }
.ed-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ed-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-4); }
.ed-col { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4); }
.ed-icon { width: var(--icon); height: var(--icon); flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* focus: one ring everywhere */
:where(button, a[href], input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid transparent; outline-offset: 2px; box-shadow: var(--focus-ring); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; } }

/* Button */
.ed-btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control); padding: 0 var(--space-4); border-radius: var(--radius-md); border: var(--border) solid var(--line-strong); background: var(--surface-raised); color: var(--ink); cursor: pointer; text-decoration: none; transition: background-color 120ms, color 120ms, border-color 120ms; }
.ed-btn:hover { background: var(--surface-sunken); }
.ed-btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.ed-btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.ed-btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.ed-btn-danger:hover { filter: brightness(0.92); }
.ed-btn-quiet { border-color: transparent; background: transparent; color: var(--brand); }
.ed-btn-quiet:hover { background: var(--brand-soft); }
.ed-btn-sm { min-height: var(--control-sm); padding: 0 var(--space-3); font-size: 0.875rem; }
.ed-btn-icon { padding: 0; width: var(--control); }
.ed-btn-icon.ed-btn-sm { width: var(--control-sm); }
.ed-btn[disabled], .ed-btn[aria-disabled="true"] { background: var(--surface-sunken); border-color: var(--line); color: var(--ink-subtle); cursor: not-allowed; }
.ed-btn[aria-busy="true"] .ed-spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: var(--radius-full); animation: ed-spin 0.8s linear infinite; }
@keyframes ed-spin { to { transform: rotate(360deg); } }
@media (pointer: coarse) { .ed-btn { min-height: var(--touch); } }
[data-theme="hc"] .ed-btn { border-width: var(--border-hc); }

/* Kbd */
.ed-kbd { display: inline-block; font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.3; padding: 1px var(--space-2); border: var(--border) solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--ink); }
.ed-kbd-seq { display: inline-flex; gap: var(--space-1); align-items: center; }

/* Fields */
.ed-field { display: flex; flex-direction: column; gap: var(--space-1); max-width: 100%; }
.ed-label { font-weight: 500; }
.ed-label .ed-req { color: var(--danger); margin-left: 2px; }
.ed-hint { font-size: 0.8125rem; color: var(--ink-muted); }
.ed-error { font-size: 0.8125rem; color: var(--danger); display: flex; gap: var(--space-1); align-items: flex-start; }
.ed-error .ed-icon { width: 16px; height: 16px; margin-top: 2px; }
.ed-input, .ed-select { font: inherit; min-height: var(--control); padding: 0 var(--space-3); border-radius: var(--radius-sm); border: var(--border) solid var(--line-strong); background: var(--surface-raised); color: var(--ink); width: 100%; }
.ed-input::placeholder { color: var(--ink-subtle); }
textarea.ed-input { min-height: calc(var(--control) * 2); padding: var(--space-2) var(--space-3); line-height: 1.5; resize: vertical; font-family: inherit; }
.ed-input[aria-invalid="true"], .ed-select[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.ed-input[disabled], .ed-select[disabled] { background: var(--surface-sunken); color: var(--ink-subtle); cursor: not-allowed; }
.ed-input[readonly] { background: var(--surface-sunken); }
.ed-input-mono { font-family: var(--font-mono); letter-spacing: 0.06em; }
.ed-input-wrap { position: relative; display: flex; align-items: center; }
.ed-input-wrap .ed-affix { position: absolute; right: var(--space-3); color: var(--ink-muted); font-size: 0.8125rem; pointer-events: none; }
.ed-select { appearance: none; padding-right: var(--space-8); background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7178' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right var(--space-3) center; background-size: 20px; }
[data-theme="dark"] .ed-select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a8b0b6' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); }
[data-theme="hc"] .ed-select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); }
[data-theme="hc"] .ed-input, [data-theme="hc"] .ed-select { border-width: var(--border-hc); }

/* Checkbox, Radio, Switch */
.ed-check { display: inline-flex; gap: var(--space-2); align-items: flex-start; min-height: var(--control-sm); cursor: pointer; }
.ed-check input { appearance: none; margin: 2px 0 0; width: 20px; height: 20px; flex: 0 0 auto; border: var(--border) solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-raised); display: grid; place-content: center; cursor: pointer; }
.ed-check input[type="radio"] { border-radius: var(--radius-full); }
.ed-check input:checked { background: var(--brand); border-color: var(--brand); }
.ed-check input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--on-brand); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.ed-check input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--on-brand); }
.ed-check input:indeterminate { background: var(--brand); border-color: var(--brand); }
.ed-check input:indeterminate::after { content: ""; width: 10px; height: 2px; background: var(--on-brand); }
.ed-check input[disabled] { background: var(--surface-sunken); border-color: var(--line); cursor: not-allowed; }
.ed-check input[disabled] + span { color: var(--ink-subtle); }
.ed-check .ed-check-text { display: flex; flex-direction: column; }
.ed-check .ed-hint { margin-top: 1px; }
[data-theme="hc"] .ed-check input { border-width: var(--border-hc); }
.ed-radiogroup { display: flex; flex-direction: column; gap: var(--space-2); border: 0; padding: 0; margin: 0; }
.ed-radiogroup legend { font-weight: 500; padding: 0; margin-bottom: var(--space-2); }
.ed-radiogroup-row { flex-direction: row; flex-wrap: wrap; gap: var(--space-4); }
.ed-switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; min-height: var(--control-sm); }
.ed-switch-track { position: relative; width: 44px; height: 24px; border-radius: var(--radius-full); border: var(--border) solid var(--line-strong); background: var(--surface-sunken); flex: 0 0 auto; transition: background-color 120ms; }
.ed-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: var(--radius-full); background: var(--line-strong); transition: transform 120ms, background-color 120ms; }
.ed-switch[aria-checked="true"] .ed-switch-track { background: var(--brand); border-color: var(--brand); }
.ed-switch[aria-checked="true"] .ed-switch-track::after { transform: translateX(20px); background: var(--on-brand); }
.ed-switch-state { font-size: 0.8125rem; color: var(--ink-muted); min-width: 3ch; }
.ed-switch[aria-checked="true"] .ed-switch-track::before { content: ""; position: absolute; left: 7px; top: 8px; width: 6px; height: 3px; border: 2px solid var(--on-brand); border-top: 0; border-right: 0; transform: rotate(-45deg); }
[data-theme="hc"] .ed-switch-track { border-width: var(--border-hc); }
.ed-switch[disabled] { cursor: not-allowed; color: var(--ink-subtle); }
.ed-switch[disabled] .ed-switch-track { background: var(--surface-sunken); border-color: var(--line-strong); }
.ed-switch[disabled] .ed-switch-track::after { background: var(--ink-subtle); }
.ed-switch[disabled] .ed-switch-track::before { border-color: var(--ink-subtle); }

/* GradeInput */
.ed-gradeinput { display: inline-flex; flex-direction: column; gap: var(--space-1); }
.ed-gradeinput-box { display: inline-flex; align-items: center; gap: var(--space-2); }
.ed-gradeinput input { width: 64px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 1rem; }
.ed-gradeinput-preview { font-size: 0.8125rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ed-gradeinput-block { display: flex; gap: var(--space-2); align-items: flex-start; font-size: 0.8125rem; color: var(--danger); max-width: 36ch; }
.ed-gradeinput-block .ed-icon { width: 16px; height: 16px; margin-top: 2px; }

/* AttendanceChip */
.ed-att { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 28px; padding: 0 var(--space-2); border-radius: var(--radius-full); border: var(--border) solid transparent; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ed-att-code { font-size: 0.8125rem; }
.ed-att-word { font-weight: 400; }
.ed-att-ob { background: var(--att-present-soft); color: var(--att-present); }
.ed-att-nb { background: var(--att-absent-soft); color: var(--att-absent); }
.ed-att-sp { background: var(--att-late-soft); color: var(--att-late); }
.ed-att-zw { background: var(--att-excused-soft); color: var(--att-excused); }
.ed-att-u  { background: var(--att-justified-soft); color: var(--att-justified); }
.ed-att-rs, .ed-att-w { background: var(--surface-raised); color: var(--att-school); border-color: var(--att-school); }
.ed-att-draft { background: var(--surface-raised); color: var(--accent); border: var(--border) dashed var(--accent); }
.ed-att-none { background: var(--surface-sunken); color: var(--ink-muted); }
button.ed-att { cursor: pointer; font-family: inherit; }
button.ed-att[aria-pressed="true"] { box-shadow: inset 0 0 0 1px currentColor; }
[data-theme="hc"] .ed-att { border-color: var(--ink); border-width: var(--border-hc); }
[data-theme="hc"] .ed-att-draft { border-style: dashed; }
.ed-att-group { display: inline-flex; gap: var(--space-1); padding: 2px; }
.ed-att-group .ed-att { min-width: 36px; justify-content: center; min-height: 32px; }
@media (pointer: coarse) { .ed-att-group .ed-att { min-height: var(--touch); min-width: var(--touch); } }

/* AttendanceRoster */
.ed-roster { border: var(--border) solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); overflow: hidden; }
.ed-roster-head { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border-bottom: var(--border) solid var(--line); background: var(--surface-sunken); }
.ed-roster-head h3 { margin: 0; font-size: 1rem; font-weight: 500; flex: 1 1 auto; }
.ed-roster-count { font-size: 0.8125rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ed-roster table { width: 100%; border-collapse: collapse; }
.ed-roster th, .ed-roster td { text-align: left; padding: var(--space-2) var(--space-4); border-bottom: var(--border) solid var(--line); vertical-align: middle; }
.ed-roster tr:last-child td { border-bottom: 0; }
.ed-roster th[scope="row"] { font-weight: 400; }
.ed-roster .ed-no { color: var(--ink-muted); font-variant-numeric: tabular-nums; width: 3ch; padding-right: 0; }
.ed-roster tr.ed-nb { background: var(--danger-soft); }
.ed-roster tr:focus-within { background: var(--brand-soft); }
.ed-roster .ed-late-min { display: inline-flex; align-items: center; gap: var(--space-1); margin-left: var(--space-2); }
.ed-roster .ed-late-min input { width: 56px; min-height: var(--control-sm); padding: 0 var(--space-2); text-align: right; }
[data-theme="hc"] .ed-roster, [data-theme="hc"] .ed-roster th, [data-theme="hc"] .ed-roster td { border-color: var(--ink); }

/* GradeCell */
.ed-grade { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 2px; width: var(--grade-cell); height: var(--grade-cell); border-radius: var(--radius-sm); border: var(--border) solid var(--line); background: var(--surface-raised); color: var(--ink); font-weight: 600; font-size: 1rem; font-variant-numeric: tabular-nums; cursor: default; font-family: inherit; padding: 0; }
button.ed-grade { cursor: pointer; }
.ed-grade.ed-cat-1 { background: var(--cat-1); } .ed-grade.ed-cat-2 { background: var(--cat-2); } .ed-grade.ed-cat-3 { background: var(--cat-3); } .ed-grade.ed-cat-4 { background: var(--cat-4); }
.ed-grade.ed-cat-5 { background: var(--cat-5); } .ed-grade.ed-cat-6 { background: var(--cat-6); } .ed-grade.ed-cat-7 { background: var(--cat-7); } .ed-grade.ed-cat-8 { background: var(--cat-8); }
.ed-grade-fail { color: var(--danger); }
.ed-grade-special { color: var(--ink-muted); background: var(--surface-sunken); font-weight: 500; font-size: 0.8125rem; letter-spacing: 0.02em; }
.ed-grade-proposed { font-style: italic; color: var(--accent); border-style: dashed; border-color: var(--accent); background: var(--surface-raised); }
.ed-grade-empty { color: var(--ink-subtle); font-weight: 400; background: var(--surface-raised); }
.ed-grade-retake .ed-old { font-size: 0.75rem; font-weight: 400; color: var(--ink-muted); text-decoration: line-through; }
.ed-grade-retake .ed-arrow { font-size: 0.75rem; color: var(--ink-muted); }
.ed-grade-comment::after { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: var(--radius-full); background: var(--ink); }
.ed-grade-lock .ed-icon { position: absolute; bottom: 2px; right: 2px; width: 11px; height: 11px; stroke-width: 2.2; }
.ed-grade[aria-readonly="true"] { cursor: default; }
.ed-grade-w { position: absolute; top: -6px; left: -4px; font-size: 0.6875rem; line-height: 1; font-weight: 500; letter-spacing: 0.04em; padding: 1px 3px; border-radius: var(--radius-sm); background: var(--surface-inverse); color: var(--ink-inverse); }
.ed-grade-wrap { position: relative; display: inline-block; padding: 6px 0 0 4px; }
[data-theme="hc"] .ed-grade { border-color: var(--ink); border-width: var(--border-hc); }
[data-theme="hc"] .ed-grade-proposed { border-style: dashed; }

/* GradeGrid */
.ed-grid-scroll { overflow: auto; max-width: 100%; border: var(--border) solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); }
.ed-grid { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.ed-grid caption { text-align: left; padding: var(--space-3) var(--space-4); font-weight: 500; }
.ed-grid th, .ed-grid td { padding: var(--space-2); border-bottom: var(--border) solid var(--line); border-right: var(--border) solid var(--line); vertical-align: middle; white-space: nowrap; }
.ed-grid thead th { position: sticky; top: 0; z-index: var(--z-sticky); background: var(--surface-sunken); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); text-align: center; min-width: 48px; }
.ed-grid thead th .ed-grid-cat { display: block; width: 100%; height: 4px; border-radius: 2px; margin-top: 4px; }
.ed-grid thead th .ed-grid-w { display: block; font-weight: 600; color: var(--ink); letter-spacing: 0.02em; text-transform: none; }
.ed-grid th[scope="row"], .ed-grid .ed-grid-corner { position: sticky; left: 0; z-index: calc(var(--z-sticky) + 1); background: var(--surface-raised); text-align: left; font-weight: 400; min-width: 200px; }
.ed-grid thead .ed-grid-corner { z-index: calc(var(--z-sticky) + 2); background: var(--surface-sunken); }
.ed-grid th[scope="row"] .ed-no { color: var(--ink-muted); font-variant-numeric: tabular-nums; display: inline-block; width: 3ch; }
.ed-grid td { text-align: center; }
.ed-grid td.ed-grid-avg, .ed-grid th.ed-grid-avg { background: var(--surface-sunken); font-variant-numeric: tabular-nums; font-weight: 600; min-width: 64px; }
.ed-grid tr:hover td, .ed-grid tr:hover th[scope="row"] { background: var(--surface-sunken); }
.ed-grid tr.ed-nb td.ed-grid-blocked { color: var(--ink-subtle); }
.ed-grid .ed-grid-blocked .ed-att { min-height: 22px; font-size: 0.6875rem; padding: 0 6px; }
.ed-grid .ed-grid-blockedbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; min-height: var(--control-sm); border-radius: var(--radius-full); }
.ed-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-3) var(--space-4); font-size: 0.8125rem; color: var(--ink-muted); border-top: var(--border) solid var(--line); }
.ed-legend span { display: inline-flex; align-items: center; gap: var(--space-1); }
.ed-legend i { width: 14px; height: 14px; border-radius: 3px; border: var(--border) solid var(--line-strong); display: inline-block; }
[data-theme="hc"] .ed-grid th, [data-theme="hc"] .ed-grid td, [data-theme="hc"] .ed-grid-scroll { border-color: var(--ink); }

/* Badge */
.ed-badge { display: inline-flex; align-items: center; gap: var(--space-1); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1; padding: 5px var(--space-2); border-radius: var(--radius-sm); background: var(--surface-sunken); color: var(--ink); border: var(--border) solid transparent; }
.ed-badge-brand { background: var(--brand-soft); color: var(--brand); }
.ed-badge-success { background: var(--success-soft); color: var(--success); }
.ed-badge-accent { background: var(--accent-soft); color: var(--accent); }
.ed-badge-danger { background: var(--danger-soft); color: var(--danger); }
.ed-badge-info { background: var(--info-soft); color: var(--info); }
.ed-badge-outline { background: transparent; border-color: var(--line-strong); color: var(--ink-muted); }
.ed-badge .ed-icon { width: 12px; height: 12px; stroke-width: 2.2; }
[data-theme="hc"] .ed-badge { border-color: var(--ink); }

/* ProgressBar */
.ed-progress { display: flex; flex-direction: column; gap: var(--space-1); min-width: 160px; }
.ed-progress-head { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 0.8125rem; }
.ed-progress-head b { font-weight: 500; }
.ed-progress-head span { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ed-progress-track { height: 8px; border-radius: var(--radius-sm); background: var(--surface-sunken); border: var(--border) solid var(--line); overflow: hidden; }
.ed-progress-fill { height: 100%; background: var(--brand); border-radius: inherit; }
.ed-progress-warn .ed-progress-fill { background: var(--accent); }
.ed-progress-danger .ed-progress-fill { background: var(--danger); }
.ed-progress-mark { position: relative; }
.ed-progress-mark::after { content: ""; position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); left: var(--ed-mark, 50%); }
[data-theme="hc"] .ed-progress-track { border-color: var(--ink); }

/* StatTile */
.ed-stat { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); border-radius: var(--radius-lg); border: var(--border) solid var(--line); background: var(--surface-raised); box-shadow: var(--shadow-sm); min-width: 160px; }
.ed-stat-label { font-size: 0.8125rem; color: var(--ink-muted); }
.ed-stat-value { font-size: 1.75rem; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ed-stat-delta { font-size: 0.8125rem; display: inline-flex; align-items: center; gap: var(--space-1); }
.ed-stat-up { color: var(--success); } .ed-stat-down { color: var(--danger); } .ed-stat-flat { color: var(--ink-muted); }
.ed-stat-alert { border-color: var(--danger); }
.ed-stat-alert .ed-stat-value { color: var(--danger); }
[data-theme="hc"] .ed-stat { border-color: var(--ink); }

/* SyncStatus */
.ed-sync { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); font-size: 0.8125rem; border-radius: var(--radius-md); border: var(--border) solid var(--line); background: var(--surface-raised); color: var(--ink-muted); }
.ed-sync-synced { color: var(--success); border-color: var(--success); background: var(--success-soft); }
.ed-sync-pending { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.ed-sync-offline { color: var(--ink); border-color: var(--line-strong); background: var(--surface-sunken); }
.ed-sync-error { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.ed-sync b { font-weight: 500; }
.ed-sync-count { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Alert */
.ed-alert { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: var(--border) solid; align-items: flex-start; }
.ed-alert .ed-icon { margin-top: 2px; }
.ed-alert-body { flex: 1 1 auto; min-width: 0; }
.ed-alert-title { font-weight: 500; margin: 0 0 2px; }
.ed-alert p { margin: 0; }
.ed-alert-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.ed-alert-info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.ed-alert-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.ed-alert-warning { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ed-alert-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.ed-alert-crisis { background: var(--crisis); border-color: var(--crisis); color: var(--ink-inverse); }
.ed-alert-body p { color: var(--ink); }
.ed-alert-crisis .ed-alert-body p { color: var(--ink-inverse); }
.ed-alert-crisis .ed-btn { background: var(--ink-inverse); color: var(--surface-inverse); border-color: var(--ink-inverse); }
.ed-alert-crisis .ed-btn:hover { filter: brightness(0.9); }
[data-theme="hc"] .ed-alert { border-width: var(--border-hc); }

/* Toast */
.ed-toast-region { position: fixed; bottom: var(--space-4); left: var(--space-4); right: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); z-index: var(--z-toast); pointer-events: none; }
.ed-toast { pointer-events: auto; display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); background: var(--surface-inverse); color: var(--ink-inverse); box-shadow: var(--shadow-lg); max-width: 480px; margin-left: auto; margin-right: 0; }
.ed-toast-static { position: static; }
.ed-toast .ed-icon { flex: 0 0 auto; }
.ed-toast-success .ed-icon { color: var(--success-soft); }
.ed-toast-danger .ed-icon { color: var(--danger-soft); }
.ed-toast-body { flex: 1 1 auto; }
.ed-toast-body b { font-weight: 500; }
.ed-toast .ed-btn-quiet { color: var(--ink-inverse); text-decoration: underline; }
.ed-toast .ed-btn-quiet:hover { background: transparent; }
[data-theme="hc"] .ed-toast { border: var(--border-hc) solid var(--ink-inverse); }
[data-theme="hc"] .ed-toast-success .ed-icon, [data-theme="hc"] .ed-toast-danger .ed-icon { color: var(--ink-inverse); }

/* Dialog */
.ed-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-dialog); display: grid; place-items: center; padding: var(--space-4); }
.ed-scrim-static { position: relative; min-height: 100%; }
.ed-scrim-blocking { z-index: var(--z-blocking); }
.ed-dialog { width: 100%; max-width: 520px; background: var(--surface-raised); color: var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: var(--border) solid var(--line); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.ed-dialog h2 { margin: 0; font-size: 1.5rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.005em; }
.ed-dialog-body { display: flex; flex-direction: column; gap: var(--space-3); }
.ed-dialog-body p { margin: 0; }
.ed-dialog-actions { display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; }
.ed-dialog-blocking { border-top: 6px solid var(--crisis); }
.ed-dialog-timeout .ed-dialog-timer { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
[data-theme="hc"] .ed-dialog { border-width: var(--border-hc); border-color: var(--ink); }

/* Tabs */
.ed-tabs { display: flex; flex-direction: column; }
.ed-tablist { display: flex; gap: var(--space-1); border-bottom: var(--border) solid var(--line); overflow-x: auto; }
.ed-tab { font: inherit; font-weight: 500; min-height: var(--control); padding: 0 var(--space-3); background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ink-muted); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-2); margin-bottom: -1px; }
.ed-tab:hover { color: var(--ink); background: var(--surface-sunken); }
.ed-tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.ed-tab .ed-badge { text-transform: none; letter-spacing: 0; }
.ed-tabpanel { padding: var(--space-4) 0; }
[data-theme="hc"] .ed-tab[aria-selected="true"] { border-bottom-width: 3px; }

/* AccountSwitcher */
.ed-switcher { position: relative; display: inline-block; }
.ed-switcher-btn { font: inherit; display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control); padding: 0 var(--space-3) 0 var(--space-1); border-radius: var(--radius-md); border: var(--border) solid var(--line-strong); background: var(--surface-raised); color: var(--ink); cursor: pointer; }
.ed-switcher-btn .ed-icon { color: var(--ink-muted); }
.ed-switcher-menu { position: absolute; top: calc(100% + var(--space-1)); left: 0; min-width: 280px; background: var(--surface-raised); border: var(--border) solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: var(--z-popover); padding: var(--space-1); margin: 0; list-style: none; }
.ed-switcher-menu-static { position: static; box-shadow: none; margin-top: var(--space-2); }
.ed-switcher-item { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: var(--space-2); border-radius: var(--radius-sm); border: 0; background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; min-height: var(--touch); }
.ed-switcher-item:hover { background: var(--surface-sunken); }
.ed-switcher-item[aria-current="true"] { background: var(--brand-soft); }
.ed-switcher-item .ed-meta { font-size: 0.8125rem; color: var(--ink-muted); display: block; }
.ed-switcher-item .ed-check-mark { margin-left: auto; color: var(--brand); }
.ed-switcher-sep { border-top: var(--border) solid var(--line); margin: var(--space-1) 0; }
[data-theme="hc"] .ed-switcher-btn, [data-theme="hc"] .ed-switcher-menu { border-width: var(--border-hc); border-color: var(--ink); }

/* Avatar */
.ed-avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-full); background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 0.8125rem; letter-spacing: 0.02em; flex: 0 0 auto; border: var(--border) solid transparent; }
.ed-avatar-sm { width: 24px; height: 24px; font-size: 0.6875rem; }
.ed-avatar-lg { width: 48px; height: 48px; font-size: 1.125rem; }
.ed-avatar-staff { background: var(--surface-sunken); color: var(--ink); border-color: var(--line-strong); }
.ed-avatar-child { background: var(--accent-soft); color: var(--accent); }
[data-theme="hc"] .ed-avatar { border-color: var(--ink); }

/* SkipLink */
.ed-skip { position: absolute; left: var(--space-4); top: -100px; padding: var(--space-2) var(--space-4); background: var(--brand); color: var(--on-brand); border-radius: var(--radius-md); font-weight: 500; text-decoration: none; z-index: var(--z-blocking); }
.ed-skip:focus, .ed-skip:focus-visible { top: var(--space-4); }
.ed-skip-static { position: static; display: inline-block; }

/* TopBar */
.ed-topbar { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: 0 var(--space-4); background: var(--surface-raised); border-bottom: var(--border) solid var(--line); position: sticky; top: 0; z-index: var(--z-bar); max-width: 100%; overflow-x: auto; }
@media (max-width: 560px) { .ed-topbar .ed-context { display: none; } .ed-topbar-right .ed-btn > span:not(.ed-avatar) { display: none; } }
.ed-topbar-static { position: static; }
.ed-wordmark { font-weight: 600; font-size: 1.125rem; letter-spacing: -0.01em; color: var(--brand); text-decoration: none; display: inline-flex; align-items: center; gap: var(--space-2); }
.ed-wordmark i { width: 10px; height: 18px; background: var(--brand); border-radius: 2px; display: inline-block; }
.ed-topbar nav { display: flex; gap: var(--space-1); flex: 1 1 auto; overflow-x: auto; }
.ed-topbar nav a { color: var(--ink-muted); text-decoration: none; font-weight: 500; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); white-space: nowrap; min-height: var(--control-sm); display: inline-flex; align-items: center; }
.ed-topbar nav a:hover { background: var(--surface-sunken); color: var(--ink); }
.ed-topbar nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
.ed-topbar-right { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.ed-topbar-right .ed-btn { white-space: nowrap; }
.ed-topbar .ed-context { font-size: 0.8125rem; color: var(--ink-muted); white-space: nowrap; }
.ed-notif { position: relative; }
.ed-notif .ed-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--danger); border: 2px solid var(--surface-raised); }

/* Table */
.ed-table-wrap { overflow: auto; border: var(--border) solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); }
.ed-table { width: 100%; border-collapse: collapse; }
.ed-table caption { text-align: left; padding: var(--space-3) var(--space-4); font-weight: 500; }
.ed-table th, .ed-table td { padding: var(--space-2) var(--space-4); text-align: left; border-bottom: var(--border) solid var(--line); vertical-align: middle; }
.ed-table thead th { position: sticky; top: 0; z-index: var(--z-sticky); background: var(--surface-sunken); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); white-space: nowrap; }
.ed-table thead th button { font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; gap: var(--space-1); align-items: center; }
.ed-table thead th[aria-sort] button { color: var(--ink); }
.ed-table tbody tr:hover { background: var(--surface-sunken); }
.ed-table tbody tr.ed-row-selected { background: var(--brand-soft); }
.ed-table tbody tr:last-child td { border-bottom: 0; }
.ed-table td.ed-num, .ed-table th.ed-num { text-align: right; }
.ed-table .ed-row-actions { display: flex; gap: var(--space-1); justify-content: flex-end; }
@media (max-width: 720px) {
  .ed-table-stack thead { display: none; }
  .ed-table-stack tr { display: block; padding: var(--space-2) 0; border-bottom: var(--border) solid var(--line); }
  .ed-table-stack td { display: flex; justify-content: space-between; gap: var(--space-3); border: 0; padding: var(--space-1) var(--space-4); text-align: left; }
  .ed-table-stack th[scope="row"] { display: block; border: 0; padding: var(--space-2) var(--space-4) var(--space-1); font-weight: 500; }
  .ed-table-stack td::before { content: attr(data-label); color: var(--ink-muted); font-size: 0.8125rem; }
  .ed-table-stack td .ed-cell { display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-end; text-align: right; }
}
[data-theme="hc"] .ed-table-wrap, [data-theme="hc"] .ed-table th, [data-theme="hc"] .ed-table td { border-color: var(--ink); }

/* AuditEntry */
.ed-audit { display: grid; grid-template-columns: 20px 1fr; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: var(--border) solid var(--line); }
.ed-audit:last-child { border-bottom: 0; }
.ed-audit .ed-icon { color: var(--ink-muted); margin-top: 2px; }
.ed-audit-edit .ed-icon { color: var(--accent); }
.ed-audit-delete .ed-icon { color: var(--danger); }
.ed-audit-create .ed-icon { color: var(--success); }
.ed-audit-head { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: baseline; }
.ed-audit-head b { font-weight: 500; }
.ed-audit-head time, .ed-audit-meta { font-size: 0.8125rem; color: var(--ink-muted); }
.ed-audit-diff { display: inline-flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.ed-audit-diff del { color: var(--danger); background: var(--danger-soft); padding: 0 var(--space-1); border-radius: var(--radius-sm); text-decoration: line-through; }
.ed-audit-diff ins { color: var(--success); background: var(--success-soft); padding: 0 var(--space-1); border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; }
.ed-audit-reason { margin: var(--space-1) 0 0; color: var(--ink); }
.ed-audit-reason::before { content: attr(data-label); color: var(--ink-muted); }
.ed-audit-meta code { font-family: var(--font-mono); font-size: 0.8125rem; }

/* Calendar */
.ed-cal { border: var(--border) solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); overflow: hidden; }
.ed-cal-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: var(--border) solid var(--line); }
.ed-cal-head h3 { margin: 0; font-size: 1rem; font-weight: 500; flex: 1 1 auto; }
.ed-cal table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ed-cal th { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); padding: var(--space-2) 0; background: var(--surface-sunken); }
.ed-cal td { border-top: var(--border) solid var(--line); border-right: var(--border) solid var(--line); height: 72px; vertical-align: top; padding: 0; }
.ed-cal td:last-child { border-right: 0; }
.ed-cal-day { display: flex; flex-direction: column; gap: 2px; width: 100%; height: 100%; padding: var(--space-1); background: none; border: 0; font: inherit; color: var(--ink); text-align: left; cursor: pointer; border-radius: 0; }
.ed-cal-day:hover { background: var(--surface-sunken); }
.ed-cal-day .ed-d { font-size: 0.8125rem; font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.ed-cal-day.ed-today .ed-d, .ed-cal-day.ed-today.ed-off .ed-d { color: var(--on-brand); background: var(--brand); border-radius: var(--radius-full); width: 22px; height: 22px; display: inline-grid; place-items: center; }
.ed-cal-day.ed-off { background: var(--surface-sunken); color: var(--ink-subtle); }
.ed-cal-day.ed-off .ed-d { color: var(--ink-subtle); }
.ed-cal-ev { font-size: 0.75rem; line-height: 1.3; padding: 1px var(--space-1); border-radius: 2px; border-left: 3px solid; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-cal-ev-test { background: var(--cat-1); border-color: var(--danger); color: var(--ink); }
.ed-cal-ev-quiz { background: var(--cat-2); border-color: var(--accent); color: var(--ink); }
.ed-cal-ev-hw { background: var(--cat-3); border-color: var(--success); color: var(--ink); }
.ed-cal-ev-meet { background: var(--info-soft); border-color: var(--info); color: var(--ink); }
.ed-cal-day.ed-limit { box-shadow: inset 0 0 0 2px var(--danger); }
.ed-cal-day.ed-limit .ed-limit-note { font-size: 0.6875rem; color: var(--danger); font-weight: 500; display: inline-flex; gap: 2px; align-items: center; }
.ed-cal-day.ed-limit .ed-limit-note .ed-icon { width: 12px; height: 12px; stroke-width: 2.2; }
[data-theme="hc"] .ed-cal td, [data-theme="hc"] .ed-cal { border-color: var(--ink); }

/* LessonCard */
.ed-lesson { display: grid; grid-template-columns: 64px 1fr auto; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: var(--border) solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); align-items: start; }
.ed-lesson-time { font-size: 0.8125rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ed-lesson-time b { display: block; color: var(--ink); font-weight: 600; font-size: 1rem; }
.ed-lesson-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ed-lesson-subject { font-weight: 500; }
.ed-lesson-meta { font-size: 0.8125rem; color: var(--ink-muted); display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ed-lesson-sub { color: var(--accent); font-weight: 500; }
.ed-lesson-cancel .ed-lesson-subject { text-decoration: line-through; color: var(--ink-muted); }
.ed-lesson-cancel { border-left: 4px solid var(--danger); }
.ed-lesson-subbed { border-left: 4px solid var(--accent); }
.ed-lesson-room .ed-lesson-newroom { color: var(--info); font-weight: 500; }
.ed-lesson-room del { color: var(--ink-muted); }
.ed-lesson-now { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.ed-lesson-side { display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-end; }
@media (max-width: 480px) { .ed-lesson { grid-template-columns: 56px 1fr; } .ed-lesson-side { grid-column: 1 / -1; flex-direction: row; align-items: center; } }
[data-theme="hc"] .ed-lesson { border-color: var(--ink); }

/* MessageItem */
.ed-msg { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: var(--border) solid var(--line); background: var(--surface-raised); align-items: start; text-decoration: none; color: inherit; }
.ed-msg:last-child { border-bottom: 0; }
.ed-msg:hover { background: var(--surface-sunken); }
.ed-msg-unread { background: var(--brand-soft); }
.ed-msg-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ed-msg-from { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.ed-msg-from b { font-weight: 500; }
.ed-msg-subject { font-weight: 500; }
.ed-msg-unread .ed-msg-subject { font-weight: 600; }
.ed-msg-preview { font-size: 0.8125rem; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-msg-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); font-size: 0.8125rem; color: var(--ink-muted); white-space: nowrap; }
.ed-receipt { display: inline-flex; align-items: center; gap: var(--space-1); }
.ed-receipt .ed-icon { width: 14px; height: 14px; stroke-width: 2.2; }
.ed-receipt-read { color: var(--success); }
.ed-receipt-delivered { color: var(--ink-muted); }
.ed-receipt-pending { color: var(--accent); }
@media (max-width: 480px) { .ed-msg { grid-template-columns: auto minmax(0, 1fr); } .ed-msg-side { grid-column: 2; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-2); white-space: normal; } }

/* ConfidentialNote */
.ed-conf { border: var(--border) solid var(--info); border-radius: var(--radius-md); background: var(--surface-raised); overflow: hidden; }
.ed-conf-head { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; padding: var(--space-2) var(--space-4); background: var(--info-soft); color: var(--info); font-size: 0.8125rem; }
.ed-conf-head b { font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.75rem; display: inline-flex; gap: var(--space-1); align-items: center; }
.ed-conf-head .ed-icon { width: 16px; height: 16px; stroke-width: 2; }
.ed-conf-readers { margin-left: auto; }
.ed-conf-body { padding: var(--space-3) var(--space-4); }
.ed-conf-body p { margin: 0 0 var(--space-2); }
.ed-conf-body p:last-child { margin-bottom: 0; }
.ed-conf-sealed { padding: var(--space-4); display: flex; gap: var(--space-3); align-items: center; color: var(--ink-muted); background: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-sunken) 8px 16px); }
.ed-conf-foot { padding: var(--space-2) var(--space-4); border-top: var(--border) solid var(--line); font-size: 0.8125rem; color: var(--ink-muted); display: flex; gap: var(--space-3); flex-wrap: wrap; }
[data-theme="hc"] .ed-conf { border-width: var(--border-hc); }

/* PrintSheet */
.ed-sheet { background: #ffffff; color: #000000; width: 100%; max-width: 640px; aspect-ratio: 210 / 297; padding: 8% 7%; border: 1px solid var(--line); box-shadow: var(--shadow-md); display: flex; flex-direction: column; font-size: 0.8125rem; line-height: 1.4; margin: 0 auto; }
.ed-sheet-head { display: flex; justify-content: space-between; gap: var(--space-4); border-bottom: 1px solid #000000; padding-bottom: var(--space-2); margin-bottom: var(--space-4); }
.ed-sheet-head b { font-weight: 600; }
.ed-sheet-head span { color: #3a3a3a; }
.ed-sheet .ed-sheet-title { font-size: 1.25rem; line-height: 1.25; margin: 0 0 var(--space-3); font-weight: 600; }
.ed-sheet-body { flex: 1 1 auto; }
.ed-sheet table { width: 100%; border-collapse: collapse; }
.ed-sheet th, .ed-sheet td { border: 1px solid #000000; padding: 3px 6px; text-align: left; font-weight: 400; }
.ed-sheet th { background: #f0f0f0; font-weight: 600; }
.ed-sheet-sign { display: flex; justify-content: space-between; gap: var(--space-6); margin-top: var(--space-6); }
.ed-sheet-sign span { flex: 1 1 0; border-top: 1px solid #000000; padding-top: 4px; text-align: center; color: #3a3a3a; font-size: 0.75rem; }
.ed-sheet-foot { border-top: 1px solid #000000; margin-top: var(--space-4); padding-top: var(--space-2); font-size: 0.6875rem; color: #3a3a3a; display: flex; justify-content: space-between; gap: var(--space-4); }
.ed-sheet-foot .ed-gdpr { max-width: 70%; }
@media print { body { background: #ffffff; } .ed-sheet { box-shadow: none; border: 0; max-width: none; aspect-ratio: auto; padding: 0; } .ed-topbar, .ed-toast-region, .ed-sync, .ed-skip { display: none !important; } .ed-att { border: 1px solid #000000; background: none !important; color: #000000 !important; } .ed-grade { background: none !important; border: 1px solid #000000; } }
