:root {
    --bg: #f5ecdf;
    --panel: #fffaf4;
    --panel-soft: #fbf2e7;
    --line: #ead8c5;
    --line-strong: #d1ad8f;
    --ink: #2a2824;
    --muted: #74695f;
    --primary: #b6663d;
    --primary-deep: #97502a;
    --teal: #2d7c72;
    --teal-soft: #e6f0eb;
    --success: #16815c;
    --danger: #b42318;
    --warning: #a65f00;
    --shadow: 0 20px 55px rgba(31, 55, 49, 0.1);
    --radius-lg: 8px;
    --radius-md: 6px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(180deg, #f8efe4 0%, #eadcc8 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.app-shell {
    width: min(1320px, calc(100% - 28px));
    margin: 0 auto;
    padding: 28px 0 44px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.site-footer {
    display: flex;
    justify-content: center;
    padding: 22px 0 0;
}

.site-footer button {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--muted);
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.site-footer button:hover {
    color: var(--primary-deep);
    background: rgba(255, 250, 244, 0.65);
}

.login-screen {
    min-height: calc(100vh - 56px);
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 430px);
    gap: 22px;
    align-items: center;
}

.login-copy {
    padding: 34px;
}

.login-copy h1 {
    max-width: 10ch;
    margin-bottom: 18px;
    font-size: clamp(2.31rem, 5.39vw, 5.08rem);
    line-height: 0.95;
}

.login-copy .eyebrow {
    margin: 0 0 14px;
    font-size: 1.8rem;
}

.login-copy p:last-child {
    max-width: 56ch;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.7;
}

.auth-card,
.topbar,
.mode-nav,
.sidebar-panel,
.dashboard-panel,
.mode-panel {
    padding: 22px;
}

.panel-heading,
.dashboard-header,
.builder-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.panel-heading h2,
.dashboard-header h2,
.builder-heading h3 {
    margin: 4px 0 0;
}

.eyebrow,
.panel-kicker,
.summary-label {
    color: var(--teal);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--teal-soft);
    color: var(--teal);
    font-size: 0.88rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill.neutral {
    background: #eef1f0;
    color: var(--muted);
}

.tab-row,
.mode-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tab-row {
    margin: 20px 0;
}

.tab-button,
.mode-button,
.primary-button,
.secondary-button,
.ghost-button,
.flashcard-action-button,
.remove-row-button,
.table-action {
    min-height: 42px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-weight: 750;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.tab-button,
.mode-button,
.ghost-button {
    background: #eef3f1;
    color: var(--ink);
}

.tab-button.is-active,
.mode-button.is-active {
    background: var(--ink);
    color: #ffffff;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary) 0%, #cc7d4d 100%);
    color: #ffffff;
}

.secondary-button {
    background: linear-gradient(135deg, var(--teal) 0%, #42998d 100%);
    color: #ffffff;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.mode-button:hover,
.tab-button:hover,
.table-action:hover {
    transform: translateY(-1px);
}

.flashcard-action-button {
    min-width: 126px;
    border: 1px solid transparent;
    color: #ffffff;
}

.auth-form,
.set-form,
.stack-form,
.quiz-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="file"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 11px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--ink);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(182, 102, 61, 0.16);
}

select {
    appearance: auto;
}

.toggle {
    grid-template-columns: auto 1fr;
    align-items: center;
}

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

.feedback {
    min-height: 24px;
    margin-top: 10px;
    color: var(--muted);
}

.feedback.is-success {
    color: var(--success);
}

.feedback.is-error {
    color: var(--danger);
}

.dashboard-shell {
    display: grid;
    gap: 16px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
}

.topbar h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 3vw, 3.2rem);
}

.account-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
    color: var(--muted);
}

.account-summary span {
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

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

.sets-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.set-search {
    margin-top: 16px;
}

.set-class-creator {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.set-class-group {
    display: grid;
    gap: 8px;
}

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

.set-class-toggle {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    color: var(--ink);
    font-weight: 900;
    text-align: left;
}

.set-class-toggle span {
    color: var(--muted);
    font-size: 0.88rem;
}

.set-class-toggle::before {
    content: "▸";
    color: var(--muted);
}

.set-class-toggle.is-open::before {
    content: "▾";
}

.set-class-delete-button {
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #f1b0a2;
    border-radius: var(--radius-md);
    background: #fff0ec;
    color: var(--danger);
    font-weight: 900;
}

.set-class-body {
    display: grid;
    gap: 8px;
    padding-left: 12px;
    border-left: 2px solid var(--line);
}

.set-class-empty {
    margin: 0;
    padding: 10px 12px;
    color: var(--muted);
    font-weight: 700;
}

.teacher-student-class-list {
    display: grid;
    gap: 10px;
}

.teacher-student-class-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 1.3fr);
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.set-class-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.inline-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    font-weight: 800;
}

.student-remove-button {
    margin-top: 8px;
    min-height: 32px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    background: #fff0ec;
    color: var(--danger);
    font-weight: 900;
}

.set-list-item {
    display: grid;
    gap: 8px;
}

.sets-portal-panel {
    width: 100%;
}

.sets-hub-panel {
    padding: 16px;
}

.sets-portal-frame {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    min-height: 620px;
}

.sets-sidebar {
    position: sticky;
    top: 14px;
    align-self: start;
    max-height: calc(100vh - 28px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border-right: 1px solid var(--line);
    background: rgba(255, 250, 244, 0.72);
    overflow-y: auto;
}

.sets-portal-main {
    min-width: 0;
    padding: 16px;
}

.set-portal-section {
    min-width: 0;
}

.set-detail-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.set-choose-button {
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #ffffff;
    font-weight: 900;
}

.set-portal-nav-item {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--muted);
    text-align: left;
    font-weight: 800;
}

.set-portal-nav-item.is-active {
    background: var(--primary);
    color: #ffffff;
}

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

.set-browser-column,
.set-learning-column {
    min-width: 0;
}

.set-learning-column {
    display: grid;
    gap: 14px;
}

.set-learning-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.set-study-nav-item {
    min-height: 38px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    color: var(--muted);
    font-weight: 800;
}

.set-study-nav-item.is-active {
    background: var(--primary);
    color: #ffffff;
}

.learn-content,
.learn-exercise-form,
.learn-card {
    display: grid;
    gap: 14px;
}

.learn-progress-panel {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.learn-progress-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.learn-progress-info span,
.learn-question-meta span {
    display: block;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.learn-progress-info strong {
    color: var(--primary-deep);
    font-size: 1rem;
}

.learn-progress-track {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    padding-right: 46px;
    padding-block: 12px;
}

.learn-progress-track span {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 14px;
    border-radius: 999px;
    background: #d9dee8;
    overflow: hidden;
}

.learn-progress-track span::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--segment-progress, 0%);
    border-radius: inherit;
    background: var(--success);
}

.learn-progress-track span.is-current {
    outline: 2px solid rgba(22, 129, 92, 0.2);
    outline-offset: 3px;
}

.learn-progress-track::before {
    content: attr(data-current);
    position: absolute;
    left: min(calc(100% - 80px), max(18px, var(--learn-current-left, 0%)));
    top: 50%;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 900;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.learn-progress-track::after {
    content: attr(data-remaining);
    position: absolute;
    right: 0;
    top: 50%;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #e8edf6;
    color: var(--primary-deep);
    font-size: 0.9rem;
    font-weight: 900;
    transform: translateY(-50%);
}

.learn-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.learn-card h3 {
    margin: 0;
    font-size: 1.45rem;
}

.learn-question-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.learn-question-meta strong {
    color: var(--primary-deep);
}

.learn-choice-list {
    display: grid;
    gap: 10px;
}

.learn-choice-button {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--ink);
    text-align: left;
    font-weight: 900;
}

.learn-choice-button:hover {
    border-color: var(--primary);
    color: var(--primary-deep);
}

.learn-answer-preview {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--primary-deep);
    font-size: 1.3rem;
    font-weight: 900;
}

.set-card {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    color: var(--ink);
    text-align: left;
}

.set-delete-button {
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: #fff0ec;
    color: var(--danger);
    font-weight: 800;
}

.set-edit-button {
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: #fff7e8;
    color: #946200;
    font-weight: 800;
}

.set-card strong,
.set-card span {
    display: block;
}

.set-card span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

.set-card.is-selected {
    border-color: var(--primary);
    box-shadow: inset 4px 0 0 var(--primary);
}

.workspace-main {
    display: grid;
    gap: 16px;
}

.large-empty {
    min-height: 230px;
    display: grid;
    place-items: center;
    text-align: center;
}

.empty-state,
.auth-gate {
    padding: 16px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    color: var(--muted);
}

.dashboard-panel,
.mode-panel {
    display: grid;
    gap: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.wide-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.teacher-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}

.teacher-grid h3 {
    margin-bottom: 0;
}

.attendance-list {
    display: grid;
    gap: 8px;
}

.start-lessons-grid,
.attendance-lesson-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.attendance-date-control {
    display: none;
}

.start-lesson-card,
.attendance-lesson-button {
    min-height: 76px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
    color: var(--ink);
    text-align: left;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.start-lesson-card:hover,
.attendance-lesson-button:hover,
.attendance-lesson-button.is-active {
    border-color: var(--primary);
    box-shadow: inset 4px 0 0 var(--primary);
    transform: translateY(-1px);
}

.start-lesson-card span,
.attendance-lesson-button span,
.start-lesson-card small {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.attendance-lesson-button small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
}

.start-lesson-card strong,
.attendance-lesson-button strong {
    display: block;
    margin-top: 4px;
    color: var(--ink);
}

.attendance-lesson-button.is-confirmed {
    border-color: var(--success);
    box-shadow: inset 4px 0 0 var(--success);
}

.attendance-confirmation-state {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
    color: var(--muted);
    font-weight: 900;
}

.material-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}

.material-delete-button {
    min-height: 32px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    background: #fff0ec;
    color: var(--danger);
    font-weight: 900;
}

.student-assignment-list {
    display: grid;
    gap: 12px;
}

.student-reviewed-assignments {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.student-reviewed-assignments summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    color: var(--primary-deep);
    font-weight: 900;
}

.student-reviewed-assignments summary span {
    min-width: 28px;
    border-radius: 999px;
    background: #e7f2ed;
    color: var(--success);
    text-align: center;
}

.student-reviewed-assignments .student-assignment-list {
    padding: 0 14px 14px;
}

.student-assignment-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.gap-quiz-sentence {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
    font-weight: 800;
}

.gap-quiz-sentence span {
    color: var(--primary-deep);
    letter-spacing: 0.08em;
}

.gap-questions-builder,
.choice-questions-builder,
.gap-quiz-question-list {
    display: grid;
    gap: 12px;
}

.gap-question-row,
.choice-question-row,
.gap-quiz-question {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.gap-answer-review {
    display: grid;
    gap: 10px;
}

.gap-answer-review-item {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
}

.gap-answer-review-item.is-correct {
    border-color: rgba(22, 129, 92, 0.45);
}

.gap-answer-review-item.is-wrong {
    border-color: rgba(180, 35, 24, 0.35);
}

.gap-answer-review-item p {
    margin: 0;
}

.choice-review-options {
    display: grid;
    gap: 4px;
    color: var(--muted);
}

.gap-answer-review-item small {
    color: var(--success);
    font-weight: 800;
}

.gap-answer-accept-button {
    justify-self: start;
    border: 0;
    border-radius: 8px;
    background: var(--success);
    color: #ffffff;
    font-weight: 800;
    padding: 8px 10px;
    cursor: pointer;
}

.gap-answer-accept-button:hover {
    background: #0f6f4e;
}

.student-assignment-submit-form,
.submission-grade-form {
    display: grid;
    gap: 8px;
}

.submission-grade-form {
    grid-template-columns: minmax(70px, 100px) minmax(120px, 1fr) auto;
}

.student-submit-button {
    background: var(--success);
    color: #ffffff;
}

.student-submit-button:hover {
    background: #0f6f4e;
}

.grade-submit-button {
    background: var(--warning);
    color: #ffffff;
}

.grade-submit-button:hover {
    background: #9b5a08;
}

.gradebook-grade-cell {
    vertical-align: middle;
}

.gradebook-grade-cell strong,
.gradebook-grade-cell small,
.gradebook-grade-cell .grade-delete-button {
    display: block;
    margin-inline: auto;
}

.gradebook-grade-cell small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.3;
}

.grade-delete-button {
    margin-top: 7px;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: var(--radius-sm);
    background: #f6d5cc;
    color: #9b2f22;
    font-size: 0.78rem;
    font-weight: 900;
}

.writing-compare {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.writing-compare.corrected {
    border-color: var(--success);
    background: #f4fff4;
}

.pronunciation-recorder,
.audio-submission {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.audio-submission {
    margin-top: 8px;
}

.audio-submission audio,
.recording-preview {
    width: 100%;
    max-width: 360px;
}

.locked-assignment-note {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #f6eadc;
    font-weight: 900;
}

.writing-compare h4 {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.writing-compare p {
    margin: 0;
    white-space: pre-wrap;
}

.correction-editor {
    grid-column: 1 / -1;
}

.correction-editor textarea {
    width: 100%;
}

.attendance-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.teacher-report {
    display: grid;
    gap: 14px;
}

.student-groups-list {
    display: grid;
    gap: 16px;
}

.student-group-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.teacher-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.message-panel {
    display: grid;
    gap: 12px;
}

.unread-badge {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    margin-left: 8px;
    border-radius: 999px;
    background: #b42318;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1;
}

.message-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}

.message-toolbar label {
    flex: 1 1 220px;
}

.message-toolbar button,
.message-form button {
    min-height: 42px;
}

.messages-refresh-button {
    display: none;
}

.message-list {
    display: grid;
    gap: 8px;
    min-height: 140px;
    max-height: 320px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.message-bubble {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    justify-self: start;
    max-width: min(680px, 88%);
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.message-bubble.is-own {
    justify-self: end;
    border-color: rgba(42, 127, 98, 0.35);
    background: #eef8f2;
}

.message-bubble div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.82rem;
}

.message-bubble p {
    margin: 6px 0 0;
    white-space: pre-wrap;
}

.message-pin-button {
    margin-top: 7px;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    background: #fff0d4;
    color: var(--warning);
    font-size: 0.78rem;
    font-weight: 900;
}

.pinned-message {
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--warning);
    border-left: 5px solid var(--warning);
    border-radius: var(--radius-md);
    background: #fff8e8;
    color: var(--ink);
    text-align: left;
}

.pinned-message span {
    color: var(--warning);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.pinned-message p {
    margin: 2px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    align-items: end;
    gap: 8px;
}

.message-compose {
    position: relative;
    display: grid;
    gap: 6px;
}

.message-compose-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.message-form .message-emoji-button,
.message-image-label {
    display: inline-grid;
    place-items: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
    color: var(--ink);
    font-size: 1.15rem;
    cursor: pointer;
}

.message-image-label input {
    display: none;
}

.message-emoji-picker {
    position: absolute;
    z-index: 12;
    bottom: 44px;
    left: 0;
    display: grid;
    grid-template-columns: repeat(6, 38px);
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(63, 44, 26, 0.18);
}

.message-emoji-picker.is-hidden {
    display: none;
}

.message-emoji-picker button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    background: transparent;
    font-size: 1.2rem;
}

.message-image-button {
    display: block;
    max-width: min(360px, 100%);
    margin-top: 8px;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: #f4ece2;
}

.message-image-button img {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: contain;
}

.message-form textarea {
    min-height: 72px;
    max-height: 180px;
    resize: vertical;
}

.message-send-button {
    width: 46px;
    min-width: 46px;
    height: 46px;
    padding: 0;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #ffffff;
    font-size: 1.2rem;
    line-height: 1;
}

.message-send-button:hover {
    background: var(--primary-deep);
}

.lesson-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lesson-strip span {
    padding: 7px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #fffaf4;
    color: var(--primary-deep);
    font-weight: 800;
    font-size: 0.9rem;
}

.lesson-calendar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.lesson-calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.lesson-calendar-columns ul {
    max-height: 140px; /* Ok. 4-5 elementów na raz, potem pojawia się scroll */
    overflow-y: auto;
    overflow-x: auto;
    margin: 0;
    padding-right: 4px;
    padding-bottom: 4px;
    list-style: none;
}
.lesson-calendar-columns ul li {
    padding: 2px 0;
    font-size: 0.85rem;
}
.lesson-calendar-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
/* Cienki, dyskretny pasek przewijania */
.lesson-calendar-columns ul::-webkit-scrollbar {
    width: 4px;  /* Szerokość dla paska pionowego */
    height: 4px; /* Wysokość dla paska poziomego */
}
.lesson-calendar-columns ul::-webkit-scrollbar-thumb {
    background: #ebd2c2;
    border-radius: 4px;
}
.lesson-calendar-heading h3 {
    margin: 0;
}

.lesson-calendar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.single-lesson-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.single-lesson-form input {
    min-height: 38px;
}

.single-lesson-add-button,
.single-lesson-delete-button {
    min-height: 38px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: #ffffff;
    font-weight: 900;
}

.single-lesson-add-button {
    background: #16815c;
}

.single-lesson-delete-button {
    background: #b42318;
}

.lesson-calendar-card {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
    overflow: hidden;
}

.lesson-calendar-card.is-active {
    border-color: var(--primary);
    box-shadow: inset 4px 0 0 var(--primary);
}

.lesson-calendar-trigger {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--ink);
    text-align: left;
}

.lesson-calendar-trigger span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.lesson-calendar-trigger strong {
    font-size: 0.9rem;
    color: var(--muted);
}

.lesson-calendar-trigger small {
    color: var(--primary-deep);
    font-size: 1.08rem;
    font-weight: 800;
}

.lesson-edit-button {
    justify-self: start;
    margin: 0 12px 12px;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: var(--radius-md);
    background: var(--teal-soft);
    color: var(--teal);
    font-weight: 900;
}

.lesson-calendar-details {
    display: none;
    padding: 0 12px 12px;
    border-top: 1px solid var(--line);
}

.lesson-calendar-card.is-active .lesson-calendar-details,
.teacher-lesson-card .lesson-calendar-details {
    display: grid;
    gap: 10px;
}

.lesson-calendar-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.lesson-calendar-columns h4 {
    margin: 0 0 6px;
    font-size: 0.9rem;
}

.meeting-link {
    width: fit-content;
    color: var(--teal);
    font-weight: 900;
}

.muted-inline {
    color: var(--muted);
}

.lesson-info-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(42, 40, 36, 0.34);
}

.modal-panel {
    width: min(720px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    overflow-y: auto;
    padding: 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: 0 26px 70px rgba(42, 40, 36, 0.22);
}

.modal-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.modal-heading h3 {
    margin: 0;
}

.modal-close-button {
    min-height: 34px;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    background: #fff0ee;
    color: var(--danger);
    font-weight: 900;
}

.privacy-policy-panel {
    max-width: 720px;
}

.set-name-modal-panel {
    max-width: 460px;
}

.group-word-set-progress {
    width: 100%;
    overflow-x: auto;
    margin: 12px 0;
}

.compact-progress-table {
    min-width: 560px;
}

.compact-progress-table th,
.compact-progress-table td {
    padding: 8px 10px;
    font-size: 0.9rem;
}

.privacy-policy-content {
    display: grid;
    gap: 10px;
    color: var(--muted);
    line-height: 1.6;
}

.privacy-policy-content p {
    margin: 0;
}

.privacy-policy-content h4 {
    margin: 10px 0 0;
    color: var(--ink);
}

.privacy-policy-content ul {
    margin: 0;
    padding-left: 20px;
}

.privacy-policy-content a {
    color: var(--primary-deep);
    font-weight: 800;
}

.lesson-bound-form {
    margin-top: 14px;
    border-color: var(--primary);
    box-shadow: inset 4px 0 0 var(--primary);
}

.teacher-card ul {
    margin: 10px 0 0;
    padding-left: 20px;
    color: var(--muted);
}

.metric-card {
    min-height: 132px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.metric-card strong {
    display: block;
    margin: 8px 0;
    font-size: 2rem;
}

.metric-card span,
.section-copy,
.next-step-title,
.typing-prompt {
    color: var(--muted);
    line-height: 1.55;
}

.next-step-title {
    margin-bottom: 0;
    color: var(--ink);
    font-weight: 800;
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
    gap: 18px;
    align-items: start;
}

.word-rows {
    display: grid;
    gap: 10px;
}

.word-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.remove-row-button,
.table-action.danger {
    background: #fff0ee;
    color: var(--danger);
}

.danger-button {
    background: #fff0ee;
    color: var(--danger);
}

.material-link {
    padding: 0;
    min-height: 0;
    border-radius: 0;
    background: transparent;
    color: var(--primary-deep);
    font-weight: 800;
    text-align: left;
    text-decoration: underline;
}

body.teacher-portal-active .topbar,
body.teacher-portal-active .mode-nav,
body.teacher-portal-active .workspace-layout > .sidebar-panel,
body.teacher-portal-active .dashboard-panel {
    display: none;
}

body.study-portal-active .topbar,
body.study-portal-active .mode-nav {
    display: none;
}

body.study-portal-active .workspace-layout {
    grid-template-columns: 1fr;
    margin-top: 0;
}

body.study-portal-active .workspace-main,
body.study-portal-active #study-content {
    width: 100%;
    min-width: 0;
}

body.teacher-portal-active .study-sidebar,
body.teacher-portal-active .study-topbar,
body.teacher-portal-active .dashboard-panel {
    display: none;
}

body.student-portal-active .study-sidebar,
body.student-portal-active .study-topbar,
body.student-portal-active .dashboard-panel,
body.student-portal-active .sidebar-panel {
    display: none;
}

body.teacher-portal-active .study-portal-frame,
body.student-portal-active .study-portal-frame {
    grid-template-columns: 1fr;
}

body.teacher-portal-active .workspace-layout,
body.student-portal-active .workspace-layout {
    grid-template-columns: 1fr;
    margin-top: 0;
}

body.teacher-portal-active .workspace-main,
body.teacher-portal-active #study-content,
body.teacher-portal-active #teacher-mode,
body.student-portal-active .workspace-main,
body.student-portal-active #study-content,
body.student-portal-active #student-mode {
    width: 100%;
}

#student-mode,
#teacher-mode {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #fffaf4;
}

#study-content,
.study-portal-frame,
.student-portal-frame,
.teacher-portal-frame,
.study-portal-main,
.student-portal-main,
.teacher-portal-main {
    margin-top: 0;
    padding-top: 0;
}

.study-portal-frame,
.student-portal-frame,
.teacher-portal-frame {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    min-height: calc(100vh - 56px);
}

.study-sidebar,
.student-sidebar,
.teacher-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px 18px;
    border-right: 1px solid var(--line);
    background: #f3e7d8;
}

.teacher-brand {
    padding: 12px 12px 20px;
    color: var(--primary-deep);
    font-size: 1.35rem;
    font-weight: 900;
}

.study-nav-item,
.student-nav-item,
.teacher-nav-item {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: transparent;
    color: #34423e;
    text-align: left;
    font-weight: 750;
}

.study-nav-item.is-active,
.study-nav-item:hover,
.student-nav-item.is-active,
.student-nav-item:hover,
.teacher-nav-item.is-active,
.teacher-nav-item:hover {
    background: #fffaf4;
    color: var(--primary-deep);
}

.study-portal-main,
.student-portal-main,
.teacher-portal-main {
    display: grid;
    align-content: start;
    gap: 0;
    min-width: 0;
    background: #fffdf9;
}

.study-topbar,
.teacher-topbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 0 20px 16px;
    border-bottom: 1px solid var(--line);
    background: #f8efe4;
}

.student-portal-main > .feedback {
    margin: 18px 20px 0;
}

.student-section {
    display: grid;
    gap: 16px;
    margin: 18px 20px 0;
}

.student-section > h3 {
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.student-section-panel {
    display: grid;
    gap: 14px;
}

.study-topbar h2,
.teacher-topbar h2 {
    margin: 2px 0 0;
}

.study-active-set-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: var(--muted);
    font-weight: 800;
}

.study-active-set-summary span {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.study-active-set-summary strong {
    color: var(--ink);
    font-size: 1rem;
}

.study-active-set-summary em {
    font-style: normal;
}

.words-progress-panel {
    margin-top: 16px;
}

.study-sets-browser {
    margin-bottom: 16px;
}

.study-sets-browser .panel-heading {
    align-items: start;
}

.profile-form {
    max-width: 620px;
}

.profile-avatar-preview {
    width: 120px;
    height: 120px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    overflow: hidden;
    background: #fffaf4;
    color: var(--muted);
    font-weight: 900;
}

.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-crop-modal-panel {
    width: min(440px, calc(100vw - 28px));
    display: grid;
    justify-items: center;
    gap: 16px;
}

.avatar-crop-modal-panel .modal-heading,
.avatar-crop-modal-panel > .section-copy {
    width: 100%;
}

.avatar-crop-stage {
    position: relative;
    width: min(280px, calc(100vw - 90px));
    aspect-ratio: 1;
    border-radius: 50%;
    background: #1e1f22;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.avatar-crop-stage.is-dragging {
    cursor: grabbing;
}

.avatar-crop-stage img {
    position: absolute;
    max-width: none;
    pointer-events: none;
    user-select: none;
}

.avatar-crop-shade {
    position: absolute;
    inset: 0;
    border: 3px solid rgba(255, 255, 255, 0.82);
    border-radius: 50%;
    box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.24);
    pointer-events: none;
}

.avatar-crop-zoom-label {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 800;
}

.avatar-crop-zoom-label input {
    width: 100%;
}

.avatar-crop-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.calendar-assignment-link {
    padding: 0;
    background: transparent;
    color: var(--teal);
    font-weight: 900;
    text-align: left;
    text-decoration: underline;
}

.student-assignment-card.is-highlighted {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(182, 102, 61, 0.18);
}

.student-grade-value,
.assignment-result-summary strong {
    font-weight: 900;
}

.writing-compare.corrected p {
    font-weight: 400;
}

.teacher-correction-change {
    padding: 1px 3px;
    border-radius: 3px;
    background: #fff0bd;
    color: var(--ink);
    font-weight: 900;
}

.student-grade-list {
    display: grid;
    gap: 10px;
}

.student-grade-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 14px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--warning);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.choice-option-field {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}

.choice-option-field span {
    color: var(--primary-deep);
    font-weight: 900;
}

.choice-quiz-question-list {
    display: grid;
    gap: 12px;
    margin: 12px 0;
}

.choice-quiz-question {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
}

.choice-quiz-question legend {
    padding: 0 5px;
    color: var(--ink);
    font-weight: 900;
}

.choice-quiz-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
    cursor: pointer;
}

.choice-quiz-option input {
    width: auto;
    margin: 0;
}

.gap-answer-field {
    display: grid;
    gap: 6px;
    margin-top: 2px;
    color: var(--muted);
    font-weight: 800;
}

.gap-answer-field input {
    width: 100%;
    border: 2px solid var(--line-strong);
    background: #ffffff;
}

.message-bubble.is-pinned {
    border-color: var(--warning);
    box-shadow: inset 3px 0 0 var(--warning);
}

.message-bubble.is-highlighted {
    box-shadow: 0 0 0 4px rgba(166, 95, 0, 0.2);
}

.message-avatar {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 2px solid var(--line-strong);
    border-radius: 50%;
    background: var(--panel-soft) center / cover no-repeat;
    color: var(--primary-deep);
    font-weight: 900;
}

.message-avatar.has-image {
    color: transparent;
}

.message-bubble-content {
    flex: 1 1 auto;
    min-width: 0;
    display: block !important;
}

.message-bubble-content > div {
    display: flex;
}

.student-grade-row div {
    display: grid;
    gap: 3px;
}

.student-grade-row span,
.student-grade-row p {
    color: var(--muted);
}

.student-grade-row p {
    grid-column: 1 / -1;
    margin: 0;
    font-weight: 800;
}

.student-grade-row .student-grade-value {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: #f6eadc;
    color: var(--warning);
    font-size: 1.2rem;
}

.submission-grade-form input[name="grade"],
.submission-grade-form input[name="feedback"],
.correction-editor textarea {
    border-width: 2px;
    font-weight: 800;
}

.submission-grade-form input[name="grade"] {
    border-color: var(--warning);
    background: #fff8e8;
}

.admin-users-list {
    display: grid;
    gap: 12px;
}

.admin-users-table select {
    min-width: 130px;
}

.compact-toggle {
    justify-content: flex-start;
}

.password-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.teacher-top-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.teacher-top-group-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: min(280px, 100%);
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
    color: var(--muted);
    font-weight: 800;
}

.teacher-top-group-picker span {
    font-size: 0.82rem;
    text-transform: uppercase;
}

.teacher-top-group-picker select {
    min-height: 34px;
    padding: 6px 8px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-weight: 800;
}

.teacher-top-actions > span {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fffaf4;
    color: var(--muted);
    font-weight: 800;
}

.teacher-grade-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: #fbf2e7;
}

#teacher-mode > .teacher-portal-frame > .teacher-portal-main > .panel-heading {
    display: none;
}

.teacher-portal-main > .teacher-grid,
.teacher-portal-main > .feedback,
.teacher-portal-main > .teacher-report {
    margin: 18px 20px 0;
}

.teacher-portal-main > .teacher-report {
    order: 1;
}

.teacher-portal-main > .teacher-grid {
    order: 2;
}

.teacher-portal-main > .feedback {
    order: 3;
}

.teacher-section-shell {
    display: grid;
    gap: 18px;
    margin: 18px 20px 0;
    order: 1;
}

.teacher-section {
    display: grid;
    gap: 16px;
}

.teacher-section > h3 {
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.teacher-section > .stack-form,
.teacher-section > .teacher-report,
.teacher-section > .teacher-section-content {
    margin: 0;
}

.teacher-section .teacher-report {
    display: block;
}

.teacher-inline-form {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    align-items: end;
    background: #fffaf4;
}

.teacher-inline-form h3 {
    grid-column: 1 / -1;
}

#teacher-assignments-section {
    align-content: start;
}

.assignment-form-card {
    display: grid;
    gap: 10px;
}

.assignment-form-card .stack-form {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

#teacher-assignments-panel {
    display: grid;
    gap: 14px;
    min-width: 0;
}

#teacher-assignments-panel > .teacher-card {
    display: grid;
    gap: 12px;
    min-width: 0;
}

#teacher-assignments-panel .material-link {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.preparation-block {
    display: grid;
    gap: 10px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.preparation-block:first-of-type {
    border-top: 0;
}

.assignment-category {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    overflow: hidden;
}

.assignment-category + .assignment-category {
    margin-top: 12px;
}

.assignment-category summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--ink);
    font-weight: 900;
    cursor: pointer;
}

.assignment-category summary span {
    min-width: 30px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #ffffff;
    color: var(--primary-deep);
    text-align: center;
}

.assignment-category-graded summary {
    background: var(--teal-soft);
    color: var(--success);
}

.assignment-category-ungraded summary {
    background: #fff0d4;
    color: var(--warning);
}

.assignment-category-content {
    padding: 0 14px 14px;
}

.preparation-review-form {
    display: grid;
    gap: 8px;
    min-width: 220px;
}

.preparation-review-form label,
.submission-grade-form label {
    display: grid;
    gap: 5px;
    font-weight: 800;
}

.preparation-review-form textarea,
.submission-grade-form textarea[name="feedback"] {
    width: 100%;
    border: 2px solid var(--line-strong);
}

.assignment-grade-comment {
    margin: 10px 0 0;
    padding: 10px 12px;
    border-left: 4px solid var(--warning);
    background: #fff8e8;
}

.preparation-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
}

.preparation-heading strong {
    color: var(--text);
}

.assignment-delete-button {
    margin-left: auto;
    flex: 0 0 auto;
}

.preparation-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
}

.preparation-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    table-layout: fixed;
}

.preparation-table th,
.preparation-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.preparation-table th {
    background: #fffaf4;
}

.preparation-table td {
    overflow-wrap: anywhere;
    vertical-align: top;
}

.preparation-table .submission-grade-form {
    min-width: 240px;
    grid-template-columns: 1fr;
    align-items: stretch;
}

.preparation-table .submission-grade-form input,
.preparation-table .submission-grade-form textarea,
.preparation-table .submission-grade-form button {
    width: 100%;
}

.preparation-table .submission-grade-form .grade-submit-button {
    justify-self: stretch;
}

.teacher-section-shell + .panel-heading,
.teacher-portal-main > .teacher-grid:empty {
    display: none;
}

#teacher-grades-section .teacher-board-header,
#teacher-grades-section .teacher-lower-grid {
    display: none;
}

.teacher-board {
    display: grid;
    gap: 14px;
}

.teacher-board-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: end;
}

.teacher-board-select {
    min-width: 260px;
}

.gradebook-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
}

.gradebook-table {
    width: 100%;
    min-width: 820px;
    border-collapse: collapse;
}

.gradebook-table th,
.gradebook-table td {
    padding: 12px 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.gradebook-table th {
    background: #fffaf4;
    color: #182320;
    font-size: 0.82rem;
    text-transform: uppercase;
}

.gradebook-table th span,
.gradebook-table th small {
    display: block;
}

.gradebook-table th small {
    margin-top: 4px;
    color: var(--muted);
    text-transform: none;
}

.gradebook-table .student-name {
    min-width: 220px;
    text-align: left;
    color: #2f4772;
}

.prepared-cell {
    background: #e8f4df;
    color: #2c761f;
    font-weight: 900;
}

.missing-cell {
    background: #fff1df;
    color: #a14b1f;
    font-weight: 900;
}

.average-cell {
    background: #ffffff;
    color: #2f4772;
    font-weight: 900;
}

.empty-grade-cell {
    color: var(--muted);
}

.teacher-lower-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
}

.tool-divider {
    height: 1px;
    margin: 22px 0;
    background: var(--line);
}

.subpanel {
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

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

.words-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

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

.words-table th {
    color: var(--muted);
    font-size: 0.9rem;
}

.word-edit-input {
    width: 100%;
    min-height: 34px;
    padding: 7px 9px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: #fffaf4;
}

.words-table tr.is-editing {
    background: rgba(255, 247, 232, 0.62);
}

.table-empty {
    text-align: center;
}

.table-action {
    margin: 3px;
    background: #e9efff;
    color: var(--primary-deep);
}

.word-status {
    display: inline-flex;
    padding: 6px 9px;
    border-radius: 999px;
    background: var(--teal-soft);
    color: var(--teal);
    font-weight: 800;
    font-size: 0.85rem;
}

.flashcard-surface {
    position: relative;
    width: 100%;
    min-height: 260px;
    display: grid;
    place-items: center;
    gap: 12px;
    padding: 24px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #fffaf4, #f2e1cf);
    color: var(--ink);
    text-align: center;
    touch-action: pan-y;
    user-select: none;
    transform-origin: center bottom;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
    will-change: transform;
    overflow: hidden;
    cursor: pointer;
}

.flashcard-surface:focus-visible {
    outline: 3px solid rgba(54, 95, 86, 0.28);
    outline-offset: 3px;
}

.flashcard-surface::after {
    position: absolute;
    top: 18px;
    right: 18px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.88);
    font-weight: 900;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.flashcard-surface.is-dragging {
    cursor: grabbing;
    transition: box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.flashcard-surface.is-review-hint {
    border-color: #d36a55;
    background: linear-gradient(180deg, #fff4ef, #f0d2c6);
    box-shadow: 0 16px 34px rgba(155, 66, 44, 0.18);
}

.flashcard-surface.is-review-hint::after {
    left: 18px;
    right: auto;
    color: #a43d29;
    content: "Do powtorki";
    opacity: 1;
    transform: translateY(0);
}

.flashcard-surface.is-mastered-hint {
    border-color: #69a977;
    background: linear-gradient(180deg, #f4fff4, #d6ead8);
    box-shadow: 0 16px 34px rgba(65, 125, 75, 0.18);
}

.flashcard-surface.is-mastered-hint::after {
    color: #2e7c43;
    content: "Opanowane";
    opacity: 1;
    transform: translateY(0);
}

.flashcard-surface.is-swipe-left {
    animation: flashcardSwipeLeft 240ms ease-in forwards;
}

.flashcard-surface.is-swipe-right {
    animation: flashcardSwipeRight 240ms ease-in forwards;
}

.flashcard-surface.is-flipping {
    animation: flashcardFlip 280ms ease-in-out;
}

.flashcard-surface strong {
    font-size: clamp(2.2rem, 4vw, 4rem);
}

.flashcard-speaker-button {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(54, 95, 86, 0.2);
    border-radius: 50%;
    background: rgba(255, 250, 244, 0.92);
    color: var(--primary);
    box-shadow: 0 10px 22px rgba(42, 40, 36, 0.12);
}

.flashcard-speaker-button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.flashcard-speaker-button:hover {
    transform: translateY(-1px);
    background: #ffffff;
}

@keyframes flashcardFlip {
    0% {
        transform: perspective(900px) rotateY(0deg);
        box-shadow: var(--shadow);
    }
    49% {
        transform: perspective(900px) rotateY(88deg) scale(0.98);
        box-shadow: 0 10px 26px rgba(31, 55, 49, 0.08);
    }
    51% {
        transform: perspective(900px) rotateY(-88deg) scale(0.98);
        box-shadow: 0 10px 26px rgba(31, 55, 49, 0.08);
    }
    100% {
        transform: perspective(900px) rotateY(0deg);
        box-shadow: var(--shadow);
    }
}

@keyframes flashcardSwipeLeft {
    from {
        transform: translateX(var(--swipe-start, 0)) rotate(-6deg);
        opacity: 1;
    }
    to {
        transform: translateX(-120%) rotate(-14deg);
        opacity: 0;
    }
}

@keyframes flashcardSwipeRight {
    from {
        transform: translateX(var(--swipe-start, 0)) rotate(6deg);
        opacity: 1;
    }
    to {
        transform: translateX(120%) rotate(14deg);
        opacity: 0;
    }
}

.flashcard-actions,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.flashcard-actions {
    justify-content: center;
    margin-top: 16px;
}

#flashcard-progress {
    display: none;
}

#prev-flashcard {
    background: linear-gradient(135deg, #b42318 0%, #d45a4f 100%);
}

#prev-flashcard,
#next-flashcard,
#flashcard-hard-button,
#flip-flashcard {
    min-width: 126px;
    color: #ffffff;
    border: 1px solid transparent;
}

#next-flashcard {
    background: linear-gradient(135deg, #16815c 0%, #37a274 100%);
}

#typing-mark-correct {
    background: #e6f0eb;
    color: var(--success);
    font-weight: 900;
}

.quiz-mark-correct {
    background: #e6f0eb;
    color: var(--success);
    font-weight: 900;
}

#flashcard-hard-button {
    background: linear-gradient(135deg, #a65f00 0%, #d28a25 100%);
}

#flip-flashcard {
    background: linear-gradient(135deg, #2563a6 0%, #4e91d9 100%);
}

#prev-flashcard:hover,
#next-flashcard:hover,
#flashcard-hard-button:hover,
#flip-flashcard:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.typing-prompt {
    padding: 14px;
    border-radius: var(--radius-md);
    background: var(--teal-soft);
    color: var(--ink);
    font-weight: 800;
}

.quiz-render,
.quiz-wrapper,
.quiz-questions {
    display: grid;
    gap: 14px;
}

.quiz-title strong {
    font-size: 1.35rem;
}

.question-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.question-card h3 {
    margin-bottom: 12px;
    font-size: 1.12rem;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
}

.option-row input {
    accent-color: var(--primary);
}

.option-row.is-correct {
    border-color: rgba(22, 129, 92, 0.55);
    background: #eef8f2;
}

.option-row.is-muted {
    opacity: 0.72;
}

.quiz-step-card .primary-button {
    justify-self: start;
    margin-top: 8px;
}

.result-note {
    margin: 10px 0 0;
    font-weight: 800;
}

.result-note.success {
    color: var(--success);
}

.result-note.error {
    color: var(--danger);
}

.result-banner {
    padding: 14px;
    border-radius: var(--radius-md);
    background: var(--teal-soft);
    color: var(--teal);
    font-weight: 800;
}

.quiz-options-panel {
    max-width: 520px;
}

.quiz-type-switches {
    display: grid;
    gap: 10px;
}

.switch-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    font-weight: 900;
}

.switch-row input[type="checkbox"] {
    width: 44px;
    height: 24px;
    appearance: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #d9c9b6;
    position: relative;
    cursor: pointer;
}

.switch-row input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform 0.16s ease;
}

.switch-row input[type="checkbox"]:checked {
    background: var(--primary);
}

.switch-row input[type="checkbox"]:checked::after {
    transform: translateX(20px);
}

.switch-row input[type="checkbox"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.is-hidden {
    display: none !important;
}

@media (max-width: 1050px) {
    .login-screen,
    .workspace-layout,
    .split-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid,
    .wide-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .study-portal-frame,
    .student-portal-frame,
    .teacher-portal-frame,
    .sets-portal-frame {
        grid-template-columns: 1fr;
    }

    .study-sidebar,
    .student-sidebar,
    .teacher-sidebar,
    .sets-sidebar {
        position: static;
        max-height: none;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .teacher-brand {
        white-space: nowrap;
        padding: 10px 12px;
    }

    .study-nav-item,
    .student-nav-item,
    .teacher-nav-item,
    .set-portal-nav-item {
        width: auto;
        white-space: nowrap;
    }

    .teacher-lower-grid {
        grid-template-columns: 1fr;
    }

    .set-portal-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .app-shell {
        width: min(100% - 18px, 1320px);
        padding-top: 12px;
    }

    .login-copy,
    .auth-card,
    .topbar,
    .mode-nav,
    .sidebar-panel,
    .dashboard-panel,
    .mode-panel {
        padding: 16px;
    }

    .topbar,
    .panel-heading,
    .dashboard-header,
    .builder-heading {
        display: grid;
    }

    .account-summary {
        justify-content: stretch;
    }

    .account-summary span,
    .account-summary button,
    .tab-button,
    .mode-button,
    .primary-button,
    .secondary-button,
    .ghost-button,
    .remove-row-button {
        width: 100%;
    }

    .stats-grid,
    .wide-stats,
    .teacher-grid,
    .word-row {
        grid-template-columns: 1fr;
    }

    .flashcard-actions,
    .inline-actions {
        display: grid;
    }
}
