/* yihuiwork · 设计系统
   浅色为默认（跟随 IDE），深色由 data-theme="dark" 切换 */

:root {
  --bg: #f6f6f4;
  --bg-rise: #ffffff;
  --bg-sink: #fbfbfa;
  --bg-hover: #efefec;
  --bg-active: #e7e7e2;
  --border: #e5e3dd;
  --border-soft: #eeece7;
  --text: #1a1a19;
  --text-2: #54534f;
  --text-3: #92908a;
  --accent: #3b6ef5;
  --accent-soft: #eaefff;
  --danger: #d64545;
  --ok: #2f9e63;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 8px 24px rgba(20, 20, 19, .06);
  --shadow-lg: 0 12px 48px rgba(20, 20, 19, .16);
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[data-theme="dark"] {
  --bg: #131317;
  --bg-rise: #1b1b20;
  --bg-sink: #17171b;
  --bg-hover: #23232a;
  --bg-active: #2b2b33;
  --border: #2b2b33;
  --border-soft: #24242b;
  --text: #ececf0;
  --text-2: #a9a9b4;
  --text-3: #71717d;
  --accent: #6b93ff;
  --accent-soft: #1c2540;
  --danger: #f07171;
  --ok: #4ec08a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 56px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

/* 注意：作者样式里的 display 会盖掉 hidden 属性的 UA 样式，
   所以这里必须显式声明一次，否则 hidden 形同虚设（管理入口藏不住）。 */
[hidden] { display: none !important; }

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

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: inherit; }
svg { width: 16px; height: 16px; flex: none; display: block; }

/* ------------------------------------------------------------ 骨架 */

.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 264px;
  flex: none;
  background: var(--bg-sink);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sb-head { padding: 14px 12px 6px; }

.brand {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 0; padding: 4px 6px; border-radius: var(--r-s);
  width: 100%;
}
.brand:hover { background: var(--bg-hover); }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px; flex: none;
  background: var(--text); color: var(--bg-rise);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: -.02em;
}
.brand-name { font-weight: 600; font-size: 14.5px; letter-spacing: -.01em; }

.new-chat {
  margin: 6px 12px 10px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 12px; border-radius: var(--r-s);
  border: 1px solid var(--border);
  background: var(--bg-rise);
  font-weight: 500;
  box-shadow: 0 1px 1px rgba(0,0,0,.02);
}
.new-chat:hover { background: var(--bg-hover); }
.new-chat svg { width: 15px; height: 15px; }

.sb-scroll { flex: 1; overflow-y: auto; padding: 0 8px 12px; min-height: 0; }
.sb-group { margin-top: 14px; }
.sb-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-3); text-transform: uppercase;
  padding: 0 8px 6px;
}

.quick-list, .conv-list { display: flex; flex-direction: column; gap: 1px; }

.quick-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  padding: 7px 9px; border: 0; border-radius: var(--r-s);
  background: none; color: var(--text-2); font-size: 13.5px;
}
.quick-item:hover { background: var(--bg-hover); color: var(--text); }
.quick-dot {
  width: 5px; height: 5px; border-radius: 50%; flex: none;
  background: var(--text-3); opacity: .55;
}
.quick-item:hover .quick-dot { background: var(--accent); opacity: 1; }

.conv-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; text-align: left;
  padding: 7px 9px; border: 0; border-radius: var(--r-s);
  background: none; color: var(--text-2); font-size: 13.5px;
}
.conv-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item:hover { background: var(--bg-hover); color: var(--text); }
.conv-item.on { background: var(--bg-active); color: var(--text); font-weight: 500; }
.conv-del {
  font-style: normal; font-size: 11px; color: var(--text-3);
  opacity: 0; padding: 0 2px; border-radius: 4px; flex: none;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); }

.sb-foot {
  border-top: 1px solid var(--border-soft);
  padding: 8px; display: flex; flex-direction: column; gap: 1px;
}
.foot-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border: 0; border-radius: var(--r-s);
  background: none; color: var(--text-2); font-size: 13.5px; text-align: left;
}
.foot-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------------------------------------------------------- 主区域 */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  height: 52px; flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
}
.topbar-title {
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.agent-chip {
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-rise);
  font-size: 12.5px; color: var(--text-2);
}
.agent-chip:hover { background: var(--bg-hover); color: var(--text); }

.model-select {
  display: flex; gap: 2px; padding: 2px;
  background: var(--bg-sink); border: 1px solid var(--border);
  border-radius: 999px;
}
.model-select button {
  padding: 4px 12px; border: 0; border-radius: 999px;
  background: none; font-size: 12.5px; color: var(--text-3);
}
.model-select button:hover { color: var(--text); }
.model-select button.on { background: var(--bg-rise); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--r-s);
  border: 0; background: none; color: var(--text-2);
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------------------------------------------------------- 对话区 */

.chat { flex: 1; overflow-y: auto; min-height: 0; }
.chat-inner { max-width: 760px; margin: 0 auto; padding: 28px 24px 40px; }

.welcome { padding: 10vh 0 0; text-align: left; }
.welcome h1 { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 6px; }
.welcome p { color: var(--text-3); margin: 0 0 26px; font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 14px 16px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--r-m);
  background: var(--bg-rise);
  transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--text-3); transform: translateY(-1px); }
.card b { font-size: 13.5px; font-weight: 600; }
.card small { color: var(--text-3); font-size: 12.5px; }

.msg { display: flex; gap: 12px; margin-bottom: 22px; }
.msg.user { justify-content: flex-end; }
.msg .body { min-width: 0; max-width: 100%; }
.msg .avatar {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--text); color: var(--bg-rise);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.msg .who { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 4px; }
.msg .text { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.msg .bubble {
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg-rise); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: var(--r-m);
  font-size: 14.5px; max-width: 560px;
}
.msg-actions { margin-top: 7px; display: flex; gap: 6px; }
.msg-actions button {
  border: 0; background: none; color: var(--text-3);
  font-size: 12px; padding: 2px 6px; border-radius: 5px;
}
.msg-actions button:hover { background: var(--bg-hover); color: var(--text); }

.cursor {
  display: inline-block; width: 2px; height: 15px;
  background: var(--text); vertical-align: -2px;
  animation: blink 1s steps(2) infinite; margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* 推理档的思考状态条：只告诉用户"在思考"，思考内容本身不下发 */
.thinking { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.thinking span { font-size: 13px; color: var(--text-3); }
.thinking i {
  display: block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-3); animation: think-dot 1.2s ease-in-out infinite;
}
.thinking i:nth-child(2) { animation-delay: .18s; }
.thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes think-dot {
  0%, 60%, 100% { opacity: .22; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* --------------------------------------------------------- 输入区 */

.composer-wrap { flex: none; padding: 0 24px 18px; }
.composer {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  border: 1px solid var(--border); border-radius: var(--r-l);
  background: var(--bg-rise); padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
  transition: border-color .12s;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none;
  background: none; color: var(--text);
  padding: 8px 0; max-height: 180px; line-height: 1.6;
}
.composer textarea::placeholder { color: var(--text-3); }
.send {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  border: 0; background: var(--text); color: var(--bg-rise);
  display: grid; place-items: center;
}
.send:hover { opacity: .85; }
.send:disabled { opacity: .3; cursor: not-allowed; }

.composer-hint {
  max-width: 760px; margin: 8px auto 0;
  font-size: 12px; color: var(--text-3); text-align: center;
}

/* ---------------------------------------------------------- 弹窗 */

.mask {
  position: fixed; inset: 0; background: rgba(20,20,19,.35);
  backdrop-filter: blur(2px); opacity: 0; pointer-events: none;
  transition: opacity .14s; z-index: 40;
}
.mask.on { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; z-index: 41;
  left: 50%; top: 50%; transform: translate(-50%, -48%) scale(.98);
  width: min(560px, calc(100vw - 32px)); max-height: 82vh;
  background: var(--bg-rise); border: 1px solid var(--border);
  border-radius: var(--r-l); box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; overflow: hidden;
}
.modal.on { display: flex; transform: translate(-50%, -50%) scale(1); }
.modal-sm { width: min(400px, calc(100vw - 32px)); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-note { margin-top: 14px; font-size: 12.5px; color: var(--text-3); }

.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-2); }
.field input, .field textarea, .field select {
  display: block; width: 100%; margin-top: 5px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-s);
  background: var(--bg-sink); color: var(--text); outline: 0;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); background: var(--bg-rise); }
.field textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

.primary {
  width: 100%; padding: 10px; border: 0; border-radius: var(--r-s);
  background: var(--text); color: var(--bg-rise); font-weight: 500;
}
.primary:hover { opacity: .88; }
.ghost {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--r-s);
  background: transparent; color: var(--text-2); font-size: 13px; text-align: left;
}
.ghost:hover { background: var(--bg-hover); color: var(--text); }

.err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }

.agent-list { display: flex; flex-direction: column; gap: 2px; }
.agent-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px; border: 0; border-radius: var(--r-s);
  background: none; text-align: left; width: 100%;
}
.agent-row:hover { background: var(--bg-hover); }
.agent-row.on { background: var(--accent-soft); }
.agent-row .av {
  width: 30px; height: 30px; border-radius: var(--r-s); flex: none;
  background: var(--bg-active); display: grid; place-items: center; font-size: 15px;
}
.agent-row .meta { display: flex; flex-direction: column; min-width: 0; }
.agent-row .meta b { font-size: 13.5px; font-weight: 500; }
.agent-row .meta small { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------- 控制台 */

.console {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg); display: flex; overflow: hidden;
}
.console[hidden] { display: none; }

.console-rail {
  width: 216px; flex: none;
  background: var(--bg-sink); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px;
}
.cr-head { display: flex; align-items: center; gap: 9px; padding: 0 6px 16px; font-size: 14px; }
.cr-head .brand-mark { width: 22px; height: 22px; font-size: 12px; border-radius: 6px; }
.cr-nav { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.cr-nav button {
  padding: 8px 11px; border: 0; border-radius: var(--r-s);
  background: none; text-align: left; color: var(--text-2); font-size: 13.5px;
}
.cr-nav button:hover { background: var(--bg-hover); color: var(--text); }
.cr-nav button.on { background: var(--bg-active); color: var(--text); font-weight: 500; }
.cr-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border-soft); }

.console-main { flex: 1; overflow-y: auto; padding: 28px 32px 60px; min-width: 0; }

.page { max-width: 940px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.page-head h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.page-head .spacer { flex: 1; }
.page-sub { color: var(--text-3); font-size: 13px; margin: 0 0 22px; }

.btn {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--r-s);
  background: var(--bg-rise); color: var(--text); font-size: 13px;
}
.btn:hover { background: var(--bg-hover); }
.btn.solid { background: var(--text); color: var(--bg-rise); border-color: var(--text); }
.btn.solid:hover { opacity: .88; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--bg-hover); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat {
  padding: 15px 16px; border: 1px solid var(--border); border-radius: var(--r-m);
  background: var(--bg-rise);
}
.stat b { display: block; font-size: 23px; font-weight: 600; letter-spacing: -.02em; }
.stat span { color: var(--text-3); font-size: 12.5px; }

.panel {
  border: 1px solid var(--border); border-radius: var(--r-m);
  background: var(--bg-rise); margin-bottom: 18px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-soft);
}
.panel-head b { font-size: 13.5px; font-weight: 600; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-body.tight { padding: 8px; }

.list-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; border-radius: var(--r-s);
}
.list-item:hover { background: var(--bg-sink); }
.list-item + .list-item { border-top: 1px solid var(--border-soft); }
.list-item .ico {
  width: 32px; height: 32px; border-radius: var(--r-s); flex: none;
  background: var(--bg-active); display: grid; place-items: center; font-size: 15px;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.list-item .s { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.list-item .pv {
  font-size: 12px; color: var(--text-3); margin-top: 6px;
  background: var(--bg-sink); border-radius: 6px; padding: 6px 9px;
  max-height: 52px; overflow: hidden;
}
.list-item .acts { display: flex; gap: 6px; flex: none; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--bg-active); color: var(--text-2);
  font-size: 11.5px; font-weight: 500;
}
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: #fff4e0; color: #a5680a; }
[data-theme="dark"] .tag.warn { background: #3a2a10; color: #e0a94a; }

.drop {
  border: 1.5px dashed var(--border); border-radius: var(--r-m);
  padding: 34px 20px; text-align: center; color: var(--text-3);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop b { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-sink); font-size: 12.5px; color: var(--text-2);
}
.chip:hover { border-color: var(--text-3); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }

.switch { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }

.empty { padding: 30px 16px; text-align: center; color: var(--text-3); font-size: 13px; }

.note {
  font-size: 12.5px; color: var(--text-3); line-height: 1.75;
  background: var(--bg-sink); border-radius: var(--r-s); padding: 11px 13px;
}
.note code {
  background: var(--bg-active); padding: 1px 5px; border-radius: 4px;
  font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace;
}

.only-mobile { display: none; }

/* --------------------------------------------------------- 响应式 */

@media (max-width: 860px) {
  .sidebar {
    position: fixed; z-index: 30; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .18s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .only-mobile { display: grid; }
  .cards { grid-template-columns: 1fr; }
  .chat-inner { padding: 20px 16px 30px; }
  .composer-wrap { padding: 0 14px 14px; }
  .console-rail { width: 168px; padding: 12px 8px; }
  .console-main { padding: 20px 16px 50px; }
  .grid2 { grid-template-columns: 1fr; }
  .topbar-right .model-select button { padding: 4px 8px; }
}

/* -------------------------------------------------------- 视频日记 */

.vd-table-wrap { overflow-x: auto; }
.vd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vd-table th {
  text-align: left; font-weight: 600; color: var(--text-3);
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; font-size: 12px;
}
.vd-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); color: var(--text); }
.vd-table tbody tr:last-child td { border-bottom: 0; }
.vd-table tbody tr:hover td { background: var(--bg-hover); }
.vd-table .ttl { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vd-table .nowrap { white-space: nowrap; }

.vd-flags { margin: 0; padding-left: 18px; }
.vd-flags li { font-size: 13.5px; line-height: 1.75; }
.vd-flags li + li { margin-top: 5px; }

.vd-advice { font-size: 14px; line-height: 1.78; }
.vd-advice h4 { margin: 20px 0 8px; font-size: 14px; font-weight: 700; }
.vd-advice h4:first-child { margin-top: 0; }
.vd-advice p { margin: 6px 0; }
.vd-advice ul { margin: 6px 0; padding-left: 20px; }
.vd-advice li { margin: 5px 0; }
.vd-advice b { font-weight: 700; }

#v-bulk {
  width: 100%; box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.6;
  padding: 10px 12px; border-radius: var(--r-s);
  border: 1px solid var(--border); background: var(--bg-sink); color: var(--text);
  resize: vertical;
}
#v-bulk:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
