/* Preamble — FLAT DESIGN SYSTEM (sleek modern flat, NOT AI-slop)
 * ───────────────────────────────────────────────────────────────────────────
 * SURFACES: solid opaque elevation fills (no translucency).
 *   Dark:  --bg-0 #090d18 canvas; --surface #131a2b (cards/chips/inputs);
 *          --surface-2 #1a2236 (nested/active/logos); --surface-3 #232c43
 *          (highest inline/active segmented); --bg-1 #0e1424 (modal body/wells);
 *          --bg-2 #141b2e (code).
 *   Light: --bg-0 #eef2f9 canvas; --surface #ffffff; --surface-2 #f1f5fb;
 *          --surface-3 #e6ecf5; --bg-1 #f4f7fc; --bg-2 #e9eef6.
 * BORDERS: --border is TRANSPARENT (cards/chips/buttons have NO border).
 *   --hairline = ONLY for inputs (resting) and inline code.
 *   --divider  = ONLY for MAJOR pane seams (topbar/body, sidebar/main,
 *                modal header/footer, section bands, table header→rows,
 *                console nav/main).
 * NO decorative gradients. Progress/meter/adoption/spend bars = SOLID
 *   var(--accent) (or var(--cyan) for a 2nd series; semantic green/amber/rose
 *   for status). SVG area-chart fades (data viz) are OK.
 * NO glows. No --accent-glow box-shadows. One soft elevation shadow
 *   var(--shadow-md) ONLY on true overlays (modals/menus/popovers); none on
 *   inline cards. Keep the .dot.live green pulse (sanctioned functional glow).
 * NO backdrop-filter anywhere EXCEPT .modal-backdrop scrim.
 * RADIUS: --radius-sm 8 (chips/inputs/icons); --radius 12 (cards);
 *   --radius-lg 16 (modals); --radius-pill 999. Retire 22px/ad-hoc radii.
 * IDENTITY: navy base, electric-blue var(--accent) primary, var(--cyan)
 *   secondary, green = STATUS ONLY. Fonts unchanged.
 * HOVER = elevation step (surface→surface-2) + optional translateY(-1px);
 *   never a glow/border.
 * ─────────────────────────────────────────────────────────────────────────── */

:root, [data-theme="dark"] {
  --bg-0: #090d18;
  --bg-1: #0e1424;
  --bg-2: #141b2e;
  --surface: #131a2b;
  --surface-2: #1a2236;
  --surface-3: #232c43;
  --surface-hover: #1a2236;
  --border: transparent;
  --border-strong: transparent;
  --border-bright: transparent;
  --hairline: rgba(255, 255, 255, 0.06);
  --divider: rgba(255, 255, 255, 0.08);
  --text: #eef2f8;
  --text-dim: #aab4c6;
  --text-muted: #8b96aa;
  --text-faint: #616c81;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.13);
  --accent-glow: transparent;
  --on-accent: #ffffff;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.12);
  --brand-shine: #bcd4ff;
  --blue: #3b82f6;
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.16);
  --pink: #f472b6;
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --rose: #fb7185;
  --rose-soft: rgba(251, 113, 133, 0.14);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
  --shadow-lg: var(--shadow-md);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: var(--radius-lg);
  --radius-pill: 999px;
  --atmos-1: radial-gradient(1200px 760px at 88% -24%, rgba(59, 130, 246, 0.06), transparent 62%);
}

[data-theme="light"] {
  --bg-0: #eef2f9;
  --bg-1: #f4f7fc;
  --bg-2: #e9eef6;
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --surface-3: #e6ecf5;
  --surface-hover: #f1f5fb;
  --border: transparent;
  --border-strong: transparent;
  --border-bright: transparent;
  --hairline: rgba(15, 23, 42, 0.08);
  --divider: rgba(15, 23, 42, 0.10);
  --text: #0b1220;
  --text-dim: #485069;
  --text-muted: #69748a;
  --text-faint: #98a2b4;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --accent-glow: transparent;
  --on-accent: #ffffff;
  --cyan: #0891b2;
  --cyan-soft: rgba(8, 145, 178, 0.10);
  --brand-shine: #2563eb;
  --blue: #2563eb;
  --violet: #7c3aed;
  --violet-soft: rgba(124, 58, 237, 0.12);
  --pink: #db2777;
  --amber: #b45309;
  --amber-soft: rgba(180, 83, 9, 0.12);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.12);
  --rose: #e11d48;
  --rose-soft: rgba(225, 29, 72, 0.10);
  --shadow-md: 0 8px 24px -8px rgba(15, 23, 42, 0.08);
  --shadow-lg: var(--shadow-md);
  --atmos-1: radial-gradient(1200px 760px at 88% -24%, rgba(37, 99, 235, 0.05), transparent 62%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-feature-settings: "ss01", "cv11";
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

body {
  overflow: hidden;
}

#root { height: 100vh; }

button { font-family: inherit; letter-spacing: inherit; cursor: pointer; }

/* Atmospheric background — single faint --atmos-1 wash over solid --bg-0 */
.atmos {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    var(--atmos-1),
    var(--bg-0);
  z-index: 0;
}

.atmos::before { display: none; }

[data-theme="light"] .atmos::before { display: none; }

.noise { display: none; }

/* Flat elevation surfaces (formerly "glass") — solid, no blur, no border */
.glass {
  background: var(--surface);
}

.glass-strong {
  background: var(--surface-2);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,0.12); background-clip: padding-box; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.08); background-clip: padding-box; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background-color: rgba(0,0,0,0.16); background-clip: padding-box; }

/* Utilities */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.grow { flex: 1; min-width: 0; }
.center { align-items: center; justify-content: center; }
.between { justify-content: space-between; }
.relative { position: relative; }
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-feature-settings: normal; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* Buttons — no border, no glow; hover = elevation step */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, transform .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset;
}
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--surface-hover); transform: none; }
.btn-icon { padding: 8px; width: 32px; height: 32px; border-radius: var(--radius-sm); }

/* Pills / chips — no border */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 0;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.chip-accent {
  color: var(--accent);
  background: var(--accent-soft);
}

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.dot.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); animation: livePulse 2.4s infinite; }
.dot.warn { background: var(--amber); }
.dot.err { background: var(--rose); }
.dot.off { background: var(--text-faint); }

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--green-soft); }
  50% { box-shadow: 0 0 0 6px rgba(52,211,153,0.05); }
}

/* Focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Headings */
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; font-weight: 600; }

/* Heading utility */
.kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 500;
}

/* Card surfaces — no border, no backdrop-filter, no inline shadow */
.card {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  transition: background .18s, transform .18s;
}
.card:hover { background: var(--surface-2); }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.fade-up { animation: fadeUp .4s cubic-bezier(.2,.7,.2,1) both; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.shimmer {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
  background-size: 200% 100%;
  animation: shimmer 2.4s linear infinite;
}

/* Soft halo decoration — retired (flat) */
.halo { position: relative; }
.halo::before { display: none; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4,5,8,0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease-out;
}
[data-theme="light"] .modal-backdrop { background: rgba(15,18,28,0.32); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-1);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: modalIn .25s cubic-bezier(.2,.8,.2,1) both;
  position: relative;
}
.modal::before { display: none; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* Markdown-ish content */
/* Break long unbroken tokens (URLs, hashes, JWTs) so they can't overflow the
   message column. Code blocks scroll horizontally instead (see .md pre). */
.md { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.md p { margin: 0 0 14px; line-height: 1.65; color: var(--text); }
.md h1, .md h2, .md h3 { margin: 24px 0 12px; }
.md h2 { font-size: 20px; }
.md h3 { font-size: 16px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 22px; line-height: 1.7; }
.md li { margin: 4px 0; }
.md code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.88em;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 6px;
}
.md pre {
  background: var(--bg-2);
  border: 0;
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0 0 14px;
}
.md pre code { background: transparent; padding: 0; border: 0; }
.md a { color: var(--cyan); text-decoration: underline; text-decoration-color: rgba(34,211,238,0.4); text-underline-offset: 2px; }
.md blockquote { padding: 10px 14px; margin: 0 0 14px; color: var(--text-dim); background: var(--surface); border-radius: 8px; }
.md hr { border: 0; border-top: 1px solid var(--divider); margin: 18px 0; }
.md-table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13.5px; display: block; overflow-x: auto; }
.md-table th, .md-table td { border: 1px solid var(--hairline); padding: 7px 11px; text-align: left; vertical-align: top; }
.md-table th { background: var(--surface); font-weight: 600; }
.md-table tr:nth-child(even) td { background: var(--surface); }

/* Universal "control plane" card pattern — shared by integrations, skills, marketplaces */
.int-card {
  position: relative;
  padding: 14px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.int-card:hover { background: var(--surface-2); transform: translateY(-1px); }
.int-card.off { cursor: default; opacity: 0.55; }
.int-card.off:hover { background: var(--surface); transform: none; }

.int-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.int-logo {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 0;
}

.int-titles { min-width: 0; }
.int-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.int-name {
  font-size: 14px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.int-kind {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.6;
  background: var(--surface-3);
  color: var(--text-muted);
  border: 0;
  flex-shrink: 0;
}
.int-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-dim);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.int-tools { color: var(--text-muted); }
.int-more {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  display: grid; place-items: center;
  align-self: center;
}
.int-more:hover { background: var(--surface-hover); color: var(--text); }
.int-cta {
  margin-top: 12px;
  display: flex; align-items: center; gap: 10px;
}

/* Control-plane shared section intro (used by Kits, Governance, Adoption) */
.kits-intro {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px 24px; margin-bottom: 20px; flex-wrap: wrap;
}
.kits-h { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.kits-sub { font-size: 13.5px; color: var(--text-dim); line-height: 1.55; max-width: 640px; }

/* Control-plane shared toolbar (search + filter group) */
.cp-toolbar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.cp-search {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text-muted);
  max-width: 520px;
}
.cp-search input {
  flex: 1; background: transparent; border: 0; outline: none;
  color: var(--text); font-family: inherit; font-size: 13.5px;
}
.cp-search input::placeholder { color: var(--text-muted); }

.filter-group {
  display: inline-flex;
  padding: 4px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-sm);
}
.fg-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.fg-btn:hover { color: var(--text); }
.fg-btn.active { background: var(--surface-3); color: var(--text); }
.fg-count {
  display: inline-block;
  min-width: 18px; padding: 0 5px;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: 99px;
}
.fg-btn.active .fg-count { color: var(--text-dim); background: var(--bg-2); }

/* Selection */
::selection { background: var(--accent-soft); color: var(--text); }

/* Brand wordmark — a sleek bold-italic "Pr" monogram (math f(x) feel) that
   expands to the full "Preamble" on hover. An occasional sheen sweeps the "Pr". */
.brand-word {
  display: inline-flex;
  align-items: baseline;
  font-family: 'Playfair Display', 'Times New Roman', Cambria, Georgia, serif;
  font-style: italic;
  line-height: 1;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
}
/* the persistent "Pr" monogram — bold, with the spotlight sheen clipped to it */
.bw-pr {
  display: inline-block;
  font-weight: 700;
  background-image: linear-gradient(105deg,
    var(--text) 0%, var(--text) 38%,
    var(--brand-shine) 50%,
    var(--text) 62%, var(--text) 100%);
  background-size: 240% 100%;
  background-position: 170% 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: brandSheen 9s ease-in-out infinite;
}
/* the "eamble" tail — lighter, collapsed by default, reveals on hover only */
.bw-tail {
  display: inline-block;
  font-weight: 500;
  color: var(--text);
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width .42s cubic-bezier(.2,.7,.2,1), opacity .3s ease;
}
.brand-word:hover .bw-tail,
.brand:hover .bw-tail,
.lp-brand:hover .bw-tail { max-width: 6em; opacity: 1; }
@keyframes brandSheen {
  0%, 84% { background-position: 170% 0; }
  100%    { background-position: -70% 0; }
}

/* Screen-reader-only */
.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;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
