/* ────────────────────────────────────────────────────────────────
   Color tokens aligned with the official prototype palette
   (prototype/assets/styles.css). Same hex values across both files.
   ──────────────────────────────────────────────────────────────── */
:root {
  --ai-bg:        #f5f8fc;   /* prototype bg-2 */
  --ai-panel:     #ffffff;   /* prototype bg-card */
  --ai-ink:       #0d1857;   /* prototype text  */
  --ai-muted:     #4d5b7d;   /* prototype text-2 */
  --ai-soft:      #eef3fa;   /* prototype bg-3 */
  --ai-line:      #e3e9f3;   /* prototype line */
  --ai-main:      #09aff4;   /* prototype clr-main */
  --ai-main-dark: #0a8fc7;   /* prototype clr-main-dark */
  --ai-navy:      #0d1857;   /* prototype clr-accent */
  --ai-danger:    #ef4444;   /* prototype clr-danger */
  --ai-good:      #10b981;   /* prototype clr-success */
  --ai-warn:      #f59e0b;   /* prototype clr-warning */
  --ai-shadow:    0 12px 32px rgba(13,24,87,.10);  /* prototype shadow-lg */
}

/* ── Dark mode — matches prototype [data-ai-theme="dark"] palette ─── */
html[data-ai-theme="dark"] {
  --ai-bg:        #060922;   /* prototype bg-1 dark */
  --ai-panel:     #0d143a;   /* prototype bg-card dark */
  --ai-ink:       #f0f4ff;   /* prototype text dark */
  --ai-muted:     #a8b2cc;   /* prototype text-2 dark */
  --ai-soft:      #11183f;   /* prototype bg-3 dark */
  --ai-line:      rgba(255,255,255,.10);  /* prototype line dark */
  --ai-main:      #09aff4;   /* same — accent color stays */
  --ai-main-dark: #0a8fc7;
  --ai-navy:      #060922;   /* matches body so sidebar blends */
  --ai-good:      #10b981;
  --ai-shadow:    0 16px 40px rgba(0,0,0,.5);
}
/* Glassy topbar tint per theme */
html[data-ai-theme="dark"] .ai-topbar {
  background: rgba(6,9,34,.88);
  border-bottom-color: var(--ai-line);
}
/* Plan hero gradient retuned for dark backgrounds */
html[data-ai-theme="dark"] .ai-plan-hero {
  background: linear-gradient(135deg,#0d143a,#0a8fc7);
}

* { box-sizing: border-box; }
body.ai-body {
  margin: 0;
  background: var(--ai-bg);
  color: var(--ai-ink);
  font-family: "Jost", Arial, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

/* ── Custom scrollbars — design system palette ─────────────────────────────
   All scrollable elements inside ai-body use the brand color scheme instead
   of the native OS/browser default scrollbar. */
.ai-body ::-webkit-scrollbar              { width: 6px; height: 6px; }
.ai-body ::-webkit-scrollbar-track        { background: var(--ai-soft); border-radius: 3px; }
.ai-body ::-webkit-scrollbar-thumb        { background: var(--ai-muted); border-radius: 3px; }
.ai-body ::-webkit-scrollbar-thumb:hover  { background: var(--ai-main); }
.ai-body ::-webkit-scrollbar-corner       { background: var(--ai-soft); }
/* Firefox */
.ai-body * { scrollbar-width: thin; scrollbar-color: var(--ai-muted) var(--ai-soft); }

/* Native date/month/datetime controls are shared by Career Forge and
   Back office. Chromium injects a calendar-picker icon that can become
   invisible on our dark input surfaces, so replace only that icon while
   leaving the native picker popup unchanged. */
.ai-body input[type="month"],
.ai-body input[type="date"],
.ai-body input[type="datetime-local"] {
  color-scheme: light;
  accent-color: var(--ai-main);
}

html[data-ai-theme="dark"] .ai-body input[type="month"],
html[data-ai-theme="dark"] .ai-body input[type="date"],
html[data-ai-theme="dark"] .ai-body input[type="datetime-local"] {
  color-scheme: dark;
}

.ai-body input[type="month"]::-webkit-calendar-picker-indicator,
.ai-body input[type="date"]::-webkit-calendar-picker-indicator,
.ai-body input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background: transparent
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230d1857'><path d='M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z'/><path d='M6.5 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-6 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-6 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></svg>")
    no-repeat center / 16px 16px;
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: .25rem;
  opacity: .85;
  cursor: pointer;
  filter: none;
}

html[data-ai-theme="dark"] .ai-body input[type="month"]::-webkit-calendar-picker-indicator,
html[data-ai-theme="dark"] .ai-body input[type="date"]::-webkit-calendar-picker-indicator,
html[data-ai-theme="dark"] .ai-body input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23e6edf3'><path d='M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z'/><path d='M6.5 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-6 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-6 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></svg>");
}

.ai-body input[type="month"]::-webkit-calendar-picker-indicator:hover,
.ai-body input[type="date"]::-webkit-calendar-picker-indicator:hover,
.ai-body input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.ai-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

.ai-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--ai-navy);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.ai-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 34px;
}

.ai-brand img { width: 38px; height: 38px; object-fit: contain; }
.ai-brand strong { display: block; font-size: 15px; line-height: 1; letter-spacing: .05em; }
.ai-brand small { color: var(--ai-main); display: block; font-size: 10px; letter-spacing: .18em; font-weight: 800; margin-top: 3px; }

.ai-sidebar-nav { display: flex; flex-direction: column; gap: 8px; }
.ai-sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 11px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.82);
  font-weight: 700;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.ai-sidebar-link i { font-size: 18px; width: 22px; text-align: center; }
.ai-sidebar-link:hover, .ai-sidebar-link.active {
  background: var(--ai-main);
  color: #fff;
  transform: translateX(2px);
}
.ai-sidebar-bottom {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.ai-exit-link { background: rgba(255,255,255,.05); }

.ai-main { min-width: 0; }
.ai-topbar {
  height: 72px;
  background: var(--ai-panel);
  border-bottom: 1px solid var(--ai-line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 25;
  backdrop-filter: blur(16px);
}
/* Hamburger is always visible (desktop = collapses sidebar column,
   mobile = opens overlay sidebar). Old .ai-mobile-menu kept for back-compat. */
.ai-mobile-menu { display: none; }
.ai-toggle-menu { display: inline-flex; }

/* Desktop collapsed state: hide the sidebar column and let main content
   span the full width. Mobile uses the existing .open / .ai-scrim behaviour. */
.ai-shell--collapsed { grid-template-columns: 1fr; }
.ai-shell--collapsed .ai-sidebar { display: none; }

/* Breadcrumb link styling */
.ai-crumb a {
  color: inherit;
  text-decoration: none;
  opacity: .65;
  transition: opacity .15s ease;
}
.ai-crumb a:hover { opacity: 1; text-decoration: underline; }

/* Drag-and-drop: visual highlight when files are being dragged onto the composer */
.ai-composer { position: relative; transition: border-color .15s ease, background .15s ease; }
.ai-composer.is-dragover {
  border: 2px dashed var(--ai-main);
  background: color-mix(in srgb, var(--ai-main) 8%, transparent);
}
.ai-composer.is-dragover::after {
  content: 'Drop files here';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--ai-main);
  pointer-events: none;
  background: color-mix(in srgb, var(--ai-panel) 70%, transparent);
  border-radius: inherit;
}

/* Attachment chips after drop or attach */
.ai-attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}
.ai-attachment-row:empty { display: none; }
/* Chip compacto estilo Claude/ChatGPT: solo preview o ícono; el nombre vive
   en el title (hover) y la × flota en la esquina del chip. */
.ai-attachment-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 56px;
  height: 56px;
  background: var(--ai-soft);
  border: 1px solid color-mix(in srgb, var(--ai-line) 80%, transparent);
  border-radius: 12px;
  font-size: 13px;
  color: var(--ai-ink);
  overflow: visible;
}
.ai-attachment-chip > i {
  font-size: 20px;
  color: var(--ai-main);
}
.ai-attachment-ext {
  position: absolute;
  bottom: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--ai-muted);
}
.ai-attachment-thumb {
  width: 100%;
  height: 100%;
  border-radius: 11px;
  object-fit: cover;
  background: color-mix(in srgb, var(--ai-ink) 8%, transparent);
}
.ai-attachment-chip button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--ai-muted);
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.ai-attachment-chip button:hover { color: #fff; background: var(--ai-danger); border-color: var(--ai-danger); }
.ai-icon-btn {
  border: 1px solid var(--ai-line);
  background: var(--ai-panel);
  color: var(--ai-ink);
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ai-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ai-muted);
  font-size: 13px;
  flex: 1;
}
.ai-crumb strong { color: var(--ai-ink); }
.ai-topbar-actions { display: flex; align-items: center; gap: 14px; }
.ai-credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--ai-panel);
  font-size: 12px;
  color: var(--ai-muted);
}
.ai-credit-pill b { color: var(--ai-main-dark); }
/* Outer button that wraps avatar + caret */
.ai-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 999px;
}
.ai-avatar-btn:focus-visible { outline: 2px solid var(--ai-main); outline-offset: 2px; }
.ai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--ai-main);
  color: #fff;
  font-weight: 800;
  padding: 0;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: cover;
  display: block;
}
.ai-avatar-caret {
  font-size: 11px;
  color: var(--ai-muted);
  transition: transform .2s ease;
  line-height: 1;
}
/* Rotate caret when dropdown is open */
.ai-user-menu:has(.ai-user-dropdown.open) .ai-avatar-caret { transform: rotate(180deg); }
.ai-user-menu { position: relative; }
.ai-user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 210px;
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: 10px;
  box-shadow: var(--ai-shadow);
  padding: 8px;
  display: none;
}
.ai-user-dropdown.open { display: block; }
.ai-user-dropdown a, .ai-user-dropdown button {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  color: var(--ai-ink);
  font-weight: 700;
  text-align: left;
}
.ai-user-dropdown form { margin: 0; }
.ai-user-dropdown a:hover, .ai-user-dropdown button:hover { background: var(--ai-soft); }

.ai-page { padding: 28px; max-width: 1240px; margin: 0 auto; }
.ai-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.ai-kicker {
  display: inline-block;
  color: var(--ai-main);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 800;
  margin-bottom: 8px;
}
.ai-page-head h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.05; }
.ai-page-head p { margin: 10px 0 0; color: var(--ai-muted); font-size: 16px; max-width: 680px; }

.ai-card {
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: 10px;
  box-shadow: var(--ai-shadow);
  padding: 20px;
}
.ai-grid { display: grid; gap: 20px; margin-bottom: 20px; }
.ai-grid-2 { grid-template-columns: minmax(0, 1.3fr) minmax(300px, .9fr); }
.ai-grid-vault { grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
.ai-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.ai-kpi span, .ai-section-title span { color: var(--ai-main); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; font-weight: 800; }
.ai-kpi strong { display: block; font-size: 30px; margin: 8px 0; }
.ai-kpi small, .ai-note, .ai-section-title small { color: var(--ai-muted); }
.ai-kpi--link { text-decoration: none; color: inherit; cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
.ai-kpi--link:hover { border-color: var(--ai-main); transform: translateY(-1px); }

.ai-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.ai-section-title a { color: var(--ai-main-dark); font-weight: 800; }

.ai-btn {
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  cursor: pointer;
}
.ai-btn-primary { background: var(--ai-main); color: #fff; border-color: var(--ai-main); }
.ai-btn-soft { background: var(--ai-soft); color: var(--ai-ink); }
.ai-btn-danger {
  background: color-mix(in srgb, var(--ai-danger) 12%, transparent);
  color: var(--ai-danger);
  border-color: color-mix(in srgb, var(--ai-danger) 35%, transparent);
}
.ai-btn.full { width: 100%; }
.ai-btn:disabled { opacity: .65; cursor: not-allowed; }

.ai-action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ai-action-grid a {
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  font-weight: 800;
}
.ai-action-grid a.featured { background: var(--ai-main); border-color: var(--ai-main); color: #fff; }

.ai-pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--ai-soft);
  color: var(--ai-ink);
  font-size: 12px;
  font-weight: 800;
}
.ai-pill.good {
  background: color-mix(in srgb, var(--ai-good) 14%, transparent);
  color: var(--ai-good);
}
.ai-url {
  font-weight: 800;
  background: var(--ai-soft);
  padding: 12px;
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-cert-row { display: flex; gap: 14px; margin-top: 18px; }
.ai-cert-row img { width: 72px; height: 72px; object-fit: contain; }

.ai-list { display: grid; gap: 10px; }
.ai-list > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  padding: 12px;
}
.ai-list span { color: var(--ai-muted); font-size: 12px; }
.ai-list a { grid-row: 1 / span 2; grid-column: 2; border: 1px solid var(--ai-line); border-radius: 7px; padding: 8px 12px; font-weight: 800; }

.ai-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ai-form-grid .wide { grid-column: 1 / -1; }
.ai-form-grid label, .ai-label { display: grid; gap: 7px; color: var(--ai-muted); font-size: 13px; font-weight: 800; }
.ai-input {
  width: 100%;
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  background: var(--ai-panel);
  color: var(--ai-ink);
  padding: 12px 14px;
  outline: 0;
}
textarea.ai-input { min-height: 110px; resize: vertical; }
.ai-select { margin-bottom: 12px; }
.ai-inline-actions, .ai-result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
/* Honor the HTML5 hidden attribute everywhere, including elements with explicit display rules. */
[hidden] { display: none !important; }
.ai-table { display: grid; gap: 0; border: 1px solid var(--ai-line); border-radius: 8px; overflow: hidden; }
.ai-table > div { display: grid; grid-template-columns: 1.3fr .5fr 1fr; gap: 12px; align-items: center; padding: 14px; border-bottom: 1px solid var(--ai-line); }
.ai-table > div:last-child { border-bottom: 0; }
.ai-table .head { background: var(--ai-soft); color: var(--ai-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; }
.ai-table button { border: 1px solid var(--ai-line); background: var(--ai-panel); color: var(--ai-ink); border-radius: 6px; padding: 6px 8px; margin-left: 4px; }

.ai-composer {
  border: 1px solid var(--ai-line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--ai-panel);
}
.ai-composer textarea {
  width: 100%;
  min-height: 180px;
  border: 0;
  outline: 0;
  resize: vertical;
  padding: 16px;
  background: transparent;
  color: var(--ai-ink);
}
.ai-attachment-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px 4px; }
.ai-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--ai-muted);
  font-size: 12px;
  font-weight: 800;
}
.ai-file-chip button { border: 0; background: transparent; color: var(--ai-muted); }
.ai-composer-footer {
  border-top: 1px solid var(--ai-line);
  background: var(--ai-soft);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
/* Globito explicativo (estilo cómic) del selector de páginas: fila propia
   arriba de los controles del footer, con la flechita hacia abajo apuntando
   al stepper (que queda a la izquierda del botón primario). */
.ai-composer-footer { flex-wrap: wrap; }
.ai-pages-bubble {
  position: relative;
  order: -1;
  flex: 0 0 100%;
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
  color: var(--ai-ink);
  background: color-mix(in srgb, var(--ai-main) 10%, var(--ai-panel));
  border: 1px solid color-mix(in srgb, var(--ai-main) 45%, transparent);
  border-radius: 10px;
  padding: 8px 14px;
  margin-bottom: 6px;
}
.ai-pages-bubble::after {
  content: '';
  position: absolute;
  bottom: -5px;
  /* El JS del composer fija --ai-bubble-arrow-right al centro del stepper. */
  right: var(--ai-bubble-arrow-right, 200px);
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  background: inherit;
  border-bottom: 1px solid color-mix(in srgb, var(--ai-main) 45%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--ai-main) 45%, transparent);
}

/* Stepper de páginas: píldora alineada a la derecha, junto al botón primario. */
.ai-pages-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: var(--ai-panel);
  padding: 3px;
  align-self: center;
}
.ai-pages-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--ai-soft);
  color: var(--ai-ink);
  font-size: 15px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.ai-pages-btn:hover {
  background: var(--ai-main);
  color: #fff;
}
.ai-pages-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  font-size: 12.5px;
  color: var(--ai-muted);
  white-space: nowrap;
}
.ai-pages-value i { color: var(--ai-main); }
.ai-pages-value strong {
  color: var(--ai-ink);
  font-size: 14px;
  min-width: 14px;
  text-align: center;
}

.ai-readiness {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 4px 12px;
  align-items: center;
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  padding: 14px;
}
.ai-readiness i { grid-row: 1 / span 2; color: var(--ai-good); font-size: 34px; }
.ai-readiness span { color: var(--ai-muted); }
.ai-preview-paper {
  margin-top: 16px;
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  padding: 18px;
  background: var(--ai-panel);
}
.ai-preview-paper h3 { margin: 0; }
.ai-preview-paper span { display: block; height: 10px; background: var(--ai-soft); border-radius: 20px; margin-top: 10px; }
.ai-preview-paper .short { width: 64%; }

.ai-tree { display: grid; gap: 6px; margin-bottom: 16px; }
.ai-tree button {
  border: 0;
  background: transparent;
  color: var(--ai-ink);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  min-height: 38px;
  border-radius: 7px;
  padding: 8px;
  text-align: left;
  font-weight: 700;
}
.ai-tree button.active, .ai-tree button:hover { background: var(--ai-soft); }
.ai-tree span { margin-left: auto; color: var(--ai-muted); }
.ai-tree .indent { padding-left: 28px; }

/* ── Knowledge Vault folder tree (matches prototype/vault.html) ────── */
.ai-vault-tree-card { padding: 14px; }
.ai-vault-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}
.ai-tnode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-muted);
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: background .12s ease, color .12s ease;
}
.ai-tnode:hover { background: var(--ai-soft); }
.ai-tnode.active {
  background: color-mix(in srgb, var(--ai-main) 12%, transparent);
  color: var(--ai-main);
}
.ai-tnode i.bi { font-size: 14px; flex-shrink: 0; }
.ai-tnode-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ai-tnode-count {
  margin-left: auto;
  font-size: 10.5px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--ai-muted);
  background: var(--ai-soft);
  padding: 1px 6px;
  border-radius: 99px;
  flex-shrink: 0;
}
.ai-tnode.active .ai-tnode-count {
  background: color-mix(in srgb, var(--ai-main) 18%, transparent);
  color: var(--ai-main);
}
.ai-tnode-indent-1 { padding-left: 22px; }
.ai-tnode-indent-2 { padding-left: 36px; }
.ai-tnode-indent-3 { padding-left: 50px; }

/* Drag-and-drop visual feedback */
.ai-tnode[draggable="true"] { cursor: grab; }
.ai-tnode.is-dragging { opacity: .4; cursor: grabbing; }
/* Protected (e.g. "General"): not draggable, no folder ops, items-only bucket */
.ai-tnode.is-protected { cursor: default; }
.ai-tnode.is-protected .ai-tnode-name::after {
  content: ' ★';
  color: var(--ai-warn);
  font-size: 10px;
  margin-left: 2px;
  vertical-align: super;
}
.ai-tnode.is-drop-target {
  outline: 2px dashed var(--ai-main);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--ai-main) 6%, transparent);
}
/* ── Generic modal (Settings → Delete account confirmation) ───────── */
.ai-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.ai-modal-backdrop[hidden] { display: none; }
.ai-modal {
  background: var(--ai-panel);
  color: var(--ai-ink);
  border: 1px solid var(--ai-line);
  border-radius: 12px;
  box-shadow: var(--ai-shadow);
  padding: 22px;
  width: min(440px, 100%);
}
/* Inline toast inside the folder tree card (replaces window.alert errors) */
.ai-vault-toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  animation: ai-toast-in .22s ease-out;
}
.ai-vault-toast.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s; }
.ai-vault-toast-error {
  background: color-mix(in srgb, var(--ai-danger) 14%, transparent);
  color: var(--ai-danger);
  border: 1px solid color-mix(in srgb, var(--ai-danger) 35%, transparent);
}
.ai-vault-toast i.bi { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.ai-vault-toast-msg { flex: 1; min-width: 0; word-wrap: break-word; }
.ai-vault-toast-close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: .7;
  flex-shrink: 0;
}
.ai-vault-toast-close:hover { opacity: 1; }
@keyframes ai-toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Inline rename / create input embedded into a tree node */
.ai-tnode-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-ink);
  background: var(--ai-soft);
  border: 1.5px solid var(--ai-main);
  border-radius: 4px;
  padding: 2px 6px;
  margin: -3px 0;  /* tighten vertical so the row height doesn't jump */
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-main) 18%, transparent);
}
.ai-tnode.is-new {
  background: color-mix(in srgb, var(--ai-main) 6%, transparent);
}
/* Inline delete confirmation strip (lives inside the row, no modal) */
.ai-tnode.is-confirming-delete {
  background: color-mix(in srgb, var(--ai-danger) 12%, transparent);
  outline: 1px solid color-mix(in srgb, var(--ai-danger) 35%, transparent);
}
.ai-tnode-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ai-tnode-confirm-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--ai-ink);
}
.ai-tnode-confirm-text b {
  color: var(--ai-danger);
  font-weight: 700;
}
.ai-tnode-confirm-yes,
.ai-tnode-confirm-no {
  border: 0;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.ai-tnode-confirm-yes {
  background: var(--ai-danger);
  color: #fff;
}
.ai-tnode-confirm-yes:hover {
  background: color-mix(in srgb, var(--ai-danger) 85%, black);
}
.ai-tnode-confirm-no {
  background: transparent;
  color: var(--ai-muted);
  border: 1px solid var(--ai-line);
}
.ai-tnode-confirm-no:hover {
  background: var(--ai-soft);
  color: var(--ai-ink);
}
/* Folder highlighted as a drop target when an item card is dragged over it */
.ai-tnode--item-drop-target {
  background: color-mix(in srgb, var(--ai-main) 14%, transparent) !important;
  outline: 2px dashed var(--ai-main);
  outline-offset: -2px;
  border-radius: 6px;
}
/* Draggable item cards */
.ai-saved-item[draggable="true"] { cursor: grab; }
.ai-saved-item[draggable="true"]:active { cursor: grabbing; }
.ai-saved-item.is-pending { opacity: .5; pointer-events: none; }
.ai-tnode.is-pending { opacity: .55; pointer-events: none; }
.ai-tnode.is-pending::after {
  content: '';
  width: 12px; height: 12px;
  margin-left: 8px;
  border: 2px solid var(--ai-main);
  border-right-color: transparent;
  border-radius: 50%;
  animation: ai-spin .7s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* ── Item-level toggle switches (truncated / hidden) ── */
.cf-item-toggle { position:relative; display:inline-block; width:28px; height:16px; flex:0 0 auto; }
.cf-item-toggle input { position:absolute; inset:0; width:100%; height:100%; opacity:0; margin:0; cursor:pointer; z-index:1; }
.cf-item-toggle-track {
  position:absolute; inset:0; pointer-events:none;
  background:rgba(255,255,255,.12); border-radius:8px;
  transition:background .2s;
}
.cf-item-toggle-track::before {
  content:''; position:absolute;
  height:12px; width:12px; left:2px; top:2px;
  background:rgba(255,255,255,.4); border-radius:50%;
  transition:transform .2s, background .2s;
}
.cf-item-toggle input:checked + .cf-item-toggle-track { background:var(--ai-main); }
.cf-item-toggle input:checked + .cf-item-toggle-track::before { transform:translateX(12px); background:#fff; }

/* Inline spinner for buttons in a loading state (composer Save/Send, etc). */
.ai-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ai-spin .7s linear infinite;
}
button[data-ai-loading="true"] {
  cursor: progress;
  opacity: .85;
}

/* ── VS Code-style expand/collapse chevron + tree lines ─────────────── */
/* Connecting line that runs vertically beside the expanded children,
   making it visually obvious which items belong to which folder. */
.ai-tnode-children {
  position: relative;
  margin-left: 20px;
  padding-left: 10px;
  border-left: 1px solid color-mix(in srgb, var(--ai-main) 30%, transparent);
}
/* Nested folder children shift further right */
.ai-tnode-children--indent-1 { margin-left: 36px; }
.ai-tnode-children--indent-2 { margin-left: 52px; }
/* Subfolder nesting container — child folders render inside their parent's DOM node */
.ai-tnode-nested {
  margin-left: 20px;
  padding-left: 10px;
  border-left: 1px solid color-mix(in srgb, var(--ai-main) 30%, transparent);
}
/* Small horizontal tick to each child row */
.ai-tnode-children .ai-tnode--item::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: color-mix(in srgb, var(--ai-main) 30%, transparent);
}
.ai-tnode--item { position: relative; }
.ai-tnode-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--ai-muted);
  padding: 0;
  cursor: pointer;
  border-radius: 3px;
  transition: color .12s ease;
}
.ai-tnode-chevron .bi {
  font-size: 10px;
  transition: transform .15s ease;
  display: block;
}
.ai-tnode-chevron--open { transform: rotate(0); }
.ai-tnode-chevron .ai-tnode-chevron--open { transform: rotate(90deg) !important; }
.bi.ai-tnode-chevron--open { transform: rotate(90deg); }
/* Empty folders: chevron is invisible but keeps the layout spacing */
.ai-tnode-chevron--empty { opacity: 0; pointer-events: none; }
.ai-tnode:hover .ai-tnode-chevron:not(.ai-tnode-chevron--empty) { color: var(--ai-ink); }

/* Item rows inside expanded folders */
.ai-tnode--item {
  cursor: default;
  font-size: 12px;
  color: var(--ai-muted);
  gap: 6px;
}
.ai-tnode--item .ai-tnode-name { font-size: 12px; color: var(--ai-muted); }
.ai-tnode--item .bi { font-size: 12px; color: var(--ai-muted); flex-shrink: 0; }
.ai-tnode--item:hover { background: color-mix(in srgb, var(--ai-ink) 4%, transparent); color: var(--ai-ink); }
.ai-tnode--item:hover .ai-tnode-name,
.ai-tnode--item:hover .bi { color: var(--ai-ink); }

/* Per-node ⋮ menu trigger (hidden until hover for cleaner look) */
.ai-tnode-menu {
  border: 0;
  background: transparent;
  color: var(--ai-muted);
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease, background .12s ease;
  flex-shrink: 0;
}
.ai-tnode:hover .ai-tnode-menu,
.ai-tnode.active .ai-tnode-menu { opacity: 1; }
.ai-tnode-menu:hover { background: color-mix(in srgb, var(--ai-ink) 10%, transparent); color: var(--ai-ink); }

/* Floating context menu (positioned fixed by JS) */
.ai-tnode-menu-pop {
  position: absolute;
  z-index: 80;
  min-width: 170px;
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  box-shadow: var(--ai-shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.ai-tnode-menu-pop button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-ink);
  cursor: pointer;
}
.ai-tnode-menu-pop button:hover:not(:disabled) { background: var(--ai-soft); }
.ai-tnode-menu-pop button.danger { color: var(--ai-danger); }
.ai-tnode-menu-pop button:disabled { opacity: .45; cursor: not-allowed; }

.ai-vault-content { display: grid; gap: 20px; }
.ai-input-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.ai-input-row i { color: var(--ai-muted); }
.ai-saved-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ai-saved-item {
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 4px 10px;
}
.ai-saved-item { position: relative; }
.ai-saved-item i { grid-row: 1 / span 2; color: var(--ai-main); font-size: 24px; }
.ai-saved-item span { color: var(--ai-muted); font-size: 12px; }
/* ⋮ menu trigger floats in the card corner — keeps the grid layout intact. */
.ai-saved-item-menu {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity .15s ease;
}
.ai-saved-item:hover .ai-saved-item-menu,
.ai-saved-item-menu:focus { opacity: 1; }
.ai-saved-item-menu i { grid-row: auto; color: var(--ai-muted); font-size: 14px; }
.ai-answer { background: var(--ai-soft); color: var(--ai-ink); border: 1px solid var(--ai-line); border-radius: 8px; padding: 16px; line-height: 1.6; }

.ai-public-cv { display: grid; place-items: center; padding: 32px 0; }
.ai-public-card {
  width: min(920px, 100%);
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: 14px;
  box-shadow: var(--ai-shadow);
  padding: clamp(24px, 5vw, 54px);
}
.ai-public-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--ai-line); padding-bottom: 24px; }
.ai-public-head h1 { margin: 0; font-size: 48px; }
.ai-public-summary { font-size: 18px; color: var(--ai-muted); line-height: 1.65; }
.ai-public-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 24px; }
.ai-public-grid section { border-top: 1px solid var(--ai-line); padding-top: 16px; }
.ai-public-card footer { margin-top: 34px; color: var(--ai-muted); font-weight: 800; }

.ai-plan-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(135deg, var(--ai-navy), var(--ai-main-dark));
  color: #fff;
  margin-bottom: 20px;
}
.ai-plan-hero span { color: rgba(255,255,255,.65); letter-spacing: .14em; font-size: 12px; }
.ai-plan-hero h2 { margin: 6px 0; font-size: 36px; }
.ai-plan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.ai-plan-card h3 { margin: 0 0 10px; }
.ai-plan-card strong { display: block; font-size: 36px; margin-bottom: 10px; }
.ai-plan-card p { color: var(--ai-muted); }
.ai-plan-card.popular {
  border-color: var(--ai-main);
  box-shadow: 0 20px 55px color-mix(in srgb, var(--ai-main) 22%, transparent);
}
.ai-paypal-slot { margin-top: 14px; min-height: 44px; }
.ai-login-wrap {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}
.ai-login-card {
  width: min(520px, 100%);
  padding: 42px;
}
.ai-login-card h1 { font-size: 44px; line-height: 1.02; margin: 12px 0; }
.ai-login-actions { display: grid; gap: 12px; margin: 28px 0 16px; }
.ai-small-copy { color: var(--ai-muted); font-size: 13px; }
.ai-alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 18px 0;
  font-weight: 700;
}
.ai-alert-danger {
  color: var(--ai-danger);
  background: color-mix(in srgb, var(--ai-danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--ai-danger) 30%, transparent);
}

/* ── Sidebar: section label ─────────────────────────────────────── */
.ai-sb-section {
  margin: 0 0 8px;
  padding: 0 4px;
  color: rgba(255,255,255,.38);
  font-size: 10px;
  letter-spacing: .18em;
  font-weight: 800;
  text-transform: uppercase;
}

/* ── Sidebar: credits mini-widget ───────────────────────────────── */
.ai-sb-credits {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.ai-sb-credits-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.ai-sb-credits-plan {
  font-size: 10px;
  letter-spacing: .14em;
  font-weight: 800;
  color: var(--ai-main);
}
.ai-sb-credits-topup {
  font-size: 11px;
  font-weight: 800;
  color: rgba(255,255,255,.55);
  transition: color .15s;
}
.ai-sb-credits-topup:hover { color: #fff; }
.ai-sb-credits-val {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.ai-sb-credits-val strong { color: #fff; font-size: 20px; }
.ai-sb-credits-val small  { color: rgba(255,255,255,.45); font-size: 12px; }
.ai-sb-credits-bar {
  height: 4px;
  background: rgba(255,255,255,.12);
  border-radius: 99px;
  margin-top: 8px;
  overflow: hidden;
}
.ai-sb-credits-bar i {
  display: block;
  height: 100%;
  width: 0%;            /* JS or server can set inline width later */
  background: var(--ai-main);
  border-radius: 99px;
}
/* New layout: ring + text side by side. Replaces the linear bar. */
.ai-sb-credits-stack {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.ai-sb-credits-ring { width: 50px; height: 50px; flex-shrink: 0; }
.ai-sb-credits-ring .ring-bg { fill: none; stroke: rgba(255,255,255,.10); stroke-width: 4; }
.ai-sb-credits-ring .ring-fg { fill: none; stroke: var(--ai-main); stroke-width: 4; stroke-linecap: round; }
.ai-sb-credits-ring .ring-label {
  fill: #fff; font-size: 10px; font-weight: 700; font-family: var(--ai-font, inherit);
}
.ai-sb-credits-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.ai-sb-credits-text strong { color: #fff; font-size: 16px; font-weight: 700; }
.ai-sb-credits-text small  { color: rgba(255,255,255,.55); font-size: 10px; letter-spacing: .04em; }
.ai-sb-credits-of          { color: rgba(255,255,255,.40); font-size: 10px; margin-top: 2px; }

/* ── Storage KPI card — Dashboard ───────────────────────────────
   Reuses the .ai-sb-credits-ring SVG primitives (same circle/stroke
   tokens) so the KPI ring matches the sidebar Credits ring visually.
   Only the layout wrapper is unique because the KPI tile has a
   different surrounding box (.ai-kpi) than the sidebar card. */
.ai-kpi-storage-stack {
  display: flex; align-items: center; gap: 12px;
  margin: 6px 0 4px;
}
.ai-kpi-storage-stack .ai-sb-credits-ring { width: 56px; height: 56px; }
.ai-kpi-storage-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.ai-kpi-storage-text strong { font-size: 22px; font-weight: 700; color: var(--ai-ink, #e5e9f5); }
.ai-kpi-storage-text small  { color: var(--ai-muted, #9aa5c4); font-size: 11px; letter-spacing: .04em; margin-top: 2px; }
.ai-kpi--storage > strong   { display: none; } /* hide the inherited big-number slot — ring + stack already cover it */
/* Theme-adaptive override for the ring inside the Storage KPI card.
   The sidebar version of .ai-sb-credits-ring assumes a dark navy
   background and uses white-on-white-alpha tokens for the track + label
   text. On the Dashboard, the KPI card surface flips with the theme so
   we need EXPLICIT colors per mode — token fallbacks (--ai-ink etc.)
   don't help because they're shared between modes and end up matching
   the surrounding card (invisible) in one of them.

   Light mode: ring track is a soft navy alpha, label text is the same
   dark navy used elsewhere on the card.
   Dark mode: ring track is white alpha, label text is pure white. */
html:not([data-ai-theme="dark"]) .ai-kpi-storage-stack .ai-sb-credits-ring .ring-bg {
  stroke: rgba(15, 23, 42, .12);
}
html:not([data-ai-theme="dark"]) .ai-kpi-storage-stack .ai-sb-credits-ring .ring-label {
  fill: #1b2235;
}
html[data-ai-theme="dark"] .ai-kpi-storage-stack .ai-sb-credits-ring .ring-bg {
  stroke: rgba(255, 255, 255, .22);
}
html[data-ai-theme="dark"] .ai-kpi-storage-stack .ai-sb-credits-ring .ring-label {
  fill: #ffffff;
}

/* ── Per-session cost card (Ask Vault right column) ─────────────── */
.ai-session-cost .ai-section-title { margin-bottom: 10px; }
.ai-session-cost-reset {
  font-size: 11px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ai-session-cost-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--ai-line);
  font-size: 13px;
}
.ai-session-cost-row:first-of-type { border-top: 0; }
.ai-session-cost-row span    { color: var(--ai-muted); }
.ai-session-cost-row strong  { color: var(--ai-ink); font-size: 15px; font-weight: 700; }

/* ── Pre-execute cost badge under the composer ──────────────────── */
.ai-cost-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin: 8px 0 6px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--ai-line);
  background: color-mix(in srgb, var(--ai-main) 6%, transparent);
  color: var(--ai-ink);
}
.ai-cost-badge.is-warn  { border-color: var(--ai-warn);   background: color-mix(in srgb, var(--ai-warn) 8%, transparent); color: var(--ai-warn); }
.ai-cost-badge.is-error { border-color: var(--ai-danger); background: color-mix(in srgb, var(--ai-danger) 8%, transparent); color: var(--ai-danger); }
.ai-cost-badge i        { font-size: 14px; }
.ai-cost-badge strong   { color: inherit; }
.ai-btn.is-disabled,
.ai-btn[disabled]       { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── Topbar: language selector ──────────────────────────────────── */
.ai-lang-dd { position: relative; }
.ai-lang-trig {
  gap: 5px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  height: 42px;
  width: auto;
}
.ai-lang-label { letter-spacing: .06em; }
.ai-lang-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 148px;
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: 10px;
  box-shadow: var(--ai-shadow);
  padding: 4px;
  z-index: 60;
}
.ai-lang-menu.open { display: block; }
.ai-lang-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ai-ink);
}
.ai-lang-menu a:hover,
.ai-lang-menu a.active { background: var(--ai-soft); }

/* ── Topbar: theme toggle ───────────────────────────────────────── */
.ai-theme-toggle { transition: background .15s; }
.ai-theme-toggle:hover { background: var(--ai-soft); }

/* ── Upgrade card (quota exceeded) ─────────────────────────────── */
.ai-upgrade-card {
  text-align: center;
  padding: 28px 20px 22px;
}
.ai-upgrade-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--ai-navy), var(--ai-main-dark));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}
.ai-upgrade-card-title {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--ai-ink);
}
.ai-upgrade-card-sub {
  margin: 0 0 16px;
  color: var(--ai-muted);
  font-size: 14px;
}
.ai-upgrade-card-list {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: grid;
  gap: 8px;
  text-align: left;
}
.ai-upgrade-card-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ai-ink);
}
.ai-upgrade-card-cta {
  width: 100%;
  margin-bottom: 12px;
  font-size: 15px;
  justify-content: center;
  gap: 10px;
}
.ai-upgrade-card-note {
  margin: 0;
  color: var(--ai-muted);
  font-size: 12px;
}

@media (max-width: 1020px) {
  .ai-shell { grid-template-columns: 1fr; }
  .ai-sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    width: min(82vw, 300px);
  }
  .ai-sidebar.open { transform: translateX(0); }
  .ai-scrim {
    position: fixed;
    inset: 0;
    background: rgba(5,10,35,.45);
    opacity: 0;
    pointer-events: none;
    z-index: 30;
    transition: opacity .2s ease;
  }
  .ai-scrim.open { opacity: 1; pointer-events: auto; }
  .ai-mobile-menu { display: inline-flex; }
  .ai-grid-2, .ai-grid-vault, .ai-kpis, .ai-plan-grid { grid-template-columns: 1fr; }
  .ai-action-grid, .ai-saved-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .ai-topbar { padding: 0 14px; }
  .ai-credit-pill span { display: none; }
  .ai-page { padding: 18px 14px; }
  .ai-page-head, .ai-public-head, .ai-plan-hero { flex-direction: column; align-items: stretch; }
  .ai-form-grid, .ai-public-grid { grid-template-columns: 1fr; }
  .ai-table > div { grid-template-columns: 1fr; }
  .ai-composer-footer { flex-direction: column; }
  .ai-pages-bubble { max-width: none; margin: 0; }
  .ai-pages-bubble::after { display: none; }
  .ai-pages-stepper { justify-content: center; }
}
