/**
 * IuVe Typography SSOT — ChatGPT-aligned scale (desktop + mobile).
 * Loaded early on /app/* pages; tokens override brand fonts inside the app shell.
 */
:root {
  --iuve-font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --iuve-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Bridge legacy brand tokens to system stack inside app */
  --iuve-font-sans: var(--iuve-font-family);
  --iuve-font-display: var(--iuve-font-family);

  --iuve-font-size-base: 16px;
  --iuve-font-size-sidebar: 14px;
  --iuve-font-size-sidebar-section: 11px;
  --iuve-font-size-sm: 13px;
  --iuve-font-size-composer: 16px;
  --iuve-font-size-xs: 11px;
  --iuve-font-size-md: 16px;
  --iuve-font-size-lg: 18px;
  --iuve-line-height-chat: 1.625;
  --iuve-line-height-sidebar: 1.4;
  --iuve-line-height-base: 1.5;
}

/* ── Global app shell ─────────────────────────────────────────────────────── */
body,
.app-shell-v2,
body[data-page="iuve-chat"] {
  font-family: var(--iuve-font-family);
  font-size: var(--iuve-font-size-base);
  line-height: var(--iuve-line-height-base);
}

/* ── Sidebar (desktop + drawer) ───────────────────────────────────────────── */
.sidebar-v2.side-nav,
.sidebar-v2.side-nav :is(
  .sidebar-v2__item,
  .side-nav-new-chat,
  .side-nav-action,
  .side-nav-links a,
  .side-nav-logout-btn,
  .side-nav-project-action,
  .side-nav-subcontrol-select
) {
  font-family: var(--iuve-font-family);
  font-size: var(--iuve-font-size-sidebar);
  line-height: var(--iuve-line-height-sidebar);
}

.sidebar-v2__section-label,
.side-nav-section-label,
.side-nav-group-label {
  font-size: var(--iuve-font-size-sidebar-section);
  line-height: 1.2;
}

.sidebar-v2__brand-text,
.sidebar-v2 .side-nav-brand-text,
.sidebar-v2 .side-nav-link-text,
.sidebar-v2 .sidebar-v2__item-label,
.shell-fab-brand-text,
.iuve-mobile-topbar__title {
  font-family: var(--iuve-font-family);
  font-size: var(--iuve-font-size-sidebar);
  font-weight: 600;
  color: #0f172a;
  letter-spacing: normal;
  background: none;
  background-image: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: #0f172a;
}

/* ── Chat messages (unified + legacy dashboard) ───────────────────────────── */
.unified-msg,
.unified-msg-body,
.chat-bubble.agent .chat-bubble-text,
.chat-bubble.user {
  font-family: var(--iuve-font-family);
  font-size: var(--iuve-font-size-base);
  line-height: var(--iuve-line-height-chat);
}

.unified-msg-body :is(p, li),
.chat-bubble.agent .chat-bubble-text :is(p, li) {
  font-size: inherit;
  line-height: var(--iuve-line-height-chat);
}

.unified-msg-body :is(h1, .markdown h1),
.chat-bubble.agent .chat-bubble-text h1 {
  font-size: 1.5em;
  line-height: 1.3;
}

.unified-msg-body :is(h2, .markdown h2),
.chat-bubble.agent .chat-bubble-text h2 {
  font-size: 1.25em;
  line-height: 1.35;
}

.unified-msg-body :is(h3, .markdown h3),
.chat-bubble.agent .chat-bubble-text h3 {
  font-size: 1.1em;
  line-height: 1.4;
}

.unified-msg-body :is(h1, h2, h3, h4, h5, h6),
.chat-bubble.agent .chat-bubble-text :is(h1, h2, h3, h4, h5, h6) {
  font-weight: 600;
  margin: 0.75em 0 0.35em;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.unified-msg-body :is(h2, h3),
.chat-bubble.agent .chat-bubble-text :is(h2, h3) {
  margin-top: 0.95em;
}

.unified-msg-body .iuve-callout,
.chat-bubble.agent .chat-bubble-text .iuve-callout {
  font-size: 0.98em;
  line-height: 1.55;
}

.unified-msg-body pre,
.unified-msg-body pre code,
.chat-bubble.agent .chat-bubble-text pre,
.chat-bubble.agent .chat-bubble-text pre code {
  font-family: var(--iuve-font-family-mono);
  font-size: 0.875em;
  line-height: 1.5;
}

.unified-msg-body :not(pre) > code,
.chat-bubble.agent .chat-bubble-text :not(pre) > code {
  font-family: var(--iuve-font-family-mono);
  font-size: 0.875em;
}

/* ── Composer ─────────────────────────────────────────────────────────────── */
.unified-input textarea,
#unified-message,
.chat-form textarea,
.chat-input-wrapper textarea {
  font-family: var(--iuve-font-family);
  font-size: var(--iuve-font-size-composer);
  line-height: var(--iuve-line-height-chat);
}

/* ── Mobile: keep 16px body/composer (iOS zoom prevention) ───────────────── */
@media (max-width: 767px) {
  body,
  .app-shell-v2,
  body[data-page="iuve-chat"],
  .unified-msg,
  .unified-msg-body,
  .chat-bubble.agent .chat-bubble-text,
  .chat-bubble.user,
  .unified-input textarea,
  #unified-message,
  .chat-form textarea,
  .chat-input-wrapper textarea,
  .sidebar-v2.side-nav :is(
    .sidebar-v2__item,
    .side-nav-new-chat,
    .side-nav-action,
    .side-nav-links a,
    .side-nav-logout-btn
  ) {
    font-size: max(16px, var(--iuve-font-size-base));
  }

  .unified-input textarea,
  #unified-message,
  .chat-form textarea,
  .chat-input-wrapper textarea {
    font-size: max(16px, var(--iuve-font-size-composer));
  }

  .sidebar-v2.side-nav :is(
    .sidebar-v2__item,
    .side-nav-new-chat,
    .side-nav-action,
    .side-nav-links a,
    .side-nav-logout-btn
  ) {
    font-size: max(14px, var(--iuve-font-size-sidebar));
  }
}
