:root {
    --teal: #127875;
    --teal-2: #1b8995;
    --ink: #272727;
    --muted: #727272;
    --line: #d0d0d0;
    --soft: #f3f7f7;
    --danger: #b42318;
    --ok: #197a38;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: #fff;
    font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    zoom: .75;
}

@supports not (zoom: 1) {
    body {
        width: 133.333%;
        min-height: 133.333vh;
        transform: scale(.75);
        transform-origin: top left;
    }
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    min-height: 96px;
    padding: 16px 30px 10px;
    background: var(--teal);
    color: #fff;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.brand-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
}

.home-button,
.nav-links a,
.nav-links span {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 24px;
    border-radius: 8px;
    background: rgba(34, 147, 161, .72);
    font-size: 18px;
    font-weight: 700;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.nav-links a,
.nav-links span {
    font-size: 16px;
    padding: 0 18px;
}

main {
    min-height: calc(100vh - 96px);
}

.dashboard,
.auth-card,
.import-panel,
.history-page,
.leaderboards,
.teacher-page {
    width: min(1120px, calc(100% - 40px));
    margin: 48px auto;
}

.teacher-page {
    width: calc(100% - 40px);
    margin: 26px auto;
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 42px;
    align-items: start;
}

.leaderboards {
    margin-top: 0;
}

.developer-credit {
    position: fixed;
    left: 18px;
    bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8b9494;
    font-size: 12px;
    line-height: 1.35;
    z-index: 5;
}

.developer-credit img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.developer-credit p {
    margin: 0;
    display: grid;
    gap: 1px;
}

.leaderboard-head h2 {
    margin: 0 0 24px;
    font-size: 30px;
}

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

.leaderboard-group {
    display: grid;
    gap: 14px;
}

.leaderboard-group h3 {
    margin: 0;
    font-size: 22px;
}

.leaderboard-group > .muted {
    margin: -6px 0 4px;
}

.leaderboard-card {
    border: 1px solid #e4ebeb;
    border-radius: 8px;
    background: #fff;
    padding: 16px;
    box-shadow: 0 12px 30px rgba(13, 70, 69, .07);
}

.teacher-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.teacher-stats div,
.teacher-panel {
    border: 1px solid #e4ebeb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(13, 70, 69, .07);
}

.teacher-stats div {
    padding: 18px;
}

.teacher-stats span {
    color: var(--muted);
}

.teacher-stats strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
}

.teacher-panel {
    padding: 18px;
}

.teacher-titlebar {
    margin-bottom: 18px;
}

.teacher-tabs {
    display: flex;
    gap: 10px;
    margin: 0 0 18px;
}

.teacher-tabs a {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    padding: 0 18px;
    border-radius: 8px;
    background: #edf4f4;
    color: var(--teal);
    font-weight: 800;
}

.teacher-tabs a.active {
    background: var(--teal);
    color: #fff;
}

.teacher-workspace {
    display: grid;
    grid-template-columns: minmax(420px, 36%) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.teacher-sidebar,
.teacher-details {
    max-height: calc(133.333vh - 270px);
    overflow: auto;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.panel-head h2 {
    margin: 0;
    font-size: 24px;
}

.teacher-table {
    display: grid;
    gap: 6px;
}

.teacher-row {
    display: grid;
    gap: 12px;
    align-items: center;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
}

.teacher-row:not(.teacher-row-head):hover {
    background: #f4f8f8;
}

.teacher-row-head {
    color: var(--muted);
    background: #f0f5f5;
}

.teacher-row.selected {
    background: #e7f4f4;
    box-shadow: inset 4px 0 0 var(--teal);
}

.teacher-student-row {
    grid-template-columns: minmax(110px, 1fr) 58px 58px 70px;
}

.teacher-question-row {
    grid-template-columns: 54px minmax(180px, 1fr) 72px 46px;
}

.teacher-question-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wrong-users {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
}

.wrong-users a {
    padding: 6px 10px;
    border-radius: 999px;
    background: #fff1f0;
    color: var(--danger);
    font-weight: 800;
}

.leaderboard-title {
    color: var(--teal);
    font-weight: 800;
    margin-bottom: 10px;
}

.rank-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 74px;
    gap: 10px;
    align-items: center;
    min-height: 34px;
    border-top: 1px solid #edf1f1;
}

.rank-row:first-of-type {
    border-top: 0;
}

.rank-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-row em {
    color: var(--teal);
    font-style: normal;
    font-weight: 800;
    text-align: right;
}

.eyebrow {
    color: var(--teal);
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 18px;
    font-size: 36px;
}

.lead {
    max-width: 640px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.7;
}

.actions,
.bottom-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 26px;
}

.primary,
.secondary,
.nav-button,
.timer-toggle {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
}

.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 26px;
    background: var(--teal);
    color: #fff;
    font-weight: 800;
}

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

.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 22px;
    background: #e8eeee;
    color: var(--teal);
    font-weight: 800;
}

.stats-panel,
.auth-card,
.import-panel,
.review-list,
.history-item {
    border: 1px solid #e4ebeb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(13, 70, 69, .08);
}

.stats-panel {
    padding: 24px;
}

.stats-panel div {
    padding: 18px 0;
    border-bottom: 1px solid #edf1f1;
}

.stats-panel div:last-child {
    border-bottom: 0;
}

.stats-panel span,
.history-item span,
.muted {
    color: var(--muted);
}

.stats-panel strong {
    display: block;
    margin-top: 8px;
    font-size: 20px;
}

.auth-card,
.import-panel {
    max-width: 620px;
    padding: 28px;
}

.stack-form {
    display: grid;
    gap: 18px;
}

.stack-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid #d7dfdf;
    border-radius: 8px;
    padding: 12px 14px;
    font: inherit;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

.error,
.success {
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.error {
    color: var(--danger);
    background: #fff1f0;
}

.success {
    color: var(--ok);
    background: #ecf8ef;
}

.practice-shell {
    position: relative;
    min-height: calc(100vh - 96px);
    padding: 18px 30px 60px;
}

.practice-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    font-size: 21px;
}

.practice-meta > div:first-child {
    display: flex;
    align-items: center;
    gap: 14px;
}

.practice-meta span {
    width: 1px;
    height: 26px;
    background: #dde3e3;
}

.timer-area {
    display: flex;
    align-items: center;
    gap: 22px;
}

#timer {
    font-family: "Courier New", monospace;
    letter-spacing: 4px;
}

.timer-toggle {
    color: var(--teal);
    background: transparent;
    font-weight: 800;
}

.question-actions {
    position: absolute;
    top: -82px;
    right: 30px;
    display: flex;
    gap: 24px;
}

.nav-button {
    min-width: 132px;
    min-height: 54px;
    padding: 0 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 147, 161, .72);
    color: #fff;
    font-size: 23px;
}

.review-button.active,
.reviewed {
    color: #fff;
    background: #0e6664;
}

.list-link {
    min-width: 96px;
}

.nav-button.next-link {
    background: #fff;
    color: var(--teal);
}

.nav-button.disabled {
    opacity: .45;
    pointer-events: none;
}

.prompt {
    margin-top: 20px;
    text-align: center;
    font: 700 32px Georgia, "Times New Roman", serif;
    color: #3d3d3d;
}

.dialogue {
    width: min(900px, 100%);
    margin: 180px auto 0;
}

.line {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: center;
    gap: 22px;
    margin: 18px 0;
}

.line img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: 3px solid #3b9b87;
    object-fit: cover;
}

.line p {
    margin: 0;
    font: 700 21px Georgia, "Times New Roman", serif;
    line-height: 1.5;
}

.sentence-builder {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: end;
}

.blank {
    width: max(136px, calc(var(--blank-chars, 8) * 12px));
    min-width: 136px;
    height: 38px;
    border: 0;
    border-bottom: 3px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: #333;
    font-size: 20px;
    line-height: 1.15;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.static-text {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    font: 700 20px Georgia, "Times New Roman", serif;
    white-space: pre-wrap;
}

.blank.filled {
    border-bottom-color: #bababa;
}

.blank.drop-target {
    background: #eef8f8;
    border-bottom-color: var(--teal);
}

.word-bank {
    width: min(900px, 100%);
    margin: 96px auto 0;
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

.word-token {
    min-height: 46px;
    padding: 0 16px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #333;
    font-size: 21px;
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: element;
}

.word-token.used {
    background: #ddd;
    color: #9b9b9b;
    cursor: default;
}

.word-token.animating {
    visibility: hidden;
}

.word-token.dragging {
    opacity: .45;
}

.fly-token {
    position: fixed;
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-size: 21px;
    pointer-events: none;
    white-space: nowrap;
    transition: transform 150ms linear;
}

.feedback {
    width: min(760px, calc(100% - 40px));
    margin: 28px auto 0;
    padding: 16px 18px;
    border-radius: 8px;
    text-align: center;
    font-weight: 800;
}

.feedback.correct {
    color: var(--ok);
    background: #ecf8ef;
}

.feedback.wrong {
    color: var(--danger);
    background: #fff1f0;
}

.explanation-box {
    width: min(760px, calc(100% - 40px));
    margin: 12px auto 0;
    padding: 14px 16px;
    border-radius: 8px;
    background: #f6f8f8;
    color: #4f5c5c;
    font-weight: 700;
    line-height: 1.6;
}

.bottom-actions {
    justify-content: center;
}

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

.tabs {
    display: flex;
    gap: 10px;
}

.tabs a {
    padding: 10px 16px;
    border-radius: 8px;
    background: #edf4f4;
    color: var(--teal);
    font-weight: 800;
}

.tabs a.active {
    background: var(--teal);
    color: #fff;
}

.history-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 24px;
}

.history-item {
    padding: 18px;
    margin-bottom: 16px;
}

.item-top {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.ok {
    color: var(--ok);
}

.bad {
    color: var(--danger);
}

.history-item .ok {
    color: var(--ok);
}

.history-item .bad,
.history-item .wrong-word {
    color: var(--danger);
}

.answer-line-history {
    line-height: 1.8;
}

.answer-word {
    display: inline-block;
    margin-right: 5px;
}

.record-explanation,
.question-explanation {
    color: #4f5c5c;
    background: #f6f8f8;
    border-radius: 8px;
    padding: 10px 12px;
    line-height: 1.6;
}

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

.question-row {
    display: grid;
    grid-template-columns: 70px minmax(220px, 1fr) minmax(180px, 300px) 70px 78px;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid #e4ebeb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(13, 70, 69, .06);
}

.question-explanation {
    grid-column: 2 / -1;
}

.question-title,
.question-set {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.question-set {
    color: var(--muted);
}

.question-row .reviewed {
    justify-self: start;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 800;
}

.review-list {
    padding: 18px;
    align-self: start;
}

.review-list h2 {
    margin-top: 0;
}

.review-list a {
    display: block;
    padding: 12px 0;
    border-top: 1px solid #edf1f1;
    color: var(--teal);
    font-weight: 800;
}

.set-card {
    display: grid;
    gap: 12px;
}

.set-card .item-top {
    align-items: center;
}

.set-card-title {
    color: var(--teal);
}

.set-card-title strong {
    font-size: 20px;
}

.set-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
    border: 1px solid #e4ebeb;
    border-radius: 8px;
    background: #f8fbfb;
}

.set-stats > div {
    display: grid;
    gap: 4px;
}

.set-stats span {
    color: var(--muted);
    font-size: 14px;
}

.set-stats strong {
    font-size: 22px;
    color: var(--ink);
}

.set-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.set-actions form {
    display: inline-flex;
}

.admin-set-page h2 {
    margin: 28px 0 14px;
    font-size: 26px;
}

.admin-set-row {
    grid-template-columns: 54px minmax(0, 1fr) minmax(180px, 280px) 72px auto;
    align-items: center;
}

.admin-set-row-actions {
    display: inline-flex;
    gap: 8px;
    justify-self: end;
}

.admin-set-row-actions form {
    display: inline-flex;
}

.admin-set-detail {
    grid-column: 1 / -1;
    padding: 10px 12px 0;
    border-top: 1px dashed #e4ebeb;
    color: #4f5c5c;
    line-height: 1.7;
    font-size: 15px;
}

.admin-set-detail p {
    margin: 4px 0;
}

@media (max-width: 780px) {
    .topbar,
    .practice-meta,
    .history-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard,
    .history-grid,
    .leaderboard-grid,
    .teacher-workspace,
    .teacher-stats {
        grid-template-columns: 1fr;
    }

    .teacher-sidebar,
    .teacher-details {
        max-height: none;
    }

    .teacher-student-row,
    .teacher-question-row {
        grid-template-columns: 1fr 1fr;
    }

    .question-actions {
        position: static;
        margin-top: 18px;
        gap: 10px;
    }

    .review-button,
    .nav-button {
        min-width: 0;
        flex: 1;
        min-height: 48px;
        font-size: 18px;
        padding: 0 12px;
    }

    .prompt {
        font-size: 30px;
    }

    .dialogue {
        margin-top: 80px;
    }

    .line {
        grid-template-columns: 82px minmax(0, 1fr);
        gap: 14px;
    }

    .line img {
        width: 76px;
        height: 76px;
    }

    .line p,
    .word-token,
    .blank,
    .static-text {
        font-size: 20px;
    }

    .blank {
        width: 124px;
    }

    .word-bank {
        margin-top: 70px;
    }

    .question-row {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .question-set,
    .question-row .ok,
    .question-row .bad,
    .question-row .muted,
    .question-row .reviewed {
        grid-column: 2;
    }

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

    .admin-set-row {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .admin-set-row > span,
    .admin-set-row > .admin-set-row-actions {
        grid-column: 2;
    }

    .admin-set-row-actions {
        justify-self: start;
    }
}
