/* ==========================================================
   教学日志智能登记台 · 暖米色 × 咖啡棕
   ========================================================== */
:root {
  --bg: #f3ecdd;
  --bg-deep: #ede4d0;
  --card: #fffdf8;
  --card-soft: #faf5ea;
  --line: #e9dfc9;
  --line-soft: #f0e8d6;
  --ink: #3c3225;
  --ink-2: #6f6350;
  --ink-3: #9c8f79;
  --brand: #a9702c;
  --brand-deep: #96621f;
  --brand-soft: #f3e7d2;
  --accent: #c88a3d;
  --danger: #c4574a;
  --danger-bg: #fbf0e9;
  --ok-bg: #e9f2e6;
  --ok: #5a8a52;
  --radius: 14px;
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --shadow: 0 2px 10px rgba(92, 68, 34, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: linear-gradient(160deg, #f6f0e2 0%, #f0e8d5 55%, #eadfc6 100%);
  color: var(--ink);
  font-size: 13.5px;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: var(--ink); outline: none; }
.serif { font-family: var(--serif); }

.app { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.app-topbar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(214,196,160,.4);
  background: linear-gradient(180deg, rgba(255,253,248,.35), rgba(250,245,234,.15));
}
.topbar-left { justify-self: start; min-width: 0; }
.topbar-center { justify-self: center; }
.topbar-right { justify-self: end; }

/* 顶栏按钮按视图显隐：栏体常驻，只有两侧按钮切换，杜绝整条栏闪烁 */
.tb-action { display: none !important; }
@keyframes tbFade { from { opacity: 0; } to { opacity: 1; } }
.app[data-view="chat"]      .tb-action[data-for~="chat"],
.app[data-view="table"]     .tb-action[data-for~="table"],
.app[data-view="timetable"] .tb-action[data-for~="timetable"] {
  display: inline-flex !important;
  animation: tbFade .28s ease;
}
.view-chat { display: flex; flex: 1; min-height: 0; }
.view-table[hidden], .view-chat[hidden] { display: none; }

/* ======================= 侧栏 ======================= */
.sidebar {
  width: 268px; flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 14px 12px 12px;
  gap: 4px;
  border-right: 1px solid rgba(214, 196, 160, .45);
  background: linear-gradient(180deg, rgba(255,253,248,.55), rgba(250,245,234,.35));
}
.sidebar-top { flex: 1; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }

.btn-new-chat {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  font-weight: 600; color: var(--ink); box-shadow: var(--shadow);
  transition: all .15s;
}
.btn-new-chat:hover { border-color: var(--brand); color: var(--brand-deep); }

.side-section { display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.side-label { font-size: 11.5px; color: var(--ink-3); padding: 2px 6px 6px; display: flex; align-items: center; justify-content: space-between; }
.side-clear {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--ink-3); background: none; border: none;
  cursor: pointer; padding: 3px 6px; border-radius: 6px;
  transition: color .18s, background .18s;
}
.side-clear:hover { color: #a4544c; background: #fdeeed; }
.side-clear:active { transform: scale(.95); }

.conv-list { overflow-y: auto; max-height: 180px; display: flex; flex-direction: column; gap: 2px; }
.conv-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 10px; text-align: left; width: 100%;
  transition: background .12s;
}
.conv-item:hover { background: rgba(255, 253, 248, .9); }
.conv-item.active { background: var(--brand-soft); }
.conv-item .t { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.active .t { color: var(--brand-deep); }
.conv-item .time { font-size: 11px; color: var(--ink-3); flex-shrink: 0; }

.quick-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 10px; font-size: 12.5px; color: var(--ink-2);
  text-align: left; width: 100%;
}
.quick-item:hover { background: rgba(255,253,248,.9); color: var(--brand-deep); }
.quick-item svg { color: var(--brand); flex-shrink: 0; }

.progress-card {
  margin-top: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
}
.progress-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); }
.progress-head b { color: var(--brand-deep); }
.progress-bar { height: 6px; background: var(--brand-soft); border-radius: 99px; margin: 9px 0 8px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--brand)); border-radius: 99px; transition: width .4s; }
.progress-note { font-size: 11px; color: var(--ink-3); }

.sidebar-bottom { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.tpl-card {
  display: flex; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  color: var(--ink-2); box-shadow: var(--shadow);
}
.tpl-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tpl-info b { font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-info span { font-size: 11px; color: var(--ink-3); }
.user-card { display: flex; gap: 10px; align-items: center; padding: 4px 8px; }
.user-avatar, .agent-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 30% 25%, #d7a35c, #a9702c);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
  box-shadow: inset 0 -2px 4px rgba(90,55,10,.25), 0 2px 6px rgba(150,98,31,.28);
}
.agent-avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.agent-avatar img, .msg-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.user-info b { font-size: 12.5px; display: block; }
.user-info span {
  font-size: 10px; color: #8a5a1e;
  background: #f3e3c3; border-radius: 99px;
  padding: 1px 7px; display: inline-block; margin-top: 2px;
}

/* ======================= 对话主区 ======================= */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.agent-id { display: flex; gap: 12px; align-items: center; }
.agent-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.badge-react {
  font-style: normal; font-size: 10.5px; font-weight: 700; color: var(--brand-deep);
  background: var(--brand-soft); padding: 2px 7px; border-radius: 99px; letter-spacing: .3px;
}
.agent-status { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.header-actions { display: flex; align-items: center; gap: 10px; }

.seg { display: flex; background: rgba(233,223,201,.5); border-radius: 99px; padding: 3px; }
.seg-btn { padding: 6px 18px; border-radius: 99px; font-size: 12.5px; color: var(--ink-2); transition: all .15s; }
.seg-btn.active { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(92,68,34,.12); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-2);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-deep); }
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  background: linear-gradient(180deg, #b57c35, #9a651f); color: #fff8ec;
  box-shadow: 0 2px 8px rgba(154,101,31,.28);
}
.btn-primary:hover { filter: brightness(1.05); }

/* 聊天区 */
.chat-scroll { flex: 1; overflow-y: auto; padding: 18px 26px 8px; }
.chat-time-divider {
  text-align: center; font-size: 11px; color: var(--ink-3); margin: 4px 0 16px;
  display: flex; align-items: center; gap: 14px;
}
.chat-time-divider::before, .chat-time-divider::after {
  content: ""; flex: 1; height: 1px; background: rgba(214,196,160,.4);
}

.msg-row { display: flex; gap: 12px; margin-bottom: 18px; }
.msg-row.user { justify-content: flex-end; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 30% 25%, #d7a35c, #a9702c);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.bubble {
  max-width: 640px; padding: 12px 16px; border-radius: 14px; line-height: 1.75; font-size: 13.5px;
  background: var(--card); border: 1px solid var(--line-soft); box-shadow: var(--shadow);
  white-space: pre-wrap; word-break: break-word;
}
.msg-row.user .bubble {
  background: #f7ecd7;
  border: 1px solid #e8d2ab;
  color: #5f421e;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 8px rgba(150, 98, 31, .08);
  transition: transform .15s, box-shadow .15s;
}
.msg-row.user .bubble:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(150, 98, 31, .13); }
.msg-row.ai .bubble { border-radius: 4px 14px 14px 14px; }

/* 建议 chips */
.suggest-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px 42px; }
.suggest-chip {
  padding: 7px 14px; border-radius: 99px; font-size: 12px; color: var(--ink-2);
  background: var(--card); border: 1px solid var(--line);
}
.suggest-chip:hover { border-color: var(--brand); color: var(--brand-deep); background: var(--brand-soft); }

/* 思考过程卡片 */
.think-card {
  margin: 4px 0 16px 42px; background: var(--card-soft);
  border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow);
}
.think-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer; user-select: none;
}
.think-title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.think-title .caret { transition: transform .2s; color: var(--ink-3); font-size: 10px; }
.think-card.collapsed .caret { transform: rotate(-90deg); }
.think-meta { font-size: 11px; color: var(--ink-3); }
.think-body { padding: 2px 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.think-card.collapsed .think-body { display: none; }

.think-step { display: flex; gap: 12px; }
.step-no {
  width: 24px; height: 24px; border-radius: 8px; flex-shrink: 0; margin-top: 1px;
  background: var(--brand-soft); color: var(--brand-deep);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.step-no.tool { background: #eef3e9; color: #6a8a5a; }
.step-content { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; min-width: 0; }
.step-tag { font-weight: 700; color: var(--ink); margin-right: 6px; }
.tool-code {
  display: inline-block; margin-top: 6px; padding: 5px 10px; border-radius: 8px;
  background: #f6efe0; border: 1px solid var(--line-soft);
  font-family: "Cascadia Code", Consolas, monospace; font-size: 11.5px; color: var(--brand-deep);
  word-break: break-all;
}
.tool-obs { margin-top: 6px; color: var(--ink-3); font-size: 12px; }
.think-loading { font-size: 12px; color: var(--ink-3); padding: 8px 16px 12px; }
.think-loading i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-right: 6px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* 动作 chips（查看数据表 / 下载） */
.action-row { display: flex; gap: 8px; margin: 10px 0 0 42px; }
.action-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-2);
}
.action-chip.primary { background: var(--brand-soft); border-color: #e3cfa4; color: var(--brand-deep); }
.action-chip:hover { border-color: var(--brand); color: var(--brand-deep); }

/* 输入区 */
.chat-composer-wrap { padding: 6px 26px 12px; }
.composer-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; min-height: 0; }
.suggest-inline {
  padding: 6px 12px; border-radius: 99px; font-size: 12px; color: var(--brand-deep);
  background: var(--brand-soft); border: 1px solid #e3cfa4;
}
.suggest-inline:hover { background: #eddfc2; }

.composer {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 4px 16px rgba(92,68,34,.08); padding: 12px 14px 10px;
}
.composer:focus-within { border-color: #d9b87c; }
.composer-attachments { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 9px; font-size: 12px;
  background: var(--card-soft); border: 1px solid var(--line-soft); color: var(--ink-2);
}
.att-chip .kind { color: var(--brand-deep); font-weight: 700; font-size: 11px; }
.att-chip .kind.doc {
  padding: 1px 6px; border-radius: 5px;
  background: var(--brand-soft, rgba(122, 106, 220, .12)); color: var(--brand-deep);
}
.att-chip.msg-doc { background: rgba(255, 255, 255, .65); }
.att-chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }
.att-chip .x { color: var(--ink-3); cursor: pointer; padding: 0 2px; }
.att-chip .x:hover { color: var(--danger); }

#chatInput {
  width: 100%; border: none; resize: none; background: transparent;
  line-height: 1.6; max-height: 140px; padding: 2px 4px;
}
#chatInput::placeholder { color: var(--ink-3); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.composer-left, .composer-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand-deep); }

.model-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 99px; background: var(--card-soft); border: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--ink-2);
}
.model-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: #7fae6f; }
.model-chip b { color: var(--ink); }
.model-switch { display: flex; background: rgba(233,223,201,.6); border-radius: 99px; padding: 2px; margin-left: 2px; }
.ms-btn { padding: 2px 9px; border-radius: 99px; font-size: 10.5px; font-weight: 700; color: var(--ink-3); }
.ms-btn.active { background: var(--card); color: var(--brand-deep); box-shadow: 0 1px 3px rgba(92,68,34,.15); }
.enter-hint { font-size: 11px; color: var(--ink-3); }
.btn-send {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(180deg, #c1873d, #a9702c);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(169,112,44,.35);
  transition: transform .12s;
}
.btn-send:hover { transform: translateY(-1px); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.chat-foot-note { text-align: center; font-size: 11px; color: var(--ink-3); margin-top: 9px; }

/* ======================= 数据表视图 ======================= */
.view-table { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-table[hidden] { display: none; }
.table-scroll { flex: 1; overflow-y: auto; }
.table-page { max-width: 1180px; margin: 0 auto; padding: 22px 26px 40px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.page-title { font-size: 30px; font-weight: 700; letter-spacing: 1px; color: #33291c; }
.page-sub { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.chip-pending { font-style: normal; font-size: 11px; color: var(--danger); background: var(--danger-bg); padding: 2px 9px; border-radius: 99px; font-weight: 600; }
.chip-ok { font-style: normal; font-size: 11px; color: var(--ok); background: var(--ok-bg); padding: 2px 9px; border-radius: 99px; font-weight: 600; }
.page-actions { display: flex; gap: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card.warn { background: linear-gradient(180deg, #fdf3ec, #fbeae4); border-color: #f2d9c4; }
.stat-label { font-size: 12px; color: var(--ink-3); }
.stat-num { font-size: 30px; font-weight: 700; margin: 8px 0 6px; color: #33291c; }
.stat-card.warn .stat-num { color: var(--danger); }
.stat-note { font-size: 11px; color: var(--ink-3); }

.filter-bar {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,253,248,.75); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 14px; margin-bottom: 14px;
}
.f-select {
  padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.filter-count { font-size: 12px; color: var(--ink-3); margin-left: 6px; }
.link-btn { font-size: 12px; color: var(--brand-deep); font-weight: 600; padding: 4px 6px; }
.link-btn:hover { text-decoration: underline; }
.f-search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px;
  color: var(--ink-3); width: 230px;
}
.f-search input { border: none; background: transparent; width: 100%; font-size: 12.5px; }

.table-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; box-shadow: var(--shadow); }
.log-table { width: 100%; min-width: 1280px; border-collapse: collapse; font-size: 12.5px; }
.log-table th {
  text-align: left; padding: 12px 14px; font-weight: 600; color: var(--ink-2);
  background: linear-gradient(180deg, #f9f2e2, #f6eeda); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.log-table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); white-space: nowrap; }
.log-table tr:hover td { background: #fdf9f0; }
.log-table td.violation { color: var(--danger); font-weight: 600; }
.log-table td.num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.log-table tr:hover .row-actions { opacity: 1; }
.row-actions button { color: var(--ink-3); padding: 3px; border-radius: 6px; font-size: 12px; }
.row-actions button:hover { background: var(--brand-soft); color: var(--brand-deep); }
.row-actions button.del:hover { background: var(--danger-bg); color: var(--danger); }
.table-foot {
  display: flex; justify-content: space-between; padding: 12px 16px;
  font-size: 12px; color: var(--ink-3);
}
.pager { display: flex; align-items: center; gap: 10px; }

.rules-card {
  margin-top: 16px; background: rgba(255,253,248,.65); border: 1px dashed var(--line);
  border-radius: 14px; padding: 14px 18px;
}
.rules-title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--brand-deep); margin-bottom: 8px; }
.rules-card ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.rules-card li { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; }
.rules-card li::before { content: "•"; color: var(--accent); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(60, 46, 25, .35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal {
  width: 620px; max-width: calc(100vw - 40px);
  background: var(--card); border-radius: 18px; padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(50,35,15,.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-size: 15px; }
.modal-close { color: var(--ink-3); font-size: 14px; padding: 4px 8px; border-radius: 8px; }
.modal-close:hover { background: var(--brand-soft); color: var(--ink); }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.modal-grid label.span2 { grid-column: span 2; }
.modal-grid input, .modal-grid select {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card-soft);
  font-weight: 400; font-size: 13px;
}
.modal-grid input:focus, .modal-grid select:focus { border-color: #d9b87c; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Toast */
.toast {
  position: fixed; right: 28px; bottom: 28px; z-index: 60;
  display: flex; align-items: center; gap: 12px;
  background: #3f342a; color: #f5eddd; border-radius: 14px; padding: 13px 18px;
  box-shadow: 0 12px 40px rgba(30,20,8,.4); max-width: 480px;
}
.toast-check {
  width: 24px; height: 24px; border-radius: 50%; background: #6f9a5d; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.toast-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.toast-body b { font-size: 13px; }
.toast-body span { font-size: 11px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-open {
  color: #f0c987; font-size: 12.5px; font-weight: 600; text-decoration: none;
  padding: 5px 12px; border: 1px solid rgba(240,201,135,.4); border-radius: 9px; flex-shrink: 0;
}
.toast-open:hover { background: rgba(240,201,135,.12); }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #ddcda8; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* 响应式 */
@media (max-width: 1080px) {
  .sidebar { width: 232px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* AI 主动提问横幅 */
.ask-banner { margin-top: 10px; background: #fff8ec; border: 1px solid #e8c98f; border-left: 3px solid #c1873d; border-radius: 10px; padding: 10px 12px; }
.ask-banner .ask-title { font-size: 12px; font-weight: 700; color: #a05a2c; margin-bottom: 4px; }
.ask-banner .ask-q { font-size: 13px; color: #3d2e1b; line-height: 1.6; }
.step-no.ask { background: #c1873d; color: #fff; }
.step-tag.ask { background: #f3e3c3; color: #8a5a1e; }

/* ======================= 课表视图 ======================= */
/* 动画：卡片依次浮入 */
@keyframes ttRise {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* 动画：表头落下 */
@keyframes ttDrop {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* 动画：今天呼吸圆点 */
@keyframes ttPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .45; transform: scale(.8); }
}

.tt-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; overflow-x: auto;
  animation: ttRise .45s cubic-bezier(.2, .7, .3, 1) both;
}
.tt-grid {
  display: grid;
  grid-template-columns: 70px repeat(7, minmax(108px, 1fr));
  gap: 8px;
  min-width: 940px;
}
.tt-cell { border-radius: 12px; min-width: 0; }

/* 左上角：周次 */
.tt-corner {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: var(--card-soft); border: 1px solid var(--line-soft);
  animation: ttDrop .4s ease both;
}
.tt-corner b { font-size: 13.5px; color: var(--brand-deep); }
.tt-corner span { font-size: 10.5px; color: var(--ink-3); }

/* 星期表头 */
.tt-dayhead {
  text-align: center; padding: 10px 0; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); background: var(--card-soft); border: 1px solid var(--line-soft);
  animation: ttDrop .4s ease both;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: background-color .22s, border-color .22s, color .22s, transform .22s;
}
.tt-dayhead:hover { background: #f4ecdb; transform: translateY(-1px); }
.tt-dayhead em {
  display: block; font-style: normal; font-size: 10.5px; font-weight: 500;
  color: var(--ink-3); margin-top: 2px; letter-spacing: .5px;
}
.tt-dayhead.today { background: #f8edd6; color: var(--brand-deep); border-color: #e3c48c; }
.tt-dayhead.today em { color: var(--brand); display: flex; align-items: center; justify-content: center; gap: 4px; }
.tt-dayhead.today em::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--brand); animation: ttPulse 2s ease-in-out infinite;
}

/* 左列：节次 + 上课/下课时间 */
.tt-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--card-soft); border: 1px solid var(--line-soft);
  padding: 10px 4px; min-height: 78px;
  animation: ttDrop .4s ease both;
  animation-delay: calc(120ms + var(--i, 0) * 55ms);
  transition: background-color .22s;
}
.tt-slot:hover { background: #f4ecdb; }
.tt-slot .no {
  font-family: var(--serif); font-size: 15px; font-weight: 700; color: var(--ink);
  width: 24px; height: 24px; line-height: 24px; text-align: center;
  background: #f3e7d2; border-radius: 50%;
  transition: background-color .22s, color .22s, transform .22s;
}
.tt-slot:hover .no { background: #ecd9b4; transform: scale(1.08); }
.tt-slot .times { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.tt-slot .t-start { font-size: 10.5px; color: var(--brand-deep); font-weight: 600; }
.tt-slot .t-end { font-size: 10.5px; color: var(--ink-3); }

/* 空格子（可点击新增） */
.tt-empty {
  min-height: 78px; border: 1.5px dashed var(--line-soft);
  background: rgba(250, 245, 234, .3);
  position: relative; cursor: pointer;
  transition: background-color .22s, border-color .22s;
  animation: ttRise .45s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: var(--d, 0s);
}
.tt-empty::after {
  content: '＋'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 300; color: var(--ink-3);
  opacity: 0; transform: scale(.7);
  transition: opacity .22s, transform .22s;
}
.tt-empty:hover { background: rgba(169, 112, 44, .05); border-color: var(--accent); }
.tt-empty:hover::after { opacity: .55; transform: scale(1); }
.tt-empty:active { transform: scale(.97); }

/* 课程卡片：单一淡色，无渐变 */
.tt-course {
  min-height: 78px; border: 1px solid var(--cbd); border-radius: 12px;
  padding: 9px 10px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--cbg); color: var(--ctx);
  animation: ttRise .45s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: var(--d, 0s);
  transition: transform .2s cubic-bezier(.2, .7, .3, 1), box-shadow .2s, border-color .2s;
}
.tt-course:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(92, 68, 34, .1);
  border-color: color-mix(in srgb, var(--cbd) 55%, var(--ctx));
}
.tt-course:active { transform: translateY(0) scale(.97); }
.tt-course b { font-size: 12.5px; line-height: 1.4; font-weight: 600; }
.tt-course .loc {
  font-size: 11px; opacity: .8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity .2s;
}
.tt-course:hover .loc { opacity: 1; }
.tt-course .meta { font-size: 10px; opacity: .6; margin-top: auto; transition: opacity .2s; }
.tt-course:hover .meta { opacity: .85; }

/* 图例 */
.tt-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tt-legend .lg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-2);
  background: var(--card); border: 1px solid var(--line);
  padding: 4px 11px; border-radius: 99px;
  animation: ttRise .4s ease both;
  animation-delay: calc(200ms + var(--i, 0) * 50ms);
  transition: transform .18s, box-shadow .18s, border-color .18s, background-color .22s;
}
.tt-legend .lg:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(92, 68, 34, .08);
  background: var(--lbg, var(--card));
  border-color: var(--lbd, var(--line));
}
.tt-legend .lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; background: var(--lbg); border: 1px solid var(--lbd); transition: transform .18s; }
.tt-legend .lg:hover i { transform: scale(1.15); }
.tt-legend .lg span { max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
  .tt-card, .tt-corner, .tt-dayhead, .tt-slot, .tt-empty, .tt-course, .tt-legend .lg { animation: none !important; }
  .tt-dayhead.today em::before { animation: none !important; }
}

/* ======================= 登录页 ======================= */
.login-page {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1000px 500px at 15% -10%, #f3e7cd, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #f0e2c4, transparent 60%),
    #f8f3e7;
}
.login-page[hidden] { display: none; }
.login-card {
  width: 380px; padding: 40px 36px 28px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 18px 50px rgba(92,68,34,.14);
  text-align: center;
  animation: loginRise .45s cubic-bezier(.22,.9,.32,1.2);
}
@keyframes loginRise { from { opacity: 0; transform: translateY(22px) scale(.97); } }
.login-avatar {
  width: 68px; height: 68px; margin: 0 auto 14px;
  border-radius: 50%; overflow: hidden;
  border: 3px solid #f0dcb6; box-shadow: 0 6px 16px rgba(150,98,31,.22);
}
.login-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.login-card h1 { font-family: var(--serif); font-size: 21px; color: var(--ink); margin: 0 0 6px; }
.login-sub { font-size: 12px; color: var(--ink-3); margin: 0 0 26px; }
.login-field { margin-bottom: 14px; text-align: left; }
.login-field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.login-field input {
  width: 100%; box-sizing: border-box; padding: 10px 12px;
  border: 1px solid var(--line-soft); border-radius: 10px;
  background: var(--card-soft); font-size: 13.5px; color: var(--ink);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.login-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(193,135,61,.15); }
.login-remember {
  display: flex; align-items: center; gap: 7px; margin: 4px 0 14px;
  font-size: 12px; color: var(--ink-2); cursor: pointer; user-select: none;
}
.login-remember input { accent-color: #c1873d; width: 14px; height: 14px; cursor: pointer; }
.login-error {
  display: none; margin-bottom: 12px; padding: 8px 10px;
  font-size: 12px; color: #a4544c; background: #fdeeed;
  border: 1px solid #eec4c0; border-radius: 8px; text-align: left;
}
.login-error.show { display: block; animation: loginShake .35s; }
@keyframes loginShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.login-btn {
  width: 100%; padding: 11px; border: none; border-radius: 10px;
  background: #b5824a; color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .2s, transform .12s, box-shadow .2s;
  box-shadow: 0 4px 12px rgba(150,98,31,.28);
}
.login-btn:hover { background: #a9702c; box-shadow: 0 6px 16px rgba(150,98,31,.32); }
.login-btn:active { transform: scale(.98); }
.login-btn:disabled { opacity: .6; cursor: wait; }
.login-hint { font-size: 11px; color: var(--ink-3); margin: 16px 0 0; }

/* ======================= 个人信息弹窗 ======================= */
.profile-modal { width: 380px; }
.pf-body { padding: 18px 20px 6px; }
.pf-avatar-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin-bottom: 16px;
}
.pf-avatar {
  width: 76px; height: 76px; border-radius: 50%; object-fit: cover;
  cursor: pointer; border: 3px solid #f0dcb6;
  box-shadow: 0 6px 16px rgba(150,98,31,.2);
  transition: transform .2s, box-shadow .2s;
}
.pf-avatar:hover { transform: scale(1.05); box-shadow: 0 8px 20px rgba(150,98,31,.3); }
.pf-avatar-tip { font-size: 11px; color: var(--ink-3); }
.pf-fields { display: flex; flex-direction: column; gap: 12px; }
.pf-fields label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.pf-fields input {
  padding: 9px 12px; border: 1px solid var(--line-soft); border-radius: 10px;
  background: var(--card-soft); font-size: 13.5px; color: var(--ink); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.pf-fields input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(193,135,61,.15); }
.pf-fields input:disabled { color: var(--ink-3); background: var(--line-soft); cursor: not-allowed; }

/* 用户卡片可点击 */
.user-card { cursor: pointer; border-radius: 12px; transition: background .2s, transform .12s; }
.user-card:hover { background: var(--card-soft); transform: translateY(-1px); }
.user-card:active { transform: scale(.98); }
.user-avatar { overflow: hidden; }
.user-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

/* 用户消息头像（右侧） */
.msg-avatar.user { background: var(--card-soft); border: 1px solid var(--line-soft); }
.msg-avatar.user img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

/* 课表导入快捷按钮（输入区，区别于普通附件按钮） */
.tt-quick-btn { position: relative; }
.tt-quick-btn::after {
  content: ''; position: absolute; right: -1px; top: -1px;
  width: 6px; height: 6px; border-radius: 50%;
  background: #c1873d; opacity: .8;
}
.tt-quick-btn:hover::after { animation: ttDotPulse 1.2s ease-in-out infinite; }
@keyframes ttDotPulse { 0%,100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.5); opacity: .35; } }
