:root {
    --ink: #142126;
    --muted: #607078;
    --line: #dce6ea;
    --paper: #ffffff;
    --soft: #f5f8f7;
    --deep: #102f36;
    --teal: #1f8a8a;
    --cyan: #1b83b6;
    --green: #4f8d52;
    --amber: #b98324;
    --coral: #c65f4b;
    --danger: #b63b3b;
    --shadow: 0 18px 48px rgba(17, 45, 54, .12);
}

* {
    box-sizing: border-box;
}

html {
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0;
}

body {
    min-width: 320px;
    margin: 0;
    background: #f3f7f7;
    color: var(--ink);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

img {
    display: block;
    max-width: 100%;
}

.app-root {
    min-height: 100vh;
}

.boot-screen,
.not-found {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

.boot-logo,
.not-found img {
    width: 176px;
    margin-bottom: 18px;
}

.not-found h1 {
    margin: 0 0 12px;
    color: var(--deep);
    font-size: 28px;
}

.not-found a {
    color: var(--teal);
    font-weight: 800;
}

.login-page {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr);
    background: var(--paper);
}

.login-intro {
    display: flex;
    min-height: 100%;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(28px, 5vw, 72px);
    background:
        linear-gradient(135deg, rgba(245, 248, 247, .96), rgba(255, 255, 255, .96)),
        url("/assets/img/qiwt-logo-site.png") no-repeat calc(100% - 48px) calc(100% - 48px) / 220px auto;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-row img {
    width: 156px;
}

.brand-kicker {
    padding-left: 14px;
    border-left: 1px solid rgba(31, 138, 138, .25);
    color: #45686d;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
}

.login-copy {
    max-width: 620px;
    margin-top: 56px;
}

.login-copy h1 {
    margin: 0 0 18px;
    color: var(--deep);
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.08;
}

.login-copy p {
    max-width: 520px;
    margin: 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.85;
}

.login-metrics {
    display: grid;
    max-width: 640px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 44px;
}

.metric-tile {
    min-height: 96px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: rgba(255, 255, 255, .82);
}

.metric-tile strong {
    display: block;
    color: var(--deep);
    font-size: 24px;
    line-height: 1.1;
}

.metric-tile span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.login-panel-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: #eef5f5;
}

.login-panel {
    width: min(440px, 100%);
    border: 1px solid rgba(31, 138, 138, .18);
    border-radius: 8px;
    padding: 30px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.panel-head {
    margin-bottom: 22px;
}

.panel-head h2 {
    margin: 0;
    color: var(--deep);
    font-size: 24px;
}

.panel-head p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.field {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.field label {
    color: #29464d;
    font-size: 13px;
    font-weight: 800;
}

.field input {
    width: 100%;
    height: 46px;
    border: 1px solid #cbdcdf;
    border-radius: 8px;
    padding: 0 13px;
    background: var(--paper);
    color: var(--ink);
    outline: none;
}

.field input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(31, 138, 138, .12);
}

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 18px;
    color: var(--muted);
    font-size: 13px;
}

.check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.check-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--teal);
}

.btn {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 16px;
    font-weight: 800;
    text-decoration: none;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

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

.btn:not(:disabled):hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--teal);
    color: #fff;
    box-shadow: 0 12px 26px rgba(31, 138, 138, .22);
}

.btn-secondary {
    border-color: var(--line);
    background: var(--paper);
    color: var(--deep);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--teal);
}

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

.btn-block {
    width: 100%;
}

.status-message {
    min-height: 22px;
    margin-top: 14px;
    color: var(--danger);
    font-size: 13px;
}

.app-layout {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
}

.sidebar-head {
    padding: 22px 22px 14px;
    border-bottom: 1px solid var(--line);
}

.sidebar-head img {
    width: 146px;
}

.learn-tag {
    display: inline-flex;
    margin-top: 14px;
    border-radius: 999px;
    padding: 5px 10px;
    background: rgba(31, 138, 138, .09);
    color: var(--teal);
    font-size: 12px;
    font-weight: 800;
}

.side-nav {
    display: grid;
    gap: 6px;
    padding: 18px 12px;
}

.nav-button {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    border: 0;
    border-radius: 8px;
    padding: 0 12px;
    background: transparent;
    color: #2d4950;
    font-weight: 800;
    text-align: left;
}

.nav-button span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.nav-button.is-active {
    background: rgba(31, 138, 138, .1);
    color: var(--teal);
}

.sidebar-foot {
    margin-top: auto;
    padding: 16px 22px 22px;
    border-top: 1px solid var(--line);
}

.user-chip {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.user-chip strong {
    display: block;
    overflow: hidden;
    color: var(--deep);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-panel {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 0;
    color: var(--deep);
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.2;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

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

.toolbar input {
    width: min(280px, 100%);
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    outline: none;
}

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

.stat-card,
.content-card,
.course-card,
.term-card,
.question-panel,
.empty-state,
.lesson-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: 0 8px 22px rgba(17, 45, 54, .06);
}

.stat-card {
    min-height: 98px;
    padding: 15px;
}

.stat-card strong {
    display: block;
    color: var(--deep);
    font-size: 26px;
    line-height: 1;
}

.stat-card span {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
    gap: 16px;
}

.content-card {
    padding: 18px;
}

.content-card h2,
.lesson-panel h2 {
    margin: 0 0 12px;
    color: var(--deep);
    font-size: 20px;
}

.course-grid,
.term-grid,
.favorite-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.course-card,
.term-card {
    display: flex;
    min-height: 190px;
    flex-direction: column;
    padding: 18px;
}

.course-card h3,
.term-card h3 {
    margin: 0;
    color: var(--deep);
    font-size: 19px;
    line-height: 1.35;
}

.course-card p,
.term-card p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    background: #eef6f6;
    color: #35676b;
    font-size: 12px;
    font-weight: 800;
}

.pill.green {
    background: rgba(79, 141, 82, .12);
    color: var(--green);
}

.pill.amber {
    background: rgba(185, 131, 36, .13);
    color: var(--amber);
}

.pill.coral {
    background: rgba(198, 95, 75, .12);
    color: var(--coral);
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 16px;
}

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

.section-block {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: var(--paper);
}

.section-block h3 {
    margin: 0 0 12px;
    color: var(--deep);
}

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

.lesson-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px solid #e8eff0;
    border-radius: 8px;
    padding: 14px;
    background: #fbfdfd;
}

.lesson-row strong {
    display: block;
    color: var(--deep);
}

.lesson-row span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.lesson-panel {
    padding: 20px;
}

.lesson-content {
    color: #243d44;
    line-height: 1.8;
}

.lesson-content p {
    margin: 0 0 12px;
}

.split-content {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
    gap: 16px;
}

.term-card {
    min-height: 230px;
}

.term-word {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 10px;
}

.term-word em {
    color: var(--muted);
    font-size: 13px;
    font-style: normal;
}

.question-panel {
    padding: 20px;
}

.question-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 13px;
}

.question-title {
    margin: 0 0 16px;
    color: var(--deep);
    font-size: 22px;
    line-height: 1.45;
}

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

.option-button {
    display: grid;
    width: 100%;
    min-height: 52px;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--paper);
    color: var(--ink);
    text-align: left;
}

.option-button strong {
    display: inline-flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #eff6f6;
    color: var(--teal);
}

.option-button.is-selected {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(31, 138, 138, .1);
}

.option-button.is-correct {
    border-color: var(--green);
    background: rgba(79, 141, 82, .08);
}

.option-button.is-wrong {
    border-color: var(--danger);
    background: rgba(182, 59, 59, .07);
}

.feedback {
    margin-top: 16px;
    border-radius: 8px;
    padding: 14px;
    background: #f5f8f7;
    color: #29464d;
    line-height: 1.7;
}

.feedback.is-right {
    background: rgba(79, 141, 82, .1);
}

.feedback.is-wrong {
    background: rgba(198, 95, 75, .1);
}

.empty-state {
    padding: 26px;
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 8px;
    color: var(--deep);
    font-size: 18px;
}

.loading {
    padding: 28px;
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 80;
    max-width: min(420px, calc(100vw - 40px));
    border-radius: 8px;
    padding: 13px 15px;
    background: var(--deep);
    color: #fff;
    box-shadow: var(--shadow);
}

.toast.is-error {
    background: var(--danger);
}

@media (max-width: 1120px) {
    .stats-grid,
    .course-grid,
    .term-grid,
    .favorite-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid,
    .split-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .login-page {
        grid-template-columns: 1fr;
    }

    .login-intro {
        min-height: auto;
        padding: 24px;
    }

    .login-metrics {
        grid-template-columns: 1fr;
    }

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

    .sidebar {
        position: static;
        height: auto;
    }

    .side-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding: 12px;
    }

    .nav-button {
        justify-content: center;
    }

    .nav-button span {
        display: none;
    }

    .sidebar-foot {
        display: none;
    }

    .main-panel {
        padding: 16px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 620px) {
    .brand-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .brand-kicker {
        border-left: 0;
        padding-left: 0;
    }

    .login-panel-wrap {
        padding: 18px;
    }

    .login-panel {
        padding: 22px;
    }

    .stats-grid,
    .course-grid,
    .term-grid,
    .favorite-grid,
    .side-nav {
        grid-template-columns: 1fr;
    }

    .lesson-row {
        grid-template-columns: 1fr;
    }
}
