:root {
    --primary: #185FA5;
    --primary-dark: #0C447C;
    --primary-light: #E6F1FB;
    --text: #1C1C1E;
    --text-2: #6B6B70;
    --text-3: #9A9AA0;
    --border: #E8E8ED;
    --bg: #F5F6F8;
    --white: #FFFFFF;
    --danger: #C4372C;
    --danger-light: #FCEBEB;
    --success: #18794E;
    --success-light: #E9F6EF;
    --warn: #8C5A0F;
    --warn-light: #FAEEDA;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.wrap {
    max-width: 640px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
}

/* 周课表（大学课程表样式） */
.tt-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tt-grid {
    display: grid;
    grid-template-columns: 30px repeat(7, minmax(0, 1fr));
    gap: 2px;
    padding: 4px;
    grid-auto-rows: 40px;
}

.tt-head {
    display: grid;
    grid-template-columns: 30px repeat(7, minmax(0, 1fr));
    gap: 2px;
    padding: 6px 4px 2px;
}

.tt-head .d {
    text-align: center;
    font-size: 11px;
    color: var(--text-2);
    line-height: 1.3;
    padding: 2px 0;
    border-radius: 6px;
}

.tt-head .d b {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.tt-head .d.today {
    background: var(--primary-light);
}

.tt-head .d.today b {
    color: var(--primary-dark);
}

.tt-time {
    font-size: 9px;
    color: var(--text-3);
    text-align: right;
    padding-right: 1px;
    line-height: 1;
    align-self: start;
    margin-top: 1px;
}

.tt-cell {
    background: #FAFAFC;
    border-radius: 4px;
    min-height: 40px;
}

.tt-lesson {
    border-radius: 5px;
    padding: 3px 3px;
    font-size: 10px;
    line-height: 1.25;
    color: #fff;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1px;
    z-index: 2;
}

.tt-lesson .n {
    font-weight: 600;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-lesson .t {
    opacity: .85;
    font-size: 9px;
    white-space: nowrap;
}

.tt-lesson.done {
    opacity: .55;
}

.tt-lesson.canceled {
    opacity: .4;
    text-decoration: line-through;
}

.tt-c1 { background: #185FA5; }
.tt-c2 { background: #2C7A7B; }
.tt-c3 { background: #7C4DBE; }
.tt-c4 { background: #C2410C; }
.tt-c5 { background: #0E7490; }
.tt-c6 { background: #9A5B13; }

.tt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 2px 8px;
    font-size: 11px;
    color: var(--text-2);
}

.tt-legend i {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: -1px;
}

/* 初始密码提醒条 */
.pwd-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--warn-light);
    color: var(--warn);
    padding: 9px 16px;
    font-size: 13px;
    line-height: 1.4;
}

.pwd-banner a {
    color: var(--warn);
    font-weight: 600;
    flex-shrink: 0;
    text-decoration: underline;
}

/* 顶栏 */
.appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
}

.appbar h1 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.appbar .back {
    font-size: 22px;
    line-height: 1;
    color: var(--text);
    padding: 4px 8px 4px 0;
    background: none;
    border: none;
    cursor: pointer;
}

.appbar .action {
    font-size: 14px;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

/* 页面内容 */
.page {
    padding: 14px 16px 84px;
}

.page-plain {
    padding: 12px 16px 24px;
}

/* 底部导航 */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 640px;
    margin: 0 auto;
    height: 58px;
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-3);
    font-size: 11px;
}

.tabbar a.active {
    color: var(--primary);
}

.tabbar .ico {
    font-size: 19px;
    line-height: 1;
}

/* 卡片 */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.card-tap:active {
    background: #FAFAFB;
}

/* 统计条 */
.stats {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.stat {
    flex: 1;
    background: var(--white);
    border-radius: var(--radius);
    padding: 10px 8px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat .n {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}

.stat .l {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
}

.stat.new .n { color: var(--danger); }
.stat.reviewing .n { color: var(--warn); }
.stat.mastered .n { color: var(--success); }

/* 筛选 */
.filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.filters select,
.filters input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text);
    outline: none;
}

.filters input[type="search"] {
    grid-column: 1 / -1;
}

/* 表单 */
.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 6px;
}

.field label .req {
    color: var(--danger);
}

/* 表单内联错误：贴在按钮上方，比底部 toast 更容易被看到 */
.form-error {
    display: none;
    margin: 0 0 12px;
    padding: 9px 12px;
    border-radius: 8px;
    background: var(--danger-light);
    color: var(--danger);
    font-size: 13px;
    line-height: 1.45;
}

.form-error.show {
    display: block;
}

/* 分段选择：老师 / 学生 */
.seg {
    display: flex;
    gap: 8px;
}

.seg-item {
    flex: 1;
    padding: 9px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-2);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.seg-item.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

/* 学生账号的只读视图：输入框仍清晰可读，只是不能改 */
.view-only input[readonly],
.view-only textarea[readonly],
.view-only select:disabled {
    background: var(--bg);
    color: var(--text);
    opacity: 1;
}

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="search"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    outline: none;
    transition: border-color .15s;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 72px;
    line-height: 1.5;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s;
}

.btn:active {
    opacity: .7;
}

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

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

.btn-danger {
    background: var(--white);
    border-color: #F3C9C5;
    color: var(--danger);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

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

/* 标签 */
.chip {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    line-height: 1.6;
    white-space: nowrap;
}

.chip-new { background: var(--danger-light); color: var(--danger); }
.chip-reviewing { background: var(--warn-light); color: var(--warn); }
.chip-mastered { background: var(--success-light); color: var(--success); }
.chip-subject { background: var(--primary-light); color: var(--primary-dark); }
.chip-gray { background: #F0F0F3; color: var(--text-2); }

/* 错题条目 */
.q-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.q-thumb {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
    background: #F0F0F3;
    flex-shrink: 0;
}

.q-thumb-empty {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.q-body {
    flex: 1;
    min-width: 0;
}

.q-title {
    font-size: 14px;
    line-height: 1.45;
    margin: 0 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
}

.q-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-3);
}

/* 图片 */
.preview {
    width: 100%;
    border-radius: var(--radius);
    display: block;
    background: #F0F0F3;
}

.upload-box {
    border: 1.5px dashed #C9CDD4;
    border-radius: var(--radius);
    padding: 26px 16px;
    text-align: center;
    color: var(--text-3);
    background: var(--white);
    cursor: pointer;
}

.upload-box .big {
    font-size: 26px;
    display: block;
    margin-bottom: 6px;
}

/* 空状态 */
.empty {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-3);
    font-size: 14px;
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    background: rgba(28, 28, 30, .92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 999;
    max-width: 80%;
    text-align: center;
    animation: toastIn .18s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* 悬浮按钮 */
.fab {
    position: fixed;
    right: calc(50% - 320px + 20px);
    bottom: 78px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 26px;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(24, 95, 165, .35);
    cursor: pointer;
    z-index: 25;
}

@media (max-width: 680px) {
    .fab {
        right: 20px;
    }
}

/* 课程表 */
.week-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.week-nav .label {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
}

/* 日期下方的小号「回到本周」：只在翻到别的周时出现 */
.link-mini {
    display: none;
    padding: 0;
    margin-top: 1px;
    background: none;
    border: none;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--primary);
    cursor: pointer;
}

.day-group {
    margin-bottom: 14px;
}

.day-head {
    font-size: 12px;
    color: var(--text-2);
    margin: 0 4px 6px;
    font-weight: 500;
}

.lesson {
    background: var(--white);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
    box-shadow: var(--shadow);
    border-left: 3px solid var(--primary);
}

.lesson.done { border-left-color: var(--success); opacity: .72; }
.lesson.canceled { border-left-color: var(--text-3); opacity: .55; }

.lesson .time {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    white-space: nowrap;
    padding-top: 1px;
}

.lesson .info {
    flex: 1;
    min-width: 0;
}

.lesson .who {
    font-size: 14px;
    font-weight: 500;
}

.lesson .sub {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

/* 登录页 */
.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 28px;
    max-width: 420px;
    margin: 0 auto;
}

.login-title {
    font-size: 26px;
    font-weight: 600;
    margin: 0 0 6px;
    letter-spacing: .5px;
}

.login-sub {
    font-size: 13px;
    color: var(--text-3);
    margin: 0 0 32px;
}

/* 弹层 */
.mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    z-index: 100;
    display: flex;
    align-items: flex-end;
}

.sheet {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 16px 16px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    animation: sheetUp .2s ease;
}

@keyframes sheetUp {
    from { transform: translateY(16px); opacity: .6; }
    to { transform: translateY(0); opacity: 1; }
}

.sheet h3 {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 600;
}

.sheet .grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.hint {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 6px;
    line-height: 1.5;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}
