/* Light palette (default) ported verbatim from LlamaNexus-WebUI's own frontend/src/index.css
   :root block - the actual app's light theme, which the dark block below was itself originally
   seeded from (see that block's own comment). --danger has no light value there to borrow, so
   it's a fresh pick paired with the existing dark --danger by hue; --success has no equivalent
   in the WebUI app at all (it doesn't use that token), so it's a fresh pick too. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-sidebar: #f7f6f4;
  --bg-elevated: #ffffff;
  --border: #e5e3df;
  --text: #2d2a26;
  --text-muted: #6b6862;
  --accent: #cc7a4d;
  --accent-hover: #b8683d;
  --accent-soft: color-mix(in srgb, var(--accent) 15%, var(--bg));
  --danger: #c0392b;
  --success: #2e7d4f;
}

/* Dark palette, ported verbatim from LlamaNexus-Docs's app/globals.css :root block (itself
   seeded from LlamaNexus-WebUI's own dark theme) - this part was already plain CSS custom
   properties, not Tailwind, so no translation needed. Applied on an explicit dark choice
   (theme-toggle in site_nav(), stored in localStorage - see the inline script in
   render_page_start()), which always wins over the OS preference below. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #1e1e1e;
  --bg-sidebar: #181818;
  --bg-elevated: #262624;
  --border: #3a3835;
  --text: #e8e6e1;
  --text-muted: #a19d95;
  --accent: #d88a5c;
  --accent-hover: #e5996a;
  --accent-soft: color-mix(in srgb, var(--accent) 15%, var(--bg));
  --danger: #e57373;
  --success: #81c995;
}

/* :not([data-theme='light']) - an explicit light choice must opt out of this even when the OS
   itself prefers dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #1e1e1e;
    --bg-sidebar: #181818;
    --bg-elevated: #262624;
    --border: #3a3835;
    --text: #e8e6e1;
    --text-muted: #a19d95;
    --accent: #d88a5c;
    --accent-hover: #e5996a;
    --accent-soft: color-mix(in srgb, var(--accent) 15%, var(--bg));
    --danger: #e57373;
    --success: #81c995;
  }
}

* { box-sizing: border-box; }

/* Reserves the vertical scrollbar's width unconditionally, whether or not a given page's content
   is actually tall enough to need one. Without this, every margin:0 auto centered block (.docs-
   main, .site-header-inner, .hero, ...) sits at a slightly different horizontal position on a
   short page (no scrollbar) than on a long one (scrollbar present) - most visible switching
   between docs pages of very different lengths, where the sidebar/content block appears to shift
   sideways for no apparent reason even though its own CSS never changes. */
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

a { color: inherit; text-decoration: none; }
.link-strong { color: var(--accent); font-weight: 600; }
.link-strong:hover { text-decoration: underline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-align: center;
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-outline { background: none; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-elevated); }
.btn-submit { width: 100%; margin-top: 4px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

/* Header / nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -0.01em; font-size: 17px; }
.site-brand img { width: 26px; height: 26px; border-radius: 7px; }
.site-nav { display: flex; align-items: center; gap: 28px; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.site-nav a:hover { color: var(--text); }

/* Light/dark switcher (site_nav()) - same two-button sun/moon group as ZenBooks-PHP's own, and
   the Node ZenBooks app's ThemeToggle before that. */
.theme-toggle {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}
.theme-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button.active { background: var(--accent); color: #fff; }

.account-menu { position: relative; }
/* No font: inherit here - that shorthand also pulls in body's line-height: 1.5, making this
   button ~4.5px taller than a plain UA-default button line-height (see ZenBooks-PHP's own
   identical rule, which never had this) and inflating the whole .site-header row's height to
   match once logged in, since it becomes the tallest flex child. */
.account-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.account-menu-trigger:hover { background: var(--bg-sidebar); }
.account-menu-popup {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  width: 160px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  z-index: 20;
}
.account-menu.open .account-menu-popup { display: block; }
.account-menu-popup a,
.account-menu-popup .link-button {
  display: block;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}
.account-menu-popup a:hover,
.account-menu-popup .link-button:hover { background: var(--bg-sidebar); }

/* Landing page */
.hero { max-width: 760px; margin: 0 auto; padding: 90px 24px 70px; text-align: center; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 24px;
}
.hero h1 { font-size: clamp(32px, 5vw, 52px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 0; }
.hero-subtitle { margin: 22px auto 0; max-width: 560px; color: var(--text-muted); font-size: 18px; }
.hero-actions { margin-top: 34px; }

.product-grid {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px 80px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.product-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 26px;
  transition: border-color 0.15s;
}
.product-card:hover { border-color: var(--accent); }
.product-card-kicker { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.product-card h3 { margin: 8px 0 0; font-size: 16px; font-weight: 700; }
.product-card-tagline { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.product-card-description { margin: 10px 0 0; font-size: 14px; color: var(--text-muted); flex: 1; }
.product-card-link { margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--accent); }
.product-card:hover .product-card-link { text-decoration: underline; }

/* Auth pages */
/* width: 100% is required, not decorative - body is display:flex;flex-direction:column (for the
   sticky footer), and a flex item with auto cross-axis margins but no explicit width shrinks-to-fit
   its content instead of filling up to max-width, so short content silently renders narrower than
   intended. Every top-level, directly-body-child centered container below needs this same pairing. */
.auth-shell { width: 100%; max-width: 420px; margin: 0 auto; padding: 64px 24px; min-height: 55vh; display: flex; flex-direction: column; justify-content: center; }
.auth-shell h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.auth-subtitle { margin: 8px 0 0; font-size: 14px; color: var(--text-muted); }
.auth-body { margin-top: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-footer { margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.auth-footer-links { display: flex; flex-direction: column; gap: 8px; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-legal-notice { margin: -6px 0 0; font-size: 12px; color: var(--text-muted); }
.auth-legal-notice a { color: var(--text-muted); text-decoration: underline; }
.auth-legal-notice a:hover { color: var(--text); }
.form-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.form-field input {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.form-field input:focus { outline: none; border-color: var(--accent); }
.form-field-hint { font-size: 12px; color: var(--text-muted); font-weight: 400; }

.password-input-wrap { position: relative; display: flex; }
.password-input-wrap input { flex: 1; padding-right: 38px; }
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.password-toggle:hover { color: var(--text); background: var(--bg-elevated); }
.password-toggle .icon-eye-off { display: none; }
.password-toggle.showing .icon-eye { display: none; }
.password-toggle.showing .icon-eye-off { display: block; }

.form-message { border-radius: 8px; padding: 9px 12px; font-size: 14px; margin: 0; }
.form-message-error { border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.form-message-success { border: 1px solid color-mix(in srgb, var(--success) 40%, transparent); background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); }

.account-section { width: 100%; max-width: 760px; margin: 0 auto; padding: 40px 24px; }
.account-section h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 24px; }
.account-section h2 { font-size: 18px; margin: 0 0 16px; }
.account-section-subtitle { font-size: 13px; color: var(--text-muted); margin: -10px 0 16px; }

.plan-status-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: -10px 0 16px; }
.plan-status-row .account-section-subtitle { margin: 0; }

.account-form-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.account-logout-form { margin-top: 20px; }

.account-password-row { display: flex; align-items: center; gap: 14px; }
.account-password-dots { letter-spacing: 2px; color: var(--text-muted); }
.account-password-row button.link-strong { background: none; border: none; padding: 0; font: inherit; cursor: pointer; }

.password-dialog {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
}
.password-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.password-dialog h2 { font-size: 18px; margin: 0 0 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.plan-card { border: 1px solid var(--border); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.plan-card:hover { border-color: var(--accent); }
.plan-card h3 { margin: 0; font-size: 15px; }
.plan-card-limits {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plan-card-limits li { padding-left: 14px; position: relative; }
.plan-card-limits li::before { content: '\2022'; position: absolute; left: 0; color: var(--accent); }
.plan-card-actions { display: flex; gap: 8px; margin-top: 4px; }
.plan-card-actions form { flex: 1; }
.plan-card-actions .btn { width: 100%; }
.plan-card-actions .btn:hover { border-color: var(--accent); }
.plan-manage-billing { margin-top: 16px; }

/* Admin stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-tile-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.stat-tile-label { font-size: 13px; color: var(--text-muted); }

.license-key-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-all;
  font-size: 13px;
}

.installs-group-heading { font-size: 14px; font-weight: 600; color: var(--text-muted); margin: 20px 0 8px; }
.installs-group-heading:first-child { margin-top: 0; }

.installs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.installs-table th, .installs-table td { border-bottom: 1px solid var(--border); padding: 8px 6px; text-align: left; }
.installs-table td:last-child, .installs-table th:last-child { text-align: right; }
.installs-table .btn { padding: 4px 10px; font-size: 12px; }

/* Docs - sidebar + content two-column layout, dimensions matching ZenBooks-PHP's own docs.php
   exactly (240px sidebar, 48px gap, 1280px max width, 760px-capped content left-aligned within
   its column) - see docs_sidebar()/docs_page_start() in app/lib/render/partials.php. No per-page
   table of contents (the previous MDX pipeline's right-hand TOC has no equivalent here) - a
   prev/next .docs-pager at the bottom instead, same as ZenBooks.
   width: 100% is required here, NOT just max-width - unlike ZenBooks-PHP (plain block <body>),
   this site's <body> is `display: flex; flex-direction: column` (the sticky-footer pattern) so
   .docs-main is a flex item, not a normal block. A flex item with only max-width (no explicit
   width) sizes to fit its content instead of stretching to fill+cap - invisible on every other
   page here since their content already wants to fill their own max-width, but glaring on a docs
   sub-page: a 760px-capped .docs-content next to a 240px sidebar only needs ~1096px, so without
   this the whole block shrank to ~1100px instead of using the full 1280px allowance, misaligning
   it against every other docs page (whose wide, uncapped index-grid content happens to need the
   full width and so never exposed the bug). */
.docs-main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 40px 24px 72px; }
.docs-layout { display: grid; grid-template-columns: 240px 1fr; gap: 48px; align-items: start; }
/* No-sidebar pages (FAQ/privacy-policy/terms-of-service/usage-policy) are the sole grid item, so
   .docs-content (760px-capped below, same as every other docs page) needs its own centering here
   - a with-sidebar page instead leaves it left-aligned within the content column, same as
   ZenBooks. */
.docs-layout.docs-layout--no-sidebar { grid-template-columns: minmax(0, 1fr); }
.docs-layout.docs-layout--no-sidebar .docs-content { margin: 0 auto; }
.docs-sidebar {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  font-size: 14px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.docs-sidebar-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.docs-sidebar-section { display: flex; flex-direction: column; }
.docs-sidebar-section a {
  display: block;
  padding: 6px 10px;
  margin: 0 -10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
}
.docs-sidebar-section a:hover { background: var(--bg-elevated); color: var(--text); }
.docs-sidebar-section a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.docs-content { min-width: 0; max-width: 760px; }
.docs-content h1 { font-size: clamp(26px, 3vw, 34px); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; }
.docs-content .docs-lede { color: var(--text-muted); font-size: 16px; margin-bottom: 32px; }
.docs-content h2 { font-size: 21px; font-weight: 700; margin: 40px 0 12px; scroll-margin-top: 24px; }
.docs-content h2:first-of-type { margin-top: 0; }
.docs-content h3 { font-size: 16px; font-weight: 700; margin: 24px 0 8px; scroll-margin-top: 24px; }
.docs-content p { margin: 0 0 14px; color: var(--text); font-size: 15px; line-height: 1.65; }
.docs-content p.docs-muted { color: var(--text-muted); }
.docs-content ul, .docs-content ol { margin: 0 0 14px; padding-left: 22px; font-size: 15px; line-height: 1.65; }
.docs-content li { margin-bottom: 6px; }
.docs-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.docs-content pre.code-block { margin-bottom: 16px; }
.docs-content strong { font-weight: 700; }
.docs-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.docs-content table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 13.5px; }
.docs-content th, .docs-content td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.docs-content th { background: var(--bg-elevated); }

.docs-note {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 20px;
  font-size: 14px;
}
.docs-note p:last-child { margin-bottom: 0; }
.docs-note-warn { border-left-color: #c15b3a; }

.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.docs-pager a {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
}
.docs-pager a:hover { background: var(--bg-elevated); }
.docs-pager-label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.docs-pager-next { text-align: right; }

/* Fixed dark background regardless of theme (a code/terminal look, deliberately not
   theme-variable-based) - same as ZenBooks-PHP's own pre.code-block. Manually marked-up (no
   syntax-highlighting library) - wrap comment lines in <span class="comment">, literal values in
   <span class="accent">. */
pre.code-block {
  max-width: 100%;
  background: #0f1115;
  color: #d6e2e0;
  border-radius: 8px;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0 0 16px;
}
pre.code-block .comment { color: #6b7583; }
pre.code-block .accent { color: #6fd6b5; }

/* Card-grid navigation within a docs page body - same pattern as ZenBooks-PHP's own docs.php
   index grid, so a product's index page can link to its own sub-pages the same way. */
.docs-index-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 16px 0 32px;
}
.docs-content a.feature-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  background: var(--bg-elevated);
  text-decoration: none;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.docs-content a.feature-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.docs-content a.feature-card h3 { color: var(--accent); margin: 0 0 6px; }
.docs-content a.feature-card p { margin: 0; font-size: 14px; color: var(--text-muted); }

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  background: var(--bg-elevated);
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  color: var(--accent);
  font-size: 18px;
  font-weight: 400;
  flex-shrink: 0;
}
.faq-item[open] summary::after { content: '\2212'; }
.faq-item summary:hover { color: var(--accent); }
.faq-item p { margin: 12px 0 0; color: var(--text-muted); }
.faq-item p:first-child { margin-top: 12px; }

@media (max-width: 860px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
  }
  .docs-index-grid { grid-template-columns: 1fr; }
}

/* 404 */
.not-found { width: 100%; max-width: 480px; margin: 0 auto; padding: 100px 24px; text-align: center; flex: 1; }
.not-found h1 { font-size: 56px; margin: 0; color: var(--text-muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: auto; }
.site-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}
.site-footer-legal { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer-legal a:hover { color: var(--text); }
