/* Lovart 一条龙 — 仿 chatgpt2api UI (stone 暖色 · shadcn 质感) */
:root {
  --bg: radial-gradient(circle at top left, rgba(255,255,255,.92), rgba(245,239,231,.96) 42%, rgba(240,235,227,.99) 100%);
  --panel: #ffffff;
  --panel2: #fafaf9;
  --border: #e7e5e4;
  --border2: #d6d3d1;
  --text: #1c1917;
  --dim: #78716c;
  --muted: #a8a29e;
  --primary: #1c1917;
  --primary-hi: #44403c;
  --ring: #d6d3d1;
  --ok: #059669; --ok-bg: #d1fae5; --ok-fg: #065f46;
  --warn: #ea580c; --warn-bg: #ffedd5; --warn-fg: #9a3412;
  --bad: #dc2626; --bad-bg: #fee2e2; --bad-fg: #991b1b;
  --info: #2563eb; --info-bg: #dbeafe; --info-fg: #1e40af;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
.icon { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
.icon.s16 { width: 16px; height: 16px; }

/* ---------- 顶栏 ---------- */
header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,253,250,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.hwrap { max-width: 1440px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 18px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg,#1c1917,#44403c); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; }
nav { display: flex; gap: 2px; height: 58px; overflow-x: auto; }
nav a {
  display: flex; align-items: center; gap: 6px; padding: 0 14px; height: 100%;
  color: var(--dim); font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: .15s;
}
nav a:hover { color: var(--text); }
nav a.on { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
nav a .cnt { font-size: 10.5px; background: var(--border); border-radius: 99px; padding: 1px 7px; color: var(--dim); }
.hspacer { flex: 1; }
.hstats { display: flex; gap: 8px; align-items: center; }
.hchip { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); background: var(--panel); border: 1px solid var(--border); border-radius: 99px; padding: 4px 12px; }
.hchip b { color: var(--text); font-weight: 700; }
.hchip .icon { width: 13px; height: 13px; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot-live.run { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }

/* ---------- 布局 ---------- */
main { max-width: 1440px; margin: 0 auto; padding: 22px 20px 70px; }
section.page { display: none; animation: fadein .18s ease; }
section.page.on { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.pagehead { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pagehead h1 { font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.pagehead .sub { color: var(--dim); font-size: 12.5px; }
.pagehead .grow { flex: 1; }

/* ---------- 卡片 ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(28,25,23,.04); }
.card .chead { display: flex; align-items: center; gap: 8px; padding: 14px 18px 0; }
.card .chead h2 { font-size: 14px; font-weight: 600; }
.card .cbody { padding: 14px 18px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.gside { grid-template-columns: 360px 1fr; }
@media (max-width: 1020px) { .g2, .g3, .gside { grid-template-columns: 1fr; } }

/* ---------- 统计卡 ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; box-shadow: 0 1px 2px rgba(28,25,23,.04); }
.metric .micon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.metric .micon .icon { width: 17px; height: 17px; }
.metric b { display: block; font-size: 21px; font-weight: 700; line-height: 1.1; letter-spacing: -.5px; }
.metric span { display: block; color: var(--dim); font-size: 11.5px; margin-top: 2px; }
.micon.gray { background: #f5f5f4; color: #44403c; }
.micon.green { background: var(--ok-bg); color: var(--ok); }
.micon.orange { background: var(--warn-bg); color: var(--warn); }
.micon.red { background: var(--bad-bg); color: var(--bad); }
.micon.blue { background: var(--info-bg); color: var(--info); }
.micon.violet { background: #ede9fe; color: #7c3aed; }

/* ---------- 表单 ---------- */
textarea, input, select {
  width: 100%; background: #fff; border: 1px solid var(--border2); color: var(--text);
  border-radius: 9px; padding: 8px 12px; font-size: 13px; font-family: inherit;
  transition: border .15s, box-shadow .15s;
}
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--muted); box-shadow: 0 0 0 3px rgba(168,162,158,.18); }
label.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--dim); margin-bottom: 5px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 7px; line-height: 1.65; }

/* ---------- 按钮 (shadcn) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 9px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
  background: var(--primary); color: #fff; transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--primary-hi); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.outline { background: #fff; color: var(--text); border-color: var(--border2); box-shadow: 0 1px 2px rgba(28,25,23,.05); }
.btn.outline:hover { background: var(--panel2); }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.ghost:hover { background: var(--panel2); color: var(--text); }
.btn.destructive { background: var(--bad); color: #fff; }
.btn.destructive:hover { background: #b91c1c; }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn.icononly { padding: 6px; }
.btn.spinner::before { content: ""; width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 表格 ---------- */
.tablewrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; padding: 9px 14px; color: var(--dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--panel2); }
td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #fafaf9; }
td.wrap { white-space: normal; word-break: break-all; min-width: 140px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: #57534e; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge .icon { width: 11px; height: 11px; }
.badge.success { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warning { background: var(--warn-bg); color: var(--warn-fg); }
.badge.danger { background: var(--bad-bg); color: var(--bad-fg); }
.badge.secondary { background: var(--panel2); color: var(--dim); border: 1px solid var(--border); }
.badge.info { background: var(--info-bg); color: var(--info-fg); }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.searchbox { position: relative; flex: 1; min-width: 180px; max-width: 300px; }
.searchbox .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbox input { padding-left: 32px; }
.toolbar select { width: auto; }

/* ---------- 画廊 ---------- */
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.gitem { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: relative; box-shadow: 0 1px 2px rgba(28,25,23,.04); transition: .18s; }
.gitem:hover { box-shadow: 0 6px 20px rgba(28,25,23,.10); transform: translateY(-1px); }
.gitem img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; background: var(--panel2); }
.gitem video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #0c0a09; }
.gmeta { padding: 9px 12px; font-size: 11px; color: var(--dim); line-height: 1.55; }
.gmeta .gp { color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; margin-bottom: 3px; }
.gact { position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; opacity: 0; transition: .15s; }
.gitem:hover .gact { opacity: 1; }
.gact button { background: rgba(255,255,255,.92); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 4px; cursor: pointer; display: flex; }
.gact button:hover { background: #fff; border-color: var(--border2); }
.gspin { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(45deg, #fafaf9 0 12px, #f5f5f4 12px 24px); color: var(--dim); font-size: 12px; flex-direction: column; gap: 10px; }
.gspin .icon { width: 22px; height: 22px; animation: spin 1.2s linear infinite; }

/* ---------- composer ---------- */
.composer textarea { min-height: 120px; font-size: 14px; font-family: inherit; border: none; box-shadow: none; padding: 14px 16px; }
.composer textarea:focus { box-shadow: none; }
.composer .cfoot { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--panel2); border-radius: 0 0 var(--radius) var(--radius); }
.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.recent .ritem { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); cursor: pointer; }
.recent img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }

/* ---------- 设置 ---------- */
.incgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.incitem { display: flex; align-items: center; gap: 7px; font-size: 12.5px; cursor: pointer; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
.incitem:hover { border-color: var(--border2); }

/* ---------- 移动端 ---------- */
.menubtn { display: none; background: transparent; border: none; cursor: pointer; padding: 6px; color: var(--dim); }
@media (max-width: 860px) {
  .menubtn { display: flex; }
  nav { position: fixed; top: 58px; left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--border); box-shadow: 0 12px 40px rgba(28,25,23,.12); flex-direction: column; height: auto; display: none; z-index: 45; }
  nav.open { display: flex; }
  nav a { height: 46px; border-bottom: none; border-left: 3px solid transparent; }
  nav a.on { border-left-color: var(--text); background: var(--panel2); }
  .hstats .hchip:nth-child(n+3) { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
/* ---------- 生图对话流 (仿 chatgpt2api image page: 会话侧栏 + 对话流 + composer) ---------- */
main:has(> .chatpage.on) { padding: 0; }
section.page.chatpage { display: none; }
section.page.chatpage.on { display: grid; grid-template-columns: 240px minmax(0,1fr); gap: 0; height: calc(100vh - 58px); max-width: 1380px; margin: 0 auto; width: 100%; overflow: hidden; }
.convside { display: none; }
@media (min-width: 1024px) { .convside { display: flex; flex-direction: column; border-right: 1px solid var(--border); padding: 12px 10px; gap: 8px; height: 100%; min-height: 0; } }
.convnew { justify-content: center; }
.convlist { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.convitem { padding: 9px 11px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; transition: .12s; }
.convitem:hover { background: var(--panel2); }
.convitem.on { background: #fff; border-color: var(--border); box-shadow: 0 1px 3px rgba(28,25,23,.06); }
.convitem .ctitle { font-size: 13px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; word-break: break-all; }
.convitem.on .ctitle { font-weight: 600; }
.convitem .ctime { font-size: 10.5px; color: var(--muted); margin-top: 3px; display: flex; justify-content: space-between; align-items: center; }
.convitem .cacts { display: none; gap: 2px; }
.convitem:hover .cacts { display: flex; }
.convitem .cacts button { background: none; border: none; cursor: pointer; padding: 2px 4px; color: var(--muted); border-radius: 4px; font-size: 11px; }
.convitem .cacts button:hover { color: var(--text); background: var(--border); }
.convclear { justify-content: flex-start; color: var(--muted); font-size: 12px; }
.convmain { display: flex; flex-direction: column; min-height: 0; min-width: 0; height: 100%; }

.feedwrap { position: relative; flex: 1; min-height: 0; display: flex; }
.feed { flex: 1; overflow-y: auto; min-height: 0; padding: 20px 16px 10px; display: flex; flex-direction: column; gap: 18px; scroll-behavior: smooth; }
.scrolllatest { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(28,25,23,.14); cursor: pointer; font-size: 17px; color: var(--dim); display: none; z-index: 6; align-items: center; justify-content: center; }
.scrolllatest.show { display: flex; }
.msg { display: flex; flex-direction: column; gap: 8px; }
.msg .mhead { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
.msg .mhead .avatar { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg,#1c1917,#44403c); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg .bubble { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; box-shadow: 0 1px 2px rgba(28,25,23,.04); font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg .mtags { display: flex; gap: 6px; flex-wrap: wrap; }
.msg .mresult { display: flex; flex-direction: column; gap: 6px; }
.msg .mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.msg .mgrid img, .msg .mgrid video { width: 100%; border-radius: 12px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.msg .turnacts { display: flex; gap: 4px; margin-top: 2px; opacity: 0; transition: .12s; }
.msg:hover .turnacts { opacity: 1; }
.msg .turnacts button { background: none; border: 1px solid var(--border); border-radius: 7px; padding: 3px 9px; cursor: pointer; font-size: 11px; color: var(--dim); }
.msg .turnacts button:hover { background: var(--panel2); color: var(--text); }
.msg .merr { background: var(--bad-bg); color: var(--bad-fg); border-radius: 12px; padding: 12px 16px; font-size: 13px; }
.msg .mrun { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 13px; background: var(--panel2); border: 1px dashed var(--border2); border-radius: 12px; padding: 14px 18px; }
.msg .mrun .icon { animation: spin 1.2s linear infinite; }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(12,10,9,.88); z-index: 95; display: none; align-items: center; justify-content: center; }
.lightbox.on { display: flex; }
.lightbox img { max-width: 92vw; max-height: 90vh; border-radius: 12px; box-shadow: 0 30px 100px rgba(0,0,0,.5); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); color: #fff; font-size: 26px; cursor: pointer; }
.lb-prev { left: 20px; } .lb-next { right: 20px; }
.lb-close { position: absolute; top: 18px; right: 22px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.12); border: none; color: #fff; font-size: 22px; cursor: pointer; }

/* ---------- 底部 composer ---------- */
.composerbar { position: sticky; bottom: 0; z-index: 5; background: rgba(250,248,245,.92); backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 10px 16px 14px; }
.cbar-inner { max-width: 860px; margin: 0 auto; background: #fff; border: 1px solid var(--border2); border-radius: 16px; box-shadow: 0 4px 24px rgba(28,25,23,.08); overflow: hidden; }
.cbar-inner:focus-within { border-color: var(--muted); }
.cbar-inner textarea { border: none; box-shadow: none; border-radius: 0; font-size: 14px; font-family: inherit; padding: 13px 16px 4px; max-height: 180px; resize: none; background: transparent; }
.cbar-inner textarea:focus { box-shadow: none; }
.cbar-controls { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; flex-wrap: wrap; }
.cbar-select { width: auto; font-size: 12px; padding: 5px 8px; border-radius: 8px; max-width: 220px; }

/* ---------- 模型参数面板 ----------
 * 原实现把参数直接塞进 .cbar-controls 的一行 flex 里, 且 select/input 限宽 110px,
 * 导致: 长选项名被截断、参数多了换行错乱、没有标签看不出哪个是哪个。
 * 改为可展开的独立面板: 带标签的网格布局, 控件占满格子。
 */
.parampanel { border-top: 1px solid var(--border); padding: 12px 14px 10px; background: var(--panel2); }
.paramgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; }
.paramitem { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.paramitem > label {
  font-size: 11px; color: var(--muted); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.paramitem select, .paramitem input {
  width: 100%; font-size: 12.5px; padding: 7px 10px; border-radius: 9px;
  min-width: 0; text-overflow: ellipsis;
}
.paramitem .pdesc { font-size: 10.5px; color: var(--dim); line-height: 1.4; }
.paramfoot { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
#btnParams.on { background: var(--panel2); border-color: var(--dim); }

/* 参数为空时的提示 */
.paramgrid .pempty { grid-column: 1 / -1; font-size: 12px; color: var(--muted); text-align: center; padding: 8px 0; }

.estchip { font-size: 11.5px; color: var(--dim); background: var(--panel2); border: 1px solid var(--border); border-radius: 99px; padding: 4px 11px; margin-left: auto; white-space: nowrap; }
.estchip.bad { color: var(--warn-fg); background: var(--warn-bg); border-color: #fdba74; }
.sendbtn { width: 38px; height: 38px; border-radius: 12px; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.sendbtn span { font-size: 18px; line-height: 1; }
.estdetail { max-width: 860px; margin: 6px auto 0; font-size: 11.5px; color: var(--muted); padding: 0 6px; }
.estdetail .estgrid { display: flex; gap: 14px; flex-wrap: wrap; }
.estdetail .estcell b { color: var(--info); }
.composerbar .refbox { padding: 0; border-bottom: none; }
.composerbar .refitem { width: 52px; height: 52px; }

/* ---------- 参考图 (图生图) ---------- */
.refhead { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; }
.refhead .lbl { flex: 1; font-size: 12px; font-weight: 600; color: var(--dim); }
.refbox { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 16px; min-height: 0; }
.refbox:not(:empty) { border-bottom: 1px solid var(--border); }
.refitem { position: relative; width: 74px; height: 74px; border-radius: 9px; overflow: hidden; border: 1px solid var(--border2); }
.refitem img { width: 100%; height: 100%; object-fit: cover; display: block; }
.refdel { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(28,25,23,.72); color: #fff; border: none; font-size: 12px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.refdel:hover { background: var(--bad); }

/* ---------- 模型参数表单 ---------- */
.pfield { margin-bottom: 10px; }
.pfield select, .pfield input { font-size: 12.5px; padding: 7px 10px; }
.pfield .lbl { display: flex; justify-content: space-between; }

/* ---------- 积分预估 ---------- */
.estgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.estcell { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 6px; text-align: center; }
.estcell b { display: block; font-size: 20px; font-weight: 700; color: var(--info); letter-spacing: -.5px; }
.estcell span { display: block; font-size: 10.5px; color: var(--dim); margin-top: 2px; }
.estcell.est-bad b { color: var(--bad); }
@media (max-width: 560px) { .estgrid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- toast ---------- */
#toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%) translateY(-8px); z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.tmsg { display: flex; align-items: center; gap: 8px; background: #1c1917; color: #fafaf9; border-radius: 10px; padding: 10px 18px; font-size: 13px; box-shadow: 0 8px 30px rgba(28,25,23,.25); opacity: 0; animation: tin .25s ease forwards; max-width: 80vw; }
.tmsg.ok { background: #064e3b; } .tmsg.err { background: #7f1d1d; }
@keyframes tin { to { opacity: 1; transform: translateY(0); } }

/* ---------- dialog ---------- */
.overlay { position: fixed; inset: 0; background: rgba(28,25,23,.45); z-index: 80; display: none; align-items: flex-start; justify-content: center; padding: 80px 16px; }
.overlay.on { display: flex; }
.dialog { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; box-shadow: 0 24px 80px rgba(28,25,23,.3); animation: din .2s ease; }

/* ---------- 登录页 (仿 chatgpt2api /login) ---------- */
#loginOverlay { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at top left, rgba(255,255,255,.92), rgba(245,239,231,.96) 42%, rgba(240,235,227,.99) 100%); }
#loginOverlay.on { display: flex; }
.logincard { width: 100%; max-width: 505px; background: rgba(255,255,255,.95); border: 1px solid rgba(255,255,255,.8); border-radius: 30px; box-shadow: 0 28px 90px rgba(28,25,23,.10); padding: 40px 34px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.loginicon { width: 56px; height: 56px; margin: 0 auto; border-radius: 18px; background: #0c0a09; color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(28,25,23,.2); }
.loginicon .icon { width: 22px; height: 22px; }
.logintitle { font-size: 28px; font-weight: 600; letter-spacing: -.5px; color: #0c0a09; }
.loginsub { font-size: 13.5px; color: var(--dim); line-height: 1.6; margin-bottom: 8px; }
.logincard input { height: 48px; border-radius: 16px; font-size: 14px; padding: 0 18px; }
.loginbtn { height: 48px; width: 100%; border-radius: 16px; font-size: 15px; letter-spacing: 4px; margin-top: 4px; }
.loginhint { font-size: 11.5px; color: var(--muted); line-height: 1.7; margin-top: 6px; }
@keyframes din { from { opacity: 0; transform: scale(.97) translateY(8px); } }
.dialog .dhead { padding: 18px 22px 0; }
.dialog .dhead h3 { font-size: 16px; font-weight: 700; }
.dialog .dhead p { color: var(--dim); font-size: 12.5px; margin-top: 4px; }
.dialog .dbody { padding: 16px 22px; }
.dialog .dfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

/* ---------- 文档/终端 ---------- */
pre.doc { background: #1c1917; color: #d6d3d1; border-radius: var(--radius); padding: 18px; font-size: 12px; overflow-x: auto; line-height: 1.75; font-family: ui-monospace, Consolas, monospace; }
pre.doc .k { color: #a5b4fc; }
.terminal { background: #141210; border-radius: var(--radius); padding: 14px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; height: 400px; overflow-y: auto; white-space: pre-wrap; color: #d6d3d1; line-height: 1.6; }
.empty { text-align: center; color: var(--muted); padding: 46px 20px; font-size: 13px; }
.empty .icon { width: 34px; height: 34px; margin-bottom: 10px; opacity: .4; }

/* ============================================================
   系统体检页 (doctor)
   ============================================================ */
#doctorBody { display: flex; flex-direction: column; gap: 16px; }

.dcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 2px rgba(28,25,23,.04); }
.dcard.ok { border-color: #a7f3d0; background: linear-gradient(180deg,#f0fdf4,var(--panel)); }
.dcard.bad { border-color: #fecaca; background: linear-gradient(180deg,#fef2f2,var(--panel)); }

.dhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.dtitle { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.dhead .dtitle { margin-bottom: 0; }
.dtitle .icon { width: 16px; height: 16px; opacity: .7; }

.dsub { font-size: 12px; color: var(--muted); }
.dlist { margin: 8px 0 0; padding-left: 20px; font-size: 12.5px; color: var(--bad-fg); line-height: 1.9; }
.dlist li { list-style: disc; }

.dcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.dcols .dcard { margin: 0; }

.drow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.drow:last-child { border-bottom: none; }
.dk { color: var(--dim); flex: 0 0 auto; }
.dv { text-align: right; word-break: break-all; }
.dv .icon { width: 13px; height: 13px; }
.dv .mono { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: var(--dim); }
.dhint { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.7; word-break: break-all; }
.dhint.err { color: var(--bad-fg); }

.pipegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pipeitem { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--panel2); }
.pipeitem.ok { border-color: #a7f3d0; background: #f0fdf4; }
.pipeitem.bad { border-color: #fecaca; background: #fef2f2; }
.pname { font-size: 12.5px; font-weight: 600; }
.pstate { font-size: 11.5px; margin-top: 4px; color: var(--muted); }
.pipeitem.ok .pstate { color: var(--ok-fg); }
.pipeitem.bad .pstate { color: var(--bad-fg); }
.pnote { font-size: 11px; color: var(--muted); margin-top: 4px; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 10px; }
.statitem { text-align: center; padding: 10px 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); }
.statitem b { display: block; font-size: 19px; font-weight: 700; line-height: 1.2; }
.statitem span { font-size: 11px; color: var(--muted); }

.badge.danger { background: var(--bad-bg); color: var(--bad-fg); }
.badge.danger .icon { width: 12px; height: 12px; }
.badge .icon { width: 12px; height: 12px; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* ============================================================
   统一 UI 状态块 (加载 / 空 / 错误)
   ============================================================ */
.empty.loading { color: var(--dim); }
.empty.loading .icon { animation: spin 1.2s linear infinite; opacity: .55; }
.empty.error { color: var(--bad-fg); }
.empty.error .icon { opacity: .6; }
.empty.empty .icon { opacity: .35; }
.empty .icon { width: 34px; height: 34px; margin-bottom: 10px; }
.empty > div { line-height: 1.7; }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 表格内的状态块更紧凑 */
td .empty { padding: 26px 16px; font-size: 12.5px; }
td .empty .icon { width: 26px; height: 26px; margin-bottom: 6px; }

/* ============================================================
   标签页 (设置页 / 图片日志页共用)
   ============================================================ */
.tabs { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs .tab {
  padding: 9px 16px; font-size: 13.5px; font-weight: 500; color: var(--muted);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s;
  font-family: inherit;
}
.tabs .tab:hover { color: var(--fg); }
.tabs .tab.on { color: var(--fg); font-weight: 600; border-bottom-color: var(--accent, var(--fg)); }
.tabpane, .setpane { display: none; }
.tabpane.on, .setpane.on { display: block; }
.setpane > .card + .card { margin-top: 16px; }

/* ============================================================
   模型胶囊 (可点击复制)
   ============================================================ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mchip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px 6px 8px; font-size: 12.5px; font-family: ui-monospace, monospace;
  color: var(--fg); background: var(--panel2);
  border: 1px solid var(--border); border-radius: 999px;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.mchip:hover { background: var(--hover, rgba(127,127,127,.12)); border-color: var(--dim); }
.mchip:active { transform: scale(.97); }
.mchip .mt {
  font-size: 9.5px; font-family: inherit; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 5px; border-radius: 4px; background: var(--badge-bg, rgba(127,127,127,.18)); color: var(--muted);
}

/* ============================================================
   提示条 (安全状态 / 环境变量接管)
   ============================================================ */
.notebox {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.65;
  border: 1px solid var(--border); background: var(--panel2);
}
.notebox .icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.notebox code { font-family: ui-monospace, monospace; padding: 1px 5px; border-radius: 4px; background: var(--badge-bg, rgba(127,127,127,.18)); }
.notebox.ok { border-color: var(--ok); background: var(--ok-bg, rgba(40,180,110,.10)); color: var(--ok-fg, inherit); }
.notebox.warn { border-color: var(--warn, #e0a030); background: rgba(224,160,48,.10); }
.notebox.danger { border-color: var(--bad); background: var(--bad-bg); color: var(--bad-fg); }

/* ============================================================
   接口信息格 (接口接入 tab)
   ============================================================ */
.infogrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.infocell {
  padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2);
  display: flex; flex-direction: column; gap: 5px;
}
.infocell span { font-size: 11px; color: var(--muted); }
.infocell code { font-family: ui-monospace, monospace; font-size: 12.5px; word-break: break-all; }

/* 详情弹窗字段网格 */
.dgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 18px; }
.drow { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.drow .dk { color: var(--muted); flex-shrink: 0; }
.drow .dv { text-align: right; word-break: break-all; font-weight: 500; }

/* 设置分组 */
.setgroup { margin-bottom: 20px; }
.setgroup h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 12px; letter-spacing: .02em; }
.setgroup .field { margin-bottom: 12px; }

/* 工具条控件不收缩 (否则标题/输入框会被压成竖排单字) */
.chead h2 { flex-shrink: 0; white-space: nowrap; }
.chead .searchbox { min-width: 170px; }
.chead input[type=date] { width: auto; min-width: 132px; flex-shrink: 0; }
.chead .btn { flex-shrink: 0; }
.chead select { flex-shrink: 0; max-width: 190px; width: auto; }
/* 控件多时换行, 避免溢出到屏幕外 (横向滚动条很难用) */
.chead { flex-wrap: wrap; row-gap: 8px; }
.chead .grow { min-width: 0; }

/* 灯箱 */
#lightboxOverlay { cursor: zoom-out; background: rgba(0,0,0,.86); }
