/* =====================================================================
   Genexts redesign: calm & minimal (Oct 2026)
   Loaded last, after style.css, polish.css and theme-light.css.
   One set of tokens per theme; every rule below uses the tokens, so
   Dark and Light always match. Remove the <link> to undo the redesign.
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
html[data-theme] {
  --r-bg: #0f1012;            /* page */
  --r-side: #0b0c0d;          /* sidebar */
  --r-surface: #17181b;       /* cards, inputs */
  --r-surface-2: #1e1f23;     /* hover, selected */
  --r-surface-3: #26272c;     /* pressed, chips */
  --r-border: rgba(255,255,255,0.07);
  --r-border-strong: rgba(255,255,255,0.12);
  --r-text: #ececee;
  --r-text-2: #a1a1aa;
  --r-text-3: #6b6b74;
  --r-accent: var(--brand, #2ee6b6);
  --r-accent-ink: #052e25;    /* text on accent */
  --r-accent-soft: rgba(var(--brand-rgb, 46, 230, 182), 0.12);
  --r-accent-text: var(--brand, #2ee6b6);
  --r-danger: #f87171;
  --r-shadow: 0 1px 2px rgba(0,0,0,0.3);
  --r-shadow-pop: 0 12px 32px rgba(0,0,0,0.45);
  --r-radius: 12px;
  --r-radius-lg: 16px;
  --bg-primary: var(--r-bg); --text-primary: var(--r-text); --text-secondary: var(--r-text-2); --text-muted: var(--r-text-3);
  color-scheme: dark;
}
html[data-theme="light"] {
  --r-bg: #ffffff;
  --r-side: #f7f7f8;
  --r-surface: #ffffff;
  --r-surface-2: #f3f3f5;
  --r-surface-3: #e9e9ec;
  --r-border: rgba(15,15,20,0.08);
  --r-border-strong: rgba(15,15,20,0.14);
  --r-text: #18181b;
  --r-text-2: #52525b;
  --r-text-3: #8b8b94;
  --r-accent: var(--brand, #2ee6b6);
  --r-accent-ink: #052e25;
  --r-accent-soft: rgba(13,148,136,0.09);
  --r-accent-text: #0d9488;
  --r-danger: #dc2626;
  --r-shadow: 0 1px 2px rgba(15,15,20,0.05);
  --r-shadow-pop: 0 12px 32px rgba(15,15,20,0.12);
  color-scheme: light;
}
/* A customer's own brand colour still fills buttons in Light mode; teal text stays a darker, readable shade. */
html[data-theme="light"][style*="--brand"] { --r-accent: var(--brand); }

/* ---------- 2. Base: flat page, no glows ---------- */
html[data-theme] body { background: var(--r-bg) !important; background-image: none !important; color: var(--r-text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; letter-spacing: -0.006em; }
html[data-theme] .view-container, html[data-theme] .genexts-main-layout, html[data-theme] .app-container,
html[data-theme] .launcher-container, html[data-theme] .ws-page, html[data-theme] .chat-shell, html[data-theme] .chat-body {
  background: var(--r-bg) !important; background-image: none !important; }
html[data-theme] h1, html[data-theme] h2, html[data-theme] h3 { color: var(--r-text); letter-spacing: -0.02em; }
html[data-theme] ::selection { background: var(--r-accent-soft); }
html[data-theme] :focus-visible { outline: 2px solid var(--r-accent) !important; outline-offset: 2px; }

/* ---------- 3. Buttons, inputs, chips (one style everywhere) ---------- */
html[data-theme] .ws-btn, html[data-theme] .sb-btn, html[data-theme] .lg-provider, html[data-theme] .btn-secondary {
  background: var(--r-surface) !important; color: var(--r-text) !important; border: 1px solid var(--r-border-strong) !important;
  border-radius: 10px !important; box-shadow: var(--r-shadow) !important; font-weight: 500 !important; transform: none !important; filter: none !important;
  transition: background 0.15s, border-color 0.15s !important; }
html[data-theme] .ws-btn:hover, html[data-theme] .sb-btn:hover, html[data-theme] .lg-provider:hover, html[data-theme] .btn-secondary:hover {
  background: var(--r-surface-2) !important; }
html[data-theme] .ws-btn.primary, html[data-theme] .sb-btn.primary, html[data-theme] .lg-submit, html[data-theme] .btn-primary,
html[data-theme] .cr-btn.primary {
  background: var(--r-accent) !important; color: var(--r-accent-ink) !important; border-color: transparent !important; box-shadow: none !important; }
html[data-theme] .ws-btn.primary:hover, html[data-theme] .sb-btn.primary:hover, html[data-theme] .lg-submit:hover, html[data-theme] .btn-primary:hover {
  background: var(--r-accent) !important; filter: brightness(1.06) !important; }
html[data-theme] .ws-btn.danger { color: var(--r-danger) !important; }
html[data-theme] .chat-icon-btn { color: var(--r-text-2); background: transparent; border-radius: 9px; }
html[data-theme] .chat-icon-btn:hover { background: var(--r-surface-2); color: var(--r-text); }
html[data-theme] .chat-icon-btn.danger:hover { color: var(--r-danger); }

html[data-theme] input[type="text"], html[data-theme] input[type="email"], html[data-theme] input[type="password"],
html[data-theme] input[type="search"], html[data-theme] textarea, html[data-theme] select, html[data-theme] .chat-pill-select {
  color: var(--r-text); }
html[data-theme] .lg-field input, html[data-theme] .hs-search, html[data-theme] .ws-search, html[data-theme] .th-search,
html[data-theme] .chat-pill-select, html[data-theme] .st-row select, html[data-theme] .modern-select {
  background-color: var(--r-surface) !important; border: 1px solid var(--r-border-strong) !important; border-radius: 10px !important; box-shadow: none !important; }
html[data-theme] .lg-field input:focus, html[data-theme] .hs-search:focus-within, html[data-theme] .chat-pill-select:focus {
  border-color: var(--r-accent) !important; box-shadow: 0 0 0 3px var(--r-accent-soft) !important; }
html[data-theme] .chat-pill-select option, html[data-theme] select option { background: var(--r-surface); color: var(--r-text); }

/* Small badges: NEW, plan, counts */
html[data-theme] .sidebar-new, html[data-theme] .st-badge, html[data-theme] .sb-plan-name, html[data-theme] .ws-tab-count {
  background: var(--r-accent-soft) !important; color: var(--r-accent-text) !important; border: none !important;
  font-size: 0.64rem !important; font-weight: 600 !important; letter-spacing: 0.02em; padding: 0.12rem 0.45rem !important; border-radius: 6px !important;
  text-transform: uppercase; box-shadow: none !important; -webkit-text-fill-color: currentColor !important; background-image: none !important; }
html[data-theme] .ws-tab-count { text-transform: none; }

/* ---------- 4. Sidebar ---------- */
html[data-theme] .sidebar { background: var(--r-side) !important; border-right: 1px solid var(--r-border) !important; box-shadow: none !important;
  padding: 1rem 0.75rem !important; }
html[data-theme] .genexts-sidebar-header { margin-bottom: 1.25rem !important; padding: 0 0.5rem !important; }
html[data-theme] .sidebar-wordmark { height: 22px; }
html[data-theme] .sidebar-toggle-btn { color: var(--r-text-3) !important; background: transparent !important; border-radius: 8px !important; }
html[data-theme] .sidebar-toggle-btn:hover { color: var(--r-text) !important; background: var(--r-surface-2) !important; }
html[data-theme] .sidebar-group-label { color: var(--r-text-3) !important; opacity: 1 !important; font-size: 0.68rem !important; font-weight: 600 !important;
  letter-spacing: 0.06em !important; padding: 1rem 0.65rem 0.35rem !important; }
html[data-theme] .sidebar-group-label:first-child { padding-top: 0 !important; }
html[data-theme] .sidebar .sidebar-item { color: var(--r-text-2) !important; background: transparent !important; border: none !important; border-radius: 8px !important;
  padding: 0.5rem 0.65rem !important; gap: 0.7rem !important; font-size: 0.9rem !important; font-weight: 450; margin-bottom: 1px; box-shadow: none !important; }
html[data-theme] .sidebar .sidebar-item:hover { background: var(--r-surface-2) !important; color: var(--r-text) !important; }
html[data-theme] .sidebar .sidebar-item.active { border: none !important; box-shadow: none !important; background: var(--r-surface-2) !important; color: var(--r-text) !important; font-weight: 550; }
html[data-theme] .sidebar-item .icon { width: 20px !important; height: 20px !important; min-width: 20px; background: none !important; border-radius: 0 !important;
  display: grid; place-items: center; color: var(--r-text-3); transform: none !important; font-size: 0; }
html[data-theme] .sidebar-item:hover .icon { color: var(--r-text-2); }
html[data-theme] .sidebar-item.active .icon { color: var(--r-accent-text); }
html[data-theme] .sidebar-item .ic { display: block; }
html[data-theme] .sidebar-item::before { display: none !important; }

html[data-theme] .sb-install { background: transparent !important; border: 1px dashed var(--r-border-strong) !important; color: var(--r-text-2) !important;
  border-radius: 8px !important; box-shadow: none !important; font-weight: 500 !important; font-size: 0.84rem !important;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
html[data-theme] .sb-install:hover { color: var(--r-text) !important; border-color: var(--r-text-3) !important; }

/* Credits: a quiet card */
html[data-theme] .sb-credits { background: var(--r-surface) !important; border: 1px solid var(--r-border) !important; border-radius: var(--r-radius) !important;
  box-shadow: none !important; padding: 0.85rem !important; }
html[data-theme] .sb-credits-label { color: var(--r-text-3) !important; font-size: 0.72rem !important; }
html[data-theme] .sb-balance { color: var(--r-text) !important; font-size: 1.3rem !important; font-weight: 600 !important; letter-spacing: -0.02em; }
html[data-theme] .sb-curve { opacity: 0.7; }
html[data-theme] .sb-btn { font-size: 0.8rem !important; padding: 0.45rem !important; }
html[data-theme] .sb-btn:not(.primary) { background: transparent !important; border-color: transparent !important; box-shadow: none !important; color: var(--r-text-2) !important; }

/* Profile */
html[data-theme] #profile-trigger { background: transparent !important; border: none !important; border-radius: 10px !important; padding: 0.5rem !important; }
html[data-theme] #profile-trigger:hover { background: var(--r-surface-2) !important; }
html[data-theme] #profile-trigger .profile-avatar { background: var(--r-surface-3) !important; color: var(--r-text) !important; width: 32px !important; height: 32px !important;
  min-width: 32px !important; font-size: 0.75rem !important; }
html[data-theme] #profile-trigger .profile-name { color: var(--r-text) !important; font-size: 0.86rem !important; }
html[data-theme] #profile-trigger .profile-plan { color: var(--r-text-3) !important; font-size: 0.72rem !important; }
html[data-theme] .profile-menu { background: var(--r-surface) !important; border: 1px solid var(--r-border-strong) !important; box-shadow: var(--r-shadow-pop) !important;
  border-radius: var(--r-radius) !important; }
html[data-theme] .profile-menu .profile-email, html[data-theme] .profile-menu .text-small { color: var(--r-text-3) !important; }

/* Phone menu button (top-left) */
html[data-theme] .mobile-nav-btn { background: var(--r-surface) !important; border: 1px solid var(--r-border) !important; color: var(--r-text-2) !important;
  box-shadow: var(--r-shadow) !important; border-radius: 10px !important; }

/* ---------- 5. Corner Dark / Light switch ---------- */
html[data-theme] .sb-theme { background: var(--r-surface) !important; border: 1px solid var(--r-border) !important; box-shadow: var(--r-shadow) !important;
  backdrop-filter: none !important; }
html[data-theme] .sb-theme button { color: var(--r-text-3) !important; background: transparent !important; box-shadow: none !important; }
html[data-theme]:not([data-theme="light"]) .sb-theme [data-theme-option="dark"],
html[data-theme="light"] .sb-theme [data-theme-option="light"] { background: var(--r-surface-3) !important; color: var(--r-text) !important; }
html[data-theme] .theme-switch { background: var(--r-surface-2) !important; border: 1px solid var(--r-border) !important; }
html[data-theme] .theme-switch button { color: var(--r-text-2) !important; }
html[data-theme] .theme-switch button[aria-checked="true"] { background: var(--r-surface) !important; color: var(--r-text) !important; box-shadow: var(--r-shadow) !important; }

/* ---------- 6. Home ---------- */
html[data-theme] .home-logo { width: 150px !important; margin-bottom: 1.75rem !important; opacity: 1; }
html[data-theme] .home-greeting { font-size: 2rem !important; font-weight: 600 !important; letter-spacing: -0.03em !important; color: var(--r-text); }
html[data-theme] .home-greeting .highlight { background: none !important; -webkit-text-fill-color: currentColor !important; color: var(--r-text) !important; font-weight: 600 !important; }
html[data-theme] .home-sub { color: var(--r-text-2) !important; font-size: 1rem !important; margin-bottom: 1.75rem !important; }
html[data-theme] .home-composer, html[data-theme] .chat-composer {
  background: var(--r-surface) !important; border: 1px solid var(--r-border-strong) !important; border-radius: 18px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important; }
html[data-theme="light"] .home-composer, html[data-theme="light"] .chat-composer { box-shadow: 0 2px 10px rgba(15,15,20,0.06) !important; }
html[data-theme] .home-composer:focus-within, html[data-theme] .chat-composer:focus-within {
  border-color: var(--r-text-3) !important; box-shadow: 0 2px 12px rgba(0,0,0,0.16) !important; }
html[data-theme] .home-composer input::placeholder, html[data-theme] #chat-input::placeholder { color: var(--r-text-3) !important; }
html[data-theme] .home-send, html[data-theme] .chat-send:not(.stop) {
  background: var(--r-accent) !important; color: var(--r-accent-ink) !important; border-radius: 12px !important; box-shadow: none !important;
  transform: none !important; }
html[data-theme] .home-send:hover, html[data-theme] .chat-send:not(.stop):hover { filter: brightness(1.06) !important; }

html[data-theme] .home-actions { gap: 0.6rem !important; margin-top: 1rem !important; }
html[data-theme] .home-action { background: transparent !important; border: 1px solid var(--r-border) !important; border-radius: var(--r-radius) !important;
  padding: 0.85rem 0.95rem !important; box-shadow: none !important; transform: none !important; }
html[data-theme] .home-action:hover { background: var(--r-surface-2) !important; border-color: var(--r-border-strong) !important; }
html[data-theme] .home-action-icon { background: var(--r-surface-2) !important; color: var(--r-text-2) !important; border-radius: 9px !important;
  width: 34px !important; height: 34px !important; }
html[data-theme] .home-action:hover .home-action-icon { color: var(--r-accent-text) !important; }
html[data-theme] .home-action-text b { font-weight: 550 !important; font-size: 0.88rem !important; color: var(--r-text); }
html[data-theme] .home-action-text small { color: var(--r-text-3) !important; font-size: 0.76rem !important; }
html[data-theme] .verify-banner { background: var(--r-surface-2) !important; border: 1px solid var(--r-border) !important; color: var(--r-text-2) !important; border-radius: 10px !important; }

/* ---------- 7. Chat ---------- */
html[data-theme] .chat-header { background: var(--r-bg) !important; border-bottom: 1px solid var(--r-border) !important; backdrop-filter: none !important; }
html[data-theme] .chat-title { font-weight: 550 !important; font-size: 0.94rem !important; color: var(--r-text); }
html[data-theme] .chat-pill-select { font-size: 0.82rem !important; color: var(--r-text-2) !important; }
html[data-theme] .chat-header .model-picker-btn, html[data-theme] .chat-header [class*="model-pick"] > button {
  background: var(--r-surface) !important; border: 1px solid var(--r-border-strong) !important; color: var(--r-text-2) !important; box-shadow: none !important; }
html[data-theme] .chat-more-menu, html[data-theme] [class*="model-picker"] [role="listbox"], html[data-theme] .mp-menu {
  background: var(--r-surface) !important; border: 1px solid var(--r-border-strong) !important; box-shadow: var(--r-shadow-pop) !important; border-radius: var(--r-radius) !important; }
html[data-theme] .chat-more-menu button { color: var(--r-text) !important; }
html[data-theme] .chat-more-menu button:hover { background: var(--r-surface-2) !important; }

html[data-theme] .chat-empty-mark { background: var(--r-surface-2) !important; border: 1px solid var(--r-border) !important; color: var(--r-accent-text) !important;
  width: 44px !important; height: 44px !important; border-radius: 12px !important; }
html[data-theme] .chat-empty h2 { font-size: 1.5rem !important; font-weight: 600 !important; }
html[data-theme] .chat-suggestion { background: transparent !important; border: 1px solid var(--r-border) !important; color: var(--r-text-2) !important;
  border-radius: var(--r-radius) !important; box-shadow: none !important; }
html[data-theme] .chat-suggestion:hover { background: var(--r-surface-2) !important; color: var(--r-text) !important; border-color: var(--r-border-strong) !important; }
html[data-theme] .chat-suggestion::after { color: var(--r-text-3) !important; }

html[data-theme] #chat-history .chat-message { color: var(--r-text) !important; }
html[data-theme] #chat-history .chat-message.user-message { background: var(--r-surface-2) !important; border: none !important; color: var(--r-text) !important;
  border-radius: 18px !important; }
html[data-theme] #chat-history .ai-avatar:not(.bot-av) { background: transparent !important; border: 1px solid var(--r-border-strong) !important;
  color: var(--r-accent-text) !important; border-radius: 50% !important; font-size: 0.75rem !important; }
html[data-theme] #chat-history .model-tag { color: var(--r-text-3) !important; font-weight: 500 !important; }
html[data-theme] .markdown-body { color: var(--r-text) !important; }
html[data-theme] .markdown-body a { color: var(--r-accent-text) !important; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--r-border-strong); }
html[data-theme] .markdown-body strong, html[data-theme] .chat-message strong { color: var(--r-text) !important; }
html[data-theme] .markdown-body blockquote { border-left: 3px solid var(--r-border-strong) !important; color: var(--r-text-2) !important; background: none !important; }
html[data-theme] .markdown-body th, html[data-theme] .markdown-body td { border-color: var(--r-border-strong) !important; }
html[data-theme] .markdown-body th { background: var(--r-surface-2); }
html[data-theme] .chat-message .inline-code, html[data-theme] .markdown-body :not(pre) > code {
  background: var(--r-surface-3) !important; color: var(--r-text) !important; border: none !important; }
html[data-theme] .msg-action { color: var(--r-text-3) !important; }
html[data-theme] .msg-action:hover { color: var(--r-text) !important; background: var(--r-surface-2) !important; }
html[data-theme] .chat-composer .chat-icon-btn { color: var(--r-text-3) !important; }
html[data-theme] .chat-composer .chat-icon-btn:hover { color: var(--r-text) !important; background: var(--r-surface-2) !important; }
html[data-theme] .chat-composer .chat-toggle.active, html[data-theme] .chat-composer .chat-toggle[aria-pressed="true"] {
  color: var(--r-accent-text) !important; background: var(--r-accent-soft) !important; }
html[data-theme] .chat-footnote { color: var(--r-text-3) !important; }
/* Code: one dark card in both themes */
html[data-theme] .chat-message .code-example.file-card { background: #0d0e10 !important; border: 1px solid var(--r-border-strong) !important; border-radius: var(--r-radius) !important; }
html[data-theme] .chat-message .code-example.file-card .file-card-header[style], html[data-theme] .chat-message .file-card-header {
  background: #16171a !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; }
html[data-theme] .chat-message .code-example.file-card .file-card-header > div:first-child > span:nth-child(3) {
  color: #a1a1aa !important; background: rgba(255,255,255,0.06) !important; }

/* Code card buttons stay small and quiet (not the big button style). */
html[data-theme] .chat-message .file-card-header button, html[data-theme] .chat-message .file-card-header .btn-primary,
html[data-theme] .chat-message .file-card-header .btn-secondary {
  background: transparent !important; border: 1px solid transparent !important; color: #a1a1aa !important; box-shadow: none !important;
  font-size: 0.74rem !important; padding: 0.3rem 0.55rem !important; border-radius: 7px !important; }
html[data-theme] .chat-message .file-card-header button:hover { background: rgba(255,255,255,0.08) !important; color: #fff !important; filter: none !important; }

/* ---------- 8. Pages (Projects, History, Settings, Tools, Plans) ---------- */
html[data-theme] .ws-page { padding-top: 2.75rem !important; }
html[data-theme] .ws-head { margin-bottom: 1.75rem !important; align-items: flex-end; }
html[data-theme] .ws-head h1 { font-size: 1.6rem !important; font-weight: 600 !important; letter-spacing: -0.025em !important; }
html[data-theme] .ws-head p { color: var(--r-text-2) !important; font-size: 0.92rem !important; }
html[data-theme] .ws-back { color: var(--r-text-3) !important; font-size: 0.84rem !important; }
html[data-theme] .ws-back:hover { color: var(--r-text) !important; }

html[data-theme] .st-section-label, html[data-theme] .hs-group-label {
  color: var(--r-text-3) !important; font-size: 0.7rem !important; font-weight: 600 !important; letter-spacing: 0.06em !important; margin: 2rem 0 0.6rem 0.15rem !important; }
html[data-theme] .ws-head + .st-section-label { margin-top: 0 !important; }
html[data-theme] .st-card, html[data-theme] .hs-group, html[data-theme] .th-card, html[data-theme] .pj-card:not(.pj-new), html[data-theme] .gw-card,
html[data-theme] .pack-card, html[data-theme] .plan-card, html[data-theme] .cr-balance-card {
  background: var(--r-surface) !important; border: 1px solid var(--r-border) !important; border-radius: var(--r-radius) !important;
  box-shadow: var(--r-shadow) !important; background-image: none !important; }
html[data-theme] .th-card:hover, html[data-theme] .pj-card:not(.pj-new):hover { border-color: var(--r-border-strong) !important; background: var(--r-surface) !important; transform: none !important; }
html[data-theme] .st-row, html[data-theme] .hs-row, html[data-theme] .st-stats + .st-row { border-top: 1px solid var(--r-border) !important; }
html[data-theme] .st-row:first-child, html[data-theme] .hs-row:first-child { border-top: none !important; }
html[data-theme] .st-row-title { font-weight: 500 !important; font-size: 0.9rem !important; color: var(--r-text); }
html[data-theme] .st-row-sub, html[data-theme] .hs-row-preview, html[data-theme] .hs-row-time { color: var(--r-text-3) !important; }
html[data-theme] .hs-row:hover { background: var(--r-surface-2) !important; }
html[data-theme] .st-stat { border-color: var(--r-border) !important; }
html[data-theme] .st-stat-label { color: var(--r-text-3) !important; font-size: 0.74rem !important; }
html[data-theme] .st-stat-value { color: var(--r-text) !important; font-weight: 600 !important; font-size: 1.2rem !important; }
html[data-theme] .st-stat-value.accent { background: none !important; -webkit-text-fill-color: currentColor !important; color: var(--r-accent-text) !important; }
html[data-theme] .st-usage-track { background: var(--r-surface-3) !important; }
html[data-theme] .st-usage-bar { background: var(--r-accent) !important; }
html[data-theme] .st-avatar { background: var(--r-surface-3) !important; color: var(--r-text) !important; }

html[data-theme] .ws-tabs { background: transparent !important; border: none !important; border-bottom: 1px solid var(--r-border) !important; border-radius: 0 !important;
  padding: 0 !important; gap: 1.25rem !important; width: 100% !important; }
html[data-theme] .ws-tab { background: transparent !important; border-radius: 0 !important; padding: 0.6rem 0 !important; color: var(--r-text-3) !important;
  border-bottom: 2px solid transparent !important; margin-bottom: -1px; flex: 0 0 auto !important; box-shadow: none !important; }
html[data-theme] .ws-tab:hover { color: var(--r-text) !important; }
html[data-theme] .ws-tab.active { color: var(--r-text) !important; border-bottom-color: var(--r-text) !important; }

html[data-theme] .pj-new, html[data-theme] .ws-empty { background: transparent !important; border: 1px dashed var(--r-border-strong) !important; border-radius: var(--r-radius) !important; color: var(--r-text-2) !important; }
html[data-theme] .pj-new:hover { border-color: var(--r-text-3) !important; color: var(--r-text) !important; background: var(--r-surface-2) !important; }
html[data-theme] .pj-new-plus, html[data-theme] .ws-empty-icon, html[data-theme] .pj-grid .pj-new-plus {
  background: var(--r-surface-2) !important; color: var(--r-text-2) !important; border: none !important; filter: grayscale(1); }
html[data-theme] .pj-icon { background: var(--r-surface-2) !important; color: var(--r-text) !important; border: 1px solid var(--r-border) !important; }
html[data-theme] #project-chats:has(> #project-chat-list:empty)::after { border-color: var(--r-border-strong) !important; color: var(--r-text-3) !important; }

/* ---------- 9. Sign-in ---------- */
html[data-theme] #login-view { background: var(--r-bg) !important; }
html[data-theme] .lg-card { background: var(--r-surface) !important; border: 1px solid var(--r-border) !important; box-shadow: var(--r-shadow-pop) !important;
  border-radius: var(--r-radius-lg) !important; backdrop-filter: none !important; }
html[data-theme="light"] .lg-card { box-shadow: 0 1px 3px rgba(15,15,20,0.06), 0 12px 40px rgba(15,15,20,0.06) !important; }
html[data-theme] .lg-title { font-weight: 600 !important; font-size: 1.35rem !important; }
html[data-theme] .lg-sub, html[data-theme] .lg-divider { color: var(--r-text-3) !important; }
html[data-theme] .lg-divider::before, html[data-theme] .lg-divider::after { background: var(--r-border) !important; }
html[data-theme] .lg-tabs { background: var(--r-surface-2) !important; border: none !important; border-radius: 10px !important; }
html[data-theme] .lg-tab { color: var(--r-text-2) !important; }
html[data-theme] .lg-tab.active { background: var(--r-surface) !important; color: var(--r-text) !important; box-shadow: var(--r-shadow) !important; }
html[data-theme] .lg-field { color: var(--r-text-2) !important; font-weight: 500 !important; }
html[data-theme] .lg-link, html[data-theme] .lg-card a { color: var(--r-accent-text) !important; }
html[data-theme] .lg-foot, html[data-theme] .lg-legal, html[data-theme] .lg-secure { color: var(--r-text-3) !important; }

/* ---------- 9b. Genexts Build ---------- */
html[data-theme] .cv-mark { background: var(--r-surface-2) !important; color: var(--r-accent-text) !important; border: 1px solid var(--r-border) !important;
  width: 32px !important; height: 32px !important; border-radius: 9px !important; font-size: 0; }
html[data-theme] .cv-sub { color: var(--r-text-3) !important; }
html[data-theme] .cv-mode { background: var(--r-surface-2) !important; border: 1px solid var(--r-border) !important; border-radius: 10px !important; }
html[data-theme] .cv-mode button { color: var(--r-text-2) !important; background: transparent !important; border-radius: 8px !important; }
html[data-theme] .cv-mode button.on { background: var(--r-surface) !important; color: var(--r-text) !important; box-shadow: var(--r-shadow) !important; }
html[data-theme] .mp-btn { background: var(--r-surface) !important; border: 1px solid var(--r-border-strong) !important; color: var(--r-text) !important; box-shadow: none !important; }
html[data-theme] .mp-pop { background: var(--r-surface) !important; border: 1px solid var(--r-border-strong) !important; box-shadow: var(--r-shadow-pop) !important; }
html[data-theme] #canvas-view .cv-roster-item { background: transparent !important; border: 1px solid var(--r-border) !important; border-radius: 10px !important; box-shadow: none !important; }
html[data-theme] #canvas-view .cv-roster-item span:last-child { color: var(--r-text-3) !important; }
html[data-theme] .cv-panel { background: var(--r-surface) !important; border: 1px solid var(--r-border) !important; box-shadow: var(--r-shadow) !important; border-radius: var(--r-radius-lg) !important; }
html[data-theme] .cv-panel-bar { border-bottom: 1px solid var(--r-border) !important; }
html[data-theme] .cv-seg { background: var(--r-surface-2) !important; border-radius: 9px !important; }
html[data-theme] .cv-seg-btn { color: var(--r-text-2) !important; background: transparent !important; }
html[data-theme] .cv-seg-btn.active { background: var(--r-surface) !important; color: var(--r-text) !important; box-shadow: var(--r-shadow) !important; }
html[data-theme] .cv-empty-stage { color: var(--r-text-3) !important; }
html[data-theme] .cv-empty-icon { color: var(--r-text-3) !important; -webkit-text-fill-color: currentColor !important; background: none !important; }
html[data-theme] .cv-user-msg { background: var(--r-surface-2) !important; border: none !important; color: var(--r-text) !important; }

/* Phones: two-row header, one scrolling column (messages → preview), message box pinned at the bottom. */
@media (max-width: 768px) {
  html[data-theme] #canvas-view .cv-shell { height: 100dvh !important; overflow-y: auto !important; overflow-x: hidden !important; display: block !important; }
  html[data-theme] #canvas-view .chat-header { flex-wrap: wrap !important; row-gap: 0.55rem !important; position: sticky; top: 0; z-index: 20;
    padding-left: 64px !important; padding-right: 0.75rem !important; }
  html[data-theme] #canvas-view .chat-header-left { flex: 1 1 100%; min-height: 42px; }
  html[data-theme] #canvas-view .cv-mark { display: none !important; }
  html[data-theme] #canvas-view .cv-sub { display: none; }
  html[data-theme] #canvas-view .chat-header-actions { flex: 1 1 100%; margin-left: -52px; justify-content: flex-start; gap: 0.4rem !important; }
  html[data-theme] #canvas-view .chat-header-actions #cv-new { margin-left: auto; }
  html[data-theme] #canvas-view .mp { min-width: 0; flex: 1 1 auto; }
  html[data-theme] #canvas-view .mp-btn { width: 100%; justify-content: space-between; }
  html[data-theme] #canvas-view .cv-gh-btn { display: none; }
  html[data-theme] #canvas-view .cv-layout { display: flex !important; flex-direction: column; min-height: calc(100dvh - 120px); }
  html[data-theme] #canvas-view .cv-main { display: contents !important; }
  html[data-theme] #canvas-view .cv-thread { order: 1; flex: 0 0 auto !important; overflow: visible !important; padding: 1.25rem 1rem 0.5rem !important; }
  html[data-theme] #canvas-view .cv-welcome { margin: 0.5rem 0 0 !important; }
  html[data-theme] #canvas-view .cv-welcome h2 { font-size: 1.35rem !important; }
  html[data-theme] #canvas-view .cv-roster { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0.4rem !important; margin: 1rem 0 !important; }
  html[data-theme] #canvas-view .cv-roster-item { padding: 0.55rem 0.65rem !important; min-width: 0; }
  html[data-theme] #canvas-view .cv-roster-item b, html[data-theme] #canvas-view .cv-roster-item span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html[data-theme] #canvas-view .chat-suggestions { grid-template-columns: 1fr !important; }
  html[data-theme] #canvas-view .cv-panel { order: 2; margin: 0.75rem 1rem 1rem !important; align-self: stretch !important; flex: 0 0 auto; }
  html[data-theme] #canvas-view .cv-panel:not(.expanded) .cv-stage { height: 56vh !important; }
  html[data-theme] #canvas-view .cv-panel.expanded { inset: env(safe-area-inset-top) 0 0 0 !important; border-radius: 0 !important; }
  html[data-theme] #canvas-view .chat-composer-wrap { order: 3; position: sticky; bottom: 0; z-index: 15; margin-top: auto;
    background: var(--r-bg) !important; border-top: 1px solid var(--r-border); padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom)) !important; }
  html[data-theme] #canvas-view .chat-footnote { display: none; }
}

/* ---------- 10. Phones ---------- */
@media (max-width: 768px) {
  html[data-theme] .sidebar { padding: calc(1rem + env(safe-area-inset-top)) 0.75rem calc(1rem + env(safe-area-inset-bottom)) !important; }
  html[data-theme] .ws-page { padding-top: 4.25rem !important; }
  html[data-theme] .home-greeting { font-size: 1.45rem !important; }
  html[data-theme] .home-action { padding: 0.8rem !important; }
}


/* ---------- Splash screen: calm, one teal glow, "Personal AI Assistant" ---------- */
#loading-view { overflow: hidden; background: var(--r-bg); }
#loading-view .splash-glow { position: absolute; inset: 0; pointer-events: none; }
#loading-view .splash-glow span {
  position: absolute; left: 50%; top: 46%; width: 620px; height: 620px; border-radius: 50%;
  transform: translate(-50%, -50%); opacity: .16;
  background: radial-gradient(circle closest-side, var(--r-accent), rgba(46,230,182,.35) 35%, transparent 100%);
  animation: splashBreathe 5s ease-in-out infinite;
}
#loading-view .splash-glow span + span {
  width: 440px; height: 440px; top: 56%; left: 57%; opacity: .10;
  background: radial-gradient(circle closest-side, #22d3ee, rgba(34,211,238,.3) 35%, transparent 100%);
  animation-delay: -2.5s;
}
#loading-view .loading-content { gap: 0; max-width: 320px; }
#loading-view .splash-wordmark { width: 200px; margin: 0 0 14px; animation: splashFade .9s ease-out both; }
#loading-view .loading-subtitle {
  margin: 0; font-size: 14px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--r-text-2); animation: splashIn .8s .12s cubic-bezier(.2,.8,.2,1) both;
}
#loading-view .progress-bar-container {
  width: 220px; height: 3px; margin: 40px 0 16px; border-radius: 99px;
  background: var(--r-border-strong); animation: splashIn .8s .22s cubic-bezier(.2,.8,.2,1) both;
}
#loading-view .progress-bar {
  position: relative; overflow: hidden; border-radius: 99px; box-shadow: 0 0 12px var(--r-accent);
  background: linear-gradient(90deg, var(--r-accent), #22d3ee);
  transition: width .25s ease-out;
}
#loading-view .progress-bar::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: splashShimmer 1.2s linear infinite;
}
#loading-view .loading-status { margin: 0; font-size: 12.5px; color: var(--r-text-3); min-height: 18px; animation: splashIn .8s .3s both; }
#loading-view .loading-status.swap { animation: splashSwap .35s ease-out; }
html[data-theme="light"] #loading-view { background: #f6f7f9; }
html[data-theme="light"] #loading-view .splash-glow span { opacity: .12; }
html[data-theme="light"] #loading-view .loading-subtitle { color: #52525b; }
html[data-theme="light"] #loading-view .loading-status { color: #8b8b94; }
@keyframes splashIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes splashFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes splashSwap { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes splashBreathe { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.08); } }
@keyframes splashShimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  #loading-view *, #loading-view *::after { animation: none !important; }
}
