/* ==========================================================================
   寒曦朦 API · 设计系统
   视觉语言对齐 shadcn-admin：中性色板 / 1px 细边 / 0.625rem 圆角 / 低对比阴影
   ========================================================================== */

/* ---------- 1. Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd,
ul,
ol {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ---------- 2. Design tokens ---------- */
:root {
  --radius: 0.625rem;

  --background: #ffffff;
  --foreground: #0b1220;
  --card: #ffffff;
  --card-foreground: #0b1220;
  --popover: #ffffff;
  --popover-foreground: #0b1220;
  --primary: #1e293b;
  --primary-foreground: #f8fafc;
  --secondary: #f1f5f9;
  --secondary-foreground: #1e293b;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --accent: #f1f5f9;
  --accent-foreground: #1e293b;
  --destructive: #e7000b;
  --destructive-foreground: #ffffff;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #94a3b8;

  --sidebar: #ffffff;
  --sidebar-foreground: #0b1220;
  --sidebar-primary: #1e293b;
  --sidebar-primary-foreground: #f8fafc;
  --sidebar-accent: #f1f5f9;
  --sidebar-accent-foreground: #1e293b;
  --sidebar-border: #e2e8f0;

  --header-bg: rgba(255, 255, 255, 0.78);
  --code-bg: #0b1220;
  --code-fg: #e2e8f0;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.05);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;

  --sidebar-width: 16rem;
  --header-height: 3.5rem;
}

.dark {
  --background: #0b1220;
  --foreground: #f8fafc;
  --card: #111a2b;
  --card-foreground: #f8fafc;
  --popover: #16202f;
  --popover-foreground: #f8fafc;
  --primary: #e2e8f0;
  --primary-foreground: #1e293b;
  --secondary: #1e293b;
  --secondary-foreground: #f8fafc;
  --muted: #1e293b;
  --muted-foreground: #90a1b9;
  --accent: #1e293b;
  --accent-foreground: #f8fafc;
  --destructive: #ff6467;
  --destructive-foreground: #0b1220;
  --border: rgba(255, 255, 255, 0.1);
  --input: rgba(255, 255, 255, 0.14);
  --ring: #64748b;

  --sidebar: #0b1220;
  --sidebar-foreground: #f8fafc;
  --sidebar-primary: #e2e8f0;
  --sidebar-primary-foreground: #1e293b;
  --sidebar-accent: #1e293b;
  --sidebar-accent-foreground: #f8fafc;
  --sidebar-border: rgba(255, 255, 255, 0.1);

  --header-bg: rgba(11, 18, 32, 0.78);
  --code-bg: #060b14;
  --code-fg: #e2e8f0;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
}

/* ---------- 3. Base ---------- */
html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}

html.dark {
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--foreground);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

::selection {
  background: color-mix(in oklab, var(--primary) 22%, transparent);
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--muted-foreground) 32%, transparent);
  border-radius: 999px;
  border: 3px solid var(--background);
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklab, var(--muted-foreground) 55%, transparent);
}

/* ---------- 4. App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100svh;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  /* 超宽屏下把内容居中，避免全部挤在左侧、右侧留下大片空白 */
  margin-inline: auto;
  padding: 1.75rem 2rem 3rem;
}

@media (min-width: 1536px) {
  .content {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }
}

/* ---------- 5. Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: 100svh;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  height: var(--header-height);
  padding: 0 1rem;
  flex: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 0.5rem;
  background: var(--primary);
  color: var(--primary-foreground);
  flex: none;
}

.brand-mark svg {
  width: 1rem;
  height: 1rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.brand-title {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nav-group-label {
  padding: 0 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  color: var(--sidebar-foreground);
  transition: background-color 0.12s ease, color 0.12s ease;
  position: relative;
}

.nav-item svg {
  width: 1rem;
  height: 1rem;
  flex: none;
  opacity: 0.75;
}

.nav-item:hover {
  background: var(--sidebar-accent);
}

.nav-item.is-active {
  background: var(--sidebar-accent);
  font-weight: 500;
}

.nav-item.is-active svg {
  opacity: 1;
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 0.375rem;
  bottom: 0.375rem;
  width: 2px;
  border-radius: 2px;
  background: var(--sidebar-primary);
}

.nav-item .nav-count {
  margin-left: auto;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
}

.sidebar-footer {
  flex: none;
  border-top: 1px solid var(--sidebar-border);
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  flex: 1;
}

.avatar {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 600;
  flex: none;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-sub {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 6. Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--header-height);
  /* 与居中的内容区左右对齐：超宽屏时跟随内容缩进，窄屏保持原来的 1.5rem */
  padding-block: 0;
  padding-inline: max(1.5rem, calc((100% - 1440px) / 2 + 2rem));
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(12px) saturate(140%);
  flex: none;
}

.header-sep {
  width: 1px;
  height: 1.25rem;
  background: var(--border);
  flex: none;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  min-width: 0;
}

.breadcrumb a:hover {
  color: var(--foreground);
}

.breadcrumb .current {
  color: var(--foreground);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb svg {
  width: 0.875rem;
  height: 0.875rem;
  opacity: 0.5;
  flex: none;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.btn.sidebar-toggle {
  display: none;
}

/* 主题图标：浅色显示月亮，深色显示太阳 */
.only-dark {
  display: none;
}

.dark .only-light {
  display: none;
}

.dark .only-dark {
  display: inline-flex;
}

.hide-sm {
  display: inline;
}

/* ---------- 7. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2.25rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease,
    opacity 0.12s ease;
  user-select: none;
}

.btn svg {
  width: 1rem;
  height: 1rem;
  flex: none;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background: color-mix(in oklab, var(--primary) 88%, var(--background));
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.btn-secondary:hover {
  background: color-mix(in oklab, var(--secondary) 88%, var(--foreground));
}

.btn-outline {
  border-color: var(--border);
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-ghost {
  color: var(--foreground);
}

.btn-ghost:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.75rem;
}

.btn-sm svg {
  width: 0.875rem;
  height: 0.875rem;
}

.btn-lg {
  height: 2.5rem;
  padding: 0 1.5rem;
}

.btn-icon {
  width: 2.25rem;
  padding: 0;
  flex: none;
}

.btn-icon.btn-sm {
  width: 2rem;
}

.btn-block {
  width: 100%;
}

/* ---------- 8. Cards ---------- */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1.375rem 1.375rem 0;
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-description {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  line-height: 1.55;
}

.card-content {
  padding: 1.375rem;
}

.card-header + .card-content {
  padding-top: 1rem;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.375rem 1.375rem;
}

/* 接口卡片：可点击的整块 */
.api-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.125rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.api-card:hover {
  border-color: color-mix(in oklab, var(--foreground) 25%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.api-card-top {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.api-icon {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  flex: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.api-icon svg {
  width: 1.0625rem;
  height: 1.0625rem;
}

.api-card:hover .api-icon {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.api-card-name {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.api-card-desc {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  line-height: 1.55;
}

.api-card-foot {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.api-card-arrow {
  margin-left: auto;
  color: var(--muted-foreground);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.api-card:hover .api-card-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ---------- 9. Badge / kbd ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 1.375rem;
  padding: 0 0.4375rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.badge-outline {
  border-color: var(--border);
  color: var(--muted-foreground);
}

.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-solid {
  background: var(--primary);
  color: var(--primary-foreground);
}

.badge-success {
  background: color-mix(in oklab, #16a34a 14%, transparent);
  color: #15803d;
  border-color: color-mix(in oklab, #16a34a 24%, transparent);
}

.dark .badge-success {
  color: #4ade80;
}

.badge-warning {
  background: color-mix(in oklab, #f59e0b 16%, transparent);
  color: #b45309;
  border-color: color-mix(in oklab, #f59e0b 26%, transparent);
}

.dark .badge-warning {
  color: #fbbf24;
}

.badge-info {
  background: color-mix(in oklab, #3b82f6 14%, transparent);
  color: #1d4ed8;
  border-color: color-mix(in oklab, #3b82f6 24%, transparent);
}

.dark .badge-info {
  color: #60a5fa;
}

.badge-danger {
  background: color-mix(in oklab, var(--destructive) 14%, transparent);
  color: var(--destructive);
  border-color: color-mix(in oklab, var(--destructive) 24%, transparent);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3125rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 0.3125rem;
  background: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

/* ---------- 10. Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4375rem;
}

.label {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
}

.input,
.select,
.textarea {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  font-size: 0.8125rem;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.textarea {
  height: auto;
  min-height: 5rem;
  padding: 0.5rem 0.75rem;
  line-height: 1.6;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-foreground);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 24%, transparent);
}

.input-with-icon {
  position: relative;
}

.input-with-icon svg {
  position: absolute;
  left: 0.6875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.9375rem;
  height: 0.9375rem;
  color: var(--muted-foreground);
  pointer-events: none;
}

.input-with-icon .input {
  padding-left: 2.125rem;
}

.form-row {
  display: flex;
  gap: 0.5rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.form-error {
  font-size: 0.75rem;
  color: var(--destructive);
}

/* ---------- 开关 ---------- */
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
}

.switch {
  position: relative;
  flex: none;
  width: 2.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
}

.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--input);
  transition: background 0.15s ease;
  pointer-events: none;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: var(--background);
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(1rem);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 24%, transparent);
}

.switch-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.switch-title {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

.switch-desc {
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--muted-foreground);
  font-weight: 400;
}

/* ---------- 11. Table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table {
  font-size: 0.8125rem;
}

.table th {
  height: 2.5rem;
  padding: 0 0.75rem;
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: color-mix(in oklab, var(--muted) 60%, transparent);
}

.table code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* ---------- 12. Tabs ---------- */
.tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tab {
  position: relative;
  height: 2.375rem;
  padding: 0 0.75rem;
  border: 0;
  background: none;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s ease;
}

.tab:hover {
  color: var(--foreground);
}

.tab.is-active {
  color: var(--foreground);
  font-weight: 500;
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--foreground);
}

.tab-panel[hidden] {
  display: none;
}

/* ---------- 13. Code block ---------- */
/* ---------- 接口预览 ---------- */
.preview-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

.preview-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.select-sm {
  width: auto;
  min-width: 5rem;
  height: 1.875rem;
  padding: 0 1.5rem 0 0.5rem;
  font-size: 0.75rem;
}

.preview-quote {
  margin: 0;
  padding: 0.875rem 1rem;
  border-left: 3px solid var(--primary);
  border-radius: 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0;
  background: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.9;
  min-height: 4.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
}

.preview-media-image {
  min-height: 7rem;
}

.preview-media img {
  display: block;
  max-width: 100%;
  max-height: 180px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  object-fit: contain;
}

.preview-media-image img {
  max-height: 320px;
}

.preview-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 1px);
  background: #000;
}

.preview-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.code {
  position: relative;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 1px);
  background: var(--code-bg);
  color: var(--code-fg);
  overflow: hidden;
}

.code-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.125rem;
  padding: 0 0.5rem 0 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.6875rem;
  color: rgba(226, 232, 240, 0.55);
  font-family: var(--font-mono);
}

.code-lang {
  margin-right: auto;
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 1.5rem;
  padding: 0 0.4375rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.3125rem;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(226, 232, 240, 0.7);
  font-size: 0.6875rem;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.code-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.code-copy svg {
  width: 0.8125rem;
  height: 0.8125rem;
}

.code-copy.is-copied {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
}

.code pre {
  margin: 0;
  padding: 0.875rem 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
}

.code pre code {
  font-family: inherit;
  color: inherit;
}

.code-inline {
  padding: 0.125rem 0.3125rem;
  border: 1px solid var(--border);
  border-radius: 0.3125rem;
  background: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78em;
  color: var(--foreground);
}

/* ---------- 14. Page header ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.page-desc {
  margin-top: 0.3125rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  max-width: 46rem;
  line-height: 1.65;
}

.page-head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 2rem 0 0.875rem;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-count {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

.section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- 15. Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.875rem;
  margin-bottom: 0.5rem;
}

.stat {
  padding: 1rem 1.125rem;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.stat-label svg {
  width: 0.875rem;
  height: 0.875rem;
}

.stat-value {
  margin-top: 0.4375rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-sub {
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

/* ---------- 16. Grid ---------- */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 0.875rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* 文档页：左主右辅 */
.doc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .doc-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted-foreground);
}

.mono {
  font-family: var(--font-mono);
}

/* 行内图标：与文字同高，用于正文里的箭头、状态等，替代 emoji 与符号字符 */
.icon-inline {
  display: inline-flex;
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.125em;
}

.icon-inline svg {
  width: 100%;
  height: 100%;
}

.text-xs {
  font-size: 0.75rem;
}

.text-sm {
  font-size: 0.8125rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

/* 文本类接口的句子展示区 */
.quote {
  min-height: 5rem;
  display: flex;
  align-items: center;
  padding: 1.25rem 1.375rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--muted);
  font-size: 1.0625rem;
  line-height: 1.8;
  letter-spacing: 0.01em;
  color: var(--foreground);
  transition: opacity 0.15s ease;
}

.quote.is-loading {
  opacity: 0.45;
}

.quote-from {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-align: right;
}

/* ---------- 17. Alert ---------- */
.alert {
  display: flex;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.alert svg {
  width: 1rem;
  height: 1rem;
  flex: none;
  margin-top: 0.125rem;
  color: var(--muted-foreground);
}

.alert-danger {
  border-color: color-mix(in oklab, var(--destructive) 35%, var(--border));
  background: color-mix(in oklab, var(--destructive) 8%, transparent);
  color: var(--destructive);
}

.alert-success {
  border-color: color-mix(in oklab, #16a34a 32%, var(--border));
  background: color-mix(in oklab, #16a34a 8%, transparent);
  color: #15803d;
}

.dark .alert-success {
  color: #4ade80;
}

/* ---------- 18. Auth ---------- */
.auth {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in oklab, var(--muted) 70%, transparent), transparent 55%),
    var(--background);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.auth-brand .brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
}

.auth-brand .brand-mark svg {
  width: 1.125rem;
  height: 1.125rem;
}

.auth-brand-name {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  box-shadow: var(--shadow-md);
}

.auth-card .card-header {
  padding: 1.75rem 1.75rem 0;
  text-align: center;
  align-items: center;
  gap: 0.375rem;
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-desc {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.auth-card .card-content {
  padding: 1.5rem 1.75rem;
}

.auth-card .card-footer {
  padding: 0 1.75rem 1.5rem;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  gap: 0.25rem;
}

.auth-card .card-footer a {
  color: var(--foreground);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-terms {
  max-width: 26rem;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

.auth-terms a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.captcha-row {
  display: grid;
  grid-template-columns: 1fr 6.5rem;
  gap: 0.5rem;
}

.captcha-img {
  height: 2.25rem;
  width: 100%;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: #fff;
  cursor: pointer;
  object-fit: contain;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- 19. Progress ---------- */
.progress {
  height: 0.375rem;
  border-radius: 999px;
  background: var(--muted);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.4s ease;
}

/* 每日趋势：纯 CSS 柱状图，柱高由内联 height 控制，悬停有原生 tooltip */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 7rem;
  padding-top: 0.5rem;
}

.spark-col {
  flex: 1;
  display: flex;
  align-items: flex-end;
  height: 100%;
  min-width: 2px;
}

.spark-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 2px;
  background: var(--primary);
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.spark-col:hover .spark-bar {
  opacity: 1;
}

/* 分时图里没有调用的整点保留一根浅色占位柱，避免 24 根柱子错位 */
.spark-bar.is-empty {
  background: var(--border);
  opacity: 0.7;
}

.spark-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

/* 仪表盘的时间区间筛选：桌面靠右，窄屏独占一行并允许日期框收缩 */
.range-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.range-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
}

.range-date {
  width: 9.5rem;
}

@media (max-width: 640px) {
  .range-custom {
    margin-left: 0;
    width: 100%;
  }

  .range-date {
    flex: 1 1 7rem;
    width: auto;
    min-width: 0;
  }
}

/* ---------- 20. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  z-index: 90;
  transform: translate(-50%, 1rem);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);
  font-size: 0.8125rem;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast svg {
  width: 0.9375rem;
  height: 0.9375rem;
  color: #16a34a;
}

/* ---------- 21. Backdrop (mobile sidebar) ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(8, 12, 20, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

/* ---------- 22. Responsive ---------- */
@media (max-width: 1180px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1023px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 17rem;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
  }

  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app.sidebar-open .backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-toggle,
  .btn.sidebar-toggle {
    display: inline-flex;
  }

  .content {
    padding: 1.25rem 1.125rem 2.5rem;
  }

  .header {
    padding: 0 1rem;
  }
}

@media (max-width: 640px) {
  .page-title {
    font-size: 1.25rem;
  }

  .hide-sm {
    display: none;
  }

  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .grid-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.625rem;
  }

  .stat {
    padding: 0.875rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .breadcrumb .crumb-root {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
