/* ============================================================
   作业核对系统 · 响应式样式表
   设计原则：
   1. 移动优先，用 min-width 断点逐级增强（480 / 768 / 1024 / 1440）
   2. 字号全部使用 rem，跟随 html 的 font-size（学生端「显示设置」可整体调大调小）
   3. 高度用 dvh，适配手机浏览器地址栏收起/展开，避免「底部被顶掉」
   4. 输入框字号 >= 16px，避免 iOS Safari 聚焦时自动放大页面
   5. 触控目标 >= 44px，手机上不误触
   6. 弹窗在手机上从底部弹出（bottom sheet），电脑上居中卡片
   7. 表格在窄屏横向滚动并可滑动，宽屏自适应铺开
   ============================================================ */

/* ---------- 主题变量（保持原有配色） ---------- */
:root {
  --green: #2f8f63; --green-d: #256e4d; --green-l: #e9f5ee;
  --blue: #2f6fb5; --blue-l: #eaf2fb;
  --orange: #d98b28; --orange-l: #fdf3e4;
  --red: #cf4b45; --red-l: #fceceb;
  --bg: #f4f6f5; --card: #fff; --text: #243029; --muted: #8b968f;
  --border: #e3e8e5; --radius: 14px;
  --dark: #1f2d26;
  --shadow-1: 0 1px 2px rgba(24, 40, 32, .05);
  --shadow-2: 0 6px 20px rgba(24, 40, 32, .10);
  --shadow-3: 0 18px 50px rgba(24, 40, 32, .20);
  --gap: .625rem;
  /* 内容区最大宽度：不同端下由断点覆盖 */
  --shell-max: 100%;
  --side-w: 216px;
}

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

html {
  font-size: 16px;                     /* 基准；「显示设置」通过 .fs-s/.fs-l 调整 */
  -webkit-text-size-adjust: 100%;      /* 防止 iOS 横屏自动放大文字（跨端显示不一致的常见原因） */
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html.fs-s { font-size: 14.5px; }
html.fs-l { font-size: 18px; }
html.fs-xl { font-size: 20.5px; }
@media (max-width: 480px) { html { font-size: 15.5px; } html.fs-l { font-size: 17.5px; } }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 1rem; line-height: 1.65;
  overflow-wrap: break-word; word-break: break-word;
  min-height: 100dvh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg, table { max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.hide { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; margin-bottom: .875rem;
  box-shadow: var(--shadow-1);
}
.card > h3 {
  font-size: 1rem; margin-bottom: .75rem; display: flex; align-items: center;
  gap: .5rem; flex-wrap: wrap; line-height: 1.45;
}
.card > h3 .sp { margin-left: auto; font-weight: 400; font-size: .78rem; color: var(--muted); }
.card > h3 + .muted { margin-top: -.25rem; }
.subcard { background: #fbfcfb; border: 1px solid var(--border); border-radius: 12px; padding: .75rem; margin-bottom: .75rem; box-shadow: none; }

.input {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--border);
  border-radius: 10px; background: #fbfcfa; outline: none; margin-bottom: .625rem;
  min-height: 44px; transition: border-color .15s, background .15s;
  max-width: 100%;
}
.input:focus { border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(47, 143, 99, .12); }
.input:disabled { background: #f1f3f2; color: var(--muted); }
textarea.input { min-height: 120px; line-height: 1.75; resize: vertical; }
select.input { cursor: pointer; }
.input.sm { padding: .4rem .55rem; min-height: 38px; font-size: .86rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  border: none; border-radius: 10px; padding: .75rem 1.1rem; background: var(--green);
  color: #fff; cursor: pointer; transition: transform .1s, opacity .15s, background .15s;
  font-size: .95rem; min-height: 44px; line-height: 1.2; text-align: center;
  -webkit-user-select: none; user-select: none;
}
.btn:hover { background: var(--green-d); }
.btn:active { transform: scale(.975); }
.btn.block { width: 100%; }
.btn.blue { background: var(--blue); } .btn.blue:hover { background: #285f9c; }
.btn.orange { background: var(--orange); } .btn.orange:hover { background: #c07a1f; }
.btn.red { background: var(--red); } .btn.red:hover { background: #b8423c; }
.btn.gray { background: #93a09a; } .btn.gray:hover { background: #7f8d86; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f5f8f6; border-color: #cfd8d3; }
.btn.sm { padding: .4rem .7rem; font-size: .82rem; border-radius: 8px; min-height: 34px; }
.btn.xs { padding: .25rem .5rem; font-size: .75rem; border-radius: 7px; min-height: 28px; }
.btn:disabled { background: #c7cfcb; cursor: not-allowed; transform: none; }
.btn.wide { padding-left: 1.4rem; padding-right: 1.4rem; }

.row { display: flex; gap: var(--gap); flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; min-width: 0; }
.row.tight { gap: .375rem; }
.row.nowrap { flex-wrap: nowrap; }

.badge { display: inline-block; padding: .12rem .55rem; border-radius: 20px; font-size: .72rem; background: var(--green-l); color: var(--green); line-height: 1.6; white-space: nowrap; }
.badge.off { background: var(--red-l); color: var(--red); }
.badge.blue { background: var(--blue-l); color: var(--blue); }
.badge.orange { background: var(--orange-l); color: var(--orange); }
.badge.gray { background: #eef1ef; color: var(--muted); }
.badge.dark { background: #2a3a32; color: #dff0e5; }
.muted { color: var(--muted); font-size: .84rem; line-height: 1.7; }
.mono { font-family: ui-monospace, Consolas, Menlo, monospace; font-size: .78rem; word-break: break-all; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.mt { margin-top: .75rem; } .mb { margin-bottom: .75rem; }
.divider { height: 1px; background: var(--border); margin: .75rem 0; }
.stack > * + * { margin-top: .5rem; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #ccd5d0; border-radius: 26px; transition: .2s; }
.slider:before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
input:checked + .slider { background: var(--green); }
input:checked + .slider:before { transform: translateX(20px); }

.frow { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.frow:last-child { border-bottom: none; }
.frow > span:first-child { font-size: .93rem; }
.frow.wrap { flex-wrap: wrap; }
.frow-tight { padding: .45rem 0; }

/* ---------- 表格 ---------- */
.tbl-wrap {
  overflow: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: 10px;
  max-height: 70vh; background: #fff;
}
.tbl-wrap.flat { max-height: none; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: .55rem .55rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; background: #f7faf8; position: sticky; top: 0; z-index: 2; white-space: nowrap; }
tbody tr:hover td { background: #fbfcfb; }
td.wrap, th.wrap { word-break: break-word; min-width: 8rem; }
td.actions { white-space: nowrap; }
.scroll-hint { display: none; font-size: .74rem; color: var(--muted); text-align: center; padding: .3rem 0 0; }
.scroll-hint.on { display: block; }

.empty { text-align: center; color: var(--muted); font-size: .86rem; padding: 1.8rem 1rem; }
.empty .ic { font-size: 1.8rem; display: block; margin-bottom: .4rem; opacity: .8; }

/* ---------- 提示 / 弹窗 ---------- */
.toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 14px); left: 50%;
  transform: translateX(-50%); background: rgba(30, 42, 35, .95); color: #fff;
  padding: .7rem 1.2rem; border-radius: 24px; font-size: .88rem; z-index: 999;
  max-width: min(92vw, 480px); text-align: center; box-shadow: var(--shadow-2);
  backdrop-filter: blur(6px); animation: toastIn .18s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.mask {
  position: fixed; inset: 0; background: rgba(20, 30, 25, .5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
  padding: 0; animation: fadeIn .15s ease-out; backdrop-filter: blur(2px);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 18px 18px 0 0; width: 100%; max-width: none;
  max-height: 92dvh; overflow: auto; padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-3); animation: sheetIn .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 4px; background: #dfe5e2; margin: -.55rem auto .75rem; }
.modal h3 { margin-bottom: .875rem; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.modal h3 .sp { margin-left: auto; font-weight: 400; font-size: .78rem; color: var(--muted); }
.modal.wide { }
.grid { display: grid; gap: var(--gap); }

/* ---------- 登录 ---------- */
.auth-wrap { max-width: 420px; margin: 0 auto; padding: clamp(1.5rem, 6vh, 3rem) 1rem 3rem; }
.auth-head { text-align: center; margin-bottom: 1.4rem; }
.auth-head .logo { font-size: 2.6rem; line-height: 1; }
.auth-head h1 { font-size: 1.45rem; margin: .4rem 0 .25rem; color: var(--green); }
.auth-head p { color: var(--muted); font-size: .84rem; }
.auth-tabs { display: flex; background: #e8edea; border-radius: 12px; padding: 4px; margin-bottom: 1rem; gap: 2px; }
.auth-tabs div { flex: 1; text-align: center; padding: .6rem .2rem; font-size: .88rem; border-radius: 9px; cursor: pointer; color: var(--muted); transition: .15s; }
.auth-tabs div.on { background: #fff; color: var(--green); font-weight: 600; box-shadow: var(--shadow-1); }

/* ---------- 学生端外壳 ---------- */
.shell { display: flex; flex-direction: column; min-height: 100dvh; }
.app { width: 100%; max-width: var(--shell-max); margin: 0 auto; padding: 0 .875rem calc(5.5rem + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: .75rem 0 .5rem; display: flex; align-items: center; gap: .625rem; }
.topbar .brand { font-weight: 700; color: var(--green); font-size: 1.05rem; }
.topbar .who { margin-left: auto; font-size: .78rem; color: var(--muted); }
.topbar .icbtn { margin-left: .25rem; }

/* 底部导航（手机） */
.navbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.navbar .ni {
  flex: 1; text-align: center; padding: .5rem .1rem .45rem; font-size: .68rem;
  color: var(--muted); cursor: pointer; min-width: 0; position: relative;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.navbar .ni.on { color: var(--green); font-weight: 600; }
.navbar .ni.on::after { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 26px; height: 2.5px; border-radius: 0 0 3px 3px; background: var(--green); }
.navbar .ni .ic { font-size: 1.2rem; display: block; line-height: 1.35; }
.navbar .navbrand, .navbar .navwho { display: none; }
.navitems { display: flex; flex: 1; width: 100%; min-width: 0; }

/* 答案页 / 工具格 ---------- */
.pages { grid-template-columns: repeat(auto-fill, minmax(3.6rem, 1fr)); gap: .5rem; }
.pbtn {
  padding: .8rem 0; text-align: center; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; font-size: .9rem; cursor: pointer; position: relative;
  min-height: 44px; display: flex; align-items: center; justify-content: center;
  transition: transform .1s, background .15s, border-color .15s;
}
.pbtn.has { background: var(--green-l); border-color: #bfe3ce; color: var(--green-d); font-weight: 600; }
.pbtn.done::after { content: "✓"; position: absolute; top: 2px; right: 5px; font-size: .62rem; color: var(--green); }
.pbtn:active { transform: scale(.95); }
.pbtn.cur { border-color: var(--green); box-shadow: 0 0 0 2px rgba(47,143,99,.18); }

.answer-img { width: 100%; height: auto; border-radius: 10px; display: block; background: #f2f4f3; max-height: 76dvh; object-fit: contain; }
.pre-txt { white-space: pre-wrap; background: #f8faf9; border-radius: 10px; padding: .875rem; font-size: .9rem; line-height: 1.9; font-family: inherit; word-break: break-word; }

.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .35rem; margin-bottom: .75rem; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: .42rem .875rem; border-radius: 20px; background: #fff; border: 1px solid var(--border); font-size: .84rem; white-space: nowrap; cursor: pointer; min-height: 36px; display: inline-flex; align-items: center; transition: .15s; }
.chip.on { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; }

.usage-bar { height: 8px; background: #e8edea; border-radius: 6px; overflow: hidden; margin-top: .375rem; }
.usage-bar i { display: block; height: 100%; background: var(--green); border-radius: 6px; transition: width .3s; }
.usage-bar i.warn { background: var(--orange); }
.usage-bar i.full { background: var(--red); }

.prog { height: 9px; background: #e8edea; border-radius: 6px; overflow: hidden; margin: .3rem 0; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #4fb583); border-radius: 6px; transition: width .4s; }
.prog-thin { height: 6px; }

/* AI 对话 */
.chat-box { max-height: 52dvh; overflow: auto; padding: .25rem 0; -webkit-overflow-scrolling: touch; }
.msg { margin-bottom: .75rem; display: flex; }
.msg .bubble { max-width: 86%; padding: .65rem .85rem; border-radius: 14px; font-size: .9rem; white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.ai .bubble b { color: var(--green-d); }
.qa-chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; scrollbar-width: none; }
.qa-chips::-webkit-scrollbar { display: none; }
.qa-chip { padding: .35rem .7rem; border-radius: 16px; background: var(--blue-l); color: var(--blue); font-size: .78rem; white-space: nowrap; cursor: pointer; border: 1px solid transparent; min-height: 32px; display: inline-flex; align-items: center; }
.qa-chip:hover { border-color: var(--blue); }

.tools-grid { grid-template-columns: repeat(2, 1fr); gap: .625rem; }
.tool-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem .625rem; text-align: center; cursor: pointer; transition: transform .12s, border-color .15s; min-height: 44px; }
.tool-card:hover { border-color: var(--green); }
.tool-card:active { transform: scale(.97); }
.tool-card .ic { font-size: 1.5rem; display: block; margin-bottom: .25rem; }
.tool-card b { display: block; font-size: .92rem; margin-bottom: .15rem; }

.calc-screen { background: var(--dark); color: #dff0e5; padding: .875rem; border-radius: 10px; font-size: 1.35rem; text-align: right; min-height: 3.6rem; word-break: break-all; }
.calc-grid { grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.calc-grid button { padding: .8rem 0; font-size: 1.05rem; border: 1px solid var(--border); background: #fff; border-radius: 10px; cursor: pointer; min-height: 48px; }
.calc-grid button:active { background: var(--green-l); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: .7rem .4rem; text-align: center; }
.stat-card b { display: block; font-size: 1.25rem; color: var(--green); line-height: 1.3; }
.stat-card span { font-size: .74rem; color: var(--muted); }
.stat-row { display: flex; gap: .5rem; text-align: center; }
.stat-row > div { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: .75rem .25rem; }
.stat-row b { display: block; font-size: 1.15rem; color: var(--green); }

/* 任务 / 公告 / 留言 */
.list-item { display: flex; gap: .625rem; align-items: flex-start; padding: .75rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.list-item + .list-item { margin-top: .5rem; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: .93rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.list-item .li-meta { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.list-item.done { opacity: .62; }
.list-item .li-side { flex: none; display: flex; flex-direction: column; gap: .35rem; align-items: flex-end; }
.notice-item { border-left: 4px solid var(--blue); background: var(--blue-l); border-radius: 8px; padding: .6rem .75rem; }
.notice-item.warn { border-color: var(--orange); background: var(--orange-l); }
.notice-item.success { border-color: var(--green); background: var(--green-l); }
.notice-item + .notice-item { margin-top: .5rem; }
.notice-item .nt { font-weight: 600; font-size: .9rem; margin-bottom: .15rem; display: flex; align-items: center; gap: .35rem; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; background: var(--green-l); color: var(--green); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .82rem; flex: none; }

/* ---------- 管理端 ---------- */
.admin { display: flex; min-height: 100dvh; background: #eef1ef; }
.side {
  width: var(--side-w); background: var(--dark); color: #cfe0d6; flex: none;
  display: flex; flex-direction: column; z-index: 60;
}
.side .logo { padding: 1.1rem 1.1rem .85rem; font-size: 1rem; color: #fff; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08); }
.side .logo small { display: block; font-weight: 400; font-size: .7rem; color: #8fae9e; margin-top: .15rem; }
.side nav { padding: .6rem .5rem; flex: 1; overflow-y: auto; }
.side nav .grp { font-size: .68rem; color: #7d9a8c; padding: .5rem .75rem .25rem; letter-spacing: .04em; }
.side nav a { display: flex; align-items: center; gap: .55rem; padding: .6rem .75rem; border-radius: 9px; color: #cfe0d6; font-size: .88rem; cursor: pointer; margin-bottom: 2px; transition: .15s; }
.side nav a:hover { background: rgba(255,255,255,.07); }
.side nav a.on { background: var(--green); color: #fff; font-weight: 600; }
.side nav a .dot { margin-left: auto; }
.side .foot { padding: .75rem; font-size: .72rem; color: #7d9a8c; border-top: 1px solid rgba(255,255,255,.08); }
.side-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,25,20,.45); z-index: 55; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-top {
  background: #fff; border-bottom: 1px solid var(--border); padding: .8rem 1.25rem;
  display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 40;
}
.admin-top h2 { font-size: 1.05rem; }
.admin-top .right { margin-left: auto; display: flex; align-items: center; gap: .625rem; font-size: .8rem; color: var(--muted); }
.burger { display: none; background: none; border: 1px solid var(--border); border-radius: 9px; width: 40px; height: 40px; font-size: 1.15rem; cursor: pointer; flex: none; }
.admin-body { padding: 1.1rem 1.25rem 3rem; overflow: auto; flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: .625rem; margin-bottom: 1rem; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: .8rem .875rem; box-shadow: var(--shadow-1); }
.kpi .t { font-size: .76rem; color: var(--muted); }
.kpi .v { font-size: 1.4rem; font-weight: 700; color: var(--green); margin-top: .1rem; line-height: 1.25; }
.kpi .s { font-size: .72rem; color: var(--muted); margin-top: .1rem; }
.kpi.blue .v { color: var(--blue); } .kpi.orange .v { color: var(--orange); } .kpi.red .v { color: var(--red); }

.bars { display: flex; align-items: flex-end; gap: .4rem; height: 8rem; padding-top: .5rem; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .25rem; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .b i { width: 100%; max-width: 2.2rem; background: var(--green); border-radius: 5px 5px 0 0; min-height: 2px; }
.bars .b span { font-size: .66rem; color: var(--muted); white-space: nowrap; }
.bars .b em { font-size: .62rem; color: var(--muted); font-style: normal; }

.uploader { border: 2px dashed #cbd8d1; border-radius: 12px; padding: 1.4rem 1rem; text-align: center; cursor: pointer; background: #fbfcfa; transition: .15s; }
.uploader:hover { border-color: var(--green); background: var(--green-l); }
.thumb { position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #f6f8f7; }
.thumb img { width: 100%; height: 7.5rem; object-fit: cover; display: block; }
.thumb .pg { font-size: .74rem; padding: .3rem; text-align: center; background: #fff; }
.thumb .del { position: absolute; top: .25rem; right: .25rem; background: rgba(0,0,0,.62); color: #fff; border: none; border-radius: 6px; font-size: .7rem; padding: .15rem .45rem; cursor: pointer; }
.thumbs { grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: .625rem; }
.device-item { display: flex; align-items: center; justify-content: space-between; gap: .625rem; background: #f8faf9; border: 1px solid var(--border); border-radius: 9px; padding: .55rem .7rem; margin-bottom: .35rem; }
.model-row { background: var(--blue-l); border: 1px solid var(--border); border-radius: 12px; padding: .75rem; margin-bottom: .625rem; }
.model-row .mhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; gap: .5rem; }
.model-row .mhead b { font-size: .9rem; }
.model-row .macts { display: flex; gap: .25rem; flex: none; }
.ai-hint { background: var(--blue-l); border: 1px solid var(--border); border-radius: 10px; padding: .55rem .7rem; margin-bottom: .625rem; font-size: .84rem; line-height: 1.7; }
.seg { display: inline-flex; background: #e8edea; border-radius: 10px; padding: 3px; gap: 2px; }
.seg div { padding: .4rem .8rem; border-radius: 8px; font-size: .84rem; cursor: pointer; color: var(--muted); }
.seg div.on { background: #fff; color: var(--green); font-weight: 600; box-shadow: var(--shadow-1); }
.kv { display: flex; justify-content: space-between; gap: .75rem; padding: .35rem 0; font-size: .84rem; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: none; }
.kv b { font-weight: 600; }
.danger-zone { border: 1px solid #f0cfcd; background: var(--red-l); border-radius: 12px; padding: .875rem; }
.ok-zone { border: 1px solid #cfe7dc; background: var(--green-l); border-radius: 12px; padding: .875rem; }

/* ============================================================
   响应式断点
   ============================================================ */

/* ---------- ≥ 600px：手机横屏 / 小平板 ---------- */
@media (min-width: 600px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .tools-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .pages { grid-template-columns: repeat(auto-fill, minmax(3.8rem, 1fr)); }
  .modal {
    border-radius: 18px; max-width: 560px; max-height: 88dvh;
    padding: 1.4rem 1.4rem 1.4rem;
  }
  .mask { align-items: center; padding: 1rem; }
  .modal::before { display: none; }
  @keyframes sheetIn { from { transform: scale(.96); opacity: .5; } to { transform: none; opacity: 1; } }
}

/* ---------- ≥ 768px：平板 / 电脑 ---------- */
@media (min-width: 768px) {
  :root { --shell-max: 720px; }
  /* 底部导航 → 顶部导航 */
  .topbar { display: none; }
  .shell { display: block; }
  .navbar {
    position: sticky; top: 0; bottom: auto; left: auto; right: auto;
    border-top: none; border-bottom: 1px solid var(--border);
    align-items: center; gap: .75rem; padding: .5rem 1.25rem 0;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
    flex-wrap: wrap;
  }
  .navbar .navbrand {
    display: block; font-weight: 700; color: var(--green); font-size: 1rem;
    flex: none; padding-bottom: .5rem;
  }
  .navbar .navwho { display: block; margin-left: auto; font-size: .8rem; color: var(--muted); padding-bottom: .5rem; }
  .navitems { flex: 1; justify-content: center; gap: .25rem; }
  .navbar .ni {
    flex: 0 1 auto; padding: .55rem .9rem .65rem; font-size: .88rem;
    display: inline-flex; align-items: center; gap: .35rem; border-radius: 10px 10px 0 0;
    min-height: 44px;
  }
  .navbar .ni .ic { font-size: 1rem; display: inline; }
  .navbar .ni.on::after { left: .9rem; right: .9rem; transform: none; width: auto; height: 3px; }
  .navbar .ni:hover { background: var(--green-l); }
  .app { padding-bottom: 3rem; }
  .chat-box { max-height: 46dvh; }
  .answer-img { max-height: 82dvh; }
  .pages { grid-template-columns: repeat(auto-fill, minmax(4.2rem, 1fr)); }
  .admin-body { padding: 1.25rem 1.5rem 3rem; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
}

/* ---------- ≥ 1024px：桌面较宽 ---------- */
@media (min-width: 1024px) {
  :root { --shell-max: 940px; }
  .tools-grid { grid-template-columns: repeat(4, 1fr); }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); }
  .chat-box { max-height: 52dvh; }
  .modal { max-width: 640px; }
  .kpi .v { font-size: 1.55rem; }
}

/* ---------- ≥ 1440px：大屏 ---------- */
@media (min-width: 1440px) {
  :root { --shell-max: 1100px; }
  .app { padding-left: 1.5rem; padding-right: 1.5rem; }
  .modal { max-width: 720px; }
  .admin-body { padding: 1.5rem 2rem 3.5rem; }
}

/* ---------- 窄屏手机（< 400px） ---------- */
@media (max-width: 400px) {
  .navbar .ni { font-size: .62rem; padding-left: 0; padding-right: 0; }
  .navbar .ni .ic { font-size: 1.1rem; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
  .kpis { grid-template-columns: 1fr; }
  .thumb img { height: 6.5rem; }
  .modal { padding-left: .875rem; padding-right: .875rem; }
}

/* ---------- 管理端：< 900px 侧栏改抽屉 ---------- */
@media (max-width: 899px) {
  .admin { flex-direction: column; }
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(78vw, 270px);
    transform: translateX(-102%); transition: transform .25s ease;
    box-shadow: var(--shadow-3); overflow-y: auto;
  }
  .side.open { transform: none; }
  .side nav a { padding: .7rem .8rem; font-size: .92rem; }
  .side-backdrop.on { display: block; }
  .burger { display: inline-flex; align-items: center; justify-content: center; }
  .admin-top { padding: .6rem .875rem; }
  .admin-top .right { font-size: .74rem; }
  .admin-body { padding: .875rem .875rem 2.5rem; }
  .scroll-hint.on { display: block; }
}

/* ---------- 横屏手机：压缩高度占用 ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .chat-box { max-height: 60dvh; }
  .auth-wrap { padding-top: 1rem; }
}

/* ---------- 打印 ---------- */
@media print {
  .navbar, .side, .admin-top, .btn, .toast { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- AI 深度思考 / 模型选择（学生端） ---------- */
.ai-ctrl {
  background: #f7faf9; border: 1px solid var(--border); border-radius: 12px;
  padding: .6rem .75rem; margin: 10px 0 4px;
}
.ai-ctrl .row.tight { gap: .5rem; }
.ai-model { font-size: .76rem; margin-top: 4px; }
/* 思考过程折叠块：先思考、后答案 */
.think-box {
  border: 1px solid #d8e6df; background: var(--green-l);
  border-radius: 12px; margin-bottom: .5rem; overflow: hidden;
}
.think-head {
  display: flex; align-items: center; gap: .4rem; cursor: pointer;
  padding: .5rem .7rem; font-size: .84rem; font-weight: 600; color: var(--green-d);
  user-select: none;
}
.think-head .badge { margin-left: auto; font-weight: 400; cursor: pointer; }
.think-body {
  padding: 0 .7rem .7rem; font-size: .86rem; line-height: 1.75; color: #2c3a32;
  white-space: pre-wrap; word-break: break-word;
  border-top: 1px dashed #cfe0d6; margin: 0 .1rem; padding-top: .6rem;
}
.think-body.collapsed { display: none; }
