:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1d2129;
  --sub: #6b7280;
  --line: #e5e7eb;
  --brand: #ff6a2b;
  --brand-2: #fff1ea;
  --blue: #2f6bff;
  --blue-2: #eaf0ff;
  --green: #10a35a;
  --green-2: #e7f7ee;
  --red: #e5484d;
  --red-2: #fdecec;
  --amber: #c27c0e;
  --amber-2: #fff6e0;
  --me: #d9f7be;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1a1d23;
    --text: #e8eaed;
    --sub: #9aa0a6;
    --line: #2a2e35;
    --brand-2: #3a2418;
    --blue-2: #1c2846;
    --green-2: #15301f;
    --red-2: #3a1d1e;
    --amber-2: #352a12;
    --me: #2c4a1f;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
small, .sub { color: var(--sub); }
.hide { display: none !important; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.side { width: 210px; flex: none; background: var(--card); border-right: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
.side .logo img { width: 28px; height: 28px; }
.side a { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.side a:hover { background: var(--bg); }
.side a.on { background: var(--brand-2); color: var(--brand); font-weight: 600; }
.side .group { font-size: 12px; color: var(--sub); padding: 14px 12px 4px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page { padding: 20px; max-width: 1200px; width: 100%; }
.tabbar { display: none; }

.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--bg); color: var(--sub); white-space: nowrap; }
.chip.green { background: var(--green-2); color: var(--green); }
.chip.red { background: var(--red-2); color: var(--red); }
.chip.blue { background: var(--blue-2); color: var(--blue); }
.chip.amber { background: var(--amber-2); color: var(--amber); }
.chip.brand { background: var(--brand-2); color: var(--brand); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #bbb; }
.dot.on { background: var(--green); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 16px; margin-bottom: 14px; }
.card.tight { padding: 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { color: var(--sub); font-size: 12px; }
.stat.warn b { color: var(--red); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top-align { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.list > * + * { border-top: 1px solid var(--line); }
.item { padding: 10px 0; }
.empty { text-align: center; color: var(--sub); padding: 32px 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.banner.warn { background: var(--amber-2); color: var(--amber); }
.banner.err { background: var(--red-2); color: var(--red); }
.banner.info { background: var(--blue-2); color: var(--blue); }
.steps { counter-reset: s; padding-left: 0; list-style: none; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 6px 0 6px 34px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-2); color: var(--brand); font-weight: 700; text-align: center; line-height: 24px; font-size: 12px; }
.steps li.done::before { content: '✓'; background: var(--green-2); color: var(--green); }

/* 表单 */
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }
input[type='checkbox'], input[type='radio'] { width: auto; margin: 0 4px 0 0; accent-color: var(--brand); }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 4px; }
label.c { display: inline-flex; align-items: center; margin-right: 14px; cursor: pointer; }
.help { font-size: 12px; color: var(--sub); margin-top: 3px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 7px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--brand); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.danger { color: var(--red); }
button.ghost { border-color: transparent; background: transparent; }
button.sm { padding: 3px 10px; font-size: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 5px 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: #fff; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #ccc; border-radius: 11px; transition: 0.2s; cursor: pointer; }
.switch i::after { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { left: 18px; }

/* 登录 */
.login { max-width: 380px; margin: 9vh auto; padding: 0 16px; }
.login .logo { text-align: center; margin-bottom: 24px; }
.login .logo img { width: 56px; height: 56px; }
.login .logo h1 { margin-top: 10px; }

/* 消息 */
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; height: calc(100vh - 100px); }
.inbox .pane { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.clist { overflow-y: auto; flex: 1; }
.citem { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.citem:hover { background: var(--bg); }
.citem.on { background: var(--brand-2); }
.citem .n { font-weight: 600; }
.chat { flex: 1; overflow-y: auto; padding: 14px; background: var(--bg); }
.msg { display: flex; margin: 8px 0; }
.msg .b { max-width: 72%; padding: 8px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg.out { justify-content: flex-end; }
.msg.out .b { background: var(--me); border-color: transparent; }
.msg.out.ai .b { background: var(--blue-2); }
.msg .meta { font-size: 11px; color: var(--sub); margin-top: 2px; }
.msg .col { display: flex; flex-direction: column; max-width: 72%; }
.msg.out .col { align-items: flex-end; }
.msg .col .b { max-width: 100%; }
.msg.sys { justify-content: center; font-size: 12px; color: var(--sub); }
.composer { border-top: 1px solid var(--line); padding: 10px; background: var(--card); }
.composer textarea { min-height: 60px; }
.draft { border: 1px dashed var(--blue); background: var(--blue-2); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.why { font-size: 12px; color: var(--sub); }
.why summary { cursor: pointer; }

/* 录音 */
.rec { width: 64px; height: 64px; border-radius: 50%; border: none; background: var(--brand); color: #fff; font-size: 13px; justify-content: center; }
.rec.on { background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5); } 100% { box-shadow: 0 0 0 16px rgba(229, 72, 77, 0); } }

.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 560px; padding: 18px; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: rgba(20, 20, 20, 0.88); color: #fff; padding: 9px 16px; border-radius: 10px; z-index: 99; max-width: 90vw; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--sub); font-weight: 500; font-size: 12px; }
.shot { max-width: 140px; max-height: 260px; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }

@media (max-width: 860px) {
  .side { display: none; }
  .top { padding: 10px 12px; }
  .page { padding: 12px 12px 84px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; text-align: center; padding: 7px 0 6px; font-size: 11px; color: var(--sub); position: relative; }
  .tabbar a.on { color: var(--brand); }
  .tabbar a i { display: block; font-style: normal; font-size: 19px; line-height: 1.2; }
  .tabbar .badge { position: absolute; top: 2px; left: 55%; }
  .inbox { grid-template-columns: minmax(0, 1fr); height: auto; }
  .inbox.detail .pane.l { display: none; }
  .inbox:not(.detail) .pane.r { display: none; }
  .inbox .pane.r { height: calc(100vh - 150px); }
  .msg .b, .msg .col { max-width: 86%; }
}
