/* 每日签到 - 移动端优先样式 */
:root {
    --bg: #f2f4f8;
    --card: #ffffff;
    --text: #1f2430;
    --muted: #8a90a0;
    --accent: #4f6ef2;
    --green: #22c55e;
    --border: #e6e8ef;
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

/* ---------- 顶栏 ---------- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px 4px;
    max-width: 560px;
    margin: 0 auto;
}
.topbar-left { display: flex; align-items: center; gap: 6px; }
.topbar h1 { font-size: 19px; margin: 0; }
.back {
    text-decoration: none;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    padding: 2px 8px 2px 0;
}
.user-box { display: flex; align-items: center; gap: 10px; }
.user-box span { color: var(--muted); font-size: 13px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.btn-ghost { text-decoration: none; display: inline-block; }

/* ---------- 通用控件 ---------- */
input[type="text"], input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;              /* ≥16px 防 iOS 聚焦缩放 */
    outline: none;
    transition: border-color .15s;
    background: #fff;
}
input:focus { border-color: var(--accent); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 13px 18px;
    font-size: 16px;
    cursor: pointer;
    transition: opacity .15s;
    text-align: center;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    padding: 7px 13px;
    cursor: pointer;
    font-size: 14px;
    transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--text); border-color: #c9cdd8; }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 主容器（移动优先：单列窄边距） ---------- */
.wrap {
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 14px calc(40px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ---------- 页顶引导卡 ---------- */
.guide {
    background: var(--accent);
    background: linear-gradient(135deg, #eef2ff, #f5f8ff);
    border: 1px solid #dde5ff;
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13.5px;
}
.guide summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: "▾"; margin-left: auto; color: var(--accent); transition: transform .2s; }
.guide:not([open]) summary::after { transform: rotate(-90deg); }
.guide ol { margin: 10px 0 2px; padding-left: 20px; color: #4a5068; }
.guide li { margin-bottom: 4px; }

/* ---------- 导航页 ---------- */
.hero { text-decoration: none; color: inherit; display: block; text-align: center; padding: 20px 16px; }
.hero-title { font-size: 17px; font-weight: 700; }
.hero-sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 14px; }
.hero-btn { display: inline-block; padding: 11px 26px; }

.nav-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.nav-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    transition: transform .12s, box-shadow .12s;
}
.nav-card:active { transform: scale(.98); }
.nav-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--accent);
    background: linear-gradient(135deg, #eef2ff, #e4ebff);
    color: var(--accent);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.nav-name { font-size: 16px; font-weight: 700; }
.nav-desc { font-size: 13px; color: var(--muted); }
.nav-badge {
    align-self: flex-start;
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
    background: var(--bg);
    border-radius: 20px;
    padding: 3px 10px;
}
.nav-badge.ok { color: #fff; background: var(--green); }

/* ---------- 签到页 ---------- */
.today-card { text-align: center; padding: 24px 16px; }
.today-date { font-size: 14px; color: var(--muted); }
.today-status {
    font-size: 26px;
    font-weight: 800;
    margin: 10px 0 14px;
}
.today-status.ok { color: var(--green); }
.today-stats { display: flex; justify-content: center; gap: 22px; color: var(--muted); font-size: 13.5px; }
.today-stats b { color: var(--accent); font-size: 16px; }

.checkin-box { display: flex; flex-direction: column; gap: 10px; }

.link-more {
    text-decoration: none;
    color: var(--accent);
    text-align: center;
    font-size: 14px;
    font-weight: 600;
}

/* ---------- 日历页 ---------- */
.cal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
#cal-title { font-weight: 600; font-size: 15px; }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}
.cal-grid .wd { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-grid .day { font-size: 13px; padding: 9px 0; border-radius: 8px; }
.cal-grid .day.checked { background: var(--accent); color: #fff; font-weight: 600; }
.cal-grid .day.today { outline: 2px solid var(--green); outline-offset: -2px; }
.cal-grid .day.checked.today { outline-color: #fff; box-shadow: inset 0 0 0 2px var(--green); }
.cal-grid .blank { padding: 9px 0; }

/* ---------- 最近记录 ---------- */
.sec-title { font-size: 15px; margin: 0 0 10px; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.recent li:last-child { border-bottom: 0; }
.recent .date { font-weight: 600; white-space: nowrap; }
.recent .note { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.recent .empty { justify-content: center; color: var(--muted); }

/* ---------- 账号页 ---------- */
.auth-card { padding: 20px 16px; }
.tabs {
    display: flex;
    background: var(--bg);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 16px;
}
.tab {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 9px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
}
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
#login-form input, #register-form input { margin-bottom: 12px; }

.account-card { text-align: center; padding: 26px 16px; }
.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f6ef2, #7b93ff);
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}
.acc-name { font-size: 19px; font-weight: 700; }
.acc-sub { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.acc-stats { display: flex; justify-content: center; gap: 36px; margin-bottom: 20px; }
.acc-stat b { display: block; font-size: 22px; color: var(--accent); }
.acc-stat span { font-size: 12px; color: var(--muted); }

/* ---------- 老师点名页 ---------- */
.session-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}
.session-info { font-size: 14px; color: var(--muted); min-width: 0; }
.session-info b { color: var(--text); display: block; font-size: 15px; }
.operator-tag { font-size: 12px; color: var(--accent); margin-top: 4px; }

/* ---------- 项目主题卡 / 页脚 ---------- */
.theme-card { text-align: center; padding: 16px; }
.theme-label { font-size: 12px; color: var(--muted); }
.theme-text { font-size: 17px; font-weight: 700; margin-top: 4px; }

.page-footer { text-align: center; padding: 4px 0 12px; }
.page-footer a { color: var(--muted); font-size: 13px; text-decoration: none; }
.page-footer a:hover { color: var(--accent); }

/* ---------- 点名管理密码门 ---------- */
.gate-card { text-align: center; padding: 28px 20px; }
.gate-title { margin: 0; font-size: 18px; }
.gate-sub { margin: 8px 0 16px; font-size: 13px; color: var(--muted); }
.gate-card input { margin-bottom: 12px; }

/* ---------- 点名管理页发起区 ---------- */
.new-session { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
#session-info { font-size: 14px; color: var(--muted); }
#session-info b { color: var(--text); }

/* ---------- 操作者身份弹窗 ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(31, 36, 48, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
    width: 100%;
    max-width: 340px;
    text-align: center;
    padding: 26px 22px;
}
.modal-title { margin: 0 0 8px; font-size: 18px; }
.modal-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.modal-box input { margin-bottom: 14px; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
    font-size: 12.5px;
    color: var(--muted);
    background: var(--bg);
    border-radius: 20px;
    padding: 4px 12px;
}
.chip.ok { color: #fff; background: var(--green); }

.seat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 8px;
}
.seat {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: transform .1s, background .15s, border-color .15s;
    min-width: 0;
}
.seat:active { transform: scale(.95); }
.seat .nm {
    font-size: 14px;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.seat .st {
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    display: none;
}
.seat.unnamed { border-style: dashed; }
.seat.mine { background: #e8edff; border-color: var(--accent); }
.seat.mine .st { background: var(--accent); display: block; }
.seat .cancel {
    position: absolute;
    left: 5px;
    bottom: 4px;
    font-size: 10px;
    color: var(--accent);
}
.seat.locked {
    background: #e9f9f0;
    border-color: var(--green);
    cursor: not-allowed;
    opacity: .75;
}
.seat.locked .st { display: block; }
.seat:disabled { cursor: not-allowed; }
.seat.mine:disabled { opacity: .7; }

/* ---------- 名单管理页 ---------- */
.roster-actions { display: flex; gap: 10px; margin-bottom: 14px; }
.btn-danger {
    background: #fff;
    border: 1px solid #f3b4b4;
    color: #d9534f;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 14px;
    cursor: pointer;
}
.btn-danger:hover { background: #fdf1f1; }

/* ---------- 名单列表 ---------- */
.rl-row {
    display: grid;
    grid-template-columns: 34px 1fr 64px 84px 52px;
    align-items: center;
    gap: 6px;
    padding: 9px 2px;
    font-size: 14px;
    border-bottom: 1px solid var(--line, #eceef3);
}
.rl-head { font-size: 12px; color: var(--muted); padding-bottom: 8px; }
.rl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-present .rl-muted { color: #1a7f4b; }
.rl-muted { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-del {
    background: #fff;
    border: 1px solid #f3b4b4;
    color: #d9534f;
    border-radius: 8px;
    padding: 5px 0;
    font-size: 12px;
    cursor: pointer;
}
.rl-del:hover { background: #fdf1f1; }
.rl-del:disabled { opacity: .5; }
.rl-empty { padding: 24px 0; text-align: center; color: var(--muted); font-size: 13px; }
.rl-foot { display: flex; gap: 8px; margin-top: 14px; }
.rl-foot input { flex: 1; min-width: 0; }
.rl-foot .btn-primary { flex-shrink: 0; padding: 12px 18px; }
.rl-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }

/* ---------- Toast ---------- */
#toast {
    position: fixed;
    left: 50%;
    bottom: calc(36px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(20px);
    background: rgba(31, 36, 48, .92);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 99;
    max-width: 86vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 桌面端增强（≥640px 才生效） ---------- */
@media (min-width: 640px) {
    .wrap { padding: 16px 20px 56px; }
    .nav-grid { grid-template-columns: repeat(3, 1fr); }
    .nav-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(31,36,48,.08); }
    .checkin-box { flex-direction: row; align-items: stretch; }
    .checkin-box input { flex: 1; }
    .checkin-box .btn-primary { flex-shrink: 0; min-width: 120px; }
    .seat-grid { grid-template-columns: repeat(8, 1fr); }
    .new-session { flex-direction: row; }
    .new-session input { flex: 1; }
    .new-session .btn-primary { flex-shrink: 0; }
}
