/* Code Vortex Academy LMS: reusable components. */

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--primary);
    color: var(--on-primary);
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    background: var(--primary-hover);
    text-decoration: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* Waiting on the server: still clearly the button that was pressed, just not pressable again yet. */
.btn[aria-busy="true"],
.icon-button[aria-busy="true"] {
    cursor: progress;
    opacity: 0.85;
}

.btn-secondary {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
}

.btn-ghost:hover {
    background: var(--surface-3);
    color: var(--text);
}

.btn-danger {
    background: var(--bad);
    color: #ffffff;
}

.btn-danger:hover {
    background: color-mix(in srgb, var(--bad) 85%, #000000);
}

.btn-soft {
    background: var(--primary-soft);
    color: var(--primary);
}

.btn-soft:hover {
    background: var(--primary-soft-2);
}

.btn-sm {
    min-height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 0.82rem;
}

.btn-icon {
    width: 32px;
    min-height: 32px;
    padding: 0;
}

/* ---------- Cards and stat tiles ---------- */

.card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 0;
}

.card-title {
    font-size: 1.02rem;
}

.card-subtitle {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.84rem;
}

.card-body {
    padding: 16px 20px 20px;
}

.card-body.flush {
    padding: 12px 0 0;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.card.interactive {
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.card.interactive:hover {
    border-color: var(--primary-soft-2);
    box-shadow: var(--shadow);
    text-decoration: none;
    transform: translateY(-1px);
}

.stat {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
}

.stat-label {
    color: var(--text-2);
    font-size: 0.84rem;
    font-weight: 500;
}

.stat-value {
    margin-top: 6px;
    font-family: var(--font-body);
    font-size: 1.9rem;
    font-weight: 650;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-hint {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.78rem;
}

.stat-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.05rem;
}

/* ---------- Badges, avatars, callouts ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--text-2);
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }

.avatar {
    --avatar-hue: 265;
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: hsl(var(--avatar-hue) 70% 92%);
    color: hsl(var(--avatar-hue) 45% 30%);
    font-size: 0.78rem;
    font-weight: 700;
}

:root[data-theme="dark"] .avatar {
    background: hsl(var(--avatar-hue) 32% 24%);
    color: hsl(var(--avatar-hue) 80% 84%);
}

.avatar.sm { width: 28px; height: 28px; font-size: 0.68rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }

.person {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.person strong,
.person a {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person small {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.callout {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-2);
}

.callout > i { margin-top: 3px; }
.callout.info { border-color: transparent; background: var(--info-soft); color: var(--info); }
.callout.warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.callout.bad { border-color: transparent; background: var(--bad-soft); color: var(--bad); }
.callout.good { border-color: transparent; background: var(--good-soft); color: var(--good); }

/* ---------- Forms ---------- */

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

.form-grid .span-2,
.form-grid .field.span-2 {
    grid-column: 1 / -1;
}

.form-section {
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > label,
.field > .field-label {
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 600;
}

/* A group of links and files inside a form sits in a soft panel so it reads as one field. */
.field [data-attachments-field] {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.field .optional {
    color: var(--muted);
    font-weight: 400;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
    min-height: 96px;
    resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
    border-color: var(--bad);
}

.field-hint {
    color: var(--muted);
    font-size: 0.78rem;
}

.field-error {
    color: var(--bad);
    font-size: 0.78rem;
}

.field-error:empty {
    display: none;
}

.form-alert {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bad-soft);
    color: var(--bad);
}

.check {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.check input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.check .field-hint {
    flex-basis: 100%;
    margin-left: 28px;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    top: 50%;
    left: 12px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.input-with-icon .input {
    padding-left: 36px;
}

.upload-field {
    display: flex;
    gap: 8px;
}

.upload-field .input {
    flex: 1;
}

.upload-button {
    position: relative;
    min-height: 40px;
}

.upload-progress {
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-3);
}

.upload-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--primary);
    transition: width 0.2s ease;
}

/* Submission links and files */

.attach-editor {
    display: grid;
    gap: 20px;
}

.attach-section {
    display: grid;
    gap: 10px;
}

.attach-head h3 {
    font-size: 0.95rem;
}

.attach-head small {
    display: block;
    margin-top: 2px;
}

.attach-link {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.attach-link .btn-icon {
    min-height: 40px;
    width: 40px;
}

.attach-link .field-error {
    grid-column: 1 / -1;
    margin-top: -2px;
}

.attach-link.has-error [data-url] {
    border-color: var(--bad);
}

.attach-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.attach-file .grow,
.resource-link .grow {
    flex: 1;
    min-width: 0;
}

.attach-file .upload-progress {
    margin-top: 8px;
}

.attach-file.is-error {
    border-color: var(--bad);
    background: var(--bad-soft);
}

.attach-file.is-error .notification-icon {
    color: var(--bad);
}

.attachment-title,
.attachment-detail {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* minmax(0, 1fr) lets long web addresses shorten with an ellipsis instead of widening the page. */
.attachment-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

/* Materials handed out with a brief, under the instructions. */
.materials {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.materials-title {
    color: var(--text);
    font-size: 0.9rem;
}

.materials-title .fas {
    color: var(--muted);
}

.attachment-thumb {
    flex: none;
    width: 48px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface-3);
}

.dropzone {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 22px 16px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-2);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone > i {
    font-size: 1.4rem;
    color: var(--primary);
}

.dropzone strong {
    color: var(--primary);
}

/* The real file input covers the zone, so clicking and dropping files both work natively. */
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragging {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.dropzone:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

@media (max-width: 640px) {
    .attach-link {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .attach-link [data-label] {
        grid-column: 1;
        grid-row: 2;
    }

    .attach-link .btn-icon {
        grid-column: 2;
        grid-row: 1;
    }

    /* Stacked, each link's address and label need a clear edge from the next link. */
    .attach-link + .attach-link {
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}

.segmented button {
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    font-weight: 600;
    cursor: pointer;
}

.segmented button.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Toolbar, tables, pagination ---------- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.toolbar .input-with-icon {
    flex: 1 1 260px;
    max-width: 420px;
}

.toolbar .select {
    width: auto;
    min-width: 150px;
}

.toolbar-end {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table th.sortable {
    cursor: pointer;
    user-select: none;
}

.table th.sortable:hover {
    color: var(--text);
}

.table th .sort-icon {
    margin-left: 4px;
    opacity: 0.5;
}

.table th.is-sorted .sort-icon {
    color: var(--primary);
    opacity: 1;
}

.table td.align-right,
.table th.align-right {
    text-align: right;
}

.table tbody tr:hover {
    background: var(--surface-2);
}

.table tbody tr.is-selected {
    background: color-mix(in srgb, var(--primary-soft) 70%, transparent);
}

.table tbody tr.is-clickable {
    cursor: pointer;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table .col-check {
    width: 44px;
    padding-right: 0;
}

.table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

.table-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
}

.pager {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---------- Tabs ---------- */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-2);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.tab:hover {
    color: var(--text);
}

.tab.is-active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

.tab .badge {
    padding: 0 7px;
}

/* ---------- Dialogs, drawers, toasts ---------- */

dialog.modal,
dialog.drawer {
    padding: 0;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}

dialog.modal {
    width: min(620px, calc(100vw - 24px));
    max-height: calc(100vh - 48px);
    border-radius: var(--radius-lg);
}

dialog.modal.sm { width: min(440px, calc(100vw - 24px)); }
dialog.modal.lg { width: min(880px, calc(100vw - 24px)); }

dialog.drawer {
    width: min(640px, 100vw);
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0 0 0 auto;
    border-width: 0 0 0 1px;
    border-radius: 0;
}

dialog.drawer.wide {
    width: min(920px, 100vw);
}

dialog::backdrop {
    background: var(--overlay);
}

dialog[open].modal {
    display: flex;
    flex-direction: column;
    animation: modal-in 0.18s ease;
}

dialog[open].drawer {
    display: flex;
    flex-direction: column;
    animation: drawer-in 0.22s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@keyframes drawer-in {
    from { transform: translateX(40px); opacity: 0; }
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.12rem;
}

.modal-header p {
    margin-top: 2px;
    font-size: 0.84rem;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.toast-stack {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 8px 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.18s ease;
}

.toast > i {
    margin-top: 3px;
    color: var(--info);
}

.toast p {
    flex: 1;
    overflow-wrap: anywhere;
}

.toast .icon-button {
    width: 28px;
    height: 28px;
}

.toast.success > i { color: var(--good); }
.toast.error > i { color: var(--bad); }
.toast.warn > i { color: var(--warn); }
.toast.is-leaving { opacity: 0; transition: opacity 0.2s ease; }

/* ---------- Empty, loading, errors ---------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 20px;
    color: var(--text-2);
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 4px;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.25rem;
}

.empty h3 {
    color: var(--text);
    font-size: 1rem;
}

.empty p {
    max-width: 46ch;
    font-size: 0.88rem;
}

.empty .btn {
    margin-top: 8px;
}

.empty.compact {
    padding: 22px 16px;
}

.skeleton {
    display: block;
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s linear infinite;
}

.skeleton + .skeleton {
    margin-top: 10px;
}

@keyframes shimmer {
    to { background-position: -200% 0; }
}

.page-loading {
    display: grid;
    gap: 16px;
}

/* ---------- Lists, progress, details ---------- */

.list {
    display: flex;
    flex-direction: column;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.list-item:first-child {
    border-top: 0;
}

/* List rows can be buttons too; drop the browser's button border and font. */
button.list-item {
    width: 100%;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

a.list-item:hover,
button.list-item:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.list-item .grow {
    flex: 1;
    min-width: 0;
}

.list-item strong {
    display: block;
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.date-chip {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 50px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    line-height: 1;
}

.date-chip b {
    font-size: 1.1rem;
}

.date-chip span {
    margin-top: 3px;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
}

.progress {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--primary-soft);
}

.progress span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-row .progress {
    flex: 1;
}

.progress-row small {
    min-width: 38px;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.details {
    display: grid;
    grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
    gap: 10px 16px;
    margin: 0;
}

.details dt {
    color: var(--muted);
    font-size: 0.84rem;
}

.details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.prose {
    color: var(--text-2);
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.divider {
    height: 1px;
    margin: 16px 0;
    background: var(--border);
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.profile-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
}

/* ---------- Charts ---------- */

.chart {
    position: relative;
}

.chart svg {
    display: block;
    width: 100%;
    overflow: visible;
}

.chart .grid-line {
    stroke: var(--chart-grid);
    stroke-width: 1;
}

.chart .axis-line {
    stroke: var(--chart-axis);
    stroke-width: 1;
}

.chart .axis-label {
    fill: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.chart .value-label {
    fill: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.chart .mark {
    fill: var(--chart-series);
    transition: opacity 0.15s ease;
}

.chart .hit {
    fill: transparent;
    cursor: default;
}

.chart .hit:focus {
    outline: none;
}

.chart.is-hovering .mark:not(.is-active) {
    opacity: 0.55;
}

.chart-tooltip {
    position: absolute;
    z-index: 5;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
    pointer-events: none;
    white-space: nowrap;
    transform: translate(-50%, calc(-100% - 10px));
}

.chart-tooltip strong {
    display: block;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.chart-tooltip span {
    color: var(--muted);
    font-size: 0.76rem;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 12px;
    color: var(--text-2);
    font-size: 0.8rem;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.chart-table {
    margin-top: 4px;
}

.chart-empty {
    padding: 36px 0;
    color: var(--muted);
    text-align: center;
}

.hbar-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hbar-row {
    display: grid;
    grid-template-columns: minmax(90px, 30%) minmax(0, 1fr) 48px;
    align-items: center;
    gap: 12px;
}

.hbar-label {
    overflow: hidden;
    color: var(--text-2);
    font-size: 0.84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hbar-track {
    position: relative;
    height: 14px;
}

.hbar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    min-width: 2px;
    border-radius: 0 4px 4px 0;
    background: var(--chart-series);
}

.hbar-value {
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.stacked-bar {
    display: flex;
    gap: 2px;
    height: 22px;
    overflow: hidden;
    border-radius: 6px;
}

.stacked-bar span {
    min-width: 3px;
    height: 100%;
}

/* ---------- Calendar ---------- */

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.calendar-weekday {
    padding: 8px 10px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.calendar-day {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 118px;
    padding: 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.calendar-day.is-outside {
    background: var(--surface-2);
}

.calendar-day.is-outside .calendar-date {
    color: var(--muted);
}

.calendar-date {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 600;
}

.calendar-day.is-today .calendar-date {
    background: var(--primary);
    color: var(--on-primary);
}

.calendar-event {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    overflow: hidden;
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--text);
    font-size: 0.74rem;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event:hover {
    text-decoration: none;
    filter: brightness(0.97);
}

.calendar-event.assignment { border-left-color: var(--warn); background: var(--warn-soft); }
.calendar-event.project { border-left-color: var(--info); background: var(--info-soft); }
.calendar-event.classwork { border-left-color: var(--good); background: var(--good-soft); }
.calendar-more { color: var(--muted); font-size: 0.72rem; padding-left: 4px; }

@media (max-width: 760px) {
    .calendar-day {
        min-height: 72px;
    }

    .calendar-event span {
        display: none;
    }
}

/* ---------- Attendance register and gradebook grids ---------- */

.grid-table th:first-child,
.grid-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 220px;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
}

.grid-table th:first-child {
    z-index: 3;
    background: var(--surface-2);
}

.grid-table th,
.grid-table td {
    padding: 10px 12px;
}

.grid-table .col-head {
    min-width: 108px;
    text-align: center;
    text-transform: none;
    letter-spacing: 0;
}

.grid-table .col-head strong {
    display: block;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
}

.grid-table .col-head small {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 500;
}

.grid-table td.cell {
    text-align: center;
}

.status-cell {
    min-width: 84px;
    min-height: 30px;
    padding: 0 8px;
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
}

.status-cell.present { border: 0; background: var(--good-soft); color: var(--good); }
.status-cell.late { border: 0; background: var(--warn-soft); color: var(--warn); }
.status-cell.absent { border: 0; background: var(--bad-soft); color: var(--bad); }
.status-cell.excused { border: 0; background: var(--info-soft); color: var(--info); }

.grade-cell {
    font-variant-numeric: tabular-nums;
}

/* ---------- Course builder and player ---------- */

.builder-module {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.builder-module + .builder-module {
    margin-top: 12px;
}

.builder-module-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius) var(--radius) 0 0;
}

.builder-module-head .grow,
.builder-lesson .grow {
    flex: 1;
    min-width: 0;
}

.builder-lessons {
    min-height: 44px;
    padding: 6px;
}

.builder-lesson {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
}

.builder-lesson:hover {
    background: var(--surface-2);
}

.drag-handle {
    color: var(--muted);
    cursor: grab;
}

.is-dragging {
    opacity: 0.45;
}

.drop-target {
    box-shadow: inset 0 2px 0 var(--primary);
}

.player {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.player-outline {
    position: sticky;
    top: calc(var(--topbar-height) + 16px);
    max-height: calc(100vh - var(--topbar-height) - 32px);
    overflow-y: auto;
}

.outline-module + .outline-module {
    border-top: 1px solid var(--border);
}

.outline-module h4 {
    padding: 14px 16px 6px;
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.outline-lesson {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 16px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    text-align: left;
    cursor: pointer;
}

.outline-lesson:hover {
    background: var(--surface-2);
}

.outline-lesson.is-active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.outline-lesson .fa-circle-check {
    color: var(--good);
}

.video-frame {
    aspect-ratio: 16 / 9;
    max-width: 100%;
    overflow: hidden;
    border-radius: var(--radius);
    background: #000000;
}

.video-frame iframe,
.video-frame video {
    width: 100%;
    height: 100%;
    border: 0;
}

.resource-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
}

.resource-link:hover {
    border-color: var(--primary-soft-2);
    background: var(--surface-2);
    text-decoration: none;
}

.resource-link .grow {
    flex: 1;
    min-width: 0;
}

@media (max-width: 960px) {
    .player {
        grid-template-columns: minmax(0, 1fr);
    }

    .player-outline {
        position: static;
        max-height: none;
    }
}

/* ---------- Announcements ---------- */

.announcement {
    padding: 18px 20px;
}

.announcement + .announcement {
    border-top: 1px solid var(--border);
}

.announcement.is-pinned {
    background: color-mix(in srgb, var(--primary-soft) 45%, transparent);
}

.announcement h3 {
    font-size: 1.02rem;
}

.announcement-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 6px 0 10px;
    color: var(--muted);
    font-size: 0.8rem;
}

/* ---------- Sign-in page ---------- */

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
    min-height: 100vh;
}

.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    padding: clamp(28px, 5vw, 64px);
    overflow: hidden;
    background: radial-gradient(circle at 20% 10%, #7c3aed 0%, transparent 45%), radial-gradient(circle at 90% 80%, #312e81 0%, transparent 50%), #1e1b4b;
    color: #ffffff;
}

.auth-aside h1 {
    max-width: 18ch;
    font-size: clamp(2rem, 3.4vw, 3.2rem);
}

.auth-aside p {
    max-width: 52ch;
    margin-top: 14px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 1.02rem;
}

.auth-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.auth-feature {
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06);
}

.auth-feature i {
    color: #facc15;
}

.auth-feature strong {
    display: block;
    margin-top: 8px;
}

.auth-feature span {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.84rem;
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 5vw, 64px) 16px;
}

.auth-card {
    width: min(420px, 100%);
}

.auth-card h2 {
    font-size: 1.7rem;
}

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-features {
        display: none;
    }
}
