/* ==========================================================================
   Nashmi Developers — Softelv
   Design language: Amman limestone, brass and ink (taken from the Nashmi mark)
   RTL-first · logical properties · light + dark systems
   ========================================================================== */

/* ── 1. Tokens ─────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --font-sans: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #F5F2EC;
  --bg-tint: #EFEBE3;
  --surface: #FFFFFF;
  --surface-2: #F9F7F3;
  --surface-3: #F1EDE6;
  --sidebar: #EFEBE4;
  --overlay: rgba(24, 21, 16, .42);

  --text: #1A1814;
  --text-2: #4A453C;
  --muted: #756E61;
  --faint: #A29B8D;

  --border: #E4DDD1;
  --border-strong: #D3CABB;
  --hairline: rgba(26, 24, 20, .06);

  --ink: #1B1A17;
  --ink-hover: #34312B;
  --on-ink: #F7F4EE;

  --brass: #9E7134;
  --brass-strong: #85591F;
  --brass-soft: #F5ECDD;
  --brass-line: #E5D3B3;
  --brass-fill: #C89B57;

  --green: #2B7650;
  --green-soft: #E5F2EA;
  --amber: #A76400;
  --amber-soft: #FBF0DD;
  --red: #B42318;
  --red-soft: #FBEAE7;
  --blue: #2C5B89;
  --blue-soft: #E7EEF6;

  --code-bg: #1A1917;
  --code-border: #2B2925;
  --code-text: #E8E3D8;
  --code-muted: #8E877A;
  --code-string: #DDBB84;
  --code-keyword: #E7917F;
  --code-number: #9ECDA9;
  --code-fn: #A9C4E4;

  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--brass-fill);

  --shadow-1: 0 1px 2px rgba(26, 24, 20, .05);
  --shadow-2: 0 1px 2px rgba(26, 24, 20, .04), 0 6px 20px -6px rgba(26, 24, 20, .12);
  --shadow-3: 0 2px 6px rgba(26, 24, 20, .06), 0 28px 64px -18px rgba(26, 24, 20, .32);

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-in: cubic-bezier(.55, 0, 1, .45);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --d1: 120ms;
  --d2: 200ms;
  --d3: 340ms;

  --sidebar-w: 264px;
  --topbar-h: 60px;

  /* isometric materials */
  --iso-brass-1: #F2DCAE;
  --iso-brass-2: #C99A56;
  --iso-brass-l: #B8873F;
  --iso-brass-r: #936423;
  --iso-ink-1: #45434A;
  --iso-ink-2: #26252A;
  --iso-ink-l: #1C1B1F;
  --iso-ink-r: #121114;
  --iso-lime-1: #FFFFFF;
  --iso-lime-2: #ECE5D8;
  --iso-lime-l: #DCD2C0;
  --iso-lime-r: #C6B9A1;
  --iso-red-1: #E0594C;
  --iso-red-2: #B42318;
  --iso-red-l: #962016;
  --iso-red-r: #741911;
  --iso-green: #2B7650;
  --iso-edge: rgba(255, 255, 255, .7);
  --iso-shadow: rgba(60, 44, 20, .30);
  --iso-grid: rgba(120, 100, 70, .16);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0E0E10;
  --bg-tint: #131316;
  --surface: #161619;
  --surface-2: #1B1B1F;
  --surface-3: #212126;
  --sidebar: #121215;
  --overlay: rgba(0, 0, 0, .62);

  --text: #F1EDE5;
  --text-2: #D0CABE;
  --muted: #9C9587;
  --faint: #6D675C;

  --border: #26262B;
  --border-strong: #35353C;
  --hairline: rgba(255, 255, 255, .05);

  --ink: #F1EDE5;
  --ink-hover: #FFFFFF;
  --on-ink: #141311;

  --brass: #D3B07A;
  --brass-strong: #E4C791;
  --brass-soft: rgba(211, 176, 122, .10);
  --brass-line: rgba(211, 176, 122, .28);
  --brass-fill: #C89B57;

  --green: #6CC895;
  --green-soft: rgba(108, 200, 149, .11);
  --amber: #EDB45F;
  --amber-soft: rgba(237, 180, 95, .11);
  --red: #F0806F;
  --red-soft: rgba(240, 128, 111, .11);
  --blue: #8DB6E2;
  --blue-soft: rgba(141, 182, 226, .11);

  --code-bg: #0B0B0D;
  --code-border: #232327;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -8px rgba(0, 0, 0, .6);
  --shadow-3: 0 2px 8px rgba(0, 0, 0, .4), 0 32px 72px -16px rgba(0, 0, 0, .75);

  --iso-ink-1: #55535C;
  --iso-ink-2: #34333A;
  --iso-ink-l: #28272D;
  --iso-ink-r: #1D1C21;
  --iso-lime-1: #F4EFE6;
  --iso-lime-2: #D9D0C0;
  --iso-lime-l: #BDB29E;
  --iso-lime-r: #A0947E;
  --iso-green: #2B7650;
  --iso-edge: rgba(255, 255, 255, .42);
  --iso-shadow: rgba(0, 0, 0, .7);
  --iso-grid: rgba(90, 76, 52, .22);
}

/* ── 2. Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

img, svg { display: block; max-width: 100%; }
svg.i { display: inline-block; flex-shrink: 0; vertical-align: middle; }
svg.mark { display: inline-block; flex-shrink: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--brass-line); color: var(--text); }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: 0; line-height: 1.35; color: var(--text); }

code, kbd, pre, .mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.ltr { direction: ltr; unicode-bidi: isolate; }
[dir="ltr"] { unicode-bidi: isolate; }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--r-sm); }

.skip-link {
  position: fixed;
  inset-inline-start: 16px;
  top: -60px;
  z-index: 1000;
  background: var(--ink);
  color: var(--on-ink);
  padding: 8px 16px;
  border-radius: var(--r-md);
  transition: top var(--d2) var(--ease);
}
.skip-link:focus { top: 16px; }

.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;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }

/* boot */
.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 24px;
}
.boot img { border-radius: 14px; box-shadow: var(--shadow-2); }
.boot-bar { width: 120px; height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; display: block; }
.boot-bar span { display: block; height: 100%; width: 40%; background: var(--brass-fill); animation: boot 1.1s var(--ease) infinite; }
@keyframes boot { from { transform: translateX(160%); } to { transform: translateX(-260%); } }

/* ── 3. Type helpers ───────────────────────────────────────────────────── */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brass);
}
.eyebrow .mark { color: var(--brass-fill); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.t-sm { font-size: 13px; line-height: 1.7; }
.t-xs { font-size: 12px; line-height: 1.6; }

/* ── 4. Buttons ────────────────────────────────────────────────────────── */
.btn {
  --h: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h);
  padding-inline: 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  position: relative;
  transition: background-color var(--d1) var(--ease), border-color var(--d1) var(--ease), color var(--d1) var(--ease), transform var(--d1) var(--ease), box-shadow var(--d1) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn .i { width: 16px; height: 16px; }

.btn-primary { background: var(--ink); color: var(--on-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, var(--shadow-1); }
.btn-primary:hover:not(:disabled) { background: var(--ink-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--faint); }

.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-brass {
  background: linear-gradient(180deg, #D6AE6C, #B8873F);
  color: #1B1406;
  border-color: #A87A36;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, var(--shadow-1);
}
.btn-brass:hover:not(:disabled) { background: linear-gradient(180deg, #DDB777, #BF8E46); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
:root[data-theme="dark"] .btn-danger { color: #1A0B08; }

.btn-danger-ghost { color: var(--red); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-soft); }

.btn-sm { --h: 32px; padding-inline: 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { --h: 48px; padding-inline: 22px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-icon { --h: 36px; width: var(--h); padding: 0; color: var(--muted); border-radius: 8px; }
.btn-icon:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-icon.btn-sm { --h: 30px; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: var(--on-ink) transparent var(--on-ink) var(--on-ink);
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--text) transparent var(--text) var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

.link { color: var(--brass); font-weight: 500; text-underline-offset: 3px; }
.link:hover { text-decoration: underline; }

/* ── 5. Forms ──────────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label { font-size: 13px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.hint.is-error { color: var(--red); }

.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding-inline: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--text);
  transition: border-color var(--d1) var(--ease), box-shadow var(--d1) var(--ease), background-color var(--d1);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brass-fill); box-shadow: 0 0 0 3px var(--brass-soft); outline: none; }
.input[readonly] { background: var(--surface-2); }
.input.is-invalid { border-color: var(--red); }
.textarea { height: auto; min-height: 112px; padding: 10px 12px; line-height: 1.7; resize: vertical; }
.input.mono, .textarea.mono { font-family: var(--font-mono); font-size: 13px; }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23857d6f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  cursor: pointer;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-inline-end: 44px; }
.input-group .btn-icon { position: absolute; inset-inline-end: 4px; }
.input-group > .i { position: absolute; inset-inline-start: 12px; color: var(--faint); pointer-events: none; }
.input-group > .i + .input { padding-inline-start: 38px; }

.copy-field {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding-inline: 12px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 0;
}
.copy-field code {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
  color: var(--text);
}

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 36px; height: 20px;
  border-radius: 20px;
  background: var(--border-strong);
  position: relative;
  transition: background-color var(--d2) var(--ease);
  flex-shrink: 0;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform var(--d2) var(--spring);
}
.switch input:checked + .switch-track { background: var(--ink); }
.switch input:checked + .switch-track::after { transform: translateX(-16px); }
[dir="ltr"] .switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
:root[data-theme="dark"] .switch input:checked + .switch-track::after { background: #141311; }

/* segmented */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  height: 30px;
  padding-inline: 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--d1), background-color var(--d1);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected="true"], .segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
}
.segmented .count { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ── 6. Badges, pills, status ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding-inline: 9px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge-amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge-brass { background: var(--brass-soft); color: var(--brass); border-color: var(--brass-line); }
.badge-ink { background: var(--ink); color: var(--on-ink); border-color: transparent; }
.badge .i { width: 13px; height: 13px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding-inline: 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  direction: ltr;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-brass { background: var(--brass-soft); color: var(--brass); border-color: var(--brass-line); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.status-dot.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.status-dot.idle { background: var(--faint); }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding-inline: 5px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
}

/* ── 7. Surfaces ───────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-head p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-flat { box-shadow: none; }

.callout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-2);
}
.callout .i { margin-top: 3px; color: var(--muted); }
.callout strong { color: var(--text); font-weight: 600; }
.callout-brass { background: var(--brass-soft); border-color: var(--brass-line); }
.callout-brass .i { color: var(--brass); }
.callout-amber { background: var(--amber-soft); border-color: transparent; }
.callout-amber .i { color: var(--amber); }
.callout-red { background: var(--red-soft); border-color: transparent; }
.callout-red .i { color: var(--red); }

.divider { height: 1px; background: var(--border); border: 0; margin-block: 20px; }

/* ── 8. Code ───────────────────────────────────────────────────────────── */
.code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  color: var(--code-text);
  min-width: 0;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--code-border);
  direction: ltr;
}
.code-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.code-tabs::-webkit-scrollbar { display: none; }
.code-tabs button {
  height: 28px;
  padding-inline: 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--code-muted);
  white-space: nowrap;
}
.code-tabs button:hover { color: var(--code-text); }
.code-tabs button[aria-selected="true"] { color: var(--code-text); background: rgba(255, 255, 255, .07); }
.code-title { font-family: var(--font-mono); font-size: 12px; color: var(--code-muted); }
.code-copy {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding-inline: 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--code-muted);
}
.code-copy:hover { color: var(--code-text); background: rgba(255, 255, 255, .07); }
.code-copy .i { width: 14px; height: 14px; }
.code pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.75;
  direction: ltr;
  text-align: left;
  tab-size: 2;
  white-space: pre;
}
.code pre.wrap { white-space: pre-wrap; word-break: break-word; }
.tok-c { color: var(--code-muted); font-style: italic; }
.tok-s { color: var(--code-string); }
.tok-k { color: var(--code-keyword); }
.tok-n { color: var(--code-number); }
.tok-f { color: var(--code-fn); }

code.inline {
  font-size: .88em;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
}

/* ── 9. Tables ─────────────────────────────────────────────────────────── */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: start;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--d1); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-clickable { cursor: pointer; }
.table .cell-main { color: var(--text); font-weight: 500; }
.table .cell-sub { font-size: 12px; color: var(--muted); }
.table .nowrap { white-space: nowrap; }
.table .actions { width: 1%; white-space: nowrap; text-align: end; }
.table .truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.meter { display: grid; gap: 6px; min-width: 120px; }
.meter-bar { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.meter-bar span { display: block; height: 100%; border-radius: 6px; background: var(--ink); transition: width var(--d3) var(--ease); }
.meter-bar span.warn { background: var(--amber); }
.meter-bar span.err { background: var(--red); }
.meter-bar span.brass { background: var(--brass-fill); }
.meter-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }

/* ── 10. Empty / skeleton ──────────────────────────────────────────────── */
.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  padding: 56px 24px;
}
.empty .iso { margin-bottom: 8px; }
.empty h3 { font-size: 16px; }
.empty p { font-size: 14px; color: var(--muted); max-width: 42ch; }
.empty .btn { margin-top: 12px; }

.skeleton {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── 11. Popovers, menus, tooltips ─────────────────────────────────────── */
.menu {
  position: fixed;
  z-index: 400;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  transform-origin: var(--origin, top right);
  animation: pop-in var(--d2) var(--ease);
}
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding-inline: 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-2);
  text-align: start;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); color: var(--text); box-shadow: none; }
.menu-item .i { width: 16px; height: 16px; color: var(--muted); }
.menu-item.is-danger { color: var(--red); }
.menu-item.is-danger .i { color: var(--red); }
.menu-item .check { margin-inline-start: auto; color: var(--brass); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-label { font-size: 12px; color: var(--faint); padding: 6px 10px 4px; }

@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translate(-50%, 4px);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  padding: 6px 9px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--d1) var(--ease), transform var(--d1) var(--ease);
  z-index: 50;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: 350ms; }

/* ── 12. Modals, drawers, toasts ───────────────────────────────────────── */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow-y: auto;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  animation: fade-in var(--d2) var(--ease);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  animation: modal-in var(--d3) var(--spring);
  overflow: hidden;
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 920px; }
.modal-head { display: flex; align-items: flex-start; gap: 16px; padding: 22px 24px 0; }
.modal-head .iso { flex-shrink: 0; margin-top: -4px; }
.modal-head h2 { font-size: 18px; font-weight: 600; line-height: 1.4; }
.modal-head p { font-size: 13.5px; color: var(--muted); margin-top: 4px; line-height: 1.7; }
.modal-head .btn-icon { margin-inline-start: auto; margin-top: -6px; margin-inline-end: -8px; }
.modal-body { padding: 20px 24px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.modal-foot .spacer { margin-inline-end: auto; }

.modal-root.is-closing .modal { animation: modal-out 160ms var(--ease-in) forwards; }
.modal-root.is-closing .modal-backdrop { animation: fade-out 160ms var(--ease-in) forwards; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }

.drawer-root { position: fixed; inset: 0; z-index: 500; }
.drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-end: 0;
  width: min(560px, 100%);
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  animation: drawer-in var(--d3) var(--ease);
}
.drawer-root.is-closing .drawer { animation: drawer-out 180ms var(--ease-in) forwards; }
.drawer-root.is-closing .modal-backdrop { animation: fade-out 180ms var(--ease-in) forwards; }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes drawer-out { to { transform: translateX(-100%); } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 16px; }
.drawer-head .btn-icon { margin-inline-start: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 20px; align-content: start; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { color: var(--text); min-width: 0; overflow-wrap: anywhere; }

.text-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow-y: auto;
  color: var(--text-2);
}

.toasts {
  position: fixed;
  z-index: 700;
  bottom: 24px;
  inset-inline-start: 24px;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--on-ink);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  font-size: 13.5px;
  line-height: 1.6;
  animation: toast-in var(--d3) var(--spring);
}
.toast .i { width: 18px; height: 18px; margin-top: 1px; }
.toast.ok .i { color: #7ED3A1; }
.toast.err .i { color: #F2998B; }
.toast.info .i { color: #E3C28A; }
:root[data-theme="dark"] .toast.ok .i { color: var(--green); }
:root[data-theme="dark"] .toast.ok .i, :root[data-theme="dark"] .toast.err .i, :root[data-theme="dark"] .toast.info .i { filter: saturate(1.2) brightness(.7); }
.toast strong { font-weight: 600; display: block; }
.toast-close { margin-inline-start: auto; opacity: .6; color: inherit; }
.toast-close:hover { opacity: 1; }
.toast.is-leaving { animation: toast-out 180ms var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* command palette */
.palette { max-width: 600px; align-self: start; margin-top: 12vh; }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.palette-input .i { color: var(--faint); }
.palette-input input { flex: 1; height: 56px; border: 0; background: none; font-size: 16px; outline: none; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 8px; }
.palette-group { font-size: 12px; color: var(--faint); padding: 8px 10px 4px; }
.palette-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding-inline: 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-2);
  text-align: start;
}
.palette-item .i { color: var(--muted); }
.palette-item[aria-selected="true"] { background: var(--surface-3); color: var(--text); }
.palette-item .hint-key { margin-inline-start: auto; font-size: 12px; color: var(--faint); }
.palette-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--faint); background: var(--surface-2); }
.palette-foot span { display: inline-flex; gap: 6px; align-items: center; }

/* ── 13. Public layout ─────────────────────────────────────────────────── */
.site { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: 24px; }

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color var(--d2), border-color var(--d2), backdrop-filter var(--d2);
  border-bottom: 1px solid transparent;
}
.site-nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--border);
}
.site-nav .container { height: 68px; display: flex; align-items: center; gap: 32px; }
.site-nav nav { display: flex; gap: 4px; }
.site-nav nav a {
  font-size: 14px;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: 8px;
  transition: color var(--d1), background-color var(--d1);
}
.site-nav nav a:hover { color: var(--text); background: var(--surface-3); }
.site-nav nav a.is-active { color: var(--text); }
.site-nav .nav-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }

.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; box-shadow: var(--shadow-1); }
.brand-name { font-size: 17px; font-weight: 700; line-height: 1.1; color: var(--text); }
.brand-name small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); margin-top: 3px; letter-spacing: 0; }

.hero { position: relative; overflow: hidden; padding-block: 56px 96px; }
.hero::before {
  content: "";
  position: absolute;
  inset: -10% -10% 0;
  background-image: var(--lattice);
  background-size: 64px 64px;
  opacity: .5;
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 30% 45%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 55% at 30% 45%, #000 20%, transparent 75%);
  pointer-events: none;
}
:root { --lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23b99a68' stroke-opacity='.28' stroke-width='.8'%3E%3Cpath d='M32 10 38.4 25.6 54 32 38.4 38.4 32 54 25.6 38.4 10 32 25.6 25.6Z'/%3E%3Crect x='18' y='18' width='28' height='28' transform='rotate(45 32 32)'/%3E%3Cpath d='M0 0 10 32M64 0 54 32M0 64 10 32M64 64 54 32'/%3E%3C/g%3E%3C/svg%3E"); }
:root[data-theme="dark"] { --lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23c9a66d' stroke-opacity='.14' stroke-width='.8'%3E%3Cpath d='M32 10 38.4 25.6 54 32 38.4 38.4 32 54 25.6 38.4 10 32 25.6 25.6Z'/%3E%3Crect x='18' y='18' width='28' height='28' transform='rotate(45 32 32)'/%3E%3Cpath d='M0 0 10 32M64 0 54 32M0 64 10 32M64 64 54 32'/%3E%3C/g%3E%3C/svg%3E"); }

.hero-grid { position: relative; display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center; }
.hero h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.6rem);
  font-weight: 700;
  line-height: 1.22;
  margin-top: 20px;
  max-width: 18ch;
}
.hero h1 em { font-style: normal; color: var(--brass); }
.hero-lead { font-size: clamp(1rem, 1.3vw, 1.125rem); color: var(--text-2); margin-top: 20px; max-width: 58ch; line-height: 1.9; }
.hero-ctas { display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 36px; font-size: 13px; color: var(--muted); }
.hero-meta span { display: inline-flex; align-items: center; gap: 8px; }
.hero-meta .i { color: var(--brass); width: 16px; height: 16px; }

.hero-visual { position: relative; }
.hero-visual .iso { width: 100%; max-width: 520px; height: auto; margin-inline: auto; }
.hero-code {
  position: relative;
  width: min(380px, 76%);
  margin-top: -27%;
  margin-inline-start: auto;
  box-shadow: var(--shadow-3);
  animation: rise-in 700ms var(--ease) 200ms both;
}
.hero-code pre { font-size: 12px; padding: 14px 16px; }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.float { animation: float 6s ease-in-out infinite; }
.float-b { animation-duration: 7.5s; animation-delay: -2s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.section { padding-block: 96px; position: relative; }
.section-tint { background: var(--bg-tint); border-block: 1px solid var(--border); }
.section-head { max-width: 640px; margin-bottom: 48px; }
.section-head h2 { font-size: clamp(1.6rem, 2.8vw, 2.25rem); font-weight: 700; line-height: 1.3; margin-top: 12px; }
.section-head p { font-size: 16px; color: var(--text-2); margin-top: 12px; line-height: 1.9; }
.section-head.is-center { margin-inline: auto; text-align: center; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; counter-reset: step; border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); overflow: hidden; }
.step { padding: 32px 28px; position: relative; }
.step + .step { border-inline-start: 1px solid var(--border); }
.step-num { font-family: var(--font-mono); font-size: 12px; color: var(--faint); }
.step .iso { margin-block: 12px 20px; }
.step h3 { font-size: 17px; }
.step p { font-size: 14px; color: var(--muted); margin-top: 6px; line-height: 1.8; }

.bento { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.tile {
  grid-column: span 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  transition: border-color var(--d2), transform var(--d2) var(--ease), box-shadow var(--d2);
}
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.tile.span-3 { grid-column: span 3; }
.tile.span-4 { grid-column: span 4; }
.tile .iso { margin-bottom: 8px; }
.tile h3 { font-size: 17px; }
.tile p { font-size: 14px; color: var(--muted); line-height: 1.85; }
.tile .code { margin-top: auto; }
.tile-ink { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.tile-ink h3 { color: var(--on-ink); }
.tile-ink p { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }
.tile-ink .code { border-color: rgba(255, 255, 255, .1); }
:root[data-theme="dark"] .tile-ink .code { border-color: var(--border); }

.diff-line { display: block; padding-inline: 18px; margin-inline: -18px; }
.diff-del { background: rgba(240, 128, 111, .10); color: #E9A094; }
.diff-add { background: rgba(108, 200, 149, .10); color: #A4DDBB; }

.cta-band {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  background: var(--ink);
  color: var(--on-ink);
  padding: 64px 56px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: center;
}
.cta-band::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--lattice);
  background-size: 64px 64px;
  opacity: .35;
  -webkit-mask-image: linear-gradient(to left, #000, transparent 70%);
  mask-image: linear-gradient(to left, #000, transparent 70%);
  pointer-events: none;
}
.cta-band h2 { color: var(--on-ink); font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 700; }
.cta-band p { color: color-mix(in srgb, var(--on-ink) 70%, transparent); margin-top: 8px; max-width: 52ch; }
.cta-band .btn { position: relative; z-index: 1; }
.cta-band .btn-primary { background: var(--on-ink); color: var(--ink); }
.cta-band .btn-primary:hover { background: color-mix(in srgb, var(--on-ink) 88%, var(--brass-fill)); }

.site-footer { border-top: 1px solid var(--border); padding-block: 48px 32px; margin-top: auto; font-size: 13.5px; color: var(--muted); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.footer-grid h4 { font-size: 13px; color: var(--text); margin-bottom: 12px; font-weight: 600; }
.footer-grid ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.footer-grid a:hover { color: var(--text); }
.footer-bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); font-size: 12.5px; }

/* ── 14. Plans ─────────────────────────────────────────────────────────── */
.plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.plan {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  min-width: 0;
  transition: border-color var(--d2), box-shadow var(--d2);
}
.plan:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.plan.is-current { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.plan-name { font-size: 16px; font-weight: 600; }
.plan-desc { font-size: 13px; color: var(--muted); margin-top: 4px; min-height: 44px; }
.plan-price { margin-block: 20px 4px; display: flex; align-items: baseline; gap: 6px; }
.plan-price strong { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.plan-price span { font-size: 13px; color: var(--muted); }
.plan-note { font-size: 12px; color: var(--faint); min-height: 20px; }
.plan-list { list-style: none; padding: 0; display: grid; gap: 10px; margin-block: 20px 24px; font-size: 13.5px; color: var(--text-2); }
.plan-list li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.6; }
.plan-list .i { width: 16px; height: 16px; color: var(--brass); margin-top: 3px; }
.plan-list strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.plan .btn { margin-top: auto; }
.plan-so {
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(201, 155, 87, .20), transparent 60%),
    var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}
.plan-so .plan-name, .plan-so .plan-price strong, .plan-so .plan-list strong { color: var(--on-ink); }
.plan-so .plan-desc, .plan-so .plan-price span, .plan-so .plan-list, .plan-so .plan-note { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }
.plan-so .plan-list .i { color: #D6AE6C; }
.plan-so.is-current { box-shadow: 0 0 0 2px var(--brass-fill); }

/* ── 15. Console layout ────────────────────────────────────────────────── */
.console { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
}
.sidebar-top { padding: 18px 18px 12px; display: flex; align-items: center; gap: 8px; }
.sidebar-top .btn-icon { margin-inline-start: auto; display: none; }
.sidebar-search {
  margin: 4px 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding-inline: 10px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--faint);
  font-size: 13px;
  text-align: start;
  transition: border-color var(--d1);
}
.sidebar-search:hover { border-color: var(--border-strong); color: var(--muted); }
.sidebar-search kbd { margin-inline-start: auto; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; display: grid; gap: 2px; align-content: start; }
.side-group { font-size: 12px; color: var(--faint); padding: 16px 10px 6px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 36px;
  padding-inline: 10px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--text-2);
  position: relative;
  transition: background-color var(--d1), color var(--d1);
}
.side-link .i { color: var(--muted); transition: color var(--d1); }
.side-link:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--text); }
.side-link.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
}
.side-link.is-active .i { color: var(--brass); }
.side-link.is-active::before {
  content: "";
  position: absolute;
  inset-inline-start: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: var(--brass-fill);
}
.side-link .count { margin-inline-start: auto; font-size: 11.5px; min-width: 20px; height: 20px; padding-inline: 6px; border-radius: 10px; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber); font-weight: 600; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.account-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  text-align: start;
  transition: background-color var(--d1);
}
.account-btn:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #D9B67C, #A87A36);
  color: #1B1406;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.account-meta { min-width: 0; flex: 1; }
.account-meta strong { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.account-meta span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline: 32px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-toggle { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-width: 0; }
.crumbs strong { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .i { width: 14px; height: 14px; color: var(--faint); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }

.content { width: 100%; max-width: 1280px; margin-inline: auto; padding: 32px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; line-height: 1.3; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 6px; max-width: 70ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view { animation: view-in 280ms var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 55; animation: fade-in var(--d2); }

/* ── 16. Overview ──────────────────────────────────────────────────────── */
.welcome {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 24px 28px;
  margin-bottom: 24px;
  border-radius: var(--r-xl);
  background:
    radial-gradient(80% 140% at 0% 0%, var(--brass-soft), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
}
.welcome h1 { font-size: 22px; font-weight: 700; }
.welcome p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  box-shadow: var(--shadow-1);
}
.kpi-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi-label .i { width: 15px; height: 15px; color: var(--faint); }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--text); direction: ltr; text-align: end; unicode-bidi: isolate; align-self: flex-start; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: auto; }
.kpi-usage .meter { margin-top: 6px; }
.kpi-usage .usage-rows { display: grid; gap: 10px; margin-top: 8px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.grid-2.grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
#main:focus, #main:focus-visible { box-shadow: none; outline: none; }
.section, .hero { scroll-margin-top: 68px; }
.stack { display: grid; gap: 24px; min-width: 0; }

.quick-fields { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }

.checklist { list-style: none; padding: 0; display: grid; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.check-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed var(--border-strong); color: transparent; flex-shrink: 0; margin-top: 2px; }
.check-ico .i { width: 13px; height: 13px; }
.checklist li.is-done .check-ico { background: var(--green); border: 0; color: #fff; }
:root[data-theme="dark"] .checklist li.is-done .check-ico { color: #0E1A13; }
.checklist strong { display: block; font-size: 14px; font-weight: 500; color: var(--text); }
.checklist li.is-done strong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.checklist span { font-size: 12.5px; color: var(--muted); }
.checklist .btn { margin-inline-start: auto; flex-shrink: 0; }

.activity { list-style: none; padding: 0; }
.activity li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color var(--d1);
}
.activity li:hover { background: var(--surface-2); }
.activity li:last-child { border-bottom: 0; }
.activity .a-main { min-width: 0; }
.activity .a-main strong { display: block; font-size: 13.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity .a-main span { font-size: 12px; color: var(--muted); }
.activity .a-side { text-align: end; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── 17. Keys / models ─────────────────────────────────────────────────── */
.key-cell { display: flex; align-items: center; gap: 4px; }
.key-cell code { font-size: 12.5px; color: var(--text-2); direction: ltr; }

.quota-note { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.model-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  min-width: 0;
  transition: border-color var(--d2), box-shadow var(--d2);
}
.model-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.model-card-head { display: flex; gap: 14px; align-items: flex-start; }
.model-card-head h3 { font-size: 15px; font-family: var(--font-mono); font-weight: 500; direction: ltr; text-align: end; word-break: break-all; }
.model-card-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.model-card .text-block { max-height: 118px; font-size: 13px; overflow: hidden; position: relative; }
.model-card .text-block.is-empty { color: var(--faint); font-style: normal; }
.model-card-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.model-card-foot .btn:last-child { margin-inline-start: auto; }

.counter { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--red); }

.secret-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 14px 8px;
  border-radius: var(--r-md);
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--code-border);
}
.secret-box code { flex: 1; font-size: 13.5px; direction: ltr; text-align: left; word-break: break-all; }
.secret-box .btn { flex-shrink: 0; }

/* ── 18. Playground ────────────────────────────────────────────────────── */
.pg { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; height: calc(100vh - var(--topbar-h) - 64px - 84px); min-height: 560px; }
.pg-chat { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pg-thread { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; scroll-behavior: smooth; }
.pg-intro { margin: auto; text-align: center; max-width: 440px; display: grid; justify-items: center; gap: 8px; }
.pg-intro h3 { font-size: 17px; }
.pg-intro p { font-size: 14px; color: var(--muted); }
.pg-suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.pg-suggest button {
  font-size: 13px;
  padding: 7px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  transition: border-color var(--d1), color var(--d1);
}
.pg-suggest button:hover { border-color: var(--border-strong); color: var(--text); }

.msg { display: grid; gap: 6px; max-width: min(760px, 100%); animation: view-in 240ms var(--ease); }
.msg-who { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.msg-who .mono { direction: ltr; }
.msg-body { font-size: 14.5px; line-height: 1.9; color: var(--text); overflow-wrap: anywhere; }
.msg-user { align-self: flex-start; }
.msg-user .msg-body {
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 14px;
  border-start-start-radius: 4px;
  white-space: pre-wrap;
}
.msg-ai { align-self: stretch; }
.msg-ai .msg-body p + p, .msg-ai .msg-body p + ul, .msg-ai .msg-body ul + p, .msg-ai .msg-body .code + p, .msg-ai .msg-body p + .code { margin-top: 10px; }
.msg-ai .msg-body ul, .msg-ai .msg-body ol { padding-inline-start: 22px; margin-block: 6px; }
.msg-ai .msg-body li + li { margin-top: 4px; }
.msg-ai .msg-body h4 { font-size: 15px; margin-top: 12px; }
.msg-ai .msg-body .code { margin-block: 10px; }
.msg-ai .msg-body strong { font-weight: 600; }
.msg-err { color: var(--red); display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.msg-err .i { margin-top: 4px; }
.msg-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--faint); }
.msg-meta .btn-icon { --h: 26px; color: var(--faint); }
.caret { display: inline-block; width: 7px; height: 1.1em; vertical-align: text-bottom; background: var(--brass-fill); margin-inline-start: 2px; animation: blink 1s steps(2) infinite; border-radius: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: typing 1.2s var(--ease) infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.pg-composer { border-top: 1px solid var(--border); padding: 14px 16px; background: var(--surface); }
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 6px;
  padding-inline-start: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color var(--d1), box-shadow var(--d1);
}
.composer-box:focus-within { border-color: var(--brass-fill); box-shadow: 0 0 0 3px var(--brass-soft); }
.composer-box textarea {
  flex: 1;
  border: 0;
  background: none;
  resize: none;
  outline: none;
  padding-block: 8px;
  max-height: 200px;
  min-height: 24px;
  line-height: 1.7;
  font-size: 14.5px;
}
.composer-hint { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--faint); margin-top: 8px; }

.pg-side { overflow-y: auto; display: flex; flex-direction: column; }
.pg-side .panel-body { display: grid; gap: 18px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.stat { background: var(--surface); padding: 10px 12px; }
.stat span { display: block; font-size: 11.5px; color: var(--muted); }
.stat strong { display: block; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; text-align: end; unicode-bidi: isolate; margin-top: 2px; }

/* ── 19. Logs ──────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .input-group { flex: 1; min-width: 220px; max-width: 360px; }
.toolbar .input { height: 36px; }
.toolbar .spacer { margin-inline-start: auto; }
.lat { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.lat.fast { color: var(--green); }
.lat.mid { color: var(--amber); }
.lat.slow { color: var(--red); }

/* ── 20. Docs ──────────────────────────────────────────────────────────── */
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; align-items: start; }
.docs-toc { position: sticky; top: calc(var(--topbar-h) + 24px); display: grid; gap: 2px; }
.site .docs-toc { top: 92px; }
.docs-toc a { font-size: 13.5px; color: var(--muted); padding: 6px 12px; border-inline-start: 2px solid var(--border); transition: color var(--d1), border-color var(--d1); }
.docs-toc a:hover { color: var(--text); }
.docs-toc a.is-active { color: var(--text); border-color: var(--brass-fill); font-weight: 500; }
.docs-toc .toc-title { font-size: 12px; color: var(--faint); padding: 0 12px 8px; }
.prose { max-width: 780px; min-width: 0; }
.prose section { scroll-margin-top: 96px; }
.prose section + section { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--border); }
.prose h2 { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.prose h3 { font-size: 16px; margin-block: 24px 10px; }
.prose p { color: var(--text-2); line-height: 1.95; }
.prose p + p { margin-top: 12px; }
.prose ul { padding-inline-start: 22px; color: var(--text-2); line-height: 1.95; margin-top: 8px; }
.prose .code, .prose .callout, .prose .table-frame { margin-top: 16px; }
.table-frame { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.table-frame .table td, .table-frame .table th { padding: 10px 14px; }
.endpoint { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 13.5px; direction: ltr; padding: 8px 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); }
.method { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: var(--green-soft); color: var(--green); }
.method.get { background: var(--blue-soft); color: var(--blue); }

/* ── 21. Admin ─────────────────────────────────────────────────────────── */
.admin-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.dist { display: grid; gap: 12px; }
.dist-row { display: grid; grid-template-columns: 150px 1fr 56px; gap: 12px; align-items: center; font-size: 13px; }
.dist-row .meter-bar { height: 8px; }
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-cell .avatar { width: 30px; height: 30px; font-size: 12px; }

/* ── 22. Auth modal ────────────────────────────────────────────────────── */
.auth { display: grid; grid-template-columns: 300px minmax(0, 1fr); max-width: 820px; }
.auth-art {
  position: relative;
  background:
    radial-gradient(90% 60% at 50% 30%, rgba(201, 155, 87, .22), transparent 70%),
    var(--ink);
  color: var(--on-ink);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
:root[data-theme="dark"] .auth-art { background: radial-gradient(90% 60% at 50% 30%, rgba(201, 155, 87, .16), transparent 70%), #0A0A0C; color: #F1EDE5; border-inline-end: 1px solid var(--border); }
.auth-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--lattice);
  background-size: 56px 56px;
  opacity: .3;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 80%);
  mask-image: linear-gradient(to bottom, #000, transparent 80%);
  pointer-events: none;
}
.auth-art .iso { align-self: center; margin-block: 8px; position: relative; z-index: 1; }
.auth-art h3 { color: inherit; font-size: 18px; position: relative; z-index: 1; }
.auth-art ul { list-style: none; padding: 0; display: grid; gap: 10px; font-size: 13px; position: relative; z-index: 1; opacity: .8; }
.auth-art li { display: flex; gap: 8px; align-items: flex-start; }
.auth-art li .i { color: #D6AE6C; margin-top: 4px; width: 15px; height: 15px; }
.auth-main { display: flex; flex-direction: column; min-width: 0; }
.auth-main .modal-body { flex: 1; }
.auth-tabs { margin: 22px 24px 0; }
.auth-done { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 32px 8px 8px; }
.auth-done h3 { font-size: 18px; }
.auth-done p { color: var(--muted); font-size: 14px; max-width: 38ch; }
.form-error { margin-top: 16px; }

/* ── 23. Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2.grid-even { grid-template-columns: minmax(0, 1fr); }
  .pg { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 980px) {
  .console { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(300px, 86vw);
    transform: translateX(105%);
    transition: transform var(--d3) var(--ease);
    box-shadow: var(--shadow-3);
  }
  .console.nav-open .sidebar { transform: none; }
  .sidebar-top .btn-icon { display: inline-flex; }
  .topbar { padding-inline: 16px; }
  .topbar .menu-toggle { display: inline-flex; }
  .content { padding: 24px 16px; }
  .hero-grid { grid-template-columns: 1fr; gap: 16px; }
  .hero-visual { min-height: 0; order: -1; }
  .hero-visual .iso { width: min(100%, 440px); }
  .hero-code { width: 100%; margin-top: -16%; }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .tile, .tile.span-3, .tile.span-4 { grid-column: span 2; }
  .steps { grid-template-columns: 1fr; }
  .step + .step { border-inline-start: 0; border-top: 1px solid var(--border); }
  .docs { grid-template-columns: 1fr; gap: 24px; }
  .docs-toc { position: static; display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .docs-toc .toc-title { display: none; }
  .docs-toc a { border-inline-start: 0; border-bottom: 2px solid var(--border); white-space: nowrap; }
  .docs-toc a.is-active { border-color: var(--brass-fill); }
  .pg { grid-template-columns: 1fr; height: auto; }
  .pg-chat { height: calc(100dvh - var(--topbar-h) - 48px - 70px); min-height: 480px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .site-nav nav { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .cta-band { grid-template-columns: 1fr; padding: 40px 28px; }
  .welcome { grid-template-columns: auto 1fr; }
  .welcome-actions { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .container { padding-inline: 16px; }
  .section { padding-block: 64px; }
  .hero { padding-block: 24px 64px; }
  .kpis, .admin-kpis { grid-template-columns: 1fr; }
  .plans { grid-template-columns: 1fr; }
  .quick-fields, .field-row { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 21px; }
  .welcome { padding: 20px; grid-template-columns: 1fr; }
  .welcome .iso { display: none; }
  .modal-root { padding: 0; place-items: end center; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92dvh; overflow-y: auto; animation-name: sheet-in; }
  .palette { margin-top: 0; align-self: end; }
  .modal-root.is-closing .modal { animation-name: sheet-out; }
  .site-nav .nav-actions .btn-secondary { display: none; }
  .footer-grid { grid-template-columns: 1fr; }
  .toasts { inset-inline-start: 16px; bottom: 16px; }
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table-cards td { padding: 4px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
  .table-cards td[data-label]::before { content: attr(data-label); font-size: 12px; color: var(--faint); flex-shrink: 0; }
  .table-cards td.actions { justify-content: flex-end; padding-top: 8px; width: 100%; }
  .table-cards .truncate { max-width: 60vw; }
  .toolbar .input-group { max-width: none; }
  .topbar-actions .btn-label { display: none; }
  .dist-row { grid-template-columns: 130px 1fr 40px; }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }

@media (hover: none) {
  [data-tip]::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .float { animation: none; }
}

