﻿:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-weak: #e7f3f1;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e3e7e5;
  --bg: #f5f7f6;
  --card: #ffffff;
  --warn: #b45309;
  --warn-bg: #fff7e6;
  --danger: #b91c1c;
  --danger-bg: #fdecec;
  --ok: #15803d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  font-size: calc(15px * var(--fs));
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 6px 10px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 顶栏 */
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { display: inline-flex; }
.brand-name { font-weight: 700; font-size: calc(17px * var(--fs)); letter-spacing: .5px; white-space: nowrap; }
.brand-sub { font-size: calc(12px * var(--fs)); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.model-chip {
  border: 1px solid var(--line); background: var(--brand-weak); color: var(--brand-dark); border-radius: 999px;
  padding: 4px 12px; font-size: calc(13px * var(--fs)); cursor: pointer; max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.model-chip.not-ready { background: var(--warn-bg); color: var(--warn); border-color: #f3d19c; }

/* 按钮 */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  transition: background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { border-color: #c9d3d0; background: #fafcfb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--brand-weak); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: calc(13px * var(--fs)); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { border: 0; background: none; font-size: calc(22px * var(--fs)); line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: #f0f2f1; }

/* 布局 */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: calc(100vh - 60px); }
.sidebar { border-right: 1px solid var(--line); background: #fbfcfb; padding: 14px; overflow-y: auto; display: flex; flex-direction: column; }
.side-title { font-size: calc(12px * var(--fs)); color: var(--muted); margin: 16px 4px 6px; }
.side-foot { margin-top: auto; padding-top: 12px; font-size: calc(12px * var(--fs)); color: var(--muted); }
.session-list { list-style: none; margin: 0; padding: 0; }
.session-list li { display: flex; align-items: center; border-radius: 8px; }
.session-list li.active { background: var(--brand-weak); }
.session-list li:hover:not(.active) { background: #f0f3f2; }
.session-open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 8px 10px; cursor: pointer; }
.session-open .t { display: block; font-size: calc(14px * var(--fs)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-open .d { display: block; font-size: calc(12px * var(--fs)); color: var(--muted); }
.session-del { opacity: 0; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px 8px; border-radius: 6px; }
.session-list li:hover .session-del, .session-del:focus-visible { opacity: 1; }
.session-del:hover { color: var(--danger); background: var(--danger-bg); }
.main { overflow-y: auto; scroll-behavior: auto; }
.view { max-width: 1040px; margin: 0 auto; padding: 20px 24px 0; min-height: 100%; display: flex; flex-direction: column; }

/* 备课信息表单 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.intake { padding: 24px 28px; margin-bottom: 24px; }
.intake h2 { margin: 0 0 4px; font-size: calc(20px * var(--fs)); }
.muted { color: var(--muted); }
.intake .muted { margin: 0 0 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: calc(14px * var(--fs)); padding: 0; }
.field > span.hint, .field > span.err { font-weight: 400; font-size: calc(13px * var(--fs)); }
.field .req { color: var(--danger); font-style: normal; }
.field input[type=text], .field input:not([type]), .field select, .field textarea, .field input[type=number], .field input[type=password], .field input[type=url] {
  border: 1px solid #d4dbd8; border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
.field.invalid input { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: calc(13px * var(--fs)); }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1 1 200px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline input[type=number] { width: 80px !important; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; border: 1px solid #d4dbd8; border-radius: 999px; padding: 5px 14px; cursor: pointer; background: #fff; font-weight: 400; }
.seg input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
details.more { margin: 2px 0 14px; }
details.more > summary { cursor: pointer; color: var(--brand); margin-bottom: 10px; }
.intake .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.hint { font-size: calc(13px * var(--fs)); color: var(--muted); margin: 10px 0 0; }
.starters { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); font-size: calc(14px * var(--fs)); color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.uploader { border: 1px dashed #c9d3d0; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; background: #fbfcfb; font-size: calc(14px * var(--fs)); }
.uploader .muted { font-size: calc(13px * var(--fs)); }
.mat-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mat { display: inline-flex; align-items: center; gap: 6px; background: #eef2f1; border-radius: 999px; padding: 2px 4px 2px 10px; font-size: calc(13px * var(--fs)); }
.mat.sent { background: #f3f4f6; color: var(--muted); }
.mat button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 6px; }

/* 对话 */
.session-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.session-head h1 { font-size: calc(20px * var(--fs)); margin: 0; }
.session-head .meta { color: var(--muted); font-size: calc(13px * var(--fs)); }
.thread { flex: 1; display: flex; flex-direction: column; gap: 16px; padding-bottom: 20px; }
.msg-user { align-self: flex-end; max-width: 78%; }
.msg-user .bubble { background: var(--brand); color: #fff; border-radius: 14px 14px 4px 14px; padding: 10px 14px; white-space: pre-wrap; word-break: break-word; }
.msg-user .attach { font-size: calc(12px * var(--fs)); color: var(--muted); text-align: right; margin-top: 4px; }
.msg-agent { padding: 18px 24px 16px; }
.msg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: calc(13px * var(--fs)); color: var(--muted); margin-bottom: 8px; }
.msg-head .who { font-weight: 700; color: var(--ink); font-size: calc(14px * var(--fs)); }
.badge { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: calc(12px * var(--fs)); background: #eef2f1; color: var(--brand-dark); }
.badge.sample { background: #fef3c7; color: #92400e; }
.sample-banner { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 8px 12px; font-size: calc(13px * var(--fs)); margin-bottom: 10px; }
.sec-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; position: sticky; top: 0; background: #fff; padding: 6px 0; z-index: 2; border-bottom: 1px solid var(--line); }
.sec-nav button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 1px 8px; font-size: calc(12.5px * var(--fs)); cursor: pointer; }
.sec-nav button:hover { border-color: var(--brand); color: var(--brand); }
.live-status { display: flex; align-items: center; gap: 10px; color: var(--brand-dark); font-size: calc(14px * var(--fs)); padding: 6px 0 10px; }
.spinner { width: 16px; height: 16px; border: 2px solid #b8dcd6; border-top-color: var(--brand); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.notice { border-radius: 8px; padding: 8px 12px; font-size: calc(14px * var(--fs)); margin: 8px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice-info { background: #eef6ff; color: #1e40af; }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-error { background: var(--danger-bg); color: var(--danger); }
.notice .btn { margin-left: auto; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); align-items: center; }
.tools .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.tools .label { font-size: calc(13px * var(--fs)); color: var(--muted); }
.quick-reply { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 程序自检 */
details.check { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfb; }
details.check > summary { cursor: pointer; padding: 8px 12px; font-size: calc(14px * var(--fs)); }
details.check > summary .hint { display: inline; margin: 0; font-size: calc(12px * var(--fs)); }
.check-body { padding: 0 14px 12px; }
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: grid; grid-template-columns: 24px 210px 1fr; gap: 6px; padding: 5px 0; border-bottom: 1px dashed #e7ebe9; font-size: calc(13.5px * var(--fs)); }
.check-list li:last-child { border-bottom: 0; }
.check-list .detail { color: var(--muted); }
.check-list li.warn .detail { color: var(--warn); }
.check-list li.fail .detail { color: var(--danger); }
.need-check { margin-top: 10px; font-size: calc(13.5px * var(--fs)); }
.need-check ul { margin: 4px 0 0; padding-left: 18px; color: #7c5a12; }

/* 输入区 */
.composer { position: sticky; bottom: 0; background: linear-gradient(to bottom, rgba(245, 247, 246, 0), var(--bg) 18px); padding: 18px 0 16px; }
.composer-box { background: #fff; border: 1px solid #d4dbd8; border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
.chip-row .group { font-size: calc(12px * var(--fs)); color: var(--muted); margin-right: 2px; }
.chip { border: 1px solid var(--line); background: #f7faf9; border-radius: 999px; padding: 3px 11px; font-size: calc(13px * var(--fs)); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.key { background: var(--brand-weak); border-color: #b8dcd6; color: var(--brand-dark); }
details.more-chips { display: inline; }
details.more-chips > summary { display: inline-block; cursor: pointer; font-size: calc(13px * var(--fs)); color: var(--brand); padding: 3px 6px; list-style: none; }
details.more-chips > summary::-webkit-details-marker { display: none; }
details.more-chips[open] { display: block; width: 100%; }
details.more-chips .chip-row { margin: 6px 0 0; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.input-row textarea { flex: 1; border: 0; resize: none; min-height: 44px; max-height: 200px; padding: 8px 4px; outline: none; }
.input-actions { display: flex; gap: 6px; align-items: center; }
.composer .hint { margin: 6px 4px 0; font-size: calc(12px * var(--fs)); }

/* Markdown（备课包） */
.md { font-size: calc(15px * var(--fs)); word-break: break-word; }
.md h1 { font-size: calc(22px * var(--fs)); text-align: center; margin: 6px 0 4px; }
.md h1 + p { text-align: center; color: var(--muted); font-size: calc(13.5px * var(--fs)); }
.md h2 { font-size: calc(18px * var(--fs)); margin: 26px 0 10px; padding: 4px 0 4px 10px; border-left: 4px solid var(--brand); background: linear-gradient(90deg, var(--brand-weak), transparent 70%); scroll-margin-top: 52px; }
.md h3 { font-size: calc(16px * var(--fs)); margin: 18px 0 8px; color: var(--brand-dark); }
.md h4 { font-size: calc(15px * var(--fs)); margin: 14px 0 6px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 2px 0; }
.md blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid #99c7c1; background: #f6faf9; color: #374151; }
.md code { background: #f1f4f3; border-radius: 4px; padding: 0 4px; font-family: Consolas, "Courier New", monospace; font-size: calc(13.5px * var(--fs)); }
.md pre { background: #f5f7f6; padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.table-wrap { overflow-x: auto; margin: 8px 0 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: calc(14px * var(--fs)); min-width: 520px; }
.md th, .md td { border: 1px solid #d5ddda; padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { background: #eef5f3; font-weight: 600; white-space: nowrap; }
.md table.draw { min-width: 0; }
.md table.draw th { white-space: normal; }
.md table.draw td { height: 96px; }
.md tbody tr:nth-child(even) td { background: #fbfcfc; }
mark.tag { border-radius: 4px; padding: 0 2px; }
mark.tag-verify { background: #fde68a; color: #78350f; }
mark.tag-default { background: #dbeafe; color: #1e3a8a; }
mark.tag-todo { background: #e5e7eb; color: #374151; }
mark.tag-ext { background: #ede9fe; color: #5b21b6; }
mark.tag-demo { background: #fce7f3; color: #9d174d; }

/* 弹窗与提示 */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal::backdrop { background: rgba(17, 24, 39, .4); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: calc(17px * var(--fs)); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-body h3 { font-size: calc(15px * var(--fs)); margin: 14px 0 6px; }
.modal-body p, .modal-body li { font-size: calc(14px * var(--fs)); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-actions .left { margin-right: auto; display: flex; gap: 8px; }
.prompt-text { width: 100%; height: 50vh; font-family: Consolas, "Microsoft YaHei", monospace; font-size: calc(13px * var(--fs)); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.result { margin-top: 8px; font-size: calc(14px * var(--fs)); }
.result.ok { color: var(--ok); }
.result.bad { color: var(--danger); }
.model-pick { margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #111827; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: calc(14px * var(--fs)); z-index: 100; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 80vw; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* 窄屏：一列布局。列宽用 minmax(0, 1fr)：普通的 1fr 最小值等于内容宽度，
   任何一块宽内容都会把整列（连同侧栏）撑出屏幕。 */
@media (max-width: 900px) {
  .topbar { position: static; }
  .layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; }
  .main { overflow: visible; min-width: 0; }
  .brand-sub { display: none; }
  .view { padding: 14px 12px 0; }
  .msg-agent { padding: 14px; }
  .msg-user { max-width: 92%; }
  .check-list li { grid-template-columns: 22px 1fr; }
  .check-list .detail { grid-column: 2; }
}
@media (max-width: 600px) {
  .topbar { height: auto; flex-wrap: wrap; row-gap: 4px; padding: 8px 12px; }
  .top-actions { width: 100%; flex-shrink: 1; min-width: 0; gap: 4px; }
  .model-chip { flex: 1 1 auto; min-width: 0; max-width: none; }
  .top-actions .btn.ghost { padding: 6px 8px; }
  .intake { padding: 18px 16px; }
}
