:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --text: #171a26;
  --muted: #5c6378;
  --border: #dde1ec;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #e8e7fd;
  --ok: #138a4f;
  --err: #c2372f;
  --warn: #a86400;
  --code-bg: #0f1424;
  --code-text: #dbe2f4;
  --hero: radial-gradient(1200px 400px at 70% -10%, #dcdafc 0%, transparent 60%),
          radial-gradient(800px 300px at 10% 0%, #e4f0ff 0%, transparent 60%);
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 16px rgba(20, 24, 40, .04);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e19; --surface: #131829; --surface-2: #1b2136; --text: #e6e9f4; --muted: #9aa2bb;
    --border: #262d46; --accent: #8b85ff; --accent-text: #0b0e19; --accent-soft: #252450;
    --ok: #3ccf87; --err: #ff7369; --warn: #f0b04a; --code-bg: #0a0d18; --code-text: #dbe2f4;
    --hero: radial-gradient(1200px 400px at 70% -10%, #2a2668 0%, transparent 60%),
            radial-gradient(800px 300px at 10% 0%, #13284a 0%, transparent 60%);
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0e19; --surface: #131829; --surface-2: #1b2136; --text: #e6e9f4; --muted: #9aa2bb;
  --border: #262d46; --accent: #8b85ff; --accent-text: #0b0e19; --accent-soft: #252450;
  --ok: #3ccf87; --err: #ff7369; --warn: #f0b04a; --code-bg: #0a0d18; --code-text: #dbe2f4;
  --hero: radial-gradient(1200px 400px at 70% -10%, #2a2668 0%, transparent 60%),
          radial-gradient(800px 300px at 10% 0%, #13284a 0%, transparent 60%);
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace; font-size: .9em; }
:not(pre) > code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; word-break: break-all; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .88rem; margin: .6em 0 0; }
.wrap { width: 100%; max-width: 1920px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 56px); }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-in { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 34px; height: 34px;
  border-radius: 8px; cursor: pointer; font-size: 16px; flex: none; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 9px; cursor: pointer;
  font: inherit; font-size: .92rem; white-space: nowrap; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { padding: 3px 9px; font-size: .8rem; }

/* 首页 */
.hero { background: var(--hero); padding: 64px 0 40px; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: .85rem; margin: 0 0 .6em; letter-spacing: .04em; }
.hero h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); max-width: 18em; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 40em; }
.baseurl { display: flex; gap: 8px; align-items: stretch; max-width: 560px; margin-top: 24px; }
.baseurl code { flex: 1; min-width: 0; display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 9px; overflow-x: auto; white-space: nowrap; word-break: normal; }
.hero-cta { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi-v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-l { color: var(--muted); font-size: .85rem; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 32px; }
.section-title { margin-top: 8px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card p { margin: .3em 0; }
.card + .card { margin-top: 14px; }
.features .card + .card { margin-top: 0; }
.features .card p { color: var(--muted); font-size: .92rem; }

.code { background: var(--code-bg); color: var(--code-text); padding: 16px; border-radius: 10px; overflow-x: auto;
  margin: 0 0 32px; line-height: 1.55; font-size: .85rem; }
.card .code { margin-bottom: 0; }

/* 页面头 */
.page-head { padding: 32px 0 8px; }

/* 模型广场 */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 12px 0 20px; }
.toolbar input { flex: 1 1 240px; min-width: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); padding: 4px 12px; border-radius: 999px;
  cursor: pointer; font: inherit; font-size: .85rem; }
.chip.active { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; padding-bottom: 32px; }
.model { display: flex; flex-direction: column; gap: 8px; }
.model-grid .card + .card { margin-top: 0; }
.model-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.model h3 { margin: 0; }
.model-id { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font-family: ui-monospace, Consolas, monospace;
  font-size: .86rem; text-align: left; word-break: break-all; }
.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.kind-image { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.levels { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--muted); }
.levels button { font-family: ui-monospace, Consolas, monospace; font-size: .78rem; border: 1px dashed var(--border); background: none;
  color: var(--text); border-radius: 6px; padding: 1px 6px; cursor: pointer; }
.levels button:hover { border-color: var(--accent); }
.model-actions { margin-top: auto; display: flex; gap: 8px; }

/* 在线体验 */
.play { display: grid; grid-template-columns: 260px 1fr; gap: 14px; padding-top: 24px; padding-bottom: 24px; height: calc(100vh - 56px - 60px); min-height: 520px; }
.play-side { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.play-side label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.play-main { display: flex; flex-direction: column; padding: 0; overflow: hidden; min-width: 0; }
.chat { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.empty { margin: auto; text-align: center; color: var(--muted); }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.error { align-self: flex-start; background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.msg pre { background: var(--code-bg); color: var(--code-text); padding: 10px; border-radius: 8px; overflow-x: auto; white-space: pre; margin: 6px 0; }
.msg img { max-width: 100%; border-radius: 8px; display: block; margin-top: 6px; }
.msg .meta { display: block; font-size: .75rem; color: var(--muted); margin-top: 6px; }
.msg .reasoning { display: block; font-size: .82rem; color: var(--muted); border-left: 2px solid var(--border); padding-left: 8px; margin-bottom: 6px; }
.cursor::after { content: "▍"; animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { resize: none; max-height: 200px; }

/* 文档 */
.docs { padding-bottom: 32px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; white-space: nowrap; width: 1%; }
.table tr:last-child th, .table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }
#st-models th { width: auto; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* 状态 */
.bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; height: 140px; align-items: end; margin: 8px 0; }
.bar { display: flex; flex-direction: column-reverse; height: 100%; justify-content: flex-start; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar .ok { background: var(--ok); }
.bar .err { background: var(--err); }
.legend { display: flex; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.sw.ok { background: var(--ok); } .sw.err { background: var(--err); }
.up { color: var(--ok); } .down { color: var(--err); }

.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 18px 0; margin-top: 24px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg);
  padding: 8px 16px; border-radius: 9px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .kpis, .features { grid-template-columns: repeat(2, 1fr); }
  .play { grid-template-columns: 1fr; height: auto; }
  .play-main { height: 70vh; min-height: 420px; }
  .hero { padding: 40px 0 24px; }
}
@media (max-width: 520px) {
  .model-grid { grid-template-columns: minmax(0, 1fr); }
  .brand span { display: none; }
  .topbar-in { gap: 8px; }
  .nav a { padding: 6px 7px; font-size: .9rem; }
  .kpi-v { font-size: 1.2rem; }
  .msg { max-width: 100%; }
  .baseurl { flex-direction: column; }
}
