/* =========================================================
   10xAI — Design system
   ========================================================= */
:root {
  /* Frame / sidebar (dark) */
  --frame: #0e0e0f;
  --side-text: #ececee;
  --side-dim: #c9c9ce;
  --side-muted: #77777e;
  --side-hover: #1b1b1e;
  --side-card: #19191b;
  --side-line: #27272a;

  /* Main panel (light) */
  --panel: #f4f4f5;
  --surface: #ffffff;
  --ink: #0b0b0c;
  --ink-2: #2a2a2f;
  --fg: #0b0b0c;
  --border: #e6e6ea;
  --muted: #8e8e96;
  --faint: #b9b9c0;
  --line: #e6e6ea;
  --hover: #ececef;

  /* Accent — Matching official 10xAI Logo */
  --lime: #bafa1b;
  --lime-2: #a5e808;
  --lime-glow: rgba(186, 250, 27, 0.45);

  --r-xl: 22px;
  --r-lg: 18px;
  --r: 14px;
  --r-sm: 10px;

  --sh-sm: 0 1px 2px rgba(16, 16, 20, .04), 0 1px 1px rgba(16, 16, 20, .03);
  --sh-md: 0 14px 34px -14px rgba(16, 16, 20, .22);
  --sh-lg: 0 24px 60px -18px rgba(16, 16, 20, .35), 0 2px 6px rgba(16, 16, 20, .06);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 264px;
  --content-w: 760px;

  --font: 'Lato', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--frame);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

svg.i {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(120, 120, 130, .25); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   Layout
   ========================================================= */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  padding: 12px 12px 12px 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 14px 8px;
  color: var(--side-text);
  transition: width .32s var(--ease), padding .32s var(--ease);
  overflow: hidden;
}
.sidebar__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 18px 6px;
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; text-decoration: none; }
.brand__mark { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; transition: transform .3s var(--ease); }
.brand:hover .brand__mark { transform: scale(1.08); }
.brand__logo-img { height: 26px; width: auto; object-fit: contain; flex-shrink: 0; transition: opacity .2s, transform .2s; }
.brand:hover .brand__logo-img { transform: scale(1.02); }
.brand__x { color: var(--lime); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; flex-shrink: 0;
  color: var(--ink-2);
  transition: background .2s, color .2s, transform .2s var(--ease), box-shadow .2s;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:active { transform: scale(.94); }
.icon-btn--dark { color: var(--side-muted); }
.icon-btn--dark:hover { background: var(--side-hover); color: #fff; }
.icon-btn--card { background: var(--surface); box-shadow: var(--sh-sm); border: 1px solid var(--line); }
.icon-btn--card:hover { background: var(--surface); box-shadow: var(--sh-md); transform: translateY(-1px); }

.sidebar__nav, .sidebar__footer { display: flex; flex-direction: column; gap: 2px; }
.sidebar__footer { padding-top: 6px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 11px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--side-dim);
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background .2s, color .2s, border-color .2s;
}
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item--primary { background: var(--side-card); border-color: var(--side-line); color: #fff; margin-bottom: 4px; }
.nav-item--primary:hover { border-color: #3a3a3e; }

/* Prominent New Chat CTA */
.sidebar__cta-wrap {
  margin-bottom: 12px;
}
.btn-new-chat {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: #1b1b1f;
  border: 1px solid rgba(186, 250, 27, 0.35);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}
.btn-new-chat svg.i {
  color: #bafa1b;
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
  flex-shrink: 0;
}
.btn-new-chat:hover {
  background: #24242b;
  border-color: #bafa1b;
  color: #bafa1b;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px -2px rgba(186, 250, 27, 0.28);
}
.btn-new-chat:active {
  transform: scale(0.98);
}
.sidebar__section-divider {
  display: flex;
  align-items: center;
  margin: 10px 4px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #63636e;
}

.kbd { margin-left: auto; display: inline-flex; gap: 4px; }
.kbd span {
  font-size: 11px; line-height: 1; font-weight: 700;
  padding: 4px 6px; border-radius: 6px;
  background: #2a2a2e; color: #bcbcc2;
}
.kbd--ghost span { background: transparent; color: var(--side-muted); padding: 4px 2px; }
.nav-item:not(:hover) .kbd--ghost { opacity: 0; }
.kbd--light span { background: var(--hover); color: var(--muted); }

.sidebar__section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sidebar__label { font-size: 12px; color: var(--side-muted); padding: 22px 11px 8px; letter-spacing: .02em; }
.recent-list { overflow-y: auto; flex: 1; margin-right: -6px; padding-right: 6px; }
.recent-list::-webkit-scrollbar-thumb { background: #2a2a2e; }
.recent-item {
  position: relative;
  display: flex; align-items: center;
  border-radius: var(--r-sm);
  transition: background .2s;
  animation: fadeIn .35s var(--ease) both;
}
.recent-item:hover, .recent-item.is-active { background: var(--side-hover); }
.recent-item.is-active::before {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--lime);
}
.recent-item__btn {
  flex: 1; min-width: 0; text-align: left;
  padding: 9px 11px; font-size: 14px; color: var(--side-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-item:hover .recent-item__btn, .recent-item.is-active .recent-item__btn { color: #fff; }
.recent-item__del {
  width: 28px; height: 28px; margin-right: 4px; border-radius: 8px;
  display: grid; place-items: center; color: var(--side-muted);
  opacity: 0; transition: opacity .2s, background .2s, color .2s;
}
.recent-item__del svg.i { width: 15px; height: 15px; }
.recent-item:hover .recent-item__del { opacity: 1; }
.recent-item__del:hover { background: #2a2a2e; color: #ff8a80; }
.recent-empty { font-size: 13px; color: var(--side-muted); padding: 6px 11px; line-height: 1.5; }

.sidebar__spacer { flex: 1; }

/* Trial card */
.trial-card {
  background: linear-gradient(160deg, #1c1c1f 0%, #151517 100%);
  border: 1px solid var(--side-line);
  border-radius: var(--r);
  padding: 14px;
  margin: 14px 0 8px;
  position: relative;
  overflow: hidden;
}
.trial-card::after {
  content: ''; position: absolute; width: 140px; height: 140px; right: -60px; top: -70px;
  background: radial-gradient(circle, rgba(186, 250, 27, .16), transparent 70%);
  pointer-events: none;
}
.trial-card__title { font-size: 15px; color: #fff; margin-bottom: 6px; }
.trial-card__text { font-size: 12px; line-height: 1.5; color: #9a9aa1; }
.trial-card__progress { height: 4px; background: #2a2a2e; border-radius: 4px; margin: 12px 0; overflow: hidden; }
.trial-card__progress span { display: block; height: 100%; background: var(--lime); border-radius: 4px; box-shadow: 0 0 10px var(--lime-glow); }

.btn-lime {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--lime);
  color: var(--ink);
  font-size: 15px; font-weight: 700;
  transition: transform .2s var(--ease), box-shadow .25s, background .2s;
}
.btn-lime svg.i { width: 16px; height: 16px; stroke-width: 2.2; }
.btn-lime:hover { background: #c6fb3b; box-shadow: 0 8px 24px -6px var(--lime-glow); transform: translateY(-1px); }
.btn-lime:active { transform: translateY(0) scale(.98); }

.show-collapsed { display: none !important; }
.upgrade-mini { color: var(--lime) !important; }

/* Collapsed sidebar (desktop) */
.app.is-collapsed .sidebar { width: 74px; padding-inline: 12px; }
.app.is-collapsed .hide-collapsed { display: none !important; }
.app.is-collapsed .show-collapsed { display: flex !important; }
.app.is-collapsed .sidebar__header { flex-direction: column; padding: 4px 0 14px; gap: 12px; }
.app.is-collapsed .btn-new-chat { justify-content: center; padding: 0; width: 46px; height: 44px; margin: 0 auto; }
.app.is-collapsed .nav-item { justify-content: center; padding: 11px 0; }

.scrim { display: none; }

/* ---------- Main panel ---------- */
.main {
  flex: 1; min-width: 0;
  background: var(--panel);
  border-radius: var(--r-xl);
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
}
.main::before {
  /* subtle ambient glow */
  content: ''; position: absolute; inset: -30% -10% auto; height: 70%;
  background: radial-gradient(ellipse at 50% 0%, rgba(186, 250, 27, .14), transparent 60%);
  pointer-events: none;
  transition: opacity .5s;
}
.main.is-chat::before { opacity: 0; }

.topbar {
  position: relative; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
}
.topbar__left, .topbar__actions { display: flex; align-items: center; gap: 10px; }
.mobile-only { display: none; }

.model-picker { position: relative; }
.model-picker__btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 12px;
  font-size: 18px; font-weight: 700; letter-spacing: -.01em;
  transition: background .2s;
}
.model-picker__btn:hover, .model-picker__btn[aria-expanded="true"] { background: var(--hover); }
.model-picker__chev { transition: transform .25s var(--ease); color: var(--muted); }
.model-picker__btn[aria-expanded="true"] .model-picker__chev { transform: rotate(180deg); }

.model-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--dot, #10a37f);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, #10a37f) 20%, transparent);
}
.model-dot--sm { width: 8px; height: 8px; box-shadow: none; }

.avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #1a1a1d, #3a3a40);
  color: var(--lime); font-weight: 900; font-size: 14px; letter-spacing: .02em;
  box-shadow: var(--sh-sm);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.avatar:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }

/* ---------- Popovers ---------- */
.popover {
  position: absolute; z-index: 40;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--sh-lg);
  padding: 6px;
  opacity: 0; pointer-events: none;
  transform: translateY(-6px) scale(.98);
  transform-origin: top left;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.popover.open { opacity: 1; pointer-events: auto; transform: none; }
.popover__label { font-size: 12px; color: var(--muted); padding: 8px 10px 6px; }

.model-menu { top: calc(100% + 8px); left: 0; width: 390px; max-width: calc(100vw - 32px); }
#modelList { max-height: 420px; overflow-y: auto; padding-right: 2px; }
.model-bracket-header {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 8px 10px 4px;
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #64748b;
  border-top: 1px solid #f1f5f9;
}
.model-bracket-header:first-child {
  border-top: none;
  margin-top: 0;
}
.model-item {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 12px; text-align: left;
  transition: background .15s;
}
.model-item:hover { background: var(--panel); }
.model-item.is-active { background: var(--panel); }
.model-item.is-locked {
  opacity: 0.62;
  cursor: pointer;
}
.model-item.is-locked:hover {
  background: #f8fafc;
  opacity: 0.88;
}
.model-item__logo {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 15px;
}
.model-item__text { flex: 1; min-width: 0; }
.model-item__name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.model-item__desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 6px; border-radius: 6px; background: var(--hover); color: var(--ink-2);
}
.tag--lime { background: var(--lime); color: var(--ink); }
.model-item__check { color: var(--ink); opacity: 0; }
.model-item.is-active .model-item__check { opacity: 1; }
.model-menu__foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; padding: 10px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.model-menu__foot svg.i { width: 14px; height: 14px; }

.more-wrap { position: relative; }
.more-menu { top: calc(100% + 8px); right: 0; width: 200px; transform-origin: top right; }
.account-wrap { position: relative; }
.account-menu { top: calc(100% + 8px); right: 0; width: 280px; transform-origin: top right; }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; font-size: 14px; text-align: left;
  transition: background .15s;
}
.menu-item svg.i { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover { background: var(--panel); }
.menu-item--danger { color: #d93025; }
.menu-item--danger svg.i { color: #d93025; }
.menu-item:disabled { opacity: .4; pointer-events: none; }

/* =========================================================
   Stage (home + chat)
   ========================================================= */
.stage {
  position: relative; z-index: 1;
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  padding: 0;
}
#viewWorkspace {
  display: none;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px 56px;
  box-sizing: border-box;
}
#viewWorkspace.is-active {
  display: flex;
}
.main.is-chat #viewWorkspace {
  justify-content: flex-end;
  padding-bottom: 14px;
}

/* Hero */
.hero { text-align: center; margin-bottom: 32px; }
.hero > * { animation: rise .7s var(--ease) both; }
.hero__title { font-size: clamp(30px, 4vw, 44px); font-weight: 700; letter-spacing: -.025em; line-height: 1.15; }
.hero__tagline {
  font-size: clamp(26px, 3.6vw, 40px); font-weight: 700; letter-spacing: -.025em; line-height: 1.25;
  color: var(--faint);
  animation-delay: .08s !important;
}
.hl {
  color: var(--ink);
  background: linear-gradient(transparent 58%, var(--lime) 58%, var(--lime) 92%, transparent 92%);
  padding: 0 .08em;
}
.hero__sub { font-size: 15px; color: var(--muted); margin-top: 10px; animation-delay: .16s !important; }

/* Composer */
.composer {
  width: 100%; max-width: var(--content-w);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 14px 12px;
  box-shadow: var(--sh-sm);
  transition: border-color .2s, box-shadow .25s;
  animation: rise .7s .22s var(--ease) both;
}
.composer:focus-within {
  border-color: #d4d4da;
  box-shadow: 0 0 0 4px rgba(186, 250, 27, .28), var(--sh-md);
}
.composer textarea {
  width: 100%; min-height: 52px; max-height: 220px;
  border: 0; outline: 0; resize: none; background: transparent;
  font-size: 15px; line-height: 1.55; padding: 2px 4px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer__bar { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.composer__left, .composer__right { display: flex; align-items: center; gap: 8px; }

.tool-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--ink-2);
  transition: background .2s, transform .2s var(--ease), border-color .2s;
}
.tool-btn:hover { background: var(--hover); border-color: #d9d9de; }
.tool-btn:active { transform: scale(.92); }
.tool-btn.is-recording { background: #ffecec; border-color: #ffc9c9; color: #d93025; animation: pulse 1.2s infinite; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px; border-radius: 10px;
  font-size: 13px; font-weight: 700; color: var(--ink-2);
  border: 1px solid var(--line);
  transition: background .2s;
}
.chip:hover { background: var(--panel); }

.send-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff;
  transition: background .2s, color .2s, transform .2s var(--ease), opacity .2s, box-shadow .25s;
}
.send-btn svg.i { stroke-width: 2.2; grid-area: 1 / 1; }
.send-btn:disabled { opacity: .3; cursor: default; }
.send-btn:not(:disabled):hover { background: var(--lime); color: var(--ink); box-shadow: 0 6px 18px -4px var(--lime-glow); transform: translateY(-1px); }
.send-btn__stop { display: none; }
.send-btn.is-stop .send-btn__send { display: none; }
.send-btn.is-stop .send-btn__stop { display: block; }

/* Suggestion cards */
.suggestions {
  width: 100%; max-width: var(--content-w);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: 18px;
}
.s-card {
  display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 12px 14px 14px;
  box-shadow: var(--sh-sm);
  transition: transform .3s var(--ease), box-shadow .3s, border-color .3s;
  animation: rise .7s var(--ease) both;
}
.s-card:nth-child(1) { animation-delay: .3s; }
.s-card:nth-child(2) { animation-delay: .38s; }
.s-card:nth-child(3) { animation-delay: .46s; }
.s-card:hover { transform: translateY(-4px); box-shadow: var(--sh-md); border-color: var(--line); }
.s-card__icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--lime); color: var(--ink);
  margin-bottom: 14px;
  transition: transform .4s var(--ease);
}
.s-card__icon svg.i { width: 17px; height: 17px; }
.s-card:hover .s-card__icon { transform: rotate(-8deg) scale(1.08); }
.s-card__title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.s-card__desc { font-size: 12.5px; line-height: 1.45; color: var(--muted); }

.disclaimer { display: none; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* Mode switching */
.messages { display: none; }
.main.is-chat .hero,
.main.is-chat .suggestions { display: none; }
.main.is-chat .messages { display: block; flex: 1; min-height: 0; width: calc(100% + 48px); margin: 0 -24px; overflow-y: auto; }
.main.is-chat .disclaimer { display: block; }
.main.is-chat .composer { animation: none; }

/* =========================================================
   Messages
   ========================================================= */
.thread { max-width: calc(var(--content-w) + 48px); margin: 0 auto; padding: 8px 24px 24px; }

.msg { display: flex; gap: 14px; margin: 26px 0; animation: rise .4s var(--ease) both; }
.msg--user { justify-content: flex-end; }
.msg--user .bubble {
  max-width: 78%;
  background: var(--ink); color: #f5f5f6;
  padding: 12px 16px;
  border-radius: 18px 18px 6px 18px;
  font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-wrap: break-word;
  box-shadow: var(--sh-md);
}
.msg__avatar {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 13px;
  box-shadow: var(--sh-sm);
}
.msg__body { flex: 1; min-width: 0; padding-top: 4px; }
.msg__meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.msg__meta strong { color: var(--ink); font-weight: 700; margin-right: 6px; }

.prose { font-size: 15px; line-height: 1.72; color: var(--ink-2); word-wrap: break-word; }
.prose > * + * { margin-top: 12px; }
.prose h2, .prose h3, .prose h4 { color: var(--ink); font-weight: 700; letter-spacing: -.01em; line-height: 1.35; margin-top: 20px; }
.prose h2 { font-size: 19px; } .prose h3 { font-size: 17px; } .prose h4 { font-size: 15px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: 5px; }
.prose li::marker { color: var(--muted); }
.prose strong { color: var(--ink); }
.prose code { font-family: var(--mono); font-size: 13px; background: var(--hover); padding: 2px 6px; border-radius: 6px; }
.prose pre {
  background: #111113; color: #e7e7ea;
  border-radius: 12px; padding: 14px 16px; overflow-x: auto;
  font-size: 13px; line-height: 1.6;
}
.prose pre code { background: none; padding: 0; color: inherit; }

/* Rich Markdown Tables */
.prose .table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0;
  border-radius: 12px;
  border: 1px solid #e1e4ea;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}
.prose table.rich-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.55;
  text-align: left;
}
.prose table.rich-table thead {
  background: #f6f8fa;
  border-bottom: 2px solid #d0d7de;
}
.prose table.rich-table th {
  padding: 12px 16px;
  font-weight: 700;
  color: #1f2328;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.prose table.rich-table td {
  padding: 12px 16px;
  color: #24292f;
  border-bottom: 1px solid #eaeef2;
  vertical-align: top;
}
.prose table.rich-table tbody tr:last-child td {
  border-bottom: none;
}
.prose table.rich-table tbody tr:nth-child(even) {
  background: #fcfdfe;
}
.prose table.rich-table tbody tr:hover {
  background: #f0f7ff;
}

/* Rich Blockquotes */
.prose blockquote {
  margin: 14px 0;
  padding: 12px 18px;
  border-left: 4px solid #bafa1b;
  background: #f8fafc;
  border-radius: 0 10px 10px 0;
  color: #334155;
  font-size: 14px;
}
.prose hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 18px 0;
}

.prose.is-streaming > :last-child::after {
  content: ''; display: inline-block; width: 8px; height: 16px; margin-left: 3px; vertical-align: -2px;
  background: var(--ink); border-radius: 2px; animation: blink 1s steps(2) infinite;
}

.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: bounce 1.2s infinite var(--ease); }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

.msg__actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  margin-left: 0;
  opacity: 0;
  transition: opacity .18s var(--ease);
}
.msg--ai:hover .msg__actions, .msg--ai:last-child .msg__actions { opacity: 1; }
.act-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.act-btn svg.i {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
  display: block;
}
.act-btn:hover {
  background: var(--hover);
  color: var(--ink);
  border-color: var(--line);
}
.act-btn:active {
  transform: scale(0.92);
}
.act-btn.is-on {
  color: var(--ink);
  background: var(--lime);
  border-color: var(--lime);
}

/* =========================================================
   Search modal
   ========================================================= */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 12, .45);
  backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 14vh;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal__dialog {
  width: min(580px, 92vw);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--sh-lg);
  overflow: hidden;
  transform: translateY(10px) scale(.98);
  transition: transform .25s var(--ease);
}
.modal.open .modal__dialog { transform: none; }
.search-field { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-field input { flex: 1; border: 0; outline: 0; font-size: 16px; color: var(--ink); background: transparent; }
.search-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.search-result {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px; text-align: left;
  transition: background .15s;
}
.search-result:hover, .search-result.is-focus { background: var(--panel); }
.search-result svg.i { color: var(--muted); }
.search-result__title { font-size: 14px; font-weight: 700; }
.search-result__snippet { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 440px; }
.search-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 14px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200;
  display: flex; align-items: center; gap: 10px;
  background: var(--frame); color: #fff;
  padding: 11px 16px; border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--sh-lg);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  transition: transform .3s var(--ease), opacity .3s;
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px var(--lime-glow); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* =========================================================
   Animations
   ========================================================= */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 48, 37, .35); } 50% { box-shadow: 0 0 0 6px rgba(217, 48, 37, 0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px) {
  .app { padding: 0; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    background: var(--frame);
    transform: translateX(-100%);
    transition: transform .32s var(--ease);
    width: 280px !important;
  }
  .app.is-mobile-open .sidebar { transform: none; }
  .app.is-mobile-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .45); animation: fadeIn .25s; }
  .main { border-radius: 0; }
  .mobile-only { display: grid; }
  .topbar { padding: 12px 14px; }
  .model-picker__btn { font-size: 16px; padding: 8px 10px; }
  .model-menu { width: min(360px, calc(100vw - 28px)); }
  #shareBtn { display: none; }
}

@media (max-width: 640px) {
  .stage { padding: 0 14px 18px; justify-content: flex-end; }
  .hero { margin: auto 0 24px; }
  .hero__sub { font-size: 14px; }
  .suggestions { grid-template-columns: 1fr; gap: 8px; }
  .s-card { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 12px; padding: 12px; }
  .s-card__icon { margin-bottom: 0; }
  .s-card__desc { display: none; }
  .main.is-chat .messages { width: calc(100% + 28px); margin: 0 -14px; }
  .thread { padding: 8px 14px 18px; }
  .msg--user .bubble { max-width: 88%; }
  .msg__avatar { display: none; }
  .chip span:last-child { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* =========================================================
   SPA View Architecture & Studio Hubs
   ========================================================= */
.view-container {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}
.view-container.is-active {
  display: flex;
  flex-direction: column;
}

/* History Hub View */
.hub-view {
  padding: 28px 36px 48px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.hub-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.hub-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--fg);
  margin: 0 0 6px 0;
  letter-spacing: -0.02em;
}
.hub-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}
.hub-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.hub-search-input {
  flex: 1;
  min-width: 240px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 14px;
  color: var(--fg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.hub-search-input:focus {
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}
.hub-pill {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border, #e6e6ea);
  background: #f6f8fa;
  color: #57606a;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hub-pill:hover {
  background: #eaecef;
  color: #0b0b0c;
  border-color: #d0d7de;
}
.hub-pill.is-active {
  background: #0e0e0f !important;
  color: #ffffff !important;
  border-color: #0e0e0f !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.history-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.history-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -10px rgba(0,0,0,0.1);
  border-color: #d0d7de;
}
.history-card.is-pinned {
  border-color: #bafa1b;
  background: #fcfdf8;
  box-shadow: 0 4px 14px rgba(186, 250, 27, 0.15);
}
.history-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.history-card__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  margin: 0;
  line-height: 1.4;
  flex: 1;
  word-break: break-word;
}
.history-card__badges {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.history-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f0f2f5;
  color: #444;
}
.history-card__snippet {
  font-size: 13px;
  color: #57606a;
  line-height: 1.5;
  margin-bottom: 16px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #f0f2f5;
  padding-top: 12px;
  margin-top: auto;
}
.history-card__date {
  font-size: 12px;
  color: #8c959f;
}
.history-card__actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Brand Studio Full-Page View */
.studio-container {
  padding: 28px 36px 60px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
@media (max-width: 900px) {
  .studio-grid { grid-template-columns: 1fr; }
  .hub-view, .studio-container { padding: 18px 16px 40px; }
}
.studio-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.studio-card__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.studio-card__desc {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 16px 0;
  line-height: 1.45;
}
.studio-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.studio-field:last-child {
  margin-bottom: 0;
}
.studio-label {
  font-size: 12px;
  font-weight: 700;
  color: #444c56;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.studio-input, .studio-textarea, .studio-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fdfdfd;
  font-size: 13.5px;
  color: var(--fg);
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.studio-input:focus, .studio-textarea:focus, .studio-select:focus {
  border-color: #58a6ff;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}
.studio-textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

/* =========================================================
   ATS Resume Builder & Live Document Preview Engine
   ========================================================= */
.resume-builder-container {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #f4f5f7;
}

/* Left Editor Panel */
.resume-editor-panel {
  width: 500px;
  min-width: 420px;
  height: 100%;
  overflow-y: auto;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.resume-editor-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.resume-editor-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Right Document Canvas */
.resume-canvas-panel {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  background: #2a2a30;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.resume-canvas-toolbar {
  width: 100%;
  padding: 12px 24px;
  background: #18181b;
  border-bottom: 1px solid #27272a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 15;
  box-sizing: border-box;
}
.resume-sheet-viewport {
  padding: 36px 20px 80px;
  display: flex;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}

/* Paper Sheet Emulation (A4 standard: 210mm x 297mm) */
.resume-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  color: #111111;
  padding: 18mm 20mm;
  box-sizing: border-box;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 10pt;
  line-height: 1.45;
  position: relative;
  transition: transform 0.2s ease;
}

/* Accordions */
.rb-accordion {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  transition: border-color 0.2s;
}
.rb-accordion.is-open {
  border-color: #58a6ff;
  box-shadow: 0 2px 8px rgba(88, 166, 255, 0.08);
}
.rb-accordion-header {
  padding: 12px 16px;
  background: #fafbfc;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13.5px;
  color: #24292f;
  user-select: none;
}
.rb-accordion.is-open .rb-accordion-header {
  background: #f0f7ff;
  color: #0969da;
}
.rb-accordion-body {
  padding: 16px;
  display: none;
  border-top: 1px solid var(--border);
  flex-direction: column;
  gap: 12px;
}
.rb-accordion.is-open .rb-accordion-body {
  display: flex;
}

/* Dynamic Item Cards (Jobs, Schools, Projects) */
.rb-item-card {
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  padding: 12px;
  background: #fcfcfd;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.rb-item-card:hover {
  border-color: #c0c6cc;
}
.rb-card-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rb-bullet-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

/* =========================================================
   THE 4 ATS TEMPLATES (STRICT ATS COMPLIANCE)
   ========================================================= */

/* Template 1: Modern Minimalist (ATS Standard) */
.tpl-modern .sheet-header {
  border-bottom: 2px solid #111111;
  padding-bottom: 8px;
  margin-bottom: 12px;
  text-align: left;
}
.tpl-modern .sheet-name {
  font-size: 22pt;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 0 0 4px 0;
  color: #111111;
}
.tpl-modern .sheet-contact {
  font-size: 9pt;
  color: #444444;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tpl-modern .sheet-section {
  margin-bottom: 12px;
}
.tpl-modern .section-title {
  font-size: 11pt;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #cccccc;
  padding-bottom: 3px;
  margin: 0 0 6px 0;
  color: #111111;
}
.tpl-modern .entry-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 10pt;
}
.tpl-modern .entry-sub {
  display: flex;
  justify-content: space-between;
  font-style: italic;
  font-size: 9.5pt;
  color: #333333;
  margin-bottom: 3px;
}
.tpl-modern ul.sheet-bullets {
  margin: 2px 0 6px 18px;
  padding: 0;
}
.tpl-modern ul.sheet-bullets li {
  margin-bottom: 2px;
  font-size: 9.5pt;
}

/* Template 2: Executive Leadership */
.tpl-executive {
  font-family: Georgia, 'Times New Roman', serif;
}
.tpl-executive .sheet-header {
  text-align: center;
  border-bottom: 2px solid #002d62;
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.tpl-executive .sheet-name {
  font-size: 24pt;
  font-weight: 700;
  color: #002d62;
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tpl-executive .sheet-contact {
  font-size: 9pt;
  color: #555;
  justify-content: center;
  display: flex;
  gap: 10px;
}
.tpl-executive .section-title {
  color: #002d62;
  border-bottom: 1.5px solid #002d62;
  font-size: 11.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 6px 0;
}
.tpl-executive .sheet-summary-box {
  background: #f7f9fa;
  border-left: 3px solid #002d62;
  padding: 6px 12px;
  font-style: italic;
  margin-bottom: 10px;
  font-size: 9.5pt;
}

/* Template 3: Tech & Engineering */
.tpl-tech {
  font-family: 'JetBrains Mono', 'Lato', -apple-system, monospace;
}
.tpl-tech .sheet-name {
  font-size: 20pt;
  font-weight: 900;
  color: #0d1117;
  letter-spacing: -0.03em;
}
.tpl-tech .section-title {
  font-size: 10.5pt;
  font-weight: 900;
  color: #0969da;
  border-bottom: 1px solid #d0d7de;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tpl-tech .skills-matrix {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
  font-size: 9pt;
}
.tpl-tech .skills-row {
  display: flex;
}
.tpl-tech .skills-row-label {
  width: 130px;
  font-weight: 700;
  color: #24292f;
  flex-shrink: 0;
}

/* Template 4: Compact 1-Page */
.tpl-compact {
  font-size: 9pt;
  line-height: 1.35;
  padding: 12mm 14mm;
}
.tpl-compact .sheet-name {
  font-size: 18pt;
  font-weight: 900;
}
.tpl-compact .sheet-section {
  margin-bottom: 8px;
}
.tpl-compact .section-title {
  font-size: 10pt;
  font-weight: 900;
  border-bottom: 1px solid #111;
  margin-bottom: 4px;
}
.tpl-compact ul.sheet-bullets li {
  margin-bottom: 1px;
}

/* Print Rules for 100% Vector Crisp PDF */
@media print {
  body {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .sidebar, .topbar, .resume-editor-panel, .resume-canvas-toolbar, .toast, .scrim {
    display: none !important;
  }
  .app, .main, .stage, .resume-builder-container, .resume-canvas-panel, .resume-sheet-viewport {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }
  .resume-sheet {
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    page-break-after: avoid;
  }
}


