:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --ink: #10233b;
  --muted: #5b7290;
  --line: #e2ebf5;
  --brand: #1668e3;
  --brand-2: #0ea5a3;
  --brand-soft: #eaf2ff;
  --ok: #0f9d6b;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(16, 35, 59, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(1080px, calc(100% - 40px)); margin: 0 auto; }

/* nav */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: rgba(245, 248, 252, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-size: 16px;
}
.nav-links { display: flex; align-items: center; gap: 18px; font-size: 14px; color: var(--muted); }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--ink); }
.nav-user { font-size: 14px; color: var(--muted); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.15s ease;
  background: var(--surface); color: var(--ink);
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--brand), #2f86f0); color: #fff; box-shadow: 0 8px 20px rgba(22, 104, 227, 0.25); }
.btn-ghost { border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #c7d8ea; }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* hero */
.hero { padding: 72px 0 48px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand-soft); color: var(--brand);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.hero h1 { font-size: clamp(30px, 4.6vw, 46px); line-height: 1.15; margin: 18px 0 14px; letter-spacing: -0.5px; }
.hero h1 em { font-style: normal; background: linear-gradient(120deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { color: var(--muted); font-size: 17px; max-width: 520px; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-meta { margin-top: 22px; display: flex; gap: 22px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.hero-meta strong { color: var(--ink); }

/* code card */
.code-card {
  background: #0b1a2b; border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); color: #d7e5f7; overflow: hidden;
}
.code-card .code-head { display: flex; gap: 6px; margin-bottom: 14px; }
.code-card .dot { width: 10px; height: 10px; border-radius: 50%; background: #24405e; }
.code-card pre { margin: 0; font-family: var(--mono); font-size: 13px; line-height: 1.7; overflow-x: auto; }
.code-card .k { color: #7dd3fc; }
.code-card .s { color: #86efac; }
.code-card .c { color: #64748b; }

/* sections */
.section { padding: 44px 0; }
.section-head { margin-bottom: 24px; }
.section-head h2 { font-size: 26px; margin: 0 0 6px; }
.section-head p { color: var(--muted); margin: 0; }
.grid { display: grid; gap: 18px; }
.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)); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { color: var(--muted); margin: 0; font-size: 14px; }
.model-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.model-id { font-family: var(--mono); font-size: 12px; color: var(--brand); background: var(--brand-soft); padding: 4px 8px; border-radius: 6px; }
.badge { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #ecfdf5; color: var(--ok); font-weight: 600; }
.badge.gray { background: #f1f5f9; color: var(--muted); }

.feature-icon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-size: 18px; margin-bottom: 14px;
}

/* forms / auth */
.auth-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 48px 20px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 34px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 24px; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; background: #fbfdff; color: var(--ink); font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 104, 227, 0.12); background: #fff;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.error-text { color: var(--danger); font-size: 13px; min-height: 20px; margin: 6px 0; }
.switch-line { text-align: center; font-size: 14px; color: var(--muted); margin-top: 18px; }

/* dashboard */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 34px 0 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; margin: 0; }
.page-head p { color: var(--muted); margin: 4px 0 0; font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -0.5px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); }

.progress { height: 10px; background: #eaf1f9; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 20px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head .actions { display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 20px 22px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: var(--mono); font-size: 13px; }
.table-wrap { overflow-x: auto; }

.empty { color: var(--muted); text-align: center; padding: 26px 0; font-size: 14px; }

.alert { border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.alert.info { background: #eff6ff; color: #1d4ed8; }
.alert.warn { background: #fffbeb; color: #b45309; }

/* toast */
#toast-host { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: #10233b; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 24px rgba(0,0,0,0.2); opacity: 0; transform: translateY(8px); transition: 0.2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b91c1c; }
.toast.ok { background: #047857; }

/* modal */
.modal-mask { position: fixed; inset: 0; background: rgba(16, 35, 59, 0.45); display: grid; place-items: center; padding: 20px; z-index: 90; }
.modal { width: min(520px, 100%); background: #fff; border-radius: 18px; padding: 26px; box-shadow: 0 24px 60px rgba(16,35,59,0.25); }
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.secret-box { display: flex; gap: 8px; align-items: center; background: #f4f8fd; border: 1px dashed #b9cfe6; border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }
.secret-box code { flex: 1; font-family: var(--mono); font-size: 13px; word-break: break-all; }

/* playground */
.chat-box { height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fbfdff; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant.pending { color: var(--muted); font-style: italic; }
.chat-input { display: flex; gap: 10px; margin-top: 12px; }
.chat-input textarea { flex: 1; resize: vertical; min-height: 46px; max-height: 140px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 14px; background: #fff; }
.chat-input textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,104,227,0.12); }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .nav-links { gap: 10px; }
  .nav-links .hide-sm { display: none; }
  .page-head { margin-top: 22px; }
  .hero { padding-top: 42px; }
}
