/* doubao2api 控制台样式
   设计基调参考 grok2api：中性灰阶、8px 圆角、紧凑排版、明暗双主题。 */

:root {
  --radius: 0.5rem;
  --background: oklch(0.995 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(0.975 0.002 90);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --secondary: oklch(0.965 0.002 90);
  --secondary-foreground: oklch(0.2 0 0);
  --muted: oklch(0.965 0.002 90);
  --muted-foreground: oklch(0.55 0 0);
  --accent: oklch(0.95 0.003 90);
  --accent-foreground: oklch(0.16 0 0);
  --destructive: oklch(0.58 0.22 27);
  --success: oklch(0.62 0.15 150);
  --warning: oklch(0.72 0.15 80);
  --info: oklch(0.62 0.13 240);
  --border: oklch(0.91 0 0);
  --input: oklch(0.9 0 0);
  --sidebar: oklch(0.995 0 0);
  --sidebar-foreground: oklch(0.18 0 0);
  --sidebar-accent: oklch(0.96 0 0);
  --sidebar-border: oklch(0.93 0 0);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.05);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.08);
}

html.dark {
  --background: oklch(0.13 0 0);
  --foreground: oklch(0.95 0 0);
  --card: oklch(0.18 0 0);
  --card-foreground: oklch(0.95 0 0);
  --popover: oklch(0.17 0 0);
  --secondary: oklch(0.21 0 0);
  --secondary-foreground: oklch(0.94 0 0);
  --muted: oklch(0.21 0 0);
  --muted-foreground: oklch(0.64 0 0);
  --accent: oklch(0.24 0 0);
  --accent-foreground: oklch(0.96 0 0);
  --destructive: oklch(0.65 0.2 28);
  --success: oklch(0.7 0.14 150);
  --warning: oklch(0.79 0.14 80);
  --info: oklch(0.7 0.12 240);
  --border: oklch(0.27 0 0);
  --input: oklch(0.3 0 0);
  --sidebar: oklch(0.145 0 0);
  --sidebar-foreground: oklch(0.92 0 0);
  --sidebar-accent: oklch(0.22 0 0);
  --sidebar-border: oklch(0.25 0 0);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-md: 0 4px 14px oklch(0 0 0 / 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code, pre { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }

.hidden { display: none !important; }

/* ---------------- 登录页 ---------------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--background);
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-md);
}

.login-brand { display: flex; align-items: center; gap: 11px; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-version {
  font-size: 10.5px; font-weight: 500; color: var(--muted-foreground);
  padding: 1px 5px; border-radius: 999px;
  background: var(--secondary); border: 1px solid var(--border);
}
.brand-sub { font-size: 12px; color: var(--muted-foreground); }
.brand-mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--foreground);
  color: var(--background);
  font-size: 14px; font-weight: 600;
}
.login-hint { margin: 0; font-size: 13px; color: var(--muted-foreground); }
.login-error {
  margin: 0; font-size: 12px; color: var(--destructive);
  background: color-mix(in oklch, var(--destructive) 10%, transparent);
  border: 1px solid color-mix(in oklch, var(--destructive) 30%, transparent);
  padding: 7px 10px; border-radius: var(--radius);
}
.login-foot { margin: 0; font-size: 11px; color: var(--muted-foreground); text-align: center; }
.login-foot code { font-size: 10.5px; }

/* ---------------- 布局 ---------------- */

.shell { min-height: 100vh; background: var(--background); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: 248px; height: 100vh;
  display: flex; flex-direction: column;
  padding: 20px 14px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  overflow: hidden;
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px; margin-bottom: 22px; flex: none;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand .brand-mark { width: 26px; height: 26px; font-size: 12px; border-radius: 7px; }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  height: 33px; padding: 0 9px;
  border-radius: var(--radius);
  font-size: 13px; color: var(--muted-foreground);
  transition: background-color .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-accent); color: var(--foreground); }
.nav-item.active { background: var(--sidebar-accent); color: var(--foreground); font-weight: 500; }
.nav-icon { width: 17px; height: 17px; flex: none; display: grid; place-items: center; opacity: .85; }
.nav-icon svg { width: 16px; height: 16px; stroke-width: 1.8; }
.nav-divider {
  margin: 18px 0 6px; padding: 0 9px;
  font-size: 11.5px; color: var(--foreground); opacity: .9;
}

.sidebar-foot { flex: none; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--sidebar-border); }
.user-chip { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 500; }
.user-status { font-size: 11px; color: var(--muted-foreground); }

.content-wrap {
  min-height: 100vh;
  margin-left: 248px;
  display: flex; flex-direction: column;
}
.content { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 30px 28px 40px; }
.site-foot {
  padding: 16px 28px 26px; text-align: center;
  font-size: 11.5px; color: var(--muted-foreground);
}
.site-foot a { text-decoration: underline; text-underline-offset: 2px; }

.mobile-bar {
  display: none; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  position: sticky; top: 0; z-index: 40;
}

/* ---------------- 通用组件 ---------------- */

.page-head { margin-bottom: 22px; }
.page-title { font-size: 19px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.page-desc { margin: 5px 0 0; font-size: 13px; color: var(--muted-foreground); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 13.5px; font-weight: 600; margin: 0; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }

.stat {
  padding: 14px 15px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 11.5px; color: var(--muted-foreground); margin: 0 0 6px; }
.stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0; line-height: 1.15; }
.stat-unit { font-size: 12px; font-weight: 400; color: var(--muted-foreground); margin-left: 3px; }
.stat-hint { font-size: 11px; color: var(--muted-foreground); margin: 5px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px;
  font-size: 12.5px; font-weight: 500; font-family: inherit;
  color: var(--foreground);
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--foreground); color: var(--background); border-color: var(--foreground); }
.btn-primary:hover:not(:disabled) { opacity: .88; background: var(--foreground); }
.btn-secondary { background: var(--secondary); }
.btn-danger { color: var(--destructive); border-color: color-mix(in oklch, var(--destructive) 35%, transparent); }
.btn-danger:hover:not(:disabled) { background: color-mix(in oklch, var(--destructive) 10%, transparent); }
.btn-sm { height: 25px; padding: 0 9px; font-size: 11.5px; }
.btn-block { width: 100%; }
.btn svg { width: 14px; height: 14px; }

.icon-btn {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border: none; border-radius: var(--radius);
  background: transparent; color: var(--muted-foreground);
  cursor: pointer; transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--accent); color: var(--foreground); }
.icon-btn svg { width: 15px; height: 15px; stroke-width: 1.8; }

.input, .textarea, .select {
  width: 100%;
  min-height: 31px;
  padding: 6px 10px;
  font-size: 13px; font-family: inherit;
  color: var(--foreground);
  background: var(--popover);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 78px; resize: vertical; line-height: 1.6; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--foreground);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--foreground) 10%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.select { appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23888' stroke-width='1.6'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12px; font-weight: 500; color: var(--foreground); }
.label-sub { font-size: 11px; color: var(--muted-foreground); font-weight: 400; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px;
  font-size: 11px; font-weight: 500;
  border-radius: 999px;
  background: var(--secondary); color: var(--secondary-foreground);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-ok { background: color-mix(in oklch, var(--success) 14%, transparent); color: var(--success); border-color: color-mix(in oklch, var(--success) 30%, transparent); }
.badge-warn { background: color-mix(in oklch, var(--warning) 16%, transparent); color: var(--warning); border-color: color-mix(in oklch, var(--warning) 32%, transparent); }
.badge-err { background: color-mix(in oklch, var(--destructive) 12%, transparent); color: var(--destructive); border-color: color-mix(in oklch, var(--destructive) 30%, transparent); }
.badge-info { background: color-mix(in oklch, var(--info) 13%, transparent); color: var(--info); border-color: color-mix(in oklch, var(--info) 30%, transparent); }

.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-weight: 500; font-size: 11.5px;
  color: var(--muted-foreground);
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--secondary);
  position: sticky; top: 0;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: color-mix(in oklch, var(--accent) 55%, transparent); }
.table-wrap { overflow-x: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.muted { color: var(--muted-foreground); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.empty {
  padding: 40px 20px; text-align: center;
  color: var(--muted-foreground); font-size: 13px;
}
.empty-icon { font-size: 22px; opacity: .4; display: block; margin-bottom: 8px; }

.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.spacer { flex: 1; }

.row { display: flex; align-items: center; gap: 9px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; word-break: break-all; }

.copy-field { display: flex; gap: 7px; align-items: center; }
.copy-field .input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.alert {
  padding: 10px 13px; border-radius: var(--radius); font-size: 12.5px;
  border: 1px solid var(--border); background: var(--secondary);
}
.alert-ok { background: color-mix(in oklch, var(--success) 10%, transparent); border-color: color-mix(in oklch, var(--success) 28%, transparent); color: var(--success); }
.alert-err { background: color-mix(in oklch, var(--destructive) 10%, transparent); border-color: color-mix(in oklch, var(--destructive) 28%, transparent); color: var(--destructive); }
.alert-warn { background: color-mix(in oklch, var(--warning) 12%, transparent); border-color: color-mix(in oklch, var(--warning) 30%, transparent); color: var(--warning); }

/* ---------------- 试聊 ---------------- */

.chat-wrap { display: grid; grid-template-columns: 250px 1fr; gap: 14px; align-items: start; }
.chat-side { display: flex; flex-direction: column; gap: 10px; }
.chat-main { display: flex; flex-direction: column; min-height: 460px; }
.chat-log { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; max-height: 560px; }
.msg { display: flex; flex-direction: column; gap: 5px; }
.msg-role { font-size: 11px; color: var(--muted-foreground); font-weight: 500; }
.msg-body {
  padding: 10px 13px; border-radius: var(--radius);
  background: var(--secondary); font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
.msg-user .msg-body { background: color-mix(in oklch, var(--info) 10%, var(--secondary)); }
.msg-thinking .msg-body { background: color-mix(in oklch, var(--warning) 10%, transparent); color: var(--muted-foreground); font-size: 12.5px; font-style: italic; }
.chat-input { display: flex; gap: 9px; padding: 13px; border-top: 1px solid var(--border); align-items: flex-end; }

/* ---------------- 登录/账号页 ---------------- */

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 13px; padding: 20px; }
.qr-image { width: 210px; height: 210px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; padding: 8px; }
.qr-image img { width: 100%; height: 100%; display: block; }

.tabs { display: flex; gap: 3px; padding: 3px; background: var(--muted); border-radius: var(--radius); width: fit-content; }
.tab {
  height: 26px; padding: 0 12px; font-size: 12.5px; font-family: inherit;
  border: none; border-radius: calc(var(--radius) - 2px);
  background: transparent; color: var(--muted-foreground); cursor: pointer;
}
.tab.active { background: var(--popover); color: var(--foreground); font-weight: 500; box-shadow: var(--shadow-sm); }

/* ---------------- 文档页 ---------------- */

.docs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
pre.code {
  margin: 0; padding: 13px 15px;
  background: var(--secondary); border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11.5px; line-height: 1.65;
  overflow-x: auto; white-space: pre;
  max-width: 100%;
}
.code-block { min-width: 0; }
.docs-grid > .card { min-width: 0; overflow: hidden; }
.docs-grid > .card > .card-body { min-width: 0; }
.code-block { margin: 0 0 13px; }
.code-block:last-child { margin-bottom: 0; }
.code-title { font-size: 11.5px; color: var(--muted-foreground); margin: 0 0 6px; font-weight: 500; }
.endpoint { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.method { font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 4px; }
.method-get { background: color-mix(in oklch, var(--info) 15%, transparent); color: var(--info); }
.method-post { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.method-put { background: color-mix(in oklch, var(--warning) 16%, transparent); color: var(--warning); }
.method-delete { background: color-mix(in oklch, var(--destructive) 13%, transparent); color: var(--destructive); }

/* ---------------- 提示条 ---------------- */

.toast-root {
  position: fixed; right: 16px; bottom: 16px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  min-width: 220px; max-width: 380px;
  padding: 10px 13px; font-size: 12.5px;
  background: var(--popover); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: toast-in .18s ease-out;
}
.toast-ok { border-left: 3px solid var(--success); }
.toast-err { border-left: 3px solid var(--destructive); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 13px; height: 13px; flex: none;
  border: 2px solid color-mix(in oklch, currentColor 25%, transparent);
  border-top-color: currentColor; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .sidebar { display: none; }
  .content-wrap { margin-left: 0; }
  .mobile-bar { display: flex; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 32px; }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dd { margin-bottom: 8px; }
}
