:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --fg: #0a0a0a;
  --fg-2: #565656;
  --fg-3: #6b6b6b;
  --line: #ebebeb;
  --line-2: rgba(0, 0, 0, 0.08);
  --hover: #f2f2f2;
  --tint: #fafafa;

  --accent: #0070f3;
  --accent-ink: #005cc5;
  --accent-bg: #ebf5ff;
  --focus: #0070f3;

  --ok: #1a7f37;
  --ok-bg: #e6f6ea;
  --danger: #e5484d;
  --danger-ink: #c62a2f;
  --danger-bg: #fef1f1;

  --shadow-border: 0 0 0 1px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 0 0 1px rgba(0, 0, 0, 0.07), 0 1px 1px rgba(0, 0, 0, 0.03),
    0 6px 12px -6px rgba(0, 0, 0, 0.05);
  --shadow-pop: 0 1px 1px rgba(0, 0, 0, 0.02), 0 4px 8px rgba(0, 0, 0, 0.04),
    0 16px 40px -16px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);

  --r1: 6px;
  --r2: 8px;
  --r3: 12px;

  --sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #d3e3ff; color: #062a63; }
body, input, textarea { caret-color: var(--accent); }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r1);
}

.mono, .keyval, .code, .code-line code, .list-key, .nav-count { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }

* { scrollbar-width: thin; scrollbar-color: #cfcfcf transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #cfcfcf; border: 3px solid var(--bg); border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: #b3b3b3; }

/* ============================ shell ============================ */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}

.side-head { padding: 16px 16px 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--fg); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none; position: relative;
  background: #0a0a0a; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px; border-radius: 2px;
  background: linear-gradient(135deg, #ffffff 0 44%, #9aa0a6 56% 100%);
}
.brand-name { font-size: 15px; letter-spacing: -0.02em; }
.brand-lg .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
.brand-lg .brand-name { font-size: 18px; }

.side-nav { display: flex; flex-direction: column; gap: 1px; padding: 4px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; color: var(--fg-2);
  font-size: 13.5px; font-weight: 500; padding: 7px 8px; border-radius: var(--r1);
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--hover); color: var(--fg); text-decoration: none; }
.nav-item.is-active { background: var(--hover); color: var(--fg); }
.nav-ico { display: inline-flex; color: var(--fg-3); }
.nav-item.is-active .nav-ico { color: var(--fg); }
.nav-ico svg { width: 16px; height: 16px; }
.nav-count {
  margin-left: auto; font-size: 11.5px; color: var(--fg-3);
  background: var(--bg); box-shadow: var(--shadow-border); border-radius: 999px; padding: 1px 7px;
}

.side-section {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  margin-top: 14px; padding: 12px 10px 0; border-top: 1px solid var(--line);
}
.side-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 8px;
}
.side-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3);
}
.side-new { padding: 0 4px 8px; }
.side-new-input {
  width: 100%; font: inherit; font-size: 13px; color: var(--fg);
  background: var(--panel); border: 0; border-radius: var(--r1); padding: 7px 9px;
  box-shadow: 0 0 0 1px var(--focus), 0 0 0 3px rgba(0, 112, 243, 0.14);
}
.side-new-input::placeholder { color: #767676; }
.side-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding-bottom: 8px; }
.side-row {
  display: flex; align-items: center; gap: 9px; color: var(--fg-2);
  font-size: 13.5px; padding: 7px 8px; border-radius: var(--r1); cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.side-row:hover { background: var(--hover); color: var(--fg); text-decoration: none; }
.side-row.is-active { background: var(--hover); color: var(--fg); font-weight: 500; }
.side-dot {
  width: 6px; height: 6px; border-radius: 999px; flex: none;
  background: #d4d4d4; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.side-row.is-active .side-dot { background: var(--accent); box-shadow: none; }
.side-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-empty { color: var(--fg-3); font-size: 13px; padding: 6px 8px; }

.side-foot {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px; border-top: 1px solid var(--line);
}
.account { display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
.avatar {
  width: 22px; height: 22px; border-radius: 999px; flex: none;
  background: linear-gradient(135deg, #0070f3, #7a5af8);
  color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center;
  text-transform: uppercase;
}
.account-name { font-size: 13px; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout {
  display: flex; align-items: center; gap: 9px; width: 100%;
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--fg-2); padding: 7px 8px; border-radius: var(--r1);
  transition: background 0.12s, color 0.12s;
}
.signout:hover { background: var(--hover); color: var(--fg); }
.signout svg { width: 15px; height: 15px; margin-left: auto; color: var(--fg-3); }

/* ============================ main ============================ */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 10; height: 56px;
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  background: rgba(250, 250, 250, 0.8);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--fg-3); }
.crumbs a { color: var(--fg-3); }
.crumbs a:hover { color: var(--fg); text-decoration: none; }
.crumbs .sep { color: #c8c8c8; }
.crumbs .here { color: var(--fg); font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { flex: 1; width: 100%; max-width: 940px; padding: 40px 28px 120px; }

/* ============================ page head ============================ */
.page-head { margin-bottom: 28px; }
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -0.03em; margin: 0 0 6px; }
.page-sub { color: var(--fg-2); font-size: 14px; margin: 0; max-width: 62ch; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }

/* ============================ buttons ============================ */
.btn {
  appearance: none; font: inherit; font-weight: 500; font-size: 13.5px;
  padding: 8px 13px; border-radius: var(--r1); cursor: pointer; border: 0;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background 0.13s, box-shadow 0.13s, color 0.13s, transform 0.05s, opacity 0.13s;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: #0a0a0a; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2e2e2e; }
.btn-secondary { background: var(--panel); color: var(--fg); box-shadow: var(--shadow-border); }
.btn-secondary:hover:not(:disabled) { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--fg-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
.btn-danger { background: transparent; color: var(--danger-ink); box-shadow: 0 0 0 1px rgba(229, 72, 77, 0.35); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: #d93a3f; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 10px 14px; }
.icon-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer; color: var(--fg-3);
  width: 26px; height: 26px; border-radius: var(--r1); display: grid; place-items: center;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn svg { width: 15px; height: 15px; }

/* ============================ overview list ============================ */
.new-app { display: flex; gap: 10px; margin: -4px 0 22px; }
.new-app .input { flex: 1; max-width: none; }
.list { background: var(--panel); border-radius: var(--r3); box-shadow: var(--shadow-card); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 16px; padding: 13px 18px; cursor: pointer;
  transition: background 0.12s;
}
.list-row + .list-row { box-shadow: inset 0 1px 0 0 var(--line); }
.list-row:hover { background: var(--tint); }
.list-main { min-width: 0; flex: 1; }
.list-name { font-weight: 500; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { color: var(--fg-3); font-size: 12.5px; margin-top: 1px; }
.list-meta { display: flex; align-items: center; gap: 14px; flex: none; }
.list-key { font-size: 12.5px; color: var(--fg-3); }
.list-chev { color: #c2c2c2; display: inline-flex; }
.list-chev svg { width: 16px; height: 16px; }

.pill {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500; white-space: nowrap;
  color: var(--accent-ink); background: var(--accent-bg); border-radius: 999px; padding: 2px 9px;
}
.pill-muted { color: var(--fg-2); background: var(--bg); box-shadow: var(--shadow-border); }
.pill-ok { color: var(--ok); background: var(--ok-bg); }

.empty {
  text-align: center; padding: 64px 24px; border: 1px dashed #dcdcdc; border-radius: var(--r3);
  background: var(--panel);
}
.empty-mark {
  width: 40px; height: 40px; border-radius: 10px; margin: 0 auto 16px;
  display: grid; place-items: center; color: var(--fg-3); background: var(--bg); box-shadow: var(--shadow-border);
}
.empty-mark svg { width: 20px; height: 20px; }
.empty-title { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.empty-sub { color: var(--fg-2); font-size: 13.5px; margin: 0 auto 20px; max-width: 38ch; }

/* ============================ detail ============================ */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.detail-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.detail-title h1 {
  font-size: 22px; font-weight: 600; letter-spacing: -0.03em; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.stack { display: flex; flex-direction: column; gap: 20px; }
.panel { background: var(--panel); border-radius: var(--r3); box-shadow: var(--shadow-card); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 20px; box-shadow: inset 0 -1px 0 0 var(--line);
}
.panel-head h2 { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.panel-body { padding: 20px; }
.panel-body > .field:last-child { margin-bottom: 0; }
.panel-desc { color: var(--fg-2); font-size: 13.5px; margin: 4px 0 16px; }
.panel-danger { box-shadow: 0 0 0 1px rgba(229, 72, 77, 0.28), 0 1px 1px rgba(0, 0, 0, 0.03); }
.panel-danger .panel-head { box-shadow: inset 0 -1px 0 0 rgba(229, 72, 77, 0.18); }
.panel-danger .panel-head h2 { color: var(--danger-ink); }

/* ============================ forms ============================ */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--fg-2); margin-bottom: 6px; }
.field-hint { font-size: 12.5px; color: var(--fg-3); margin: 6px 0 0; }
.input, textarea.input {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--fg);
  background: var(--panel); border: 0; border-radius: var(--r1); padding: 8px 11px;
  box-shadow: var(--shadow-border); transition: box-shadow 0.13s;
}
.input::placeholder { color: #767676; }
.input:focus, textarea.input:focus {
  outline: none; box-shadow: 0 0 0 1px var(--focus), 0 0 0 3px rgba(0, 112, 243, 0.14);
}
.input[type="number"] { max-width: 160px; }
textarea.input {
  resize: vertical; min-height: 108px; line-height: 1.6;
  font-family: var(--mono); font-size: 12.5px;
}
.row { display: flex; gap: 20px; align-items: flex-start; }
.row > .field { flex: 1; min-width: 0; }

.form-error {
  color: var(--danger-ink); font-size: 13px; margin: 0 0 14px;
  background: var(--danger-bg); padding: 9px 12px; border-radius: var(--r1);
}
.form-error[hidden] { display: none; }

/* ============================ key ============================ */
.keyrow { display: flex; align-items: center; gap: 8px; }
.keyval {
  flex: 1; min-width: 0; font-size: 13px; color: var(--fg-3);
  background: var(--bg); border-radius: var(--r1); padding: 9px 12px;
  overflow-x: auto; white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line);
}
.keyval.is-revealed { color: var(--fg); }
.key-actions { display: flex; gap: 8px; flex: none; }

.confirm { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.confirm-text { color: var(--fg-2); font-size: 13.5px; }

/* ============================ toasts ============================ */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #0a0a0a; color: #fff; font-size: 13.5px; padding: 10px 14px; border-radius: var(--r2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); max-width: 340px;
  animation: rise 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.toast svg { width: 15px; height: 15px; flex: none; }
.toast.is-error { background: var(--danger); }

/* ============================ login ============================ */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(60% 55% at 50% 0%, #ffffff 0%, var(--bg) 60%);
}
.auth {
  width: 100%; max-width: 372px; background: var(--panel); border-radius: var(--r3);
  box-shadow: var(--shadow-pop); padding: 32px;
  animation: rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.auth .brand { margin-bottom: 26px; }
.auth-title { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; margin: 0 0 4px; }
.auth-sub { color: var(--fg-2); font-size: 13.5px; margin: 0 0 24px; }

/* ============================ docs ============================ */
.docs { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 56px; align-items: start; }
.docs-body { max-width: 680px; min-width: 0; }
.doc-block { margin-bottom: 40px; scroll-margin-top: 76px; }
.doc-block h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 10px; }
.doc-block p { color: var(--fg-2); font-size: 14px; line-height: 1.65; margin: 0 0 12px; }
.doc-block strong { color: var(--fg); font-weight: 500; }
.doc-gap { margin-top: 18px !important; }
.endpoint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px !important; }
.ctype { font-family: var(--mono); font-size: 12px; color: var(--fg-3); }

.inline {
  font-family: var(--mono); font-size: 12.5px; background: var(--bg);
  padding: 2px 6px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--line); color: var(--fg);
}
.method {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.02em;
  color: var(--ok); background: var(--ok-bg); padding: 3px 8px; border-radius: 5px;
}
.status { font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--fg); }

.table { box-shadow: var(--shadow-border); border-radius: var(--r2); overflow: hidden; background: var(--panel); }
.table-head, .table-row { display: grid; grid-template-columns: 150px 60px 1fr; gap: 12px; padding: 11px 16px; align-items: center; }
.table-head {
  background: var(--bg); font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--fg-3);
}
.table-row { font-size: 13.5px; color: var(--fg-2); }
.table-row + .table-row { box-shadow: inset 0 1px 0 0 var(--line); }
.cell-name { font-family: var(--mono); font-size: 12.5px; color: var(--fg); }
.cell-name.status { color: var(--fg); }
.cell-type { font-family: var(--mono); font-size: 12.5px; color: var(--fg-3); }
.cell-desc { line-height: 1.5; }

.code-line {
  display: flex; align-items: center; gap: 8px; background: var(--bg);
  border-radius: var(--r2); padding: 6px 8px 6px 13px; box-shadow: inset 0 0 0 1px var(--line);
}
.code-line code { flex: 1; font-size: 13px; color: var(--fg); overflow-x: auto; white-space: nowrap; }

.snippet { margin-bottom: 16px; }
.snippet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 6px 2px;
}
.snippet-lang { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.copy-btn { color: var(--fg-3); }

.code {
  background: #0a0a0a; color: #ededed; border-radius: var(--r2); padding: 16px;
  overflow-x: auto; margin: 0; box-shadow: var(--shadow-border);
}
.code code { font-size: 12.5px; line-height: 1.7; white-space: pre; }

.docs-toc { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.toc-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg-3); margin-bottom: 8px;
}
.docs-toc a {
  color: var(--fg-3); font-size: 13px; padding: 4px 0; transition: color 0.12s;
}
.docs-toc a:hover { color: var(--fg); text-decoration: none; }

/* ============================ motion ============================ */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.view-enter { animation: rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }

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

/* ============================ responsive ============================ */
@media (max-width: 1000px) {
  .docs { grid-template-columns: 1fr; gap: 0; }
  .docs-toc { display: none; }
}
@media (max-width: 860px) {
  .app { display: block; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto;
    flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px;
    border-right: 0; border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
  }
  .side-head { padding: 0; flex: none; }
  .side-head .brand-name { display: none; }
  .side-nav { flex-direction: row; gap: 2px; padding: 0; flex: 1; min-width: 0; }
  .nav-count { display: none; }
  .side-section { display: none; }
  .side-foot { margin-left: auto; flex-direction: row; align-items: center; padding: 0; border: 0; gap: 4px; }
  .account { display: none; }
  .signout { width: auto; padding: 7px; }
  .signout span { display: none; }
  .signout svg { margin: 0; }
  .topbar { display: none; }
  .content { padding: 24px 16px 96px; }
  .page-title { font-size: 22px; }
  .page-head-row { flex-direction: column; }
  .detail-head { flex-direction: column; align-items: stretch; }
  .detail-head .btn { align-self: flex-start; }
  .row { flex-direction: column; gap: 0; }
  .table-head, .table-row { grid-template-columns: 120px 1fr; }
  .cell-type { display: none; }
  .list-key { display: none; }
}
