/* 物理课作业台 —— 样式 */

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e2e6ec;
  --line-soft: #f0f2f6;
  --text: #1e2732;
  --muted: #78859a;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eef3ff;
  --ok: #16a34a;
  --ok-soft: #e9f8ef;
  --warn: #d97706;
  --warn-soft: #fdf4e3;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---------------- 通用控件 ---------------- */

button, .btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  transition: .15s;
  line-height: 1.4;
}
button:hover, .btn:hover { border-color: #c4cdda; background: #f7f9fc; text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary, .btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.small { padding: 5px 10px; font-size: 13px; }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: #f3c4c4; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { background: #eef1f6; color: var(--text); }

input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], textarea, select {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 12.5px; }
.mono { font-family: ui-monospace, Consolas, monospace; }

/* ---------------- 布局 ---------------- */

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .inner {
  max-width: 1040px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: .4px; }
.brand .dot { color: var(--accent); }
.spacer { flex: 1; }
.userchip {
  display: flex; align-items: center; gap: 8px;
  background: var(--line-soft); border-radius: 99px; padding: 4px 6px 4px 12px; font-size: 13px;
}
.tag {
  display: inline-block; border-radius: 99px; padding: 1px 9px;
  font-size: 12px; font-weight: 600; line-height: 1.7; white-space: nowrap;
}
.tag.teacher { background: #ece9fe; color: #5b46d6; }
.tag.student { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.gray { background: #eef1f5; color: var(--muted); }

.nav {
  background: #fff; border-bottom: 1px solid var(--line);
}
.nav .inner {
  max-width: 1040px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 2px; overflow-x: auto;
}
.nav button {
  border: none; background: none; border-radius: 0; padding: 11px 14px;
  color: var(--muted); font-size: 14px; position: relative; white-space: nowrap;
}
.nav button:hover { background: none; color: var(--text); }
.nav button.active { color: var(--accent); font-weight: 600; }
.nav button.active::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: var(--accent);
}

.page { max-width: 1040px; margin: 0 auto; padding: 20px 16px 70px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card > h2 { font-size: 15px; margin: 0 0 12px; }
.card.tight { padding: 12px 14px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.stat .n { font-size: 23px; font-weight: 700; line-height: 1.25; }
.stat .l { color: var(--muted); font-size: 12.5px; }

.empty { text-align: center; color: var(--muted); padding: 34px 12px; font-size: 14px; }

/* ---------------- 表格 ---------------- */

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.actions { text-align: right; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* ---------------- 登录页 ---------------- */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { text-align: center; margin-bottom: 18px; }
.auth-card .logo .t { font-size: 21px; font-weight: 700; }
.auth-card .logo .s { color: var(--muted); font-size: 13px; margin-top: 4px; }
.seg { display: flex; background: #eef1f6; border-radius: 9px; padding: 3px; margin-bottom: 16px; }
.seg button { flex: 1; border: none; background: none; padding: 7px; border-radius: 7px; color: var(--muted); font-size: 14px; }
.seg button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(20, 30, 50, .1); }
.notice {
  background: var(--warn-soft); border: 1px solid #f2e0bd; color: #8a5a06;
  border-radius: 8px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; white-space: pre-wrap;
}

/* ---------------- 题目 ---------------- */

.qcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.qhead { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.qno { font-weight: 700; font-size: 15px; }
.qstem { white-space: pre-wrap; word-break: break-word; margin-bottom: 12px; }
.qstem.placeholder { color: var(--muted); font-style: italic; }

/* 上下标:line-height:0 防止把行高撑开 */
sub, sup { font-size: .72em; line-height: 0; }

/* ---------------- 课堂互动 ---------------- */

/* 互动题锁定后不要把对错颜色冲淡 */
.opt:disabled { opacity: 1; cursor: default; }

.live-card { border-color: #cddcff; background: linear-gradient(#f7faff, #fff); }
.live-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.countdown {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 34px; font-weight: 700; letter-spacing: 2px;
  color: var(--accent); line-height: 1.1;
}
.countdown.urgent { color: var(--danger); animation: pulse 1s infinite; }
.countdown.over { color: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.live-bar { width: 160px; height: 10px; background: #e8ecf3; border-radius: 99px; overflow: hidden; flex: none; }
.live-bar > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

img.mini {
  width: 46px; height: 46px; object-fit: cover;
  border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in; margin-right: 4px;
}

/* 编辑框下面的渲染预览:让人直接看到上下标效果,而不用去读标签 */
.preview {
  white-space: pre-wrap; word-break: break-word;
  background: #f7f9fc; border: 1px dashed var(--line); border-radius: 8px;
  padding: 8px 10px; margin: 6px 0 12px; font-size: 14px; color: #33415c;
}
.preview:empty { display: none; }

.attach { margin-bottom: 12px; }
.attach img {
  max-height: 300px; border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in; display: block;
}
.attach .doclink { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px; text-align: left; width: 100%;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 14.5px;
}
.opt .k {
  flex: none; width: 24px; height: 24px; border-radius: 50%; background: #eef1f6; color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.opt .v { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.opt.chosen { border-color: var(--accent); background: var(--accent-soft); }
.opt.chosen .k { background: var(--accent); color: #fff; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .k { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.opt.wrong .k { background: var(--danger); color: #fff; }

.dropzone {
  border: 2px dashed #cbd4e1; border-radius: 9px; padding: 16px; text-align: center;
  color: var(--muted); font-size: 13.5px; background: #fbfcfe; transition: .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.hot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 12px; }
.thumb { position: relative; width: 104px; }
.thumb img, .thumb .filebox {
  width: 104px; height: 104px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: #f7f9fc; display: block;
}
.thumb img { cursor: zoom-in; }
.thumb .filebox {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 6px; font-size: 11px; color: var(--muted); text-align: center; overflow: hidden;
}
.thumb .filebox .ic { font-size: 24px; }
.thumb .name {
  font-size: 11.5px; color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thumb .rm {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; padding: 0;
  border-radius: 50%; background: var(--danger); color: #fff; border: 2px solid #fff;
  font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.thumb .rm:hover { background: #b91c1c; }
.thumb .bar { height: 4px; background: #e8ecf3; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.thumb .bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

.verdict { border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-top: 12px; }
.verdict.ok { background: var(--ok-soft); color: #10683a; }
.verdict.bad { background: var(--danger-soft); color: #991b1b; }
.verdict.info { background: #f1f4f9; color: var(--muted); }
.verdict.score { background: var(--accent-soft); color: var(--accent-dark); }
.verdict b { font-size: 16px; }

/* ---------------- 弹层 ---------------- */

.overlay {
  position: fixed; inset: 0; background: rgba(20, 28, 40, .45);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 60;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow: auto; padding: 18px;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
  background: #1e2732; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 90; max-width: 92vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }

/* ---------------- 小屏 ---------------- */

@media (max-width: 640px) {
  .page { padding: 14px 12px 60px; }
  .card { padding: 14px; }
  .hide-sm { display: none !important; }
  table.tbl th, table.tbl td { padding: 8px 6px; }
  .brand { font-size: 15px; }
}
