/* =========================================================================
 * 8F 班主任 AI 工作台 — 样式
 * 视觉基调：专业 / 温和 / 克制（参考 Notion · Linear · Apple）
 * 不用渐变色、不用荧光色、不用游戏化元素
 * ========================================================================= */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --card-2: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d5d8de;
  --text: #1c2027;
  --text-2: #4b5563;
  --muted: #8a9099;
  --accent: #3b5bdb;
  --accent-soft: #eef1fd;
  --ok: #2f8f66;
  --ok-soft: #eaf5f0;
  --warn: #b8860b;
  --warn-soft: #fdf6e7;
  --attn: #b4552f;
  --attn-soft: #fbeee8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .12);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

/* ------------------------------ 布局 ------------------------------ */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; white-space: nowrap; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; letter-spacing: .5px;
}
.nav { display: flex; gap: 2px; margin-left: 6px; }
.nav button {
  padding: 6px 12px; border-radius: var(--radius-sm); color: var(--text-2);
  font-size: 14.5px; font-weight: 500; transition: background .15s, color .15s;
}
.nav button:hover { background: #f1f2f5; color: var(--text); }
.nav button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar .spacer { flex: 1; }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: #f2f3f6; border: 1px solid transparent; border-radius: 999px;
  padding: 6px 14px; min-width: 240px; transition: border-color .15s, background .15s;
}
.searchbox:focus-within { background: #fff; border-color: var(--border-strong); }
.searchbox input { border: none; background: none; outline: none; width: 100%; font-size: 14px; }
.searchbox .ico { color: var(--muted); flex: none; display: grid; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 20px 40px; }

.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.page-head .spacer { flex: 1; }

/* ------------------------------ 通用元件 ------------------------------ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15.5px; }
.card-head .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  font-size: 14px; font-weight: 500; transition: background .14s, border-color .14s, opacity .14s;
  white-space: nowrap;
}
.btn:hover { background: #f6f7f9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3350c7; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #f1f2f5; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--attn); border-color: #edd7cd; }
.btn.danger:hover { background: var(--attn-soft); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12.5px;
  background: #f1f2f5; color: var(--text-2); border: 1px solid transparent;
}
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.clickable { cursor: pointer; }
.tag.clickable:hover { border-color: var(--border-strong); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: 999px;
}
.pill.stable { background: var(--ok-soft); color: var(--ok); }
.pill.watch { background: var(--warn-soft); color: var(--warn); }
.pill.todo { background: var(--attn-soft); color: var(--attn); }
.pill .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.hr { height: 1px; background: var(--border); margin: 14px 0; }
.empty { color: var(--muted); text-align: center; padding: 34px 16px; font-size: 14px; }

.note {
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 12.8px; color: var(--text-2); line-height: 1.65;
}

/* ------------------------------ 大输入框（今日随手记） ------------------------------ */
.quick { position: relative; }
.quick textarea {
  width: 100%; min-height: 132px; resize: vertical;
  padding: 18px 18px 56px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: #fff;
  font-size: 16px; line-height: 1.75; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.quick textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick textarea::placeholder { color: #a7adb6; }
.quick .actions {
  position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; align-items: center;
}
.quick-hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ------------------------------ 学生卡片 ------------------------------ */
.students { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.scard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 15px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.scard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.scard .top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.scard .nm { font-weight: 600; font-size: 15.5px; }
.scard .top .spacer { flex: 1; }
.scard .meta { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.scard .meta b { color: var(--text); font-weight: 600; font-size: 14px; }
.scard .spark { height: 30px; margin-top: 8px; }

/* ------------------------------ 时间线 ------------------------------ */
.tl { position: relative; }
.tl-week { margin-top: 20px; }
.tl-week-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.tl-week-head .line { flex: 1; height: 1px; background: var(--border); }
.rec {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 12px 15px; margin-bottom: 9px;
}
.rec.pending { border-left-color: var(--attn); }
.rec .rhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.rec .rdate { font-size: 12.5px; color: var(--muted); }
.rec .rtext { font-size: 14.5px; line-height: 1.7; }
.rec .raw {
  margin-top: 8px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--card-2); border: 1px dashed var(--border-strong);
  font-size: 13px; color: var(--text-2); line-height: 1.7;
}
.rec .racts { margin-top: 8px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* ------------------------------ 抽屉 / 弹层 ------------------------------ */
.mask {
  position: fixed; inset: 0; background: rgba(17, 20, 26, .38);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99) } to { opacity: 1; transform: none } }
.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .18s ease;
}
.modal.wide { max-width: 860px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { font-size: 16px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px 20px; overflow: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.modal-foot .spacer { flex: 1; }

.sheet { align-items: flex-end; padding: 0; }
.sheet .modal { max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
input[type=text], input[type=date], input[type=number], select, textarea.inp {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff; outline: none; font-size: 14.5px;
}
input:focus, select:focus, textarea.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.inp { resize: vertical; line-height: 1.7; }

/* ------------------------------ 语音 ------------------------------ */
.mic-fab {
  position: fixed; right: 20px; bottom: 22px; z-index: 60;
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--accent); color: #fff; box-shadow: 0 8px 22px rgba(59, 91, 219, .34);
  display: grid; place-items: center; transition: transform .15s, background .15s;
}
.mic-fab:hover { transform: scale(1.05); }
.mic-fab.rec { background: #c0392b; animation: pulse 1.5s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .45) }
  70% { box-shadow: 0 0 0 18px rgba(192, 57, 43, 0) }
  100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0) }
}
.mic-big {
  width: 108px; height: 108px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; margin: 8px auto 4px; transition: transform .15s;
}
.mic-big.rec { background: #c0392b; animation: pulse 1.5s infinite; }
.mic-big:hover { transform: scale(1.03); }
.wave { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 34px; margin: 10px 0 4px; }
.wave i { width: 4px; background: var(--accent); border-radius: 2px; height: 6px; transition: height .1s; opacity: .75; }

/* ------------------------------ 图表 ------------------------------ */
.chart { width: 100%; height: 320px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ------------------------------ 一图流 ------------------------------ */
.onepager {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 26px 28px;
  max-width: 660px;
}
.onepager h2 { font-size: 21px; margin-bottom: 2px; }
.onepager .opsub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.op-block { margin-bottom: 16px; }
.op-block h4 { font-size: 13px; color: var(--accent); letter-spacing: .04em; margin-bottom: 7px; }
.op-list { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.85; }
.op-quote {
  border-left: 3px solid var(--accent); background: var(--card-2);
  padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; color: var(--text-2); line-height: 1.8;
}

/* ------------------------------ 输出正文 ------------------------------ */
.prose { font-size: 15px; line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
.prose h1 { font-size: 18px; margin: 0 0 10px; }
.prose strong { font-weight: 650; }

/* ------------------------------ 分析结果 ------------------------------ */
.analysis h4 {
  font-size: 13.5px; color: var(--accent); margin: 16px 0 7px;
  letter-spacing: .03em; text-transform: none;
}
.analysis h4:first-child { margin-top: 0; }
.analysis p { margin: 0; font-size: 14.5px; line-height: 1.85; }
.analysis ul { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.85; }
.analysis li { margin-bottom: 4px; }
.ev { font-size: 13.5px; color: var(--text-2); border-left: 2px solid var(--border-strong); padding-left: 10px; margin-bottom: 7px; line-height: 1.7; }
.ev b { color: var(--accent); font-weight: 600; }

/* ------------------------------ 表格 ------------------------------ */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.tbl th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
table.tbl td.num { font-variant-numeric: tabular-nums; }

/* ------------------------------ 状态条 / 提示 ------------------------------ */
.banner {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px;
}
.banner.off { background: var(--warn-soft); color: #8a6100; border: 1px solid #f0e2c0; }
.banner.err { background: var(--attn-soft); color: var(--attn); border: 1px solid #f0d5c8; }
.banner.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #d3ece0; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #1c2027; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 200; box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
  animation: pop .18s ease;
}
.spinner {
  width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
.spinner.dark { border-color: rgba(28, 32, 39, .18); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg) } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 26px 0; justify-content: center; }

/* ------------------------------ 底部导航（手机） ------------------------------ */
.tabbar { display: none; }

/* ------------------------------ 移动端 ------------------------------ */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .nav, .searchbox { display: none; }
  .topbar-in { height: 52px; padding: 0 14px; gap: 10px; }
  .brand { font-size: 15px; }
  main { padding: 14px 14px 96px; }
  .page-head h1 { font-size: 19px; }
  .students { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .scard { padding: 12px 12px; }
  .scard .meta { gap: 10px; }
  .chart { height: 260px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 4px 0 max(4px, env(safe-area-inset-bottom));
  }
  .tabbar button {
    flex: 1; padding: 7px 0 5px; display: grid; justify-items: center; gap: 2px;
    color: var(--muted); font-size: 11px;
  }
  .tabbar button.on { color: var(--accent); }
  .mic-fab { bottom: 74px; }
  .modal { max-height: 92vh; }
  .onepager { padding: 20px 18px; }
}

@media (min-width: 761px) {
  .mobile-only { display: none !important; }
}
@media (max-width: 760px) {
  .desktop-only { display: none !important; }
}

/* 打印（用于一图流 → 另存为 PDF） */
@media print {
  .topbar, .tabbar, .mic-fab, .no-print, .card-head .btn { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; }
  .onepager { border: none; max-width: none; }
}
