:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f3f4f8;
  --text: #0f172a;
  --text-soft: #5b6478;
  --text-faint: #8b93a7;
  --line: #e5e7ef;
  --line-strong: #d6d9e4;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-text: #ffffff;
  --ok: #0f9d58;
  --warn: #d97706;
  --err: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 32px -12px rgba(16, 24, 40, .18);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f19;
    --bg-soft: #0e1422;
    --surface: #121a2b;
    --surface-2: #162037;
    --text: #e8ecf6;
    --text-soft: #a4aec4;
    --text-faint: #78829a;
    --line: #1e2740;
    --line-strong: #2a3552;
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -20px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.aurora {
  position: fixed;
  inset: -20% -10% auto;
  height: 620px;
  background:
    radial-gradient(46% 52% at 18% 20%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%),
    radial-gradient(40% 46% at 78% 8%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 72%);
  filter: blur(12px);
  opacity: .5;
  pointer-events: none;
  z-index: 0;
}

.wrap { width: min(1080px, calc(100% - 48px)); margin-inline: auto; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

.header-inner { display: flex; align-items: center; gap: 24px; height: 64px; }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; font-weight: 650; letter-spacing: -.01em; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.mark svg { width: 18px; height: 18px; }
.brand-name { font-size: 16px; }
.brand-sub { margin-left: 6px; font-weight: 500; color: var(--text-soft); }

.nav { display: flex; gap: 22px; margin-left: auto; }
.nav a { color: var(--text-soft); text-decoration: none; font-size: 14px; }
.nav a:hover { color: var(--text); }
.header-actions { display: flex; gap: 10px; }

/* ---------- buttons ---------- */
button { font: inherit; cursor: pointer; }

.primary, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 560; font-size: 14.5px; text-decoration: none; transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
.primary { color: var(--accent-text); background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.primary:hover { transform: translateY(-1px); }
.primary:active { transform: translateY(0); }
.primary[disabled], .ghost[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

.ghost { color: var(--text); background: var(--surface); border-color: var(--line-strong); }
.ghost:hover { background: var(--surface-2); }
.ghost.small, .primary.small { padding: 7px 12px; font-size: 13.5px; border-radius: 9px; }
.primary svg, .ghost svg { width: 18px; height: 18px; flex: 0 0 auto; }
.block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 560; }
.link:hover { text-decoration: underline; }
.icon-btn { background: none; border: 0; color: var(--text-faint); padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- hero ---------- */
.hero { position: relative; z-index: 1; padding: 88px 0 64px; text-align: center; }
.eyebrow { display: inline-block; margin: 0 0 18px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-soft); font-size: 12.5px; letter-spacing: .04em; }
.hero h1 { margin: 0 0 18px; font-size: clamp(32px, 5vw, 52px); line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
.lede { max-width: 620px; margin: 0 auto; color: var(--text-soft); font-size: 16.5px; }
.cta { display: flex; gap: 12px; justify-content: center; margin: 30px 0 0; flex-wrap: wrap; }
.trust { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; margin: 34px 0 0; padding: 0; list-style: none; color: var(--text-faint); font-size: 13px; }
.trust li { display: inline-flex; align-items: center; gap: 7px; }
.trust li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }

/* ---------- sections ---------- */
.section { position: relative; z-index: 1; padding: 56px 0; }
.section-title { margin: 0 0 8px; font-size: 26px; letter-spacing: -.02em; }
.section-lede { margin: 0 0 26px; color: var(--text-soft); max-width: 720px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 22px; }
.feature { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.feature .icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); margin-bottom: 12px; }
.feature .icon svg { width: 19px; height: 19px; }
.feature h3 { margin: 0 0 6px; font-size: 15.5px; }
.feature p { margin: 0; color: var(--text-soft); font-size: 14px; }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 18px; }
.steps > li { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.steps h3 { margin: 0 0 12px; font-size: 15px; }
.sub-title { margin: 34px 0 10px; font-size: 16px; }

pre {
  margin: 0 0 10px; padding: 16px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  font-family: var(--mono); font-size: 12.8px; line-height: 1.6; color: var(--text);
}
code { font-family: var(--mono); font-size: .92em; }
p code, li code, .note code, td code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.note { margin: 0; color: var(--text-faint); font-size: 13px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; color: var(--text-soft); background: var(--surface-2); font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
td:nth-child(3) { white-space: normal; color: var(--text-soft); }

.verb { display: inline-block; min-width: 62px; text-align: center; padding: 2px 8px; border-radius: 6px; font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .02em; }
.verb.get { color: #0369a1; background: #e0f2fe; }
.verb.post { color: #15803d; background: #dcfce7; }
.verb.del { color: #b91c1c; background: #fee2e2; }
@media (prefers-color-scheme: dark) {
  .verb.get { color: #93c5fd; background: #172554; }
  .verb.post { color: #86efac; background: #052e16; }
  .verb.del { color: #fca5a5; background: #450a0a; }
}

.site-footer { position: relative; z-index: 1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 40px 0 56px; color: var(--text-faint); font-size: 13px; border-top: 1px solid var(--line); margin-top: 24px; }
.site-footer a { color: var(--text-soft); text-decoration: none; }
.site-footer a:hover { color: var(--text); }
.dot { color: var(--line-strong); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(9, 12, 20, .55); backdrop-filter: blur(4px); animation: fade .18s ease; }
.modal-card {
  position: relative; width: min(420px, 100%); padding: 26px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6);
  animation: pop .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal .close { position: absolute; top: 14px; right: 14px; }

.auth-form { display: none; }
.auth-form.is-active { display: block; }
.auth-form h2 { margin: 0 0 18px; font-size: 20px; letter-spacing: -.01em; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-soft); }
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 14.5px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: 10px; transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: var(--text-faint); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[aria-invalid="true"] { border-color: var(--err); }

.input-action { display: flex; gap: 8px; }
.input-action input { flex: 1 1 auto; width: auto; min-width: 0; }
.input-action button { white-space: nowrap; }

.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--text-faint); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.switch { margin: 14px 0 0; text-align: center; font-size: 13.5px; color: var(--text-soft); }
.switch.muted { margin-top: 6px; }

.meter { display: none; gap: 4px; margin-top: 8px; }
.meter i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); transition: background .2s ease; }
.meter.is-visible { display: flex; }
.meter[data-score="1"] i:nth-child(1) { background: var(--err); }
.meter[data-score="2"] i:nth-child(-n+2) { background: var(--warn); }
.meter[data-score="3"] i { background: var(--ok); }

/* ---------- account ---------- */
.account-page { position: relative; z-index: 1; padding: 56px 0 80px; }
.account-page[hidden] { display: none; }
.account-head { display: flex; align-items: center; gap: 16px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.avatar { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.account-id { display: grid; gap: 2px; }
.account-id strong { font-size: 16px; }
.account-id span { color: var(--text-soft); font-size: 13.5px; }
.account-head .ghost { margin-left: auto; }

.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.account-card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.account-card h2 { margin: 0 0 6px; font-size: 16px; }
.account-card .note { margin: 0 0 16px; }
.account-card form { margin-top: 16px; }

.credential-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.credential-list li { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); font-size: 13.5px; }
.credential-list .cid { font-family: var(--mono); font-size: 12px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.credential-list .meta { margin-left: auto; color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.credential-list button { border: 0; background: none; color: var(--text-faint); padding: 4px; border-radius: 6px; }
.credential-list button:hover { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }
.empty { margin: 0 0 14px; color: var(--text-faint); font-size: 13.5px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  padding: 11px 18px; border-radius: 10px; font-size: 13.5px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 80; max-width: min(90vw, 420px); text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--err); color: #fff; }
.toast.is-ok { background: var(--ok); color: #fff; }

@media (max-width: 720px) {
  .wrap { width: calc(100% - 32px); }
  .nav { display: none; }
  .hero { padding: 56px 0 40px; }
  .br-mobile { display: none; }
  .section { padding: 40px 0; }
  .account-head { flex-wrap: wrap; }
  .account-head .ghost { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- landing actions ---------- */
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.section-cta { margin-top: 18px; display: flex; justify-content: center; }
.header-back { margin-left: auto; }

/* ---------- docs page ---------- */
.docs { padding: 48px 0 72px; position: relative; z-index: 1; }
.docs > h1 { margin: 0 0 12px; font-size: clamp(28px, 4vw, 40px); letter-spacing: -.02em; }
.docs .lede { margin: 0 0 28px; max-width: 760px; }
.docs section { margin-top: 44px; }
.docs section h2 { margin: 0 0 14px; font-size: 22px; letter-spacing: -.01em; }
.docs .steps { margin-top: 6px; }
.toc { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }
.toc a { padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 13px; color: var(--text-soft); text-decoration: none; background: var(--surface); }
.toc a:hover { color: var(--text); border-color: var(--accent); }

/* ---------- admin ---------- */
.admin { position: relative; z-index: 1; padding: 44px 0 80px; }
.admin-login { max-width: 380px; margin: 40px auto 0; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.admin-login h1 { margin: 0 0 20px; font-size: 20px; }
.admin-who { color: var(--text-soft); font-size: 13px; margin-right: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-card { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); display: grid; gap: 4px; }
.stat-card strong { font-size: 24px; letter-spacing: -.02em; }
.stat-card span { color: var(--text-soft); font-size: 12.5px; }

.admin-toolbar { display: flex; gap: 10px; align-items: center; margin: 26px 0 14px; }
.admin-toolbar input[type="search"] { flex: 1; max-width: 320px; padding: 9px 13px; font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; }
.admin-toolbar input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.admin-table td { white-space: nowrap; vertical-align: middle; }
.admin-table td:nth-child(1) { white-space: normal; }
.row-actions { display: flex; gap: 6px; }
.row-actions .danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line-strong)); }
.row-actions .danger:hover { background: color-mix(in srgb, var(--err) 10%, transparent); }

.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.on { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.badge.off { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }
.badge.admin { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* ---------- admin tabs ---------- */
.admin-tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.admin-tab {
  background: none; border: 0; padding: 10px 14px; font-size: 14px; color: var(--text-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.is-active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.admin-panel { display: none; }
.admin-panel.is-active { display: block; }

.apikey-box {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; justify-content: space-between;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); margin-bottom: 26px;
}
.apikey-box .note { margin: 4px 0 0; max-width: 46ch; }
.apikey-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.apikey-row code { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; word-break: break-all; }

.docs-section { margin-bottom: 34px; }
.docs-section h2 { margin: 0 0 10px; font-size: 19px; }
.docs-section .note { margin: 0 0 10px; }
.code-label { margin: 14px 0 6px; font-size: 12.5px; color: var(--text-faint); }

/* ---------- oauth consent ---------- */
.consent { position: relative; z-index: 1; padding: 56px 0 72px; display: grid; place-items: center; }
.consent-card {
  width: min(520px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow);
}
.consent-card h1 { margin: 0 0 10px; font-size: 21px; letter-spacing: -.01em; }
.consent-card h2 { margin: 22px 0 10px; font-size: 14px; color: var(--text-soft); font-weight: 600; }
.consent-user { display: flex; gap: 12px; align-items: center; margin: 20px 0 6px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); }
.consent-user .avatar { width: 42px; height: 42px; font-size: 20px; }
.consent-user div { display: grid; gap: 2px; }
.consent-user span { color: var(--text-soft); font-size: 13px; }
.scope-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.scope-list li { position: relative; padding: 10px 12px 10px 34px; border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; background: var(--bg-soft); }
.scope-list li::before { content: "✓"; position: absolute; left: 12px; top: 9px; color: var(--ok); font-weight: 700; }
.consent-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.consent-actions .primary, .consent-actions .ghost { min-width: 110px; }

/* ---------- profile & grants ---------- */
.avatar-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-option {
  width: 38px; height: 38px; font-size: 19px; line-height: 1; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg); display: grid; place-items: center;
}
.avatar-option.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.credential-list .meta { max-width: 60%; overflow: hidden; text-overflow: ellipsis; }

/* ---------- admin apps ---------- */
.app-create { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 26px; }
.app-create h2 { margin: 0 0 6px; font-size: 16px; }
.app-create .note { margin: 0 0 16px; }
.scope-picker { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; display: grid; gap: 8px; }
.scope-picker legend { padding: 0 6px; font-size: 12.5px; color: var(--text-soft); }
.scope-picker label { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
textarea {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 14px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: 10px; resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.secret-box { margin-top: 18px; padding: 16px; border: 1px dashed var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.secret-box strong { display: block; margin-bottom: 10px; font-size: 13.5px; }
.app-desc { margin-top: 4px; font-size: 12.5px; color: var(--text-faint); }
.app-redirects { white-space: pre-line; font-family: var(--mono); font-size: 11.5px; color: var(--text-soft); }
