/* ===== dingding_tool 设计系统 ===== */
:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --text: #1f2933;
  --text-muted: #6b7280;
  --border: #e8e4de;
  --primary: #f59e0b;
  --primary-soft: #fef3c7;
  --primary-fg: #7c4a03;
  --accent: #8b5cf6;
  --green: #10b981;
  --red: #ef4444;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 41, 51, 0.05), 0 4px 16px rgba(31, 41, 51, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f;
    --card: #1f1c16;
    --text: #f3f1ec;
    --text-muted: #a8a29a;
    --border: #34302a;
    --primary: #fbbf24;
    --primary-soft: #3a2f14;
    --primary-fg: #fcd34d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.container { max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; }

/* ===== 顶部栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 16px;
}
.topbar .title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }
.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card .muted { color: var(--text-muted); font-size: 13px; }

/* ===== 头像 ===== */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  flex: none;
}

/* ===== 徽标 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-fg);
}
.badge.green { background: #d1fae5; color: #065f46; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.gray { background: var(--border); color: var(--text-muted); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* ===== 列表 ===== */
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: none; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; }
.row .s { font-size: 13px; color: var(--text-muted); }

/* ===== 出题规范：按学科分组（左边框颜色由 admin.html 按学科注入） ===== */
.spec-intro {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-muted); margin: 2px 0 4px;
}
.spec-help summary, .spec-note summary { cursor: pointer; list-style: none; }
.spec-help summary::-webkit-details-marker, .spec-note summary::-webkit-details-marker { display: none; }
.spec-help summary { color: var(--primary-fg); border-bottom: 1px dashed currentColor; }
.spec-help p { margin: 6px 0 2px; font-size: 12.5px; line-height: 1.7; color: var(--text-muted); }
.spec-help p b { color: var(--text); }

.spec-group { margin-top: 12px; padding-left: 10px; border-left: 3px solid var(--border); }
.spec-group-head { display: flex; align-items: center; gap: 7px; }
.spec-group-head .muted { font-size: 12px; color: var(--text-muted); }

/* 难度说明：收起时只占一行，点开看全文 */
.spec-note { margin: 4px 0 1px; }
.spec-note summary {
  font-size: 12px; line-height: 1.6; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spec-note[open] summary { white-space: normal; }
.spec-note p { margin: 4px 0 0; font-size: 12px; line-height: 1.65; color: var(--text-muted); }
.spec-note p b { color: var(--text); }

/* 规范行：标题 + 右侧 meta + 知识点一行省略 */
.spec-row { padding: 7px 0; align-items: flex-start; gap: 8px; }
.spec-line1 { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.spec-line1 .t { font-weight: 600; font-size: 14px; }
.spec-line1 .meta { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.spec-line1 .tag {
  font-size: 11px; color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 6px; padding: 0 5px; line-height: 15px;
}
.spec-topic {
  font-size: 12.5px; color: var(--text-muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); padding: 5px 9px; font-size: 12.5px; font-weight: 500; }
.btn.ghost:hover { background: var(--bg); color: var(--text); }

/* ===== 出题规范选择块（新建任务表单 + 聊天草稿卡共用） ===== */
.pick-block {
  border-left: 3px solid var(--primary); background: var(--bg);
  border-radius: 0 10px 10px 0; padding: 8px 11px; margin-top: 8px;
}
.pick-head { display: flex; align-items: baseline; gap: 7px; margin-bottom: 6px; }
.pick-head .t { font-weight: 600; font-size: 13.5px; }
.pick-head .muted { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.pick-block select {
  width: 100%; padding: 7px 8px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text);
}
.pick-block .s { margin-top: 5px; font-size: 12.5px; line-height: 1.55; color: var(--text-muted); }

.spec-form { flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; padding-bottom: 0; }
.spec-form select, .spec-form input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; min-width: 0; }
.spec-form #ns-subject { flex: 1 1 76px; }
.spec-form #ns-base { flex: 1 1 92px; }
.spec-form #ns-grade { flex: 1 1 92px; }
.spec-form #ns-name, .spec-form #ns-topic { flex: 1 1 150px; }
.spec-form #ns-count { flex: 0 0 62px; width: 62px; }
.spec-form #ns-add { flex: 0 0 auto; }

/* ===== 错误卡 ===== */
.error-card {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 24px;
}

/* ===== 移动端 ===== */
@media (max-width: 480px) {
  .container { padding: 12px 12px 32px; }
  .btn { padding: 10px 14px; }
}

/* 图标通用 */
svg.icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ===== 分段控制 ===== */
/* 标签多于一屏时横向滚动（admin 有 8 个标签），而非把标签挤扁 */
.seg {
  display: flex; gap: 4px; background: var(--border); border-radius: 12px; padding: 4px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1 0 auto; white-space: nowrap; border: none; background: transparent; color: var(--text-muted);
  padding: 7px 10px; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* ===== 表单 ===== */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font-size: 14px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 60px; }
.field .row2 { display: flex; gap: 8px; }
.field .row2 > * { flex: 1; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 6px; }
.checkbox-row label {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 13px; cursor: pointer;
}
.checkbox-row label svg { width: 15px; height: 15px; }
.avatar svg { width: 22px; height: 22px; }
.badge svg { width: 14px; height: 14px; vertical-align: -2px; }
.checkbox-row label.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== 任务卡 ===== */
.task-card { display: flex; gap: 12px; align-items: flex-start; }
.task-card .grow { flex: 1; min-width: 0; }
.task-card .title { font-weight: 700; font-size: 16px; }
.task-card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; align-items: center; }
.task-card ul.dots { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-muted); }
.task-card .action { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

/* ===== 打卡按钮 ===== */
.check-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 12px;
  border: none; cursor: pointer; font-size: 14px; font-weight: 700; color: #fff;
}
.check-btn.do { background: var(--green); }
.check-btn.undo { background: var(--red); }
.check-btn.practice { background: #f59e0b; }

/* ===== 日历网格 ===== */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-head { display: contents; font-size: 12px; color: var(--text-muted); text-align: center; }
.cal-cell {
  border-radius: 8px; border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer; position: relative; background: var(--card);
  padding: 3px 1px 11px; min-height: 34px;
}
.cal-cell .d { font-weight: 600; line-height: 1.15; }
.cal-cell .p { font-size: 10px; color: var(--primary); font-weight: 700; line-height: 1.15; }
.cal-cell.empty { opacity: 0.35; }
.cal-cell.today { border-color: var(--primary); border-width: 2px; }
.cal-cell.sel { background: var(--primary-soft); }
.cal-cell .dot { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.cal-cell.all-done .dot { background: var(--green); }
.cal-cell .cnt { position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); font-size: 8px; color: var(--text-muted); font-weight: 600; line-height: 1; }

/* ===== Dashboard ===== */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.stat-item { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.stat-item .v { font-size: 16px; font-weight: 700; margin-top: 2px; }
.stat-item .l { font-size: 11px; color: var(--text-muted); }
.mini-track { height: 5px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.mini-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.chart { display: flex; gap: 3px; align-items: flex-end; height: 58px; margin-top: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart .col { flex: 0 0 24px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart .bar { width: 62%; background: var(--primary); border-radius: 3px; }
.chart .bar.zero { background: var(--border); min-height: 3px; }
.chart .bar.today { background: var(--red); }
.chart .lbl { font-size: 9px; color: var(--text-muted); margin-top: 3px; }
.type-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.type-bar .tn { width: 58px; font-size: 12px; flex: none; }
.type-bar .track { flex: 1; height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.type-bar .fill { height: 100%; border-radius: 999px; }
.type-bar .num { width: 42px; font-size: 11px; text-align: right; flex: none; color: var(--text-muted); }

/* ===== 流水 ===== */
.ledger-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.ledger-row:first-child { border-top: none; }
.ledger-row .delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.ledger-row .delta.pos { color: var(--green); }
.ledger-row .delta.neg { color: var(--red); }

/* ===== 按钮行 ===== */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-btn { color: var(--primary); background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 600; padding: 4px; }

/* ===== 聊天 ===== */
.chat-row { display: flex; flex-direction: column; margin-bottom: 10px; }
.chat-bubble { max-width: 88%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.55; word-break: break-word; }
.chat-bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.asst { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

/* ===== 游戏化 ===== */
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
.pop { animation: pop 0.4s ease; }
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.4s ease; }

/* ===== 特殊惊喜任务 ===== */
@keyframes glow { 0%,100% { box-shadow: 0 0 0 1px #f59e0b, 0 4px 16px rgba(245,158,11,0.25); } 50% { box-shadow: 0 0 0 2px #fbbf24, 0 4px 24px rgba(245,158,11,0.55); } }
.special-card { border-color: #f59e0b !important; animation: glow 1.6s ease-in-out infinite; }

/* ===== 成就徽章 ===== */
.ach-list { display: flex; flex-wrap: wrap; gap: 10px; }
.ach { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.ach .ico { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-fg); display: flex; align-items: center; justify-content: center; }

/* ===== 用户行布局（PC + 移动端一致：管理者多选独立一行）===== */
.user-row { flex-wrap: wrap; row-gap: 6px; }
.user-row .grow { flex: 1 1 200px; min-width: 200px; }
.user-row .checkbox-row { flex-basis: 100%; order: 9; }

/* ===== 移动端适配 ===== */
@media (max-width: 480px) {
  .user-row .grow { flex: 1 1 140px; min-width: 140px; }
  .user-row .link-btn { padding: 4px 6px; }
}

/* ===== 出题任务卡：答题弹窗 ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 480px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head .t { font-weight: 600; font-size: 16px; }
.modal-x { background: none; border: none; font-size: 24px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); }
.ex-item { margin-bottom: 16px; }
.ex-q { font-size: 15px; margin-bottom: 8px; line-height: 1.5; }
.ex-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 15px; box-sizing: border-box; }
.ex-result { margin-top: 8px; font-size: 14px; }
.ex-ok { color: #16a34a; font-weight: 600; }
.ex-no { color: #dc2626; font-weight: 600; }
.ex-ans { margin-top: 4px; }
.ex-exp { margin-top: 4px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.ex-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.ex-choice { padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text); font-size: 15px; cursor: pointer; }
.ex-choice.on { border-color: var(--accent, #3b82f6); background: rgba(59,130,246,0.12); font-weight: 600; }
.ex-loading { text-align: center; padding: 32px 0; color: var(--text-muted); font-size: 15px; }
.ex-summary { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; }
.ex-summary .warn { color: #dc2626; font-weight: 600; }
.ex-summary .good { color: #16a34a; font-weight: 600; }
.ex-fail { text-align: center; padding: 24px 0; }
.ex-fail .t { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.ex-fail .d { color: var(--text-muted); font-size: 13px; line-height: 1.6; }

/* ===== 聊天消息 markdown 渲染 ===== */
.chat-bubble.asst .md-ul, .chat-bubble.asst .md-ol { margin: 4px 0; padding-left: 18px; }
.chat-bubble.asst .md-ul { list-style: disc; }
.chat-bubble.asst .md-ol { list-style: decimal; }
.chat-bubble.asst li { margin: 2px 0; }
.chat-bubble.asst .md-br { height: 6px; }
.chat-bubble.asst strong { font-weight: 600; }
