/* ==========================================================================
   Kaizo 3.5 — "Obsidian" design system
   Jeden system wizualny dla PWA i aplikacji Android (WebView).

   Zasady:
   1. Zero dekoracji, która nie niesie informacji.
   2. Każdy element ma jednoznaczny stan: spoczynek / hover / focus / aktywny.
   3. Czytelność przed efektami: tekst nigdy nie jest przycinany.
   4. Ruch jest krótki (120-220 ms) i nigdy nie przesuwa layoutu.
   ========================================================================== */

/* ---------- 1. Tokeny ---------------------------------------------------- */
:root {
  /* Tło i powierzchnie */
  --bg: #06060b;
  --bg-2: #0a0a12;
  --surface: rgba(17, 17, 27, .78);
  --surface-2: rgba(24, 24, 38, .86);
  --surface-3: rgba(32, 32, 50, .92);
  --glass: rgba(10, 10, 18, .72);

  /* Linie */
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .12);
  --border: rgba(255, 255, 255, .09);
  --border-soft: rgba(255, 255, 255, .06);

  /* Tekst */
  --text: #f2f1f7;
  --text-soft: #c9c7d6;
  --muted: #8b8a9e;
  --muted-2: #6b6a7d;

  /* Akcenty */
  --accent: #8b5cf6;
  --accent-bright: #a78bfa;
  --accent-ink: #c4b5fd;
  --accent-2: #22d3ee;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;

  /* Kształt */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --radius-pill: 999px;

  /* Cień */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 8px 24px -8px rgba(0, 0, 0, .6);
  --shadow-3: 0 24px 60px -24px rgba(0, 0, 0, .8);
  --glow: 0 0 0 1px rgba(139, 92, 246, .28), 0 12px 40px -12px rgba(139, 92, 246, .45);

  /* Ruch */
  --ease: cubic-bezier(.2, .7, .3, 1);
  --fast: 120ms;
  --normal: 200ms;

  --font-size: 15.5px;
  --header-h: 60px;
  --nav-h: 76px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- 2. Reset i podstawa ------------------------------------------ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: var(--font-size);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}

body {
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
  overflow-x: hidden;
  background-color: #07070d;
  background-image:
    /* ciepła poświata pod nagłówkiem */
    radial-gradient(1100px 620px at 12% -12%, rgba(124, 58, 237, .30), transparent 62%),
    /* chłodny refleks z prawej */
    radial-gradient(900px 560px at 102% -4%, rgba(34, 211, 238, .12), transparent 58%),
    /* magenta przy dolnej krawędzi */
    radial-gradient(1000px 720px at 62% 118%, rgba(192, 38, 211, .17), transparent 64%),
    /* indygo w lewym dolnym rogu */
    radial-gradient(760px 560px at -6% 92%, rgba(79, 70, 229, .16), transparent 60%),
    /* baza */
    linear-gradient(178deg, #08080f 0%, #07070d 42%, #0a0714 74%, #07070c 100%);
  background-attachment: fixed;
}

/* Warstwa 1: siatka techniczna, wygaszana maską — głębia bez szumu. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .5;
  background-image:
    linear-gradient(rgba(255, 255, 255, .028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .028) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 78% 62% at 50% 0%, #000 12%, transparent 74%);
  -webkit-mask-image: radial-gradient(ellipse 78% 62% at 50% 0%, #000 12%, transparent 74%);
}

/* Warstwa 2: powolna aurora w kształcie stożka — jedyny ruch w tle. */
body::after {
  content: "";
  position: fixed;
  width: 92vmax;
  height: 92vmax;
  left: 50%;
  top: -56vmax;
  z-index: 0;
  pointer-events: none;
  transform: translateX(-50%);
  background:
    conic-gradient(from 210deg at 50% 50%,
      transparent 0deg,
      rgba(139, 92, 246, .16) 48deg,
      transparent 96deg,
      rgba(34, 211, 238, .10) 150deg,
      transparent 210deg,
      rgba(217, 70, 239, .12) 286deg,
      transparent 360deg);
  filter: blur(70px);
  opacity: .85;
  animation: aurora 52s var(--ease) infinite alternate;
}
@keyframes aurora {
  to { transform: translateX(-50%) rotate(14deg) scale(1.06); }
}

/* Warstwa 3: dwie plamy koloru, bardzo wolne. */
.ambient { position: fixed; z-index: 0; pointer-events: none; border-radius: 50%; filter: blur(80px); opacity: .55; }
.ambient-a {
  width: 54vmax; height: 54vmax; left: -28vmax; top: -22vmax;
  background: radial-gradient(circle, rgba(124, 58, 237, .30), transparent 68%);
  animation: floatA 38s var(--ease) infinite alternate;
}
.ambient-b {
  width: 48vmax; height: 48vmax; right: -24vmax; bottom: -22vmax;
  background: radial-gradient(circle, rgba(14, 165, 233, .18), transparent 68%);
  animation: floatB 52s var(--ease) infinite alternate;
}
.ambient-c {
  display: block;
  width: 40vmax;
  height: 40vmax;
  right: 6vmax;
  top: 28vmax;
  background: radial-gradient(circle, rgba(217, 70, 239, .14), transparent 70%);
  animation: floatC 64s var(--ease) infinite alternate;
}
@keyframes floatA { to { transform: translate(5vmax, 4vmax) scale(1.06); } }
@keyframes floatB { to { transform: translate(-4vmax, -3vmax) scale(1.08); } }
@keyframes floatC { to { transform: translate(-6vmax, 5vmax) scale(.94); } }

/* Warstwa 4: ziarno (film grain) — usuwa efekt „plastikowego” gradientu. */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .028;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Warstwa 5: winieta — skupia wzrok na treści. */
html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 100% at 50% 40%, transparent 52%, rgba(0, 0, 0, .55) 100%);
}

.app-header, .layout, .bottom-nav { position: relative; z-index: 2; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

::selection { background: rgba(139, 92, 246, .35); color: #fff; }

:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; border-radius: 6px; }

/* Cienki, spokojny scrollbar. */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .14) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .22); background-clip: content-box; }

/* ---------- 3. Nagłówek -------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 16px;
  background: rgba(6, 6, 11, .82);
  backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px; border-radius: var(--radius-sm); transition: background var(--fast) var(--ease); }
.brand:hover { background: rgba(255, 255, 255, .04); }
.brand-mark, .modal-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 11px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
  background: linear-gradient(145deg, #a78bfa 0%, #7c3aed 55%, #4c1d95 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 6px 18px -6px rgba(124, 58, 237, .8);
}
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: .96rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; white-space: nowrap; }
.brand-name span { color: var(--accent-bright); font-weight: 600; }
.brand-sub { color: var(--muted-2); font-size: .56rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; margin-top: 1px; white-space: nowrap; }

.header-spacer { flex: 1; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  white-space: nowrap;
  background: rgba(255, 255, 255, .03);
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .8;
  flex: 0 0 auto;
}
.badge.ok { color: var(--success); border-color: rgba(52, 211, 153, .3); background: rgba(52, 211, 153, .08); }
.badge.warn { color: var(--warning); border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .08); }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.install-btn, .account-chip {
  font-size: .76rem;
  font-weight: 600;
  color: var(--text-soft);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .05);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  min-height: 32px;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.install-btn:hover, .account-chip:hover { background: rgba(255, 255, 255, .09); color: var(--text); }
.account-chip::before { display: none; }

/* ---------- 4. Układ i nawigacja boczna ---------------------------------- */
.layout { display: flex; min-height: calc(100vh - var(--header-h)); max-width: 1440px; margin: 0 auto; }

.sidebar { display: none; }

.main {
  flex: 1;
  min-width: 0;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 18px 28px;
}

.side-label {
  color: var(--muted-2);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  padding: 0 10px;
  margin: 18px 0 6px;
}
.side-label:first-child { margin-top: 4px; }
.side-spacer { flex: 1; min-height: 12px; }
.side-note {
  color: var(--muted-2);
  font-size: .68rem;
  line-height: 1.5;
  padding: 10px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

.sidebar button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-xs);
  color: var(--muted);
  font-size: .86rem;
  font-weight: 500;
  text-align: left;
  position: relative;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.sidebar button > span {
  width: 18px;
  text-align: center;
  font-size: .95rem;
  opacity: .85;
  flex: 0 0 auto;
}
.sidebar button:hover { background: rgba(255, 255, 255, .045); color: var(--text-soft); }
.sidebar button.active {
  background: linear-gradient(90deg, rgba(139, 92, 246, .16), rgba(139, 92, 246, .04));
  color: #fff;
  font-weight: 600;
}
.sidebar button.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-bright);
  box-shadow: 0 0 12px rgba(167, 139, 250, .7);
}
.sidebar button.active > span { opacity: 1; color: var(--accent-bright); }

/* ---------- 5. Widoki ---------------------------------------------------- */
.view { display: none; }
.view.active { display: block; animation: viewIn var(--normal) var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }

.view-head { display: flex; align-items: flex-end; gap: 12px; margin: 0 0 16px; flex-wrap: wrap; }
.view-head > div:first-child { flex: 1; min-width: 0; }
#feature-count { flex: 0 0 auto; }

/* Czat: własna, przewijalna przestrzeń; kompozytor zawsze widoczny. */
#view-chat.active {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--header-h) - var(--nav-h) - 30px);
  min-height: 420px;
}
#view-chat .messages {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 4px 2px 8px;
  scroll-behavior: smooth;
}
#view-chat .composer { position: static; margin-top: 10px; padding-top: 0; background: transparent; }
#view-chat .hint { margin-bottom: 0; }

/* ---------- 6. Typografia ------------------------------------------------ */
.eyebrow {
  color: var(--accent-ink);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 6px;
  opacity: .85;
}
h1, h2, h3 { margin: 0 0 8px; letter-spacing: -.02em; color: var(--text); }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.95rem); font-weight: 700; line-height: 1.15; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: .92rem; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.hint { color: var(--muted-2); font-size: .72rem; margin: 8px 0 4px; }

/* ---------- 7. Karty i siatki ------------------------------------------- */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .012));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(12px);
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.section-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.section-head h2 { margin: 0; flex: 1; font-size: .95rem; font-weight: 650; }
.section-head .ghost { font-size: .78rem; }

.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.detail-head h2 { margin: 0; flex: 1; }

/* ---------- 8. Przyciski ------------------------------------------------- */
button.primary, button.secondary, button.danger, button.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-sm);
  padding: 10px 15px;
  min-height: 42px;
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: -.005em;
  border: 1px solid transparent;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease), transform var(--fast) var(--ease),
              box-shadow var(--fast) var(--ease);
  white-space: nowrap;
}
button.primary {
  color: #fff;
  background: linear-gradient(180deg, #9a6bff, #7c3aed);
  border-color: rgba(196, 181, 253, .35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 18px -8px rgba(124, 58, 237, .9);
}
button.primary:hover { background: linear-gradient(180deg, #a87cff, #8b5cf6); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .26), 0 10px 26px -10px rgba(139, 92, 246, 1); }
button.secondary {
  color: var(--text-soft);
  background: rgba(255, 255, 255, .055);
  border-color: var(--line-strong);
}
button.secondary:hover { background: rgba(255, 255, 255, .1); color: #fff; }
button.danger {
  color: var(--danger);
  background: rgba(251, 113, 133, .1);
  border-color: rgba(251, 113, 133, .32);
}
button.danger:hover { background: rgba(251, 113, 133, .18); }
button.ghost {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  min-height: 36px;
  padding: 7px 10px;
}
button.ghost:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:active:not(:disabled) { transform: translateY(1px) scale(.995); }
button .ico { display: inline-flex; }

/* ---------- 9. Formularze ------------------------------------------------ */
input, textarea, select {
  width: 100%;
  background: rgba(8, 8, 14, .85);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 42px;
  outline: none;
  color: var(--text);
  font-size: .9rem;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, textarea:hover, select:hover { border-color: rgba(255, 255, 255, .18); }
input:focus, textarea:focus, select:focus {
  border-color: rgba(139, 92, 246, .7);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .16);
  background: rgba(10, 10, 18, .95);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
label { display: block; color: var(--muted); font-size: .76rem; font-weight: 500; margin: 12px 0 6px; }
select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.filter-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.filter-row select { flex: 1; min-width: 150px; }
.checkbox { display: flex; align-items: center; gap: 10px; color: var(--text-soft); font-size: .88rem; margin: 8px 0; }
.checkbox input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }

/* ---------- 10. Czat: wiadomości ---------------------------------------- */
.messages { display: flex; flex-direction: column; gap: 14px; min-height: 40vh; padding: 4px 0 12px; }

.msg {
  /* Wiadomość nigdy nie może zostać ściśnięta przez flexbox. */
  flex: 0 0 auto;
  min-width: 0;
  max-width: min(100%, 820px);
  padding: 13px 16px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: .925rem;
  line-height: 1.62;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .028);
  box-shadow: var(--shadow-1);
}

.msg.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(160deg, rgba(139, 92, 246, .95), rgba(109, 40, 217, .92));
  border-color: rgba(196, 181, 253, .35);
  border-bottom-right-radius: 6px;
  box-shadow: 0 10px 30px -14px rgba(124, 58, 237, .9);
}
.msg.assistant {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .015));
}
.msg.assistant::before { display: none; }
.msg.system {
  align-self: center;
  max-width: 92%;
  background: rgba(255, 255, 255, .03);
  border-color: var(--line);
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
}

.msg .meta {
  color: var(--muted-2);
  font-size: .68rem;
  margin-top: 9px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.msg.user .meta { color: rgba(255, 255, 255, .7); }
.msg .ghost { margin-top: 6px; min-height: 30px; padding: 3px 8px; font-size: .74rem; }

/* Treść wiadomości (markdown) */
.msg-body { min-width: 0; }
.msg-body > *:first-child { margin-top: 0; }
.msg-body > *:last-child { margin-bottom: 0; }
.msg-body p { margin: 0 0 .7em; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  margin: 1.05em 0 .45em;
  line-height: 1.3;
  letter-spacing: -.015em;
}
.msg-body h1 { font-size: 1.24rem; }
.msg-body h2 { font-size: 1.1rem; }
.msg-body h3 { font-size: .99rem; }
.msg-body ul, .msg-body ol { margin: 0 0 .7em; padding-left: 1.3em; }
.msg-body li { margin: .2em 0; }
.msg-body li::marker { color: var(--accent-bright); }
.msg-body blockquote {
  margin: .7em 0;
  padding: 2px 0 2px 14px;
  border-left: 2px solid rgba(139, 92, 246, .5);
  color: var(--text-soft);
}
.msg-body a { color: var(--accent-ink); border-bottom: 1px solid rgba(196, 181, 253, .3); text-decoration: none; }
.msg-body a:hover { border-bottom-color: var(--accent-ink); }
.msg-body strong { font-weight: 650; color: #fff; }
.msg-body hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.msg-body img { max-width: 100%; border-radius: var(--radius-sm); display: block; margin: .6em 0; }
.msg-image { max-width: 100%; border-radius: var(--radius-sm); display: block; margin: 8px 0; border: 1px solid var(--line); }

.msg code {
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1em .38em;
  font-family: "Cascadia Code", "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: .86em;
  color: #e9e4ff;
}
.msg pre {
  background: #0a0a12;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.55;
  margin: .7em 0;
}
.msg pre code { padding: 0; background: none; border: 0; font-size: inherit; }

.msg-body table {
  width: 100%;
  border-collapse: collapse;
  margin: .7em 0;
  font-size: .85rem;
}
.msg-body th, .msg-body td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.msg-body th { background: rgba(255, 255, 255, .04); font-weight: 600; color: var(--text); }
.msg-body tr:nth-child(even) td { background: rgba(255, 255, 255, .015); }

/* Tabele nie mogą rozpychać bańki na telefonie. */
.msg-body .table-scroll { max-width: 100%; overflow-x: auto; border-radius: var(--radius-sm); }
.msg-body .table-scroll table { min-width: 420px; }

/* Blok kodu z nagłówkiem i kopiowaniem */
.code-block {
  margin: .8em 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0a0a12;
}
.code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: rgba(255, 255, 255, .03);
  border-bottom: 1px solid var(--line);
}
.code-head::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  box-shadow: 14px 0 0 rgba(255, 255, 255, .12), 28px 0 0 rgba(255, 255, 255, .07);
  margin-right: 22px;
}
.code-head span { font-size: .7rem; color: var(--muted-2); font-family: ui-monospace, monospace; flex: 1; }
.code-block pre { margin: 0; border: 0; border-radius: 0; background: transparent; }
.code-copy {
  font-size: .7rem;
  color: var(--muted);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  min-height: 24px;
  transition: all var(--fast) var(--ease);
}
.code-copy:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.code-copy.copied { color: var(--success); border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .1); }

/* Akcje pod wiadomością */
.msg-actions { display: flex; gap: 2px; margin-top: 6px; flex-wrap: wrap; opacity: .55; transition: opacity var(--normal) var(--ease); }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 7px;
  font-size: .72rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--fast) var(--ease);
}
.msg-action:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.msg-action.active { color: var(--accent-ink); background: rgba(139, 92, 246, .14); border-color: rgba(139, 92, 246, .25); }
.msg-action:disabled { opacity: .4; }
.msg-action .ico { font-size: .85rem; }

/* Cytat / odpowiedź */
.msg .quote {
  border-left: 2px solid rgba(196, 181, 253, .5);
  padding: 2px 0 2px 10px;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, .72);
  font-size: .82rem;
}
.msg-note { color: var(--muted-2); font-size: .74rem; margin-top: 6px; }
.msg-note.continuing::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent-bright);
  animation: pulseDot 1.4s var(--ease) infinite;
}
@keyframes pulseDot { 50% { opacity: .25; transform: scale(.8); } }

.msg .cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -.16em;
  background: var(--accent-bright);
  border-radius: 2px;
  animation: blink 1.05s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.msg.enter { animation: msgIn var(--normal) var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(.995); } }

.msg.streaming { border-color: rgba(139, 92, 246, .32); box-shadow: 0 0 0 1px rgba(139, 92, 246, .1), var(--shadow-2); }

/* „Kaizo pisze” */
.msg.typing { padding: 12px 16px; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-bright);
  opacity: .45;
  animation: dot 1.15s var(--ease) infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .14s; }
.typing-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Emocja */
.badge.emotion { gap: 7px; color: var(--muted); }
.badge.emotion .emotion-face { width: 16px; height: 16px; display: block; }
.badge.emotion.pulse { animation: emotionPop 320ms var(--ease); }
@keyframes emotionPop { 0% { transform: scale(1); } 45% { transform: scale(1.12); } 100% { transform: scale(1); } }
.badge.emotion[data-emotion="happy"] { color: var(--success); border-color: rgba(52, 211, 153, .3); }
.badge.emotion[data-emotion="sad"] { color: #7dd3fc; border-color: rgba(125, 211, 252, .28); }
.badge.emotion[data-emotion="angry"] { color: var(--danger); border-color: rgba(251, 113, 133, .3); }
.badge.emotion[data-emotion="disappointed"] { color: var(--warning); border-color: rgba(251, 191, 36, .28); }

/* ---------- 11. Kompozytor ---------------------------------------------- */
.composer {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(6, 6, 11, .96) 34%);
  padding-top: 10px;
  z-index: 5;
}
.composer-box {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(14, 14, 23, .92);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 7px 7px 7px 8px;
  box-shadow: var(--shadow-2);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.composer-box:focus-within {
  border-color: rgba(139, 92, 246, .55);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .12), var(--shadow-2);
}
.composer textarea {
  flex: 1;
  min-height: 38px;
  max-height: 40vh;
  padding: 9px 8px;
  border: 0;
  background: transparent;
  resize: none;
  font-size: .93rem;
  line-height: 1.55;
}
.composer textarea:focus { box-shadow: none; background: transparent; }
.composer-box .attach {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: var(--radius-xs);
  color: var(--muted);
  font-size: 1.1rem;
  flex: 0 0 auto;
}
.composer-box .attach:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.composer-box #send {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-xs);
}
.composer-box #send.stop { background: linear-gradient(180deg, #fb7185, #e11d48); border-color: rgba(255, 190, 200, .3); }
.composer button { min-height: 38px; }

#chat-usage { font-size: .7rem; color: var(--muted-2); margin-top: 6px; }

.attach-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: rgba(20, 20, 32, .98);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-3);
  z-index: 40;
  min-width: 210px;
  animation: menuIn var(--fast) var(--ease);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.attach-menu[hidden] { display: none; }
.attach-menu button {
  justify-content: flex-start;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  min-height: 38px;
  font-size: .85rem;
  font-weight: 500;
  text-align: left;
}
.attach-menu button:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.limit-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(251, 191, 36, .3);
  background: rgba(251, 191, 36, .08);
  color: #fde68a;
  font-size: .8rem;
}
.limit-bubble[hidden] { display: none; }
.limit-bubble button { margin-left: auto; min-height: 30px; padding: 4px 10px; font-size: .76rem; }

.attachment-chip, .reply-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .05);
  font-size: .78rem;
  color: var(--text-soft);
}
.attachment-chip[hidden], .reply-chip[hidden] { display: none; }
.attachment-chip button, .reply-chip button {
  margin-left: auto;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}
.attachment-chip button:hover, .reply-chip button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.reply-chip { border-left: 2px solid var(--accent-bright); }
.reply-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lista rozmów nad czatem */
.chat-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 0 10px;
  scrollbar-width: none;
}
.chat-list::-webkit-scrollbar { display: none; }
.chat-chip {
  flex: 0 0 auto;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .78rem;
  color: var(--muted);
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  transition: all var(--fast) var(--ease);
}
.chat-chip:hover { color: var(--text-soft); background: rgba(255, 255, 255, .07); }
.chat-chip.active { color: #fff; background: rgba(139, 92, 246, .2); border-color: rgba(139, 92, 246, .45); }

/* ---------- 12. Pulpit --------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 30px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse 70% 100% at 100% 0%, rgba(139, 92, 246, .22), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .012));
  box-shadow: var(--shadow-3);
}
.hero-copy { flex: 1; min-width: 0; }
.hero h1 { margin: 0 0 10px; font-size: clamp(1.65rem, 1.2rem + 1.8vw, 2.4rem); line-height: 1.1; }
.hero p { color: var(--muted); max-width: 54ch; margin-bottom: 18px; font-size: .95rem; }
.hero .row { gap: 10px; }
.hero-orbit {
  position: relative;
  width: 160px;
  height: 160px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(139, 92, 246, .25);
  box-shadow: 0 0 0 18px rgba(139, 92, 246, .04), 0 0 0 42px rgba(139, 92, 246, .025);
}
.hero-k {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border-radius: 28px;
  font-size: 42px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(150deg, #a78bfa, #6d28d9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 20px 50px -18px rgba(124, 58, 237, 1);
  animation: heroFloat 8s var(--ease) infinite alternate;
}
@keyframes heroFloat { to { transform: translateY(-7px) rotate(-2deg); } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0 0; }
.stat {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
}
.stat b {
  display: block;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat span { display: block; color: var(--muted-2); font-size: .72rem; margin-top: 2px; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.quick-tile, .more-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
  text-align: left;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.quick-tile:hover, .more-tile:hover { background: rgba(139, 92, 246, .08); border-color: rgba(139, 92, 246, .3); }
.quick-tile:active, .more-tile:active { transform: scale(.99); }
.quick-icon, .more-tile > span {
  font-size: 1.15rem;
  color: var(--accent-bright);
  margin-bottom: 4px;
  line-height: 1;
}
.quick-tile b, .more-tile b { font-size: .87rem; font-weight: 600; color: var(--text); }
.quick-tile small, .more-tile small { font-size: .72rem; color: var(--muted-2); }

.recent-list { display: flex; flex-direction: column; gap: 2px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: .87rem;
  text-align: left;
  transition: background var(--fast) var(--ease);
}
.recent-item:hover { background: rgba(255, 255, 255, .05); }
.recent-item .recent-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-bright); opacity: .7; flex: 0 0 auto; }
.recent-item .recent-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .recent-time { color: var(--muted-2); font-size: .72rem; flex: 0 0 auto; }

.platform-note h2 { font-size: .95rem; }
.platform-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.platform-bar { display: flex; align-items: center; gap: 10px; font-size: .78rem; color: var(--muted); }
.platform-bar .bar { flex: 1; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.platform-bar .bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Karta silnika */
.engine { padding: 16px 18px; }
.engine-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.engine-title { font-size: .88rem; font-weight: 600; flex: 1; }
.engine-badge {
  font-size: .68rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  background: rgba(255, 255, 255, .03);
}
.engine-badge.on { color: var(--success); border-color: rgba(52, 211, 153, .3); background: rgba(52, 211, 153, .08); }
.engine-model { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.engine-model .muted { color: var(--muted-2); }
.engine-bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .06); overflow: hidden; margin: 6px 0; }
.engine-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #34d399, #22d3ee); transition: width 400ms var(--ease); }
.engine-vram-text { font-size: .74rem; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.engine-vram-text b { color: var(--text-soft); font-weight: 600; }
.engine-note { font-size: .72rem; color: var(--muted-2); margin-top: 8px; }

/* ---------- 13. Media ---------------------------------------------------- */
.media-result { margin: 14px 0; }
.media-result img {
  width: 100%;
  max-width: 640px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
  box-shadow: var(--shadow-3);
}
.media-result .row { margin-top: 10px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; transition: transform var(--normal) var(--ease); }
.gallery figure:hover img { transform: scale(1.03); }
.gallery figcaption { padding: 7px 9px; font-size: .7rem; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.artifacts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.artifacts a {
  font-size: .76rem;
  color: var(--accent-ink);
  background: rgba(139, 92, 246, .1);
  border: 1px solid rgba(139, 92, 246, .25);
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  text-decoration: none;
}
.artifacts a:hover { background: rgba(139, 92, 246, .18); }

/* ---------- 14. Funkcje -------------------------------------------------- */
.feature-list { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.feature-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, .022);
  text-align: left;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.feature-item:hover { background: rgba(255, 255, 255, .055); border-color: var(--line); }
.feature-item:active { transform: scale(.998); }
.feature-item .id {
  flex: 0 0 auto;
  min-width: 34px;
  font-size: .68rem;
  font-weight: 600;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.feature-item .name { flex: 1; min-width: 0; font-size: .87rem; font-weight: 500; color: var(--text); }
.feature-item .name small { display: block; color: var(--muted-2); font-size: .72rem; font-weight: 400; margin-top: 1px; }
.feature-item .badge { font-size: .66rem; padding: 2px 8px; }

.mini-badge {
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, .03);
  white-space: nowrap;
}

/* ---------- 15. Projekty, wiedza, pamięć, zadania, pliki ---------------- */
.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-top: 14px; }
.project-card {
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.project-card:hover { border-color: rgba(139, 92, 246, .3); background: rgba(139, 92, 246, .05); }
.project-card h3 { margin: 0 0 4px; font-size: .9rem; }
.project-card p { color: var(--muted); font-size: .8rem; margin: 0 0 10px; }
.project-card .meta { color: var(--muted-2); font-size: .72rem; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.project-card .row { gap: 6px; }

.knowledge-item, .file-item, .task-item, .notification-item, .permission-item {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .022);
  margin-bottom: 8px;
}
.knowledge-item h3, .file-item h3, .task-item h3, .notification-item h3 { margin: 0 0 3px; font-size: .87rem; font-weight: 600; }
.knowledge-item p, .file-item p, .task-item p, .notification-item p { margin: 0 0 6px; color: var(--muted); font-size: .8rem; }
.knowledge-item .meta, .file-item .meta, .task-item .meta, .notification-item .meta { color: var(--muted-2); font-size: .72rem; }

.memory-item {
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  font-size: .85rem;
  color: var(--text-soft);
}
.memory-item:last-child { border-bottom: 0; }
.memory-item .kind { color: var(--accent-ink); font-size: .7rem; font-weight: 600; margin-right: 8px; text-transform: uppercase; letter-spacing: .06em; }

.permission-item { display: flex; align-items: flex-start; gap: 12px; }
.permission-item .permission-body { flex: 1; min-width: 0; }
.permission-item h3 { margin: 0 0 2px; font-size: .86rem; }
.permission-item p { margin: 0; color: var(--muted-2); font-size: .76rem; }
.permission-item .permission-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  margin-top: 7px;
  flex: 0 0 auto;
}
.permission-item .permission-dot.on { background: var(--success); box-shadow: 0 0 10px rgba(52, 211, 153, .6); }

.task-progress { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; margin-top: 8px; }
.task-progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------- 16. Plany ---------------------------------------------------- */
/* .plan-card = karta planu, .plan-list = lista punktów wewnątrz karty. */
.plan-card {
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plan-card.current {
  border-color: rgba(139, 92, 246, .5);
  background: linear-gradient(180deg, rgba(139, 92, 246, .14), rgba(139, 92, 246, .04));
  box-shadow: var(--glow);
}
.plan-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.plan-head > div { flex: 1; min-width: 0; }
.plan-head h2 { margin: 0; font-size: 1.18rem; font-weight: 650; }
.plan-card button[disabled] { opacity: .45; cursor: not-allowed; }

.plan-list {
  display: block;
  list-style: disc;
  margin: 4px 0 6px;
  padding-left: 1.15em;
}
.plan-list li {
  margin: .3em 0;
  color: var(--text-soft);
  font-size: .85rem;
  line-height: 1.5;
}
.plan-list li::marker { color: var(--accent-bright); }

#plans-list { display: grid; gap: 12px; }

/* ---------- 17. Więcej / kafelki ---------------------------------------- */
.more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

/* ---------- 18. Modal, toast, offline ----------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(3, 3, 7, .72);
  backdrop-filter: blur(8px);
}
.modal.show { display: grid; animation: fadeIn var(--normal) var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.modal .card {
  width: min(440px, 100%);
  margin: 0;
  padding: 24px;
  border-radius: 20px;
  border-color: var(--line-strong);
  background: linear-gradient(180deg, #14141f, #0d0d15);
  box-shadow: var(--shadow-3);
  animation: modalIn var(--normal) var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal .card h2 { font-size: 1.05rem; }
.modal-mark { margin-bottom: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  z-index: 80;
  max-width: min(520px, 90vw);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(22, 22, 34, .98);
  color: var(--text);
  font-size: .83rem;
  box-shadow: var(--shadow-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--normal) var(--ease), transform var(--normal) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.offline-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  padding: 8px 16px;
  text-align: center;
  font-size: .78rem;
  color: #fecaca;
  background: rgba(127, 29, 29, .92);
  border-bottom: 1px solid rgba(251, 113, 133, .3);
}
body.offline .offline-banner { display: block; }

/* ---------- 19. Dolna nawigacja (telefon) ------------------------------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: rgba(8, 8, 14, .94);
  backdrop-filter: blur(20px) saturate(140%);
  border-top: 1px solid var(--line);
}
.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 6px 2px;
  border-radius: var(--radius-xs);
  color: var(--muted-2);
  font-size: .64rem;
  font-weight: 500;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.bottom-nav .icon { font-size: 1.15rem; line-height: 1; color: inherit; }
.bottom-nav button.active { color: #fff; background: rgba(139, 92, 246, .16); }
.bottom-nav button.active .icon { color: var(--accent-bright); }

/* ---------- 20. Drobne elementy ----------------------------------------- */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); display: inline-block; flex: 0 0 auto; }
.dot.ok { background: var(--success); box-shadow: 0 0 8px rgba(52, 211, 153, .5); }
.dot.warn { background: var(--warning); }
.dot.bad { background: var(--danger); }
.dot.free { background: var(--accent-bright); opacity: .55; }
.badge.free { color: var(--accent-ink); border-color: rgba(167, 139, 250, .28); background: rgba(139, 92, 246, .08); }

.ico { display: inline-flex; align-items: center; justify-content: center; }
.spinner {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .18);
  border-top-color: var(--accent-bright);
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(255, 255, 255, .02); margin-bottom: 10px; }
.result pre { margin: 0; font-size: .8rem; overflow-x: auto; }
.test-note { font-size: .74rem; color: var(--muted-2); }

/* ---------- 21. Desktop -------------------------------------------------- */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }

  .layout { min-height: calc(100vh - var(--header-h)); }

  .sidebar {
    display: flex;
    flex-direction: column;
    flex: 0 0 248px;
    width: 248px;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    padding: 10px 10px 16px;
    border-right: 1px solid var(--line);
    background: rgba(8, 8, 13, .55);
  }

  .main { padding: 28px 32px 48px; }

  #view-chat.active { height: calc(100dvh - var(--header-h) - 56px); }

  .composer { bottom: 0; }

  .msg { max-width: min(86%, 780px); }

  .hero { padding: 36px; }
}

@media (min-width: 1280px) {
  .main { max-width: 1080px; }
}

/* Telefon: gęstszy rytm, ale bez zmniejszania czytelności. */
@media (max-width: 700px) {
  :root { --header-h: 56px; --nav-h: 72px; }
  .main { padding: 16px 13px 22px; }
  .hero { flex-direction: column; align-items: flex-start; padding: 22px; gap: 16px; }
  .hero-orbit { display: none; }
  .card { padding: 15px; border-radius: 16px; }
  .msg { max-width: 96%; font-size: .9rem; }
  .view-head { align-items: flex-start; }
  h1 { font-size: 1.4rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .quick-grid, .more-grid { grid-template-columns: repeat(2, 1fr); }
  .project-list { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .msg-actions { opacity: 1; }
}

@media (max-width: 420px) {
  .main { padding: 14px 11px 18px; }
  .msg { padding: 11px 13px; border-radius: 15px; }
  .composer-box { border-radius: 15px; }
  .composer-box #send { padding: 0 13px; }
  .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 390px) {
  .brand-name { font-size: .88rem; }
  .stats { grid-template-columns: 1fr 1fr; }
}

/* Dopiero poniżej 360 px jedna kolumna — wyżej dwie mieszczą się bez ściskania. */
@media (max-width: 360px) {
  .quick-grid, .more-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}

/* ---------- 22. Ruch: tylko tam, gdzie ma sens -------------------------- */
@media (hover: hover) {
  .card { transition: border-color var(--normal) var(--ease), box-shadow var(--normal) var(--ease); }
  .card:hover { border-color: rgba(255, 255, 255, .11); }
}

/* ==========================================================================
   23. PLAN FREE — interfejs podstawowy
   Free ma być zwykłym, spokojnym interfejsem szaro-fioletowym: płaskie
   powierzchnie, bez aurory, bez poświat, bez animowanych teł. Ten sam układ
   i te same funkcje, tylko prostsza oprawa. Pro i Apex dostają pełny motyw.
   ========================================================================== */
body[data-plan="free"] {
  --bg: #0e0e13;
  --bg-2: #121218;
  --surface: #15151b;
  --surface-2: #1a1a21;
  --surface-3: #202028;
  --glass: #121218;

  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .11);
  --border: rgba(255, 255, 255, .09);
  --border-soft: rgba(255, 255, 255, .06);

  --text: #e9e8ef;
  --text-soft: #c6c4d0;
  --muted: #9694a4;
  --muted-2: #77758a;

  --accent: #6f6795;
  --accent-bright: #a49bc7;
  --accent-ink: #b5acd6;
  --accent-2: #8e88ab;

  --radius: 12px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --shadow-1: none;
  --shadow-2: none;
  --shadow-3: none;
  --glow: none;

  background-color: var(--bg);
  background-image: linear-gradient(180deg, #121218 0%, #0e0e13 46%, #101017 100%);
  background-attachment: scroll;
}

/* Tło: żadnych warstw dekoracyjnych. */
body[data-plan="free"]::before,
body[data-plan="free"]::after,
body[data-plan="free"] .ambient { display: none; }
html[data-plan="free"]::before,
html[data-plan="free"]::after { display: none; }
body[data-plan="free"] .offline-banner { background: #3a1d22; }

body[data-plan="free"] .app-header {
  background: #121218;
  backdrop-filter: none;
  border-bottom: 1px solid var(--line);
}

body[data-plan="free"] .brand-mark,
body[data-plan="free"] .modal-mark {
  background: #5f5787;
  box-shadow: none;
  border-radius: 9px;
  font-size: 16px;
}

body[data-plan="free"] .sidebar { background: #101015; border-right: 1px solid var(--line); }
body[data-plan="free"] .sidebar button.active {
  background: #1c1b24;
  color: #fff;
}
body[data-plan="free"] .sidebar button.active::before { background: var(--accent-bright); box-shadow: none; }
body[data-plan="free"] .sidebar button.active > span { color: var(--accent-bright); }

body[data-plan="free"] .card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
  backdrop-filter: none;
}

body[data-plan="free"] .hero {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
  padding: 26px;
}
body[data-plan="free"] .hero-orbit { display: none; }

body[data-plan="free"] .stat { background: var(--surface); border-color: var(--line); }
body[data-plan="free"] .stat b { font-weight: 600; }

body[data-plan="free"] .quick-tile,
body[data-plan="free"] .more-tile,
body[data-plan="free"] .project-card,
body[data-plan="free"] .plan-card {
  background: var(--surface);
  border-color: var(--line);
}
body[data-plan="free"] .quick-tile:hover,
body[data-plan="free"] .more-tile:hover,
body[data-plan="free"] .project-card:hover {
  background: #1a1a22;
  border-color: var(--line-strong);
}
body[data-plan="free"] .quick-icon,
body[data-plan="free"] .more-tile > span { color: var(--accent-bright); }

body[data-plan="free"] button.primary {
  background: #5f5787;
  border-color: #6f6795;
  box-shadow: none;
  color: #fff;
}
body[data-plan="free"] button.primary:hover { background: #6a6295; box-shadow: none; }
body[data-plan="free"] button.secondary {
  background: #1b1b22;
  border-color: var(--line-strong);
  color: var(--text-soft);
}
body[data-plan="free"] button.secondary:hover { background: #22222b; color: #fff; }
body[data-plan="free"] button.ghost:hover { background: #1b1b22; }

body[data-plan="free"] .msg {
  background: #16161c;
  border-color: var(--line);
  box-shadow: none;
  border-radius: 12px;
}
body[data-plan="free"] .msg.user {
  background: #2b2740;
  border-color: #3a3457;
  box-shadow: none;
  border-bottom-right-radius: 4px;
}
body[data-plan="free"] .msg.assistant { background: #16161c; border-bottom-left-radius: 4px; }
body[data-plan="free"] .msg.system { background: #17171d; }
body[data-plan="free"] .msg.streaming { border-color: #4a4368; box-shadow: none; }

body[data-plan="free"] .composer-box {
  background: #131319;
  border-color: var(--line-strong);
  box-shadow: none;
  border-radius: 12px;
}
body[data-plan="free"] .composer-box:focus-within {
  border-color: #5f5787;
  box-shadow: none;
}
body[data-plan="free"] .composer-box #send.stop { background: #7a3a48; border-color: #8f4455; }

body[data-plan="free"] .chat-chip {
  background: #17171d;
  border-color: var(--line);
  color: var(--text-soft);
}
body[data-plan="free"] .chat-chip.active {
  background: #24212f;
  border-color: #4a4368;
  color: #fff;
}

body[data-plan="free"] .code-block,
body[data-plan="free"] .msg pre { background: #101014; border-color: var(--line); }
body[data-plan="free"] .msg code { background: #1d1d25; border-color: var(--line); color: #ded9ef; }

body[data-plan="free"] .badge {
  background: #17171d;
  border-color: var(--line);
}
body[data-plan="free"] .badge.ok { background: #14211c; border-color: #2b4438; }
body[data-plan="free"] .badge.warn { background: #241f14; border-color: #443a22; }

body[data-plan="free"] .engine-bar i { background: #6f6795; }
body[data-plan="free"] .task-progress span { background: #6f6795; }
body[data-plan="free"] .platform-bar .bar span { background: #6f6795; }

body[data-plan="free"] .plan-card.current {
  background: #1a1824;
  border-color: #4a4368;
  box-shadow: none;
}

body[data-plan="free"] .modal { background: rgba(6, 6, 9, .8); backdrop-filter: none; }
body[data-plan="free"] .modal .card { background: #16161c; box-shadow: none; }

body[data-plan="free"] .toast { background: #1c1c24; box-shadow: none; }

body[data-plan="free"] .bottom-nav { background: #0e0e13; backdrop-filter: none; }
body[data-plan="free"] .bottom-nav button.active { background: #1c1b24; }
body[data-plan="free"] .bottom-nav button.active .icon { color: var(--accent-bright); }

/* Free nie ma animowanych teł ani „oddychających” elementów. */
body[data-plan="free"] .hero-k { animation: none; }
body[data-plan="free"] .msg.enter,
body[data-plan="free"] .view.active { animation-duration: 140ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   NEXUS VISUAL REFRESH ? Kaizo desktop companion / PWA / Android WebView
   Głębsza głębia, czytelniejsze powierzchnie i krótki, spokojny ruch.
   ========================================================================== */
:root {
  --bg: #070a14;
  --bg-2: #0d1322;
  --surface: rgba(17, 24, 39, .82);
  --surface-2: rgba(25, 34, 56, .90);
  --surface-3: rgba(32, 45, 70, .94);
  --glass: rgba(8, 13, 27, .78);
  --line: rgba(148, 170, 210, .10);
  --line-strong: rgba(148, 170, 210, .18);
  --border: rgba(148, 170, 210, .13);
  --border-soft: rgba(148, 170, 210, .08);
  --text: #f1f5ff;
  --text-soft: #c9d3e8;
  --muted: #94a0b8;
  --muted-2: #71809a;
  --accent: #8b5cf6;
  --accent-bright: #b5a3ff;
  --accent-ink: #ded7ff;
  --accent-2: #43d7ef;
  --radius: 19px;
  --radius-sm: 13px;
  --radius-xs: 10px;
  --shadow-1: 0 2px 8px rgba(0,0,0,.24);
  --shadow-2: 0 12px 32px -12px rgba(0,0,0,.62);
  --shadow-3: 0 28px 70px -26px rgba(0,0,0,.78);
  --glow: 0 0 0 1px rgba(139,92,246,.22), 0 12px 34px -14px rgba(67,215,239,.22);
}
body {
  background-color: #070a14;
  background-image:
    radial-gradient(1000px 620px at 10% -12%, rgba(126, 87, 245, .25), transparent 64%),
    radial-gradient(820px 560px at 103% 2%, rgba(54, 207, 232, .12), transparent 60%),
    radial-gradient(900px 640px at 72% 116%, rgba(155, 92, 246, .13), transparent 65%),
    linear-gradient(180deg, #080c18 0%, #070a14 54%, #0b0d1c 100%);
}
body::before {
  opacity: .34;
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 82% 65% at 50% 0%, #000 8%, transparent 76%);
  -webkit-mask-image: radial-gradient(ellipse 82% 65% at 50% 0%, #000 8%, transparent 76%);
}
body::after {
  opacity: .72;
  filter: blur(84px);
  animation: nexusAurora 66s var(--ease) infinite alternate;
}
@keyframes nexusAurora {
  to { transform: translateX(-50%) rotate(18deg) scale(1.08); }
}
.app-header {
  background: rgba(8, 12, 23, .82);
  border-bottom: 1px solid rgba(148,170,210,.12);
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  backdrop-filter: blur(22px) saturate(135%);
}
.brand-mark {
  border-radius: 13px;
  background: linear-gradient(135deg, #9b78ff 0%, #7651e8 52%, #43d7ef 100%);
  box-shadow: 0 6px 24px rgba(125,92,245,.28);
}
.brand-name { letter-spacing: .08em; }
.brand-name span { color: #b5a3ff; }
.sidebar {
  background: linear-gradient(180deg, rgba(9,14,27,.94), rgba(8,12,23,.88));
  border-right: 1px solid rgba(148,170,210,.11);
  backdrop-filter: blur(18px);
}
.sidebar button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 11px;
  transition: background var(--normal) var(--ease), border-color var(--normal) var(--ease),
              color var(--normal) var(--ease), transform var(--normal) var(--ease);
}
.sidebar button:hover { transform: translateX(2px); }
.sidebar button.active {
  background: linear-gradient(105deg, rgba(139,92,246,.23), rgba(67,215,239,.09));
  border-color: rgba(165,145,255,.20);
  box-shadow: inset 3px 0 0 #a995ff, 0 6px 18px rgba(0,0,0,.16);
}
.sidebar button.active::before {
  background: linear-gradient(180deg, #b5a3ff, #43d7ef);
  box-shadow: 0 0 14px rgba(139,92,246,.45);
}
.main { scroll-behavior: smooth; }
.card {
  background: linear-gradient(145deg, rgba(25,34,56,.86), rgba(15,22,38,.91) 62%, rgba(34,25,61,.78));
  border: 1px solid rgba(148,170,210,.13);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(18px) saturate(120%);
}
.card:hover {
  border-color: rgba(173,157,255,.28);
  box-shadow: 0 16px 38px -18px rgba(0,0,0,.72), 0 0 0 1px rgba(139,92,246,.06);
}
.hero {
  border-color: rgba(160,139,255,.25);
  background:
    radial-gradient(ellipse at 90% 8%, rgba(67,215,239,.14), transparent 40%),
    linear-gradient(135deg, rgba(42,34,78,.93), rgba(19,28,49,.95) 58%, rgba(13,21,38,.96));
  box-shadow: 0 24px 62px -30px rgba(0,0,0,.85), 0 0 34px rgba(123,92,246,.08);
}
.hero h1 { letter-spacing: -.035em; }
.hero-orbit { filter: drop-shadow(0 0 28px rgba(139,92,246,.22)); }
.stat {
  background: linear-gradient(145deg, rgba(28,39,64,.88), rgba(16,24,41,.90));
  border-color: rgba(148,170,210,.12);
}
.quick-tile, .more-tile, .project-card, .plan-card {
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(26,36,59,.82), rgba(15,23,40,.91));
  border-color: rgba(148,170,210,.12);
  box-shadow: var(--shadow-1);
  transition: transform 180ms var(--ease), border-color 180ms var(--ease),
              background 180ms var(--ease), box-shadow 180ms var(--ease);
}
.quick-tile:hover, .more-tile:hover, .project-card:hover {
  transform: translateY(-3px);
  border-color: rgba(174,157,255,.34);
  box-shadow: 0 14px 30px -18px rgba(0,0,0,.78);
}
.quick-icon, .more-tile > span { color: #b5a3ff; }
button.primary {
  background: linear-gradient(115deg, #8058ee, #6f50db 58%, #347fbd);
  border: 1px solid rgba(190,179,255,.28);
  box-shadow: 0 8px 22px -12px rgba(139,92,246,.76);
}
button.primary:hover {
  filter: brightness(1.09);
  box-shadow: 0 10px 28px -12px rgba(67,215,239,.36);
  transform: translateY(-1px);
}
button.secondary, button.ghost {
  transition: background 160ms var(--ease), border-color 160ms var(--ease),
              color 160ms var(--ease), transform 160ms var(--ease);
}
button.secondary { border-color: rgba(148,170,210,.18); }
input, textarea, select {
  border-color: rgba(148,170,210,.17);
  background: rgba(8,14,27,.72);
  border-radius: 11px;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(165,145,255,.72);
  box-shadow: 0 0 0 3px rgba(139,92,246,.13);
}
.msg {
  border-radius: 18px;
  border-color: rgba(148,170,210,.13);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
.msg.user {
  background: linear-gradient(135deg, rgba(114,79,220,.96), rgba(70,76,174,.95) 66%, rgba(38,119,153,.94));
  border-color: rgba(197,185,255,.34);
}
.msg.assistant {
  background: linear-gradient(145deg, rgba(22,32,52,.94), rgba(14,22,38,.96));
}
.msg.streaming { border-color: rgba(67,215,239,.50); }
.composer-box {
  background: rgba(10,16,30,.91);
  border: 1px solid rgba(148,170,210,.19);
  border-radius: 18px;
  box-shadow: 0 16px 42px -22px rgba(0,0,0,.8);
  backdrop-filter: blur(18px);
}
.composer-box:focus-within {
  border-color: rgba(165,145,255,.62);
  box-shadow: 0 0 0 3px rgba(139,92,246,.10), 0 18px 46px -24px rgba(0,0,0,.82);
}
.badge {
  border-color: rgba(148,170,210,.18);
  background: rgba(26,36,58,.72);
}
.view.active { animation: nexusViewEnter 210ms var(--ease) both; }
@keyframes nexusViewEnter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-chip.active {
  border-color: rgba(165,145,255,.38);
  background: rgba(103,78,184,.19);
}
.plan-card.current {
  border-color: rgba(165,145,255,.42);
  box-shadow: 0 0 0 1px rgba(139,92,246,.14), 0 16px 36px -24px rgba(0,0,0,.8);
}
.toast {
  border: 1px solid rgba(148,170,210,.17);
  backdrop-filter: blur(16px);
}
@media (max-width: 760px) {
  .app-header { backdrop-filter: blur(16px); }
  .card { backdrop-filter: blur(12px); }
  .view.active { animation-duration: 160ms; }
}
@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
  .sidebar button:hover, button.primary:hover,
  .quick-tile:hover, .more-tile:hover, .project-card:hover { transform: none; }
}

/* Free remains deliberately quieter and flat; only spacing/readability refresh. */
body[data-plan="free"] {
  --bg: #0e121d;
  --bg-2: #131a28;
  --surface: #151d2d;
  --surface-2: #1b2538;
  --surface-3: #222e42;
}
body[data-plan="free"] .app-header {
  background: #131a28; backdrop-filter: none;
}
body[data-plan="free"] .sidebar {
  background: #101725; backdrop-filter: none;
}
body[data-plan="free"] .sidebar button.active {
  background: #20283a; border-color: #35334a; box-shadow: inset 3px 0 0 #a49bc7;
}
body[data-plan="free"] .hero {
  background: #151d2d; border-color: var(--line); box-shadow: none;
}
body[data-plan="free"] .msg.user { background: #34304c; }
body[data-plan="free"] .composer-box { background: #121a28; backdrop-filter: none; }


/* AURORA / KAIZO 3.1 ? full interface pass */
:root {
  --bg:#080711; --bg-2:#100d20; --surface:rgba(21,17,37,.88);
  --surface-2:rgba(31,23,52,.92); --surface-3:rgba(46,32,72,.95);
  --glass:rgba(13,10,25,.88); --line:rgba(210,177,255,.15);
  --line-strong:rgba(224,191,255,.27); --border:rgba(214,178,255,.16);
  --text:#fbf7ff; --text-soft:#e0d2f4; --muted:#ad9abf; --muted-2:#806e98;
  --accent:#a855f7; --accent-bright:#e0a5ff; --accent-ink:#f2d7ff;
  --accent-2:#64d9f6; --radius:23px; --radius-sm:16px;
  --shadow-1:0 7px 20px rgba(0,0,0,.25);
  --shadow-2:0 20px 52px -20px rgba(0,0,0,.78);
  --glow:0 0 0 1px rgba(216,146,255,.25),0 16px 44px -16px rgba(203,88,255,.34);
}
html,body { background:#080711; }
body {
  background-image:
    radial-gradient(ellipse 74% 48% at 8% -4%,rgba(166,75,255,.34),transparent 68%),
    radial-gradient(ellipse 56% 42% at 100% 18%,rgba(55,190,234,.18),transparent 70%),
    radial-gradient(ellipse 70% 56% at 54% 112%,rgba(222,71,190,.20),transparent 66%),
    linear-gradient(155deg,#090714 0%,#0b0a18 48%,#10091c 100%);
  background-attachment:fixed;
}
body::before { opacity:.23; background-size:54px 54px; }
body::after { opacity:.92; filter:blur(74px); animation-duration:42s; }
.ambient { opacity:.72; filter:blur(68px); }
.ambient-a { background:radial-gradient(circle,rgba(183,91,255,.44),transparent 69%); }
.ambient-b { background:radial-gradient(circle,rgba(67,191,242,.24),transparent 68%); }
.ambient-c { background:radial-gradient(circle,rgba(242,90,202,.26),transparent 70%); }
.app-header {
  height:68px; padding-inline:22px; background:rgba(10,8,20,.88);
  border-bottom:1px solid rgba(216,171,255,.16);
  box-shadow:0 12px 36px rgba(0,0,0,.23); backdrop-filter:blur(24px) saturate(145%);
}
.brand-mark { width:39px;height:39px;border-radius:14px;background:linear-gradient(135deg,#f0a5ff 0%,#a855f7 48%,#48d9ef 100%);box-shadow:0 8px 27px rgba(196,91,255,.38); }
.brand-name { letter-spacing:.12em; font-weight:900; }
.brand-sub { color:#c6a7df; letter-spacing:.17em; }
.layout { gap:14px; padding:14px; }
.sidebar {
  border:1px solid rgba(213,175,255,.13); border-radius:22px;
  background:linear-gradient(180deg,rgba(19,13,34,.93),rgba(11,10,24,.91));
  box-shadow:0 18px 50px rgba(0,0,0,.28); backdrop-filter:blur(20px);
}
.sidebar button { min-height:44px; border-radius:13px; padding-inline:15px; transition:all .2s ease; }
.sidebar button.active { background:linear-gradient(105deg,rgba(175,86,255,.24),rgba(64,198,236,.11)); border:1px solid rgba(224,172,255,.22); box-shadow:inset 3px 0 #e5a7ff,0 8px 24px rgba(0,0,0,.2); }
.sidebar button.active::before { background:linear-gradient(180deg,#f2b2ff,#62ddf7); box-shadow:0 0 16px rgba(212,110,255,.75); }
.main { border-radius:23px; }
.view { padding:25px 28px 28px; }
.view-head { margin-bottom:18px; }
.view h1 { font-size:clamp(27px,3vw,36px); letter-spacing:-.045em; }
.eyebrow { color:#e0a5ff; letter-spacing:.19em; font-weight:850; }
.card,.hero,.engine,.platform-note {
  border:1px solid rgba(219,176,255,.17); border-radius:24px;
  background:linear-gradient(145deg,rgba(38,25,62,.88),rgba(17,16,34,.95) 62%,rgba(35,19,48,.88));
  box-shadow:0 22px 58px -28px rgba(0,0,0,.88),inset 0 1px rgba(255,255,255,.045);
  backdrop-filter:blur(18px) saturate(125%);
}
.hero {
  min-height:260px; padding:34px; position:relative; overflow:hidden;
  background:radial-gradient(circle at 83% 47%,rgba(225,116,255,.25),transparent 31%),radial-gradient(circle at 94% 10%,rgba(68,213,243,.19),transparent 30%),linear-gradient(120deg,rgba(57,31,83,.96),rgba(22,18,42,.96) 58%,rgba(15,19,39,.97));
  border-color:rgba(224,170,255,.32);
}
.hero::after { content:"";position:absolute;right:9%;top:-42%;width:360px;height:360px;border:1px solid rgba(231,173,255,.16);border-radius:50%;box-shadow:0 0 0 24px rgba(206,134,255,.035),0 0 0 56px rgba(206,134,255,.025),0 0 70px rgba(196,92,255,.22);pointer-events:none; }
.hero h1 { font-size:clamp(32px,4vw,48px); letter-spacing:-.05em; line-height:1.08; }
.hero p { max-width:650px; color:#cbb9dc; }
.hero-orbit { filter:drop-shadow(0 0 38px rgba(211,112,255,.48)); }
.stat,.stats .card { border:1px solid rgba(212,175,255,.17);border-radius:18px;background:linear-gradient(145deg,rgba(43,31,68,.84),rgba(17,19,38,.94)); }
.quick-tile,.more-tile,.project-card,.plan-card {
  border:1px solid rgba(210,174,255,.15);border-radius:18px;
  background:linear-gradient(145deg,rgba(40,28,65,.83),rgba(17,18,37,.96));
  box-shadow:0 12px 28px rgba(0,0,0,.2);transition:transform .2s,border-color .2s,box-shadow .2s;
}
.quick-tile:hover,.more-tile:hover,.project-card:hover { transform:translateY(-4px);border-color:rgba(231,167,255,.45);box-shadow:0 18px 35px rgba(0,0,0,.3),0 0 26px rgba(189,83,255,.12); }
.quick-icon,.more-tile>span { color:#e1a6ff; }
button.primary { background:linear-gradient(115deg,#c15af2,#8d52e9 54%,#3d9ed2);border:1px solid rgba(239,190,255,.4);box-shadow:0 10px 30px -12px rgba(199,82,245,.78); }
button.primary:hover { filter:brightness(1.12);transform:translateY(-2px); }
button.secondary { background:rgba(31,24,50,.8);border:1px solid rgba(209,171,255,.22);color:#eedfff; }
input,textarea,select { background:rgba(12,11,25,.86);border:1px solid rgba(215,177,255,.20);border-radius:14px; }
input:focus,textarea:focus,select:focus { border-color:#d88dff;box-shadow:0 0 0 3px rgba(181,89,255,.15),0 0 24px rgba(181,89,255,.09); }
.msg { border-radius:20px;border-color:rgba(216,177,255,.15); }
.msg.user { background:linear-gradient(135deg,#a64de3,#744fe3 64%,#397fae);border-color:rgba(243,196,255,.42); }
.msg.assistant { background:linear-gradient(145deg,rgba(33,25,53,.97),rgba(17,18,36,.97)); }
.composer-box { background:rgba(13,11,27,.94);border:1px solid rgba(211,170,255,.27);border-radius:20px;box-shadow:0 18px 45px rgba(0,0,0,.38);backdrop-filter:blur(20px); }
.composer-box:focus-within { border-color:rgba(233,164,255,.74);box-shadow:0 0 0 3px rgba(190,92,255,.13),0 18px 48px rgba(0,0,0,.35); }
.badge { background:rgba(52,34,77,.78);border-color:rgba(219,174,255,.22); }
.view.active { animation:auroraViewIn .24s cubic-bezier(.2,.7,.3,1) both; }
@keyframes auroraViewIn { from{opacity:0;transform:translateY(9px) scale(.994)}to{opacity:1;transform:translateY(0) scale(1)} }
body[data-plan="free"] { --bg:#0b0b16;--bg-2:#141021;--surface:#191528;--surface-2:#211a32;--surface-3:#2a2140;--accent:#a98ac6;--accent-bright:#d6b5e6;--accent-ink:#ead5f5; }
body[data-plan="free"] .app-header { background:rgba(13,12,24,.94);backdrop-filter:blur(18px); }
body[data-plan="free"] .sidebar { background:linear-gradient(180deg,#171325,#10101e);backdrop-filter:blur(12px); }
body[data-plan="free"] .hero { background:linear-gradient(120deg,#241c35,#171528 64%,#151b2d);box-shadow:0 16px 38px rgba(0,0,0,.27); }
body[data-plan="free"] .msg.user { background:linear-gradient(135deg,#59456c,#40436d); }
body[data-plan="free"] .composer-box { background:#151324;backdrop-filter:blur(14px); }

/* Voice conversation: the orb stays centered in the actual mobile chat. */
.voice-toggle.active { background:linear-gradient(110deg,rgba(198,105,250,.28),rgba(94,194,241,.16));border-color:rgba(226,169,255,.5); }
#view-chat.voice-mode { display:flex!important;flex-direction:column;min-height:calc(100dvh - var(--header-h) - var(--nav-h) - var(--safe-bottom)); }
#view-chat.voice-mode .chat-list,#view-chat.voice-mode .messages,#view-chat.voice-mode .composer { display:none!important; }
.voice-stage[hidden] { display:none!important; }
.voice-stage {
  position:relative;isolation:isolate;flex:1;min-height:440px;margin:0 0 8px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;
  overflow:hidden;border:1px solid rgba(232,174,255,.18);border-radius:28px;
  background:radial-gradient(ellipse 54% 58% at 50% 46%,rgba(167,77,230,.15),transparent 76%),linear-gradient(145deg,rgba(27,17,43,.72),rgba(10,13,28,.78));
  box-shadow:inset 0 1px rgba(255,255,255,.04),0 20px 52px rgba(0,0,0,.22);
}
.voice-stage::before { content:"";position:absolute;inset:0;z-index:-1;opacity:.23;background-image:linear-gradient(rgba(224,188,255,.12) 1px,transparent 1px),linear-gradient(90deg,rgba(224,188,255,.12) 1px,transparent 1px);background-size:38px 38px;mask-image:radial-gradient(ellipse at center,#000 0%,transparent 78%); }
.voice-stage-status { display:flex;align-items:center;gap:10px;color:#d9b6ed;font-size:10px;font-weight:900;letter-spacing:.2em; }
.voice-live-dot { width:7px;height:7px;border-radius:50%;background:#d88aff;box-shadow:0 0 13px #d88aff; }
.voice-orb-wrap { position:relative;width:min(46vw,250px);height:min(46vw,250px);min-width:190px;min-height:190px;display:grid;place-items:center;margin:4px 0 2px; }
.voice-orb-aura { position:absolute;inset:5%;border-radius:50%;background:radial-gradient(circle,rgba(235,153,255,.34),rgba(175,91,255,.18) 42%,rgba(92,161,245,.05) 68%,transparent 74%);filter:blur(12px);transform:scale(.94);transition:transform .4s ease,opacity .4s ease; }
.voice-orb-core { position:relative;width:60%;height:60%;display:grid;place-items:center;border-radius:50%;background:radial-gradient(circle at 32% 24%,#ffe2ff 0%,#e9a6ff 12%,#c16bfa 37%,#874fe0 67%,#4c57b7 100%);box-shadow:inset -13px -17px 32px rgba(45,24,109,.36),inset 7px 8px 24px rgba(255,255,255,.56),0 0 32px rgba(217,122,255,.65),0 0 84px rgba(174,95,255,.33);transition:transform .42s cubic-bezier(.2,.7,.3,1),filter .4s ease; }
.voice-orb-core::before { content:"";position:absolute;inset:7%;border-radius:50%;border:1px solid rgba(255,255,255,.44);box-shadow:inset 0 0 25px rgba(255,255,255,.15); }
.voice-orb-core::after { content:"";position:absolute;inset:-12%;border-radius:50%;border:1px solid rgba(229,174,255,.38);box-shadow:0 0 24px rgba(193,104,255,.25); }
.voice-orb-core span { color:#fff8ff;font-size:clamp(30px,6vw,48px);font-weight:950;text-shadow:0 2px 14px rgba(67,36,115,.48); }
.voice-orb-ring { position:absolute;border:1px solid rgba(216,163,255,.28);border-radius:50%;pointer-events:none; }
.voice-orb-ring-a { inset:0;transform:rotateX(66deg); }
.voice-orb-ring-b { inset:9%;transform:rotateY(68deg) rotateZ(22deg);border-color:rgba(125,214,255,.28); }
.voice-caption { display:flex;flex-direction:column;align-items:center;gap:5px;text-align:center;padding:0 18px; }
.voice-caption strong { color:#fff5ff;font-size:clamp(19px,4vw,25px);letter-spacing:-.03em; }
.voice-caption span { color:#bda9ce;font-size:13px;max-width:400px; }
.voice-controls { display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap;margin-top:4px; }
.voice-mic-button { min-height:48px;padding:0 22px;border:1px solid rgba(244,196,255,.5);border-radius:999px;background:linear-gradient(110deg,#d66cf1,#9c5ce9 60%,#597ed8);color:#fff;font-weight:850;box-shadow:0 10px 32px rgba(176,81,229,.35); }
.voice-mic-button span { margin-right:8px;font-size:17px; }
.voice-mic-button:disabled { opacity:.58; }
.voice-close-button { min-height:44px;padding:0 18px;border:1px solid rgba(220,184,255,.18);border-radius:999px;background:rgba(29,22,46,.65);color:#d8c8e7; }
.voice-footnote { color:#867497;font-size:10px;text-align:center;padding:0 16px 12px; }
.voice-stage.is-listening .voice-orb-core { animation:voiceListening 1.4s ease-in-out infinite;filter:saturate(1.12) brightness(1.08); }
.voice-stage.is-listening .voice-orb-aura { transform:scale(1.16);opacity:1; }
.voice-stage.is-speaking .voice-orb-core { animation:voiceSpeaking .72s ease-in-out infinite alternate;filter:saturate(1.22) brightness(1.15); }
.voice-stage.is-speaking .voice-orb-aura { animation:voiceAura .72s ease-in-out infinite alternate; }
.voice-stage.is-thinking .voice-orb-core { animation:voiceThinking 1.7s ease-in-out infinite; }
.voice-stage[data-state="ready"] .voice-orb-core { animation:voiceIdle 3.4s ease-in-out infinite; }
@keyframes voiceIdle { 0%,100%{transform:scale(.96)}50%{transform:scale(1.035)} }
@keyframes voiceListening { 0%,100%{transform:scale(.98)}50%{transform:scale(1.10)} }
@keyframes voiceSpeaking { from{transform:scale(.99)}to{transform:scale(1.19)} }
@keyframes voiceAura { from{transform:scale(.95);opacity:.65}to{transform:scale(1.22);opacity:1} }
@keyframes voiceThinking { 0%,100%{transform:scale(.98) rotate(0)}50%{transform:scale(1.08) rotate(5deg)} }
@media(max-width:760px) {
  .app-header { height:60px;padding-inline:14px; }
  .layout { padding:8px;gap:0; }
  .view { padding:18px 14px 20px; }
  .hero { min-height:230px;padding:23px; }
  .hero::after { right:-24%;top:-20%;width:260px;height:260px; }
  #view-chat.voice-mode { min-height:calc(100dvh - 60px - var(--nav-h) - var(--safe-bottom));padding:10px 10px 14px; }
  #view-chat.voice-mode .view-head { margin-bottom:8px; }
  #view-chat.voice-mode .view-head h1 { font-size:22px; }
  .voice-stage { min-height:0; flex:1;margin:0;border-radius:24px;gap:12px;padding:14px 10px; }
  .voice-orb-wrap { width:min(66vw,238px);height:min(66vw,238px);min-width:174px;min-height:174px; }
  .voice-caption strong { font-size:20px; }
  .voice-caption span { font-size:12px; }
  .voice-footnote { font-size:9px; }
}
@media(prefers-reduced-motion:reduce) {
  .voice-stage *, .voice-stage::before { animation:none!important;transition:none!important; }
}


/* Subtle Kaizo light core remains behind chat messages outside voice mode. */
#view-chat .messages { position:relative; isolation:isolate; }
#view-chat .messages::before {
  content:""; position:absolute; z-index:0; pointer-events:none;
  width:clamp(190px,40vw,360px); aspect-ratio:1; left:50%; top:48%;
  transform:translate(-50%,-50%); border-radius:50%;
  background:radial-gradient(circle,rgba(235,167,255,.25) 0%,rgba(185,100,255,.17) 32%,rgba(108,105,230,.08) 54%,transparent 72%);
  filter:blur(11px); opacity:.78; animation:chatCoreBreathe 8s ease-in-out infinite alternate;
}
#view-chat .messages > * { position:relative; z-index:1; }
@keyframes chatCoreBreathe { from{opacity:.46;transform:translate(-50%,-50%) scale(.94)}to{opacity:.9;transform:translate(-50%,-50%) scale(1.08)} }


/* KAIZO AURORA WORKSPACE ? redesigned desktop/mobile composition */
.mobile-greeting { display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 2px 16px; }
.mobile-greeting h1 { margin:0 0 3px;font-size:clamp(25px,5vw,33px);letter-spacing:-.045em; }
.mobile-greeting p { margin:0; }
.greeting-mark { flex:0 0 46px;width:46px;height:46px;display:grid;place-items:center;border-radius:16px;background:linear-gradient(135deg,#efadff,#a45ce8 58%,#53c8e6);color:#fff;font-size:23px;font-weight:950;box-shadow:0 8px 25px rgba(185,91,231,.35); }
.hero-live { display:flex;align-items:center;gap:8px;color:#e7c7fa;font-size:9px;font-weight:950;letter-spacing:.16em;margin-bottom:10px; }
.hero-live span { width:7px;height:7px;border-radius:50%;background:#6ee7c8;box-shadow:0 0 12px rgba(110,231,200,.8); }
.hero h1 { max-width:600px;font-size:clamp(30px,5.2vw,47px);letter-spacing:-.055em;line-height:1.03; }
.hero p { max-width:590px; }
.hero .row { margin-top:15px; }
.mobile-workspace { display:grid;grid-template-columns:minmax(0,1.2fr) minmax(260px,.8fr);gap:16px;align-items:start;margin-top:22px; }
.mobile-launch-section { min-width:0; }
.mobile-launch-section .section-head { margin:0 0 12px;align-items:end; }
.mobile-launch-section .section-head h2 { font-size:1.1rem;margin:0; }
.mobile-side-stack { display:grid;gap:12px;min-width:0; }
.mobile-side-stack .card { margin:0; }
.quick-grid { grid-template-columns:repeat(2,minmax(0,1fr));gap:11px; }
.quick-tile { position:relative;min-height:116px;padding:16px;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;text-align:left;gap:5px;overflow:hidden; }
.quick-tile .quick-icon { width:35px;height:35px;display:grid;place-items:center;border-radius:12px;background:rgba(224,159,255,.12);font-size:21px;margin-bottom:4px; }
.quick-tile b { font-size:.92rem; }
.quick-tile small { color:var(--muted);font-size:.72rem; }
.quick-tile i { position:absolute;right:14px;top:13px;font-size:9px;font-style:normal;letter-spacing:.12em;color:rgba(225,181,255,.5);font-weight:900; }
.recent-panel .section-head { margin:0 0 10px;align-items:center; }
.recent-panel .section-head h2 { margin:0;font-size:1rem; }
.recent-list { display:grid;gap:7px; }
.platform-note h2 { margin-top:2px; }
#view-chat .chat-list { flex:0 0 auto; }
#view-chat .messages { position:relative;isolation:isolate; }
#view-chat .composer { flex:0 0 auto; }
.bottom-nav { height:calc(74px + var(--safe-bottom));padding:8px 9px calc(8px + var(--safe-bottom));border:1px solid rgba(223,172,255,.19);border-bottom:0;border-radius:22px 22px 0 0;background:rgba(14,10,25,.94);backdrop-filter:blur(24px) saturate(145%);box-shadow:0 -12px 38px rgba(0,0,0,.36); }
.bottom-nav button { border-radius:14px;gap:4px;color:#a99bb9;font-size:10px;font-weight:750;transition:all .2s ease; }
.bottom-nav button .icon { width:29px;height:25px;display:grid;place-items:center;border-radius:9px;font-size:18px; }
.bottom-nav button.active { color:#f3dfff;background:rgba(177,94,226,.12); }
.bottom-nav button.active .icon { background:linear-gradient(135deg,rgba(208,125,248,.35),rgba(87,181,228,.20));color:#f7dcff;box-shadow:0 0 17px rgba(181,100,230,.16); }
@media(min-width:900px) { .mobile-greeting { margin-bottom:18px; } .mobile-workspace { grid-template-columns:minmax(0,1.45fr) minmax(300px,.85fr);gap:18px; } .quick-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } .quick-tile { min-height:132px;padding:19px; } .mobile-side-stack .card { padding:20px; } }
@media(max-width:760px) { .mobile-greeting { margin:2px 3px 13px; } .mobile-workspace { grid-template-columns:1fr;gap:13px;margin-top:17px; } .mobile-side-stack { grid-template-columns:1fr; } .hero { display:flex;flex-direction:column;align-items:stretch;gap:0; } .hero-orbit { display:flex;width:100%;height:92px;align-items:center;justify-content:flex-end;opacity:.92;margin-top:-4px; } .hero-k { width:76px;height:76px;display:grid;place-items:center;border-radius:50%;font-size:34px; } .hero::after { right:-12%;top:14%;width:235px;height:235px; } .quick-tile { min-height:110px; } #view-chat.voice-mode { padding-bottom:10px; } }


/* KAIZO HISTORY PANEL — six readable rows, with the rest available by scrolling. */
.chat-history-title {
  display:flex;align-items:center;justify-content:space-between;
  margin:15px 2px 6px;color:var(--muted-2);font-size:9px;
  font-weight:900;letter-spacing:.15em;
}
.chat-history-count {
  min-width:20px;text-align:center;border-radius:8px;padding:2px 5px;
  color:#eadcff;background:rgba(168,112,230,.16);
}
.sidebar .chat-list {
  display:flex;flex-direction:column;gap:4px;
  min-height:0;max-height:294px;overflow-y:auto;overflow-x:hidden;
  padding:3px 3px 8px;scrollbar-width:thin;
  scrollbar-color:rgba(182,143,224,.42) transparent;
}
.chat-list-section {
  padding:7px 5px 3px;color:var(--muted-2);
  font-size:8px;font-weight:900;letter-spacing:.13em;text-transform:uppercase;
}
.chat-entry {
  position:relative;display:grid;grid-template-columns:minmax(0,1fr) 28px 28px;
  align-items:center;gap:2px;min-height:39px;padding:2px 3px;
  border:1px solid rgba(190,160,232,.09);border-radius:10px;
  background:rgba(255,255,255,.025);transition:background .16s ease,border-color .16s ease;
}
.chat-entry:hover { background:rgba(174,122,225,.10);border-color:rgba(206,160,248,.24); }
.chat-entry.active { background:linear-gradient(100deg,rgba(163,96,216,.20),rgba(83,160,210,.09));border-color:rgba(207,162,244,.38); }
.chat-entry-open {
  min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  padding:7px 6px;text-align:left;color:var(--text-soft);
  font-size:11px;font-weight:650;border-radius:7px;
}
.chat-entry.active .chat-entry-open { color:#fff; }
.chat-entry-pin,.chat-entry-more {
  display:grid;place-items:center;width:26px;height:28px;border-radius:8px;
  color:var(--muted);font-size:14px;opacity:.72;
}
.chat-entry-pin { font-size:12px;filter:grayscale(1); }
.chat-entry-pin.pinned { color:#e9baff;opacity:1;filter:none; }
.chat-entry-more { font-size:19px;line-height:1; }
.chat-entry-pin:hover,.chat-entry-more:hover { opacity:1;color:#fff;background:rgba(188,142,235,.18); }
.chat-entry-menu-wrap { position:relative; }
.chat-entry-menu {
  position:absolute;z-index:50;top:31px;right:0;min-width:148px;
  display:flex;flex-direction:column;gap:2px;padding:6px;
  background:rgba(20,16,34,.98);border:1px solid rgba(205,164,243,.30);
  border-radius:12px;box-shadow:0 15px 36px rgba(0,0,0,.45);backdrop-filter:blur(18px);
}
.chat-entry-menu[hidden] { display:none; }
.chat-entry-menu button {
  padding:8px 10px;text-align:left;font-size:11px;border-radius:7px;color:#e9def5;
}
.chat-entry-menu button:hover { background:rgba(170,111,220,.20);color:#fff; }
.chat-entry-menu button[data-action="delete"] { color:#ff9fb1; }
.chat-list-empty { padding:10px 7px;color:var(--muted-2);font-size:10px;line-height:1.45; }
.mobile-chat-history { display:none; }
@media(max-width:760px) {
  .sidebar .chat-history-title,.sidebar #chat-list { display:none; }
  .mobile-chat-history { display:block;flex:0 0 auto;margin:0 0 8px; }
  .mobile-chat-history-head { display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 2px 6px; }
  .chat-list-mobile {
    display:flex;flex-direction:column;gap:4px;
    max-height:286px;overflow-y:auto;overflow-x:hidden;
    padding:5px;border:1px solid rgba(202,158,241,.20);
    border-radius:13px;background:rgba(16,12,28,.68);
    scrollbar-width:thin;scrollbar-color:rgba(182,143,224,.42) transparent;
  }
  #view-chat .chat-list-mobile .chat-entry { min-height:38px; }
}
@media(min-width:761px) { .chat-list-mobile { display:none!important; } }


/* Layout repair: conversation history must never collide with settings or composer. */
.chat-entry-more {
  width:30px;height:30px;opacity:1;color:#f4e5ff;
  background:rgba(147,91,188,.28);
  border:1px solid rgba(215,177,245,.50);
  border-radius:9px;font-size:22px;font-weight:900;
}
.chat-entry-more:hover {
  color:#fff;background:rgba(173,111,221,.72);
  border-color:#ebc8ff;
}
.chat-entry-pin {
  width:29px;height:30px;opacity:1;
  background:rgba(147,91,188,.13);
  border:1px solid rgba(215,177,245,.24);
  border-radius:9px;
}
.chat-entry-pin.pinned {
  background:rgba(173,111,221,.38);
  border-color:rgba(228,185,255,.70);
  filter:none;
}
.chat-entry-open { font-size:12px; }
.sidebar .chat-list {
  overflow-y:scroll;
  overscroll-behavior:contain;
  scrollbar-width:auto;
}
.sidebar .chat-list::-webkit-scrollbar { width:9px; }
.sidebar .chat-list::-webkit-scrollbar-track {
  background:rgba(255,255,255,.07);border-radius:8px;
}
.sidebar .chat-list::-webkit-scrollbar-thumb {
  background:rgba(193,151,229,.72);border:2px solid rgba(22,17,37,.9);border-radius:8px;
}
@media(max-width:760px) {
  #view-chat.active {
    height:calc(100dvh - var(--header-h) - var(--nav-h) - 52px);
    min-height:0;overflow:hidden;
  }
  #view-chat .view-head { flex:0 0 auto;margin-bottom:9px;gap:8px; }
  #view-chat .mobile-chat-history { flex:0 0 auto;max-height:222px;margin-bottom:7px; }
  .mobile-chat-history-head { min-height:20px; }
  .mobile-chat-history-head .small { font-size:10px; }
  .chat-list-mobile {
    max-height:202px;
    overflow-y:scroll;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-y;
    scrollbar-width:auto;
  }
  .chat-list-mobile::-webkit-scrollbar { width:9px; }
  .chat-list-mobile::-webkit-scrollbar-track {
    background:rgba(255,255,255,.08);border-radius:8px;
  }
  .chat-list-mobile::-webkit-scrollbar-thumb {
    background:rgba(193,151,229,.76);border:2px solid rgba(22,17,37,.9);border-radius:8px;
  }
  #view-chat .chat-list-mobile .chat-entry { min-height:34px; }
  #view-chat .chat-list-mobile .chat-entry-open { font-size:12px;padding:5px 6px; }
  #view-chat .chat-list-mobile .chat-entry-pin,
  #view-chat .chat-list-mobile .chat-entry-more { width:29px;height:29px; }
  #view-chat .messages { flex:1 1 0;min-height:90px; }
  #view-chat .composer { flex:0 0 auto;margin-top:6px; }
  #view-chat .composer-box { min-height:50px; }
}


/* New mobile/remote welcome screen: centered visual identity, no tiny chat bubble. */
#view-chat .messages.welcome-mode {
  display:grid;place-items:center;overflow-y:auto;padding:12px 10px 18px;isolation:isolate;
}
.welcome-stage {
  width:min(100%,780px);min-height:100%;display:flex;flex-direction:column;
  align-items:center;justify-content:center;gap:13px;margin:auto;padding:30px 22px;
  text-align:center;
  background:radial-gradient(ellipse at 50% 38%,rgba(158,91,223,.13),transparent 54%),
             radial-gradient(ellipse at 50% 70%,rgba(70,151,205,.08),transparent 62%);
  border:1px solid rgba(194,151,239,.15);border-radius:22px;
}
.welcome-orb {
  position:relative;width:112px;height:112px;flex:0 0 auto;display:grid;place-items:center;
  border-radius:50%;background:radial-gradient(circle at 34% 27%,#ffe6ff 0%,#d59cff 17%,#9b61e3 43%,#4e5fc1 72%,#172640 100%);
  border:2px solid rgba(238,203,255,.78);
  box-shadow:0 0 26px rgba(178,103,235,.46),0 0 70px rgba(119,82,209,.23),inset 0 0 20px rgba(255,255,255,.18);
  animation:welcomeOrbFloat 5s ease-in-out infinite;
}
.welcome-orb::before,.welcome-orb::after {
  content:"";position:absolute;inset:-11px;border:1px solid rgba(207,155,250,.36);
  border-radius:50%;animation:welcomeOrbRing 8s linear infinite;
}
.welcome-orb::after { inset:-21px;border-color:rgba(94,193,228,.23);animation-direction:reverse; }
.welcome-orb span { color:#fff;font-size:44px;font-weight:950;text-shadow:0 2px 15px rgba(30,14,53,.55); }
.welcome-kicker { color:#d7b2f6;font-size:10px;font-weight:950;letter-spacing:.18em; }
.welcome-stage h2 { margin:0;font-size:clamp(27px,4vw,36px);letter-spacing:-.045em;font-weight:900; }
.welcome-copy { max-width:570px;margin:0;color:var(--muted);font-size:13px;line-height:1.65; }
.welcome-actions { width:min(100%,600px);display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin-top:7px; }
.welcome-action {
  min-height:44px;padding:10px 12px;text-align:center;color:#eee3fb;
  background:rgba(80,58,113,.22);border:1px solid rgba(192,151,235,.30);
  border-radius:12px;font-size:12px;font-weight:750;transition:all .18s ease;
}
.welcome-action:hover { color:#fff;background:rgba(140,91,190,.34);border-color:rgba(223,185,255,.78);transform:translateY(-1px); }
.welcome-footnote { display:flex;align-items:center;gap:7px;margin-top:4px;color:var(--muted-2);font-size:10px;letter-spacing:.04em; }
.welcome-live-dot { width:7px;height:7px;display:inline-block;border-radius:50%;background:#77e2c3;box-shadow:0 0 12px rgba(119,226,195,.62); }
@keyframes welcomeOrbFloat { 50% { transform:translateY(-5px); } }
@keyframes welcomeOrbRing { to { transform:rotate(360deg); } }
@media(max-width:760px) {
  #view-chat .messages.welcome-mode { padding:4px 2px 10px; }
  .welcome-stage { min-height:100%;gap:10px;padding:13px 8px;border-radius:16px; }
  .welcome-orb { width:82px;height:82px; }
  .welcome-orb::before { inset:-8px; }
  .welcome-orb::after { inset:-15px; }
  .welcome-orb span { font-size:34px; }
  .welcome-kicker { font-size:9px;letter-spacing:.13em; }
  .welcome-stage h2 { font-size:27px; }
  .welcome-copy { max-width:420px;font-size:12px;line-height:1.5; }
  .welcome-actions { gap:7px;margin-top:3px; }
  .welcome-action { min-height:40px;padding:8px 7px;font-size:11px; }
  .welcome-footnote { font-size:9px; }
}
@media(prefers-reduced-motion:reduce) {
  .welcome-orb,.welcome-orb::before,.welcome-orb::after { animation:none; }
  .welcome-action:hover { transform:none; }
}


/* KAIZO COLOR THEMES 3.2 — shared accents for desktop, PWA and Android WebView */
.brand-mark,
.modal-mark {
  background: linear-gradient(135deg, var(--accent-bright), var(--accent) 55%, var(--accent-2)) !important;
  box-shadow: 0 8px 27px var(--glow);
}
button.primary,
.primary,
.quick-tile:hover,
.more-tile:hover,
.chat-entry.active,
.nav-item.active {
  border-color: var(--accent) !important;
}
button.primary,
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
  color: #fff !important;
}
button.primary:hover,
.primary:hover {
  filter: brightness(1.12);
}
.hero-orbit,
.greeting-mark,
.voice-orb-core {
  border-color: var(--accent-bright) !important;
}
.hero-orbit::before,
.hero-orbit::after,
.voice-orb-aura {
  border-color: var(--accent) !important;
}
.chat-entry.active {
  background: var(--surface-2) !important;
  box-shadow: inset 3px 0 0 var(--accent-bright);
}
.quick-tile:hover,
.more-tile:hover {
  box-shadow: 0 10px 28px var(--glow);
}
a,
.link,
.msg-body a {
  color: var(--accent-bright);
}


/* DeepThink and voice controls */
.deepthink-toggle,
.voice-toggle {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 7px 12px;
  font-weight: 800;
  white-space: nowrap;
}
.deepthink-toggle.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 2px var(--glow);
}
.voice-toggle.active {
  color: #fff;
  background: var(--surface-2);
  border-color: var(--accent-bright);
}
@media (max-width: 760px) {
  .deepthink-toggle,
  .voice-toggle { padding: 6px 9px; min-height: 36px; font-size: 11px; }
}


/* Final responsive overrides */
@media (max-width: 760px) {
  .view-head .row #chat-emotion { display: none; }
  .deepthink-toggle, .voice-toggle {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 10px;
  }
}


/* Real palette surfaces: not just accent buttons */
body {
  background-color: var(--bg) !important;
  background-image:
    radial-gradient(ellipse 74% 48% at 8% -4%, var(--theme-glow-a), transparent 68%),
    radial-gradient(ellipse 56% 42% at 100% 18%, var(--theme-glow-b), transparent 70%),
    radial-gradient(ellipse 70% 56% at 54% 112%, var(--theme-glow-c), transparent 66%),
    linear-gradient(155deg, var(--bg) 0%, var(--bg-2) 100%) !important;
}
.app-header {
  background: var(--glass) !important;
  border-color: var(--line) !important;
}
.sidebar {
  background: linear-gradient(180deg, var(--surface-2), var(--surface)) !important;
  border-color: var(--line) !important;
}
.card, .hero, .engine, .platform-note {
  background: linear-gradient(145deg, var(--surface-2), var(--surface) 72%) !important;
  border-color: var(--line-strong) !important;
}
.composer-box {
  background: var(--glass) !important;
  border-color: var(--line-strong) !important;
}
.msg.user {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
  border-color: var(--accent-bright) !important;
}
.msg.assistant {
  background: linear-gradient(145deg, var(--surface-2), var(--surface)) !important;
  border-color: var(--line) !important;
}
.voice-orb-core {
  background: radial-gradient(circle at 32% 28%, var(--accent-bright), var(--accent) 58%, var(--accent-2)) !important;
  border-color: var(--accent-bright) !important;
}
.voice-orb-aura {
  box-shadow: 0 0 72px var(--glow) !important;
}

/* Composer alignment and voice dictation */
.composer-box {
  align-items: center !important;
  gap: 8px;
}
.composer textarea {
  align-self: center;
  min-height: 40px;
  margin: 0;
  line-height: 1.45;
  padding: 9px 8px;
}
.composer-box .attach,
.composer-box .voice-dictate {
  width: 40px;
  height: 40px;
  min-height: 40px;
  flex: 0 0 40px;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 0;
}
.composer-box .attach .ico,
.composer-box .voice-dictate .ico {
  display: block;
  width: 19px;
  height: 19px;
}
.composer-box .voice-dictate {
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
  transition: color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.composer-box .voice-dictate:hover {
  color: var(--accent-bright);
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.composer-box .voice-dictate.recording {
  color: #fff;
  background: var(--danger);
  border-color: rgba(255,255,255,.24);
  box-shadow: 0 0 0 4px rgba(251,113,133,.15), 0 0 22px rgba(251,113,133,.24);
  animation: dictatePulse 1.15s ease-in-out infinite;
}
.composer-box .voice-dictate:disabled {
  opacity: .42;
  cursor: not-allowed;
}
@keyframes dictatePulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(251,113,133,.12), 0 0 12px rgba(251,113,133,.12); }
  50% { box-shadow: 0 0 0 6px rgba(251,113,133,.18), 0 0 22px rgba(251,113,133,.26); }
}
.composer-box #send {
  min-height: 40px;
  height: 40px;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.composer-box #send .ico { display:block; }
.chat-emotion-mobile { display: none; }

/* More expressive emotion palette, shared with the desktop client. */
.badge.emotion[data-emotion="excited"] { color: #e879f9; border-color: rgba(232,121,249,.42); }
.badge.emotion[data-emotion="curious"] { color: #38bdf8; border-color: rgba(56,189,248,.4); }
.badge.emotion[data-emotion="surprised"] { color: #a78bfa; border-color: rgba(167,139,250,.42); }
.badge.emotion[data-emotion="confused"] { color: #f59e0b; border-color: rgba(245,158,11,.42); }
.badge.emotion[data-emotion="focused"] { color: #34d399; border-color: rgba(52,211,153,.4); }

@media (max-width: 760px) {
  .chat-emotion-mobile {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 28px;
    margin: -5px 1px 7px;
    padding: 0 2px;
  }
  .chat-emotion-mobile .badge.emotion {
    min-height: 26px;
    padding: 3px 9px;
    font-size: 10px;
    background: var(--surface-2);
    border-color: var(--line-strong);
  }
  .chat-emotion-mobile .emotion-face { width: 15px; height: 15px; }
  .composer-box { gap: 6px; padding: 6px; }
  .composer-box .attach,
  .composer-box .voice-dictate {
    width: 36px;
    height: 36px;
    min-height: 36px;
    flex-basis: 36px;
    border-radius: 10px;
  }
  .composer-box textarea {
    min-width: 0;
    min-height: 38px;
    padding: 8px 5px;
    font-size: .9rem;
  }
  .composer-box #send {
    height: 36px;
    min-height: 36px;
    padding: 0 11px;
    gap: 5px;
    font-size: .82rem;
  }
}
@media (max-width: 390px) {
  .composer-box { gap: 5px; padding: 5px; }
  .composer-box .attach,
  .composer-box .voice-dictate {
    width: 34px;
    height: 34px;
    min-height: 34px;
    flex-basis: 34px;
  }
  .composer-box #send { padding: 0 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .composer-box .voice-dictate.recording { animation: none; }
}
}

/* Kaizo Mobile / Desktop composer alignment refinement */
.composer-box { align-items:center !important; gap:8px; }
.composer textarea { align-self:center; min-height:40px; margin:0; line-height:1.45; padding:9px 8px; }
.composer-box .attach,
.composer-box .voice-dictate {
  width:40px; height:40px; min-height:40px; flex:0 0 40px; align-self:center;
  display:inline-flex; align-items:center; justify-content:center; border-radius:12px; padding:0;
}
.composer-box .attach .ico,
.composer-box .voice-dictate .ico { display:block; width:19px; height:19px; }
.composer-box .voice-dictate {
  color:var(--muted); border:1px solid transparent; background:transparent;
  transition:color .16s ease,background .16s ease,border-color .16s ease,box-shadow .16s ease;
}
.composer-box .voice-dictate:hover {
  color:var(--accent-bright); background:var(--surface-2); border-color:var(--line-strong);
}
.composer-box .voice-dictate.recording {
  color:#fff; background:var(--danger); border-color:rgba(255,255,255,.24);
  box-shadow:0 0 0 4px rgba(251,113,133,.15),0 0 22px rgba(251,113,133,.24);
  animation:dictatePulse 1.15s ease-in-out infinite;
}
.composer-box .voice-dictate:disabled { opacity:.42; cursor:not-allowed; }
@keyframes dictatePulse {
  0%,100% { box-shadow:0 0 0 3px rgba(251,113,133,.12),0 0 12px rgba(251,113,133,.12); }
  50% { box-shadow:0 0 0 6px rgba(251,113,133,.18),0 0 22px rgba(251,113,133,.26); }
}
.composer-box #send {
  min-height:40px; height:40px; align-self:center; display:inline-flex;
  align-items:center; justify-content:center; gap:7px;
}
.composer-box #send .ico { display:block; }
.chat-emotion-mobile { display:none; }

/* Expanded emotional states use the same restrained palette on every client. */
.badge.emotion[data-emotion="excited"] { color:#e879f9; border-color:rgba(232,121,249,.42); }
.badge.emotion[data-emotion="curious"] { color:#38bdf8; border-color:rgba(56,189,248,.4); }
.badge.emotion[data-emotion="surprised"] { color:#a78bfa; border-color:rgba(167,139,250,.42); }
.badge.emotion[data-emotion="confused"] { color:#f59e0b; border-color:rgba(245,158,11,.42); }
.badge.emotion[data-emotion="focused"] { color:#34d399; border-color:rgba(52,211,153,.4); }

@media (max-width:760px) {
  .chat-emotion-mobile {
    display:flex; align-items:center; gap:9px; min-height:28px;
    margin:-5px 1px 7px; padding:0 2px;
  }
  .chat-emotion-mobile .badge.emotion {
    min-height:26px; padding:3px 9px; font-size:10px;
    background:var(--surface-2); border-color:var(--line-strong);
  }
  .chat-emotion-mobile .emotion-face { width:15px; height:15px; }
  .composer-box { gap:6px; padding:6px; }
  .composer-box .attach,
  .composer-box .voice-dictate {
    width:36px; height:36px; min-height:36px; flex-basis:36px; border-radius:10px;
  }
  .composer-box textarea { min-width:0; min-height:38px; padding:8px 5px; font-size:.9rem; }
  .composer-box #send { height:36px; min-height:36px; padding:0 11px; gap:5px; font-size:.82rem; }
}
@media (max-width:390px) {
  .composer-box { gap:5px; padding:5px; }
  .composer-box .attach, .composer-box .voice-dictate {
    width:34px; height:34px; min-height:34px; flex-basis:34px;
  }
  .composer-box #send { padding:0 9px; }
}
@media (prefers-reduced-motion:reduce) {
  .composer-box .voice-dictate.recording { animation:none; }
}

/* Icon-text controls share a single baseline and never drift vertically. */
.deepthink-toggle,
.voice-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.deepthink-toggle .ico,
.voice-toggle .ico {
  display: block;
  flex: 0 0 auto;
}
.deepthink-toggle.active .ico { filter: drop-shadow(0 1px 3px rgba(0,0,0,.18)); }
@media (max-width:760px) {
  .deepthink-toggle, .voice-toggle { gap:5px; }
  .view-head .row #new-chat { padding-inline:9px; }
}


/* Kaizo layout repair v36: wiadomość użytkownika zawsze rośnie do pełnej treści. */
.msg,
.msg.user,
.msg.assistant {
  height: auto;
  min-height: max-content;
  max-height: none;
  overflow: visible;
  flex-shrink: 0;
}
.msg.user {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}
.chat-entry-pin .ico {
  width: 15px;
  height: 15px;
  display: block;
}
.chat-entry-pin {
  filter: none;
  line-height: 0;
}
.chat-entry-pin.pinned {
  color: var(--accent-bright);
}
@media (max-width: 760px) {
  .msg.user {
    max-width: min(94%, 720px);
  }
}

/* Monochrome is a real surface palette, not only a button accent. */
html[data-color-theme="monochrome"] .sidebar,
html[data-color-theme="monochrome"] .app-header,
html[data-color-theme="monochrome"] .card,
html[data-color-theme="monochrome"] .hero,
html[data-color-theme="monochrome"] .composer-box,
html[data-color-theme="monochrome"] .msg.user,
html[data-color-theme="monochrome"] .msg.assistant {
  box-shadow: none;
}


/* AURORA MOBILE REFRESH v1 — safe-area aware, calmer surfaces, clearer controls. */
html { -webkit-tap-highlight-color:transparent; }
body { overflow-x:hidden; }
.card, .hero, .engine, .platform-note { border-color:rgba(137,154,208,.19); }
button, input, textarea, select { touch-action:manipulation; }
@media (max-width:760px) {
  :root { --header-h:60px; --nav-h:76px; }
  .app-header {
    position:sticky; top:0; z-index:45;
    min-height:var(--header-h);
    padding-top:env(safe-area-inset-top);
    border-bottom:1px solid rgba(171,153,255,.18);
    border-radius:0 0 17px 17px;
    background:rgba(11,13,25,.94);
    backdrop-filter:blur(20px) saturate(145%);
    box-shadow:0 8px 28px rgba(0,0,0,.20);
  }
  .app-header .brand { min-width:0; }
  .brand-copy { min-width:0; }
  .brand-name { letter-spacing:.04em; }
  .layout { min-height:calc(100dvh - var(--header-h)); padding:0; }
  .main { min-width:0; padding:15px 13px calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); }
  .view-head { gap:10px; flex-wrap:wrap; }
  .hero, .card { border-radius:19px; }
  .hero { border-color:rgba(160,145,255,.23); }
  .quick-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .quick-tile { min-height:116px; border-radius:17px; }
  .bottom-nav {
    height:calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding:7px 8px calc(8px + env(safe-area-inset-bottom));
    border:1px solid rgba(148,157,224,.19); border-bottom:0;
    border-radius:20px 20px 0 0;
    background:rgba(10,13,25,.96);
    backdrop-filter:blur(24px) saturate(155%);
    box-shadow:0 -10px 34px rgba(0,0,0,.35);
  }
  .bottom-nav button { min-height:54px; border-radius:13px; font-size:10px; font-weight:750; }
  .bottom-nav button.active { transform:translateY(-2px); }
  .modal {
    padding:max(14px,env(safe-area-inset-top)) 14px max(14px,env(safe-area-inset-bottom));
    overflow-y:auto; overscroll-behavior:contain;
  }
  .modal .card {
    width:min(470px,100%); max-height:calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y:auto; overscroll-behavior:contain;
    border:1px solid rgba(161,145,238,.31);
    border-radius:22px;
    background:linear-gradient(155deg,rgba(26,27,49,.99),rgba(12,16,30,.99));
    box-shadow:0 25px 80px rgba(0,0,0,.52),0 0 35px rgba(112,83,210,.10);
  }
  #login-modal .card { padding:24px 21px; }
  #login-modal .modal-mark { width:50px; height:50px; margin-bottom:17px; }
  #login-modal h2 { font-size:1.24rem; line-height:1.25; }
  #login-modal #privacy-warning { padding:11px 12px; border:1px solid rgba(224,174,103,.25); border-radius:12px; background:rgba(160,111,47,.08); line-height:1.5; }
  #login-modal #invite-input { min-height:46px; }
  #login-modal .row { flex-wrap:wrap; }
  #login-modal #google-login, #login-modal #login-retry { width:100%; min-height:48px; }
  #login-modal #login-error { flex-basis:100%; }
  #token-modal .card { padding:23px 20px; }
  #view-chat .messages { overscroll-behavior:contain; }
  .composer-box { border-color:rgba(152,145,230,.25); box-shadow:0 8px 24px rgba(0,0,0,.20); }
}
@media (min-width:761px) and (max-width:1024px) {
  .sidebar { flex-basis:220px; width:220px; }
  .main { padding:22px 20px 36px; }
}
@media (prefers-reduced-motion:reduce) {
  .bottom-nav button.active { transform:none; }
}


/* KAIZO 3.2 ? JARVIS interface and user-selectable appearance presets */
:root { --kz-ink:#eaf8ff; --kz-muted:#8da9b9; --kz-line:rgba(92,203,229,.18); }
html[data-color-theme="cyan"] { --accent:#25c9e8; --accent-bright:#8ef1ff; --accent-ink:#d8fbff; --accent-2:#69e8f6; }
html[data-background="jarvis"] body { background-color:#050b13!important;background-image:radial-gradient(ellipse 65% 42% at 86% 8%,rgba(31,156,190,.20),transparent 72%),radial-gradient(ellipse 58% 46% at 8% 92%,rgba(34,108,152,.16),transparent 73%),linear-gradient(145deg,#050b13 0%,#081522 52%,#06101a 100%)!important;background-attachment:fixed; }
html[data-background="jarvis"] body::before { opacity:.36!important;background-image:linear-gradient(rgba(91,204,230,.09) 1px,transparent 1px),linear-gradient(90deg,rgba(91,204,230,.09) 1px,transparent 1px)!important;background-size:42px 42px!important;mask-image:linear-gradient(135deg,#000 0%,transparent 80%)!important; }
html[data-background="jarvis"] body::after { opacity:.42!important;filter:blur(95px)!important; }
html[data-background="matrix"] body { background-color:#050d13!important;background-image:linear-gradient(rgba(83,221,197,.055) 1px,transparent 1px),linear-gradient(90deg,rgba(83,221,197,.055) 1px,transparent 1px),radial-gradient(ellipse at 75% 15%,rgba(25,131,127,.20),transparent 62%),linear-gradient(145deg,#050d13,#071b20)!important;background-size:34px 34px,34px 34px,auto,auto!important;background-attachment:fixed; }
html[data-background="matrix"] body::before { opacity:.22!important;background-size:8px 8px!important; }
html[data-background="minimal"] body { background:#080d14!important;background-image:linear-gradient(145deg,#080d14,#0b1420)!important; }
html[data-background="minimal"] body::before,html[data-background="minimal"] body::after { opacity:0!important;animation:none!important; }
.app-header { background:rgba(4,13,22,.88)!important;border-bottom:1px solid var(--kz-line)!important;box-shadow:0 12px 35px rgba(0,0,0,.28)!important;backdrop-filter:blur(24px) saturate(135%); }
.brand-mark { background:linear-gradient(145deg,#b5f7ff,#28aeca 48%,#145b83)!important;box-shadow:0 0 26px rgba(57,215,243,.27)!important; }
.brand-name span,.brand-sub,.eyebrow { color:#8eeaff; }
.layout { gap:13px;padding:13px; }
.sidebar { background:linear-gradient(180deg,rgba(6,18,30,.96),rgba(5,13,24,.94))!important;border:1px solid rgba(90,202,229,.15)!important;border-radius:20px!important;box-shadow:0 18px 54px rgba(0,0,0,.34)!important;backdrop-filter:blur(22px) saturate(125%); }
.sidebar button { border-radius:11px;min-height:42px;transition:background .18s,border-color .18s,color .18s; }
.sidebar button:hover { transform:none!important;background:rgba(57,215,243,.07)!important; }
.sidebar button.active { background:linear-gradient(100deg,rgba(34,175,208,.19),rgba(62,120,164,.08))!important;border:1px solid rgba(91,219,244,.20)!important;box-shadow:inset 3px 0 #58e4fa,0 7px 22px rgba(0,0,0,.18)!important; }
.sidebar button.active::before { background:linear-gradient(180deg,#b4f7ff,#37cce8)!important;box-shadow:0 0 15px rgba(57,215,243,.65)!important; }
.main { border:1px solid rgba(91,185,213,.10);border-radius:21px;background:rgba(4,13,23,.23); }
.view { padding:25px 28px 30px; }
.view h1 { color:#effaff;letter-spacing:-.045em; }
.card,.hero,.engine,.platform-note { border:1px solid rgba(93,199,224,.17)!important;border-radius:20px!important;background:linear-gradient(145deg,rgba(12,35,49,.91),rgba(7,19,32,.95) 64%,rgba(9,28,42,.93))!important;box-shadow:0 20px 55px -28px rgba(0,0,0,.86),inset 0 1px rgba(225,250,255,.035)!important;backdrop-filter:blur(19px) saturate(125%); }
.hero { min-height:255px;padding:32px!important;position:relative;overflow:hidden;background:radial-gradient(ellipse 48% 90% at 86% 44%,rgba(32,168,204,.19),transparent 72%),linear-gradient(118deg,rgba(13,47,64,.97),rgba(8,23,40,.97) 64%,rgba(7,18,31,.98))!important;border-color:rgba(89,217,240,.29)!important; }
.hero::after { content:"";position:absolute;right:8%;top:-30%;width:300px;height:300px;border:1px solid rgba(91,222,244,.17);border-radius:50%;box-shadow:0 0 0 18px rgba(72,200,228,.035),0 0 0 42px rgba(72,200,228,.022),0 0 65px rgba(53,202,235,.16);pointer-events:none; }
.hero h1 { color:#f4fcff; }.hero p { color:#b8d5e2; }
.stat,.stats .card,.quick-tile,.more-tile,.project-card,.plan-card { border:1px solid rgba(92,199,225,.15)!important;border-radius:16px!important;background:linear-gradient(145deg,rgba(13,39,54,.88),rgba(7,20,34,.96))!important;box-shadow:0 13px 34px rgba(0,0,0,.24)!important; }
.quick-tile:hover,.more-tile:hover,.project-card:hover { transform:translateY(-2px)!important;border-color:rgba(94,221,242,.4)!important;box-shadow:0 18px 34px rgba(0,0,0,.31),0 0 24px rgba(57,215,243,.08)!important; }
.quick-icon,.more-tile>span { color:#8feaff!important; }
button.primary { background:linear-gradient(115deg,#1b9db9,#167a9b 58%,#245d86)!important;border:1px solid rgba(128,236,250,.38)!important;box-shadow:0 10px 29px -12px rgba(37,190,220,.55)!important;color:#f3fdff!important; }
button.primary:hover { filter:brightness(1.12);transform:translateY(-1px); }
button.secondary { background:rgba(13,36,51,.84)!important;border:1px solid rgba(96,195,218,.22)!important;color:#dff7ff!important; }
input,textarea,select { background:rgba(4,17,29,.91)!important;border:1px solid rgba(89,173,198,.24)!important;border-radius:12px!important;color:#eaf9ff!important; }
input:focus,textarea:focus,select:focus { border-color:#50d8f0!important;box-shadow:0 0 0 3px rgba(49,196,225,.14),0 0 22px rgba(49,196,225,.08)!important; }
.msg { border-radius:18px!important;border-color:rgba(91,195,220,.14)!important; }
.msg.user { background:linear-gradient(135deg,#167d9b,#1c6688 72%,#234b72)!important;border-color:rgba(116,227,244,.34)!important; }
.msg.assistant { background:linear-gradient(145deg,rgba(13,38,53,.96),rgba(7,21,35,.97))!important; }
.composer-box { background:rgba(4,16,28,.95)!important;border:1px solid rgba(86,201,228,.28)!important;border-radius:18px!important;box-shadow:0 18px 46px rgba(0,0,0,.4)!important;backdrop-filter:blur(22px); }
.composer-box:focus-within { border-color:rgba(87,226,247,.70)!important;box-shadow:0 0 0 3px rgba(48,193,222,.12),0 18px 48px rgba(0,0,0,.35)!important; }
.badge { background:rgba(11,40,56,.84)!important;border-color:rgba(93,203,228,.23)!important; }
.bottom-nav { background:rgba(4,15,25,.96)!important;border:1px solid rgba(95,202,229,.19)!important;box-shadow:0 -8px 32px rgba(0,0,0,.35)!important;backdrop-filter:blur(22px) saturate(140%); }
.bottom-nav button.active { color:#dffaff!important;background:rgba(49,193,222,.13)!important; }
.bottom-nav button.active .icon { color:#8deeff!important;background:rgba(45,185,214,.14)!important;box-shadow:0 0 16px rgba(57,215,243,.12)!important; }
html[data-glass="off"] .card,html[data-glass="off"] .hero,html[data-glass="off"] .engine,html[data-glass="off"] .sidebar,html[data-glass="off"] .app-header,html[data-glass="off"] .composer-box { backdrop-filter:none!important; }
html[data-glass="off"] .card,html[data-glass="off"] .engine { background:#0a1a27!important; }
html[data-density="compact"] .view { padding:18px 20px 22px; }
html[data-density="compact"] .card { padding:14px!important; }
html[data-density="compact"] .sidebar button { min-height:35px;padding-block:7px; }
html[data-motion="off"] *,html[data-motion="off"] *::before,html[data-motion="off"] *::after { animation:none!important;transition:none!important;scroll-behavior:auto!important; }
@media(max-width:760px) { .view{padding:16px 13px 22px!important}.hero{padding:23px 18px!important;min-height:220px}.hero::after{right:-100px;opacity:.62}.layout{padding:0;gap:0}.main{border:0;border-radius:0;background:transparent}.bottom-nav{border-radius:18px 18px 0 0!important} }


/* JARVIS command hero: a technical readout, not an orbital illustration. */
.hero::after { display:none!important; }
.hero-orbit,body[data-plan="free"] .hero-orbit {
  display:grid!important;position:relative;isolation:isolate;place-items:center;
  width:236px;height:190px;flex:0 0 236px;border-radius:16px!important;
  border:1px solid rgba(86,220,244,.34)!important;
  background:linear-gradient(145deg,rgba(12,51,67,.66),rgba(5,18,31,.85))!important;
  box-shadow:inset 0 0 36px rgba(44,190,218,.10),0 15px 42px rgba(0,0,0,.30),0 0 28px rgba(52,204,234,.10)!important;
  overflow:hidden;filter:none!important;
}
.hero-orbit::before {
  content:"";position:absolute;inset:0;z-index:-1;border:0!important;border-radius:0!important;
  background:linear-gradient(rgba(90,218,239,.09) 1px,transparent 1px),linear-gradient(90deg,rgba(90,218,239,.09) 1px,transparent 1px)!important;
  background-size:17px 17px!important;opacity:.72;
}
.hero-orbit::after {
  content:"CORE DIAGNOSTICS   /   LOCAL AI";position:absolute;left:0;right:0;bottom:11px;
  display:block;border:0!important;border-radius:0!important;color:#8cecff;
  font:800 8px/1.3 "Segoe UI",sans-serif;letter-spacing:.18em;text-align:center;
  text-shadow:0 0 12px rgba(76,215,244,.45);box-shadow:none!important;
}
.hero-k {
  position:relative;z-index:1;width:78px;height:78px;border-radius:18px!important;
  display:grid;place-items:center;font-size:35px;font-weight:900;color:#eaffff!important;
  border:1px solid rgba(151,244,255,.72)!important;
  background:radial-gradient(circle at 35% 25%,rgba(119,242,255,.52),rgba(25,125,155,.88) 62%,rgba(6,39,61,.98))!important;
  box-shadow:0 0 0 8px rgba(57,215,243,.055),0 0 32px rgba(57,215,243,.27),inset 0 1px rgba(255,255,255,.24)!important;
  animation:jarvisCorePulse 4.5s ease-in-out infinite;
}
@keyframes jarvisCorePulse { 50% { box-shadow:0 0 0 12px rgba(57,215,243,.035),0 0 43px rgba(57,215,243,.37),inset 0 1px rgba(255,255,255,.24); } }
.mobile-greeting { border-bottom:1px solid rgba(89,203,228,.12);padding-bottom:13px; }
.greeting-mark { background:linear-gradient(145deg,#baf7ff,#259ab9 54%,#104e75)!important;box-shadow:0 0 27px rgba(57,215,243,.23)!important; }
.hero-live { color:#95efff!important; }
.hero-live span { background:#66f4ce!important;box-shadow:0 0 14px rgba(102,244,206,.7)!important; }
html[data-background="jarvis"] .hero-orbit { background-color:rgba(4,17,29,.86)!important; }
html[data-background="minimal"] .hero-orbit { box-shadow:none!important; }
@media(max-width:760px) {
  .hero-orbit,body[data-plan="free"] .hero-orbit { width:100%!important;height:132px!important;flex:0 0 132px!important;justify-content:center!important;margin-top:12px!important; }
  .hero-k { width:66px;height:66px;font-size:29px; }
  .hero-orbit::after { bottom:8px;font-size:7px; }
}

html[data-background="blueprint"] body {
  background-color:#06131d!important;
  background-image:linear-gradient(rgba(70,184,220,.10) 1px,transparent 1px),linear-gradient(90deg,rgba(70,184,220,.10) 1px,transparent 1px),
    linear-gradient(rgba(70,184,220,.035) 1px,transparent 1px),linear-gradient(90deg,rgba(70,184,220,.035) 1px,transparent 1px),
    radial-gradient(ellipse at 82% 18%,rgba(21,119,150,.2),transparent 65%),linear-gradient(145deg,#06131d,#0a1d2b)!important;
  background-size:120px 120px,120px 120px,24px 24px,24px 24px,auto,auto!important;background-attachment:fixed;
}
html[data-background="blueprint"] body::before { opacity:.17!important; }
html[data-background="deep_space"] body {
  background-color:#060713!important;
  background-image:radial-gradient(ellipse 35% 40% at 18% 28%,rgba(95,68,176,.21),transparent 80%),
    radial-gradient(ellipse 38% 48% at 82% 68%,rgba(32,91,167,.17),transparent 82%),
    radial-gradient(circle at 15% 22%,rgba(225,235,255,.42) 1px,transparent 2px),
    radial-gradient(circle at 66% 33%,rgba(206,223,255,.3) 1px,transparent 2px),
    radial-gradient(circle at 83% 16%,rgba(206,223,255,.25) 1px,transparent 2px),linear-gradient(145deg,#060713,#0c1024)!important;
  background-size:auto,auto,180px 180px,240px 240px,310px 310px,auto!important;background-attachment:fixed;
}


/* KAIZO 3.2 ? palette-responsive surfaces (no hard-coded cyan lock-in). */
.app-header { border-bottom-color:var(--line-strong)!important; }
.sidebar { background:linear-gradient(180deg,var(--glass),var(--bg-2))!important;border-color:var(--line)!important; }
.sidebar button.active { background:var(--surface-2)!important;border-color:var(--line-strong)!important;box-shadow:inset 3px 0 var(--accent-bright),0 7px 22px rgba(0,0,0,.18)!important; }
.sidebar button.active::before { background:var(--accent-bright)!important;box-shadow:0 0 14px var(--glow)!important; }
.main { border-color:var(--line)!important; }
.card,.stat,.stats .card,.quick-tile,.more-tile,.project-card,.plan-card,.engine,.platform-note {
  border-color:var(--line)!important;
  background:linear-gradient(145deg,var(--surface-2),var(--glass) 72%,var(--bg-2))!important;
}
.card:hover,.quick-tile:hover,.more-tile:hover,.project-card:hover { border-color:var(--line-strong)!important; }
.hero { background:radial-gradient(ellipse 48% 90% at 86% 44%,var(--glow),transparent 72%),linear-gradient(118deg,var(--surface-2),var(--bg-2) 72%)!important;border-color:var(--line-strong)!important; }
.hero h1,.hero-copy h1 { color:var(--accent-ink); }
.hero-live,.quick-icon,.more-tile>span,.eyebrow { color:var(--accent-bright)!important; }
.hero-live span { background:var(--accent-bright)!important;box-shadow:0 0 12px var(--glow)!important; }
.hero-orbit { border-color:var(--line-strong)!important;background:linear-gradient(145deg,var(--surface-2),var(--glass))!important;box-shadow:inset 0 0 36px var(--glow),0 15px 42px rgba(0,0,0,.30)!important; }
.hero-orbit::before { background:linear-gradient(var(--line) 1px,transparent 1px),linear-gradient(90deg,var(--line) 1px,transparent 1px)!important; }
.hero-k { border-color:var(--accent-bright)!important;background:radial-gradient(circle at 35% 25%,var(--accent-bright),var(--accent) 62%,var(--bg-2))!important;color:var(--accent-ink)!important;box-shadow:0 0 0 8px var(--glow),0 0 32px var(--glow),inset 0 1px rgba(255,255,255,.24)!important; }
button.primary { background:linear-gradient(115deg,var(--accent),var(--accent-2))!important;border-color:var(--accent-bright)!important;color:var(--accent-ink)!important;box-shadow:0 10px 29px -12px var(--glow)!important; }
button.secondary { background:var(--surface)!important;border-color:var(--line-strong)!important;color:var(--text)!important; }
input,textarea,select { background:var(--glass)!important;border-color:var(--line-strong)!important;color:var(--text)!important; }
input:focus,textarea:focus,select:focus { border-color:var(--accent-bright)!important;box-shadow:0 0 0 3px var(--glow)!important; }
.msg.user { background:linear-gradient(135deg,var(--accent),var(--surface-3))!important;border-color:var(--line-strong)!important;color:var(--accent-ink)!important; }
.msg.assistant,.composer-box { background:var(--glass)!important;border-color:var(--line-strong)!important; }
.composer-box:focus-within { border-color:var(--accent-bright)!important;box-shadow:0 0 0 3px var(--glow),0 18px 48px rgba(0,0,0,.35)!important; }
.bottom-nav { background:var(--glass)!important;border-color:var(--line-strong)!important; }
.bottom-nav button.active { color:var(--accent-ink)!important;background:var(--surface-2)!important; }
.bottom-nav button.active .icon { color:var(--accent-bright)!important;background:var(--surface-3)!important;box-shadow:0 0 16px var(--glow)!important; }


/* KAIZO 3.5 — NEURAL AURORA. Purple-blue atmospheric background, distinct from Console's PCB grid. */
html[data-background="cinematic"] body {
  background-color:#080713!important;
  background-image:
    radial-gradient(ellipse 48% 40% at 14% 18%,rgba(123,78,224,.25),transparent 78%),
    radial-gradient(ellipse 42% 48% at 84% 70%,rgba(38,139,210,.20),transparent 76%),
    radial-gradient(ellipse 35% 30% at 57% 3%,rgba(186,86,218,.10),transparent 74%),
    linear-gradient(145deg,#080713 0%,#10132a 54%,#080d1c 100%)!important;
  background-attachment:fixed!important;
}
html[data-background="cinematic"] body::before {
  opacity:.22!important;
  background-image:
    radial-gradient(circle at 18% 30%,rgba(212,190,255,.56) 1px,transparent 2px),
    radial-gradient(circle at 71% 58%,rgba(129,210,255,.4) 1px,transparent 2px);
  background-size:170px 170px,230px 230px!important;
  mask-image:radial-gradient(ellipse at 50% 45%,#000 8%,transparent 86%)!important;
}
html[data-background="cinematic"] .app-header {
  background:rgba(9,10,28,.82)!important;
  border-bottom-color:rgba(159,132,232,.22)!important;
}
@media(max-width:760px) {
  html[data-background="cinematic"] .main { background:transparent!important; }
  html[data-background="cinematic"] .bottom-nav {
    background:rgba(12,12,31,.94)!important;
    border-color:rgba(153,132,230,.24)!important;
  }
}


/* KAIZO 3.5 MOBILE WORKSPACE — native-feeling touch layout and safe-area support. */
:root { --kz-mobile-nav:74px; }
@media (max-width:760px) {
  html,body { min-height:100%; min-height:100dvh; overscroll-behavior-y:contain; }
  body { padding-bottom:env(safe-area-inset-bottom); }
  .app-header {
    position:sticky!important;top:0;z-index:80;
    min-height:58px;padding:8px 13px!important;
    background:rgba(9,10,28,.94)!important;
    backdrop-filter:blur(22px) saturate(140%);
  }
  .brand-mark { width:39px!important;height:39px!important;border-radius:12px!important; }
  .brand-name { font-size:15px!important;letter-spacing:.11em; }
  .brand-sub { font-size:8px!important;letter-spacing:.11em; }
  .layout { display:block!important;min-height:calc(100dvh - 58px);padding:0!important; }
  .sidebar { display:none!important; }
  .main { display:block!important;min-width:0!important;width:100%!important;padding:0 0 calc(var(--kz-mobile-nav) + env(safe-area-inset-bottom) + 18px)!important; }
  .view { min-height:calc(100dvh - 58px);padding:15px 13px 20px!important; }
  .view-head { align-items:center;gap:10px;flex-wrap:wrap; }
  .view h1 { font-size:clamp(25px,7vw,32px)!important;line-height:1.08; }
  .view h2 { font-size:18px!important; }
  .hero { min-height:unset!important;padding:21px 17px!important;gap:14px; }
  .hero-copy { max-width:100%; }
  .hero .row { flex-wrap:wrap; }
  .hero .row button { min-height:46px; }
  .stats { grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:9px!important; }
  .quick-grid { grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:9px!important; }
  .quick-tile { min-height:112px!important;padding:13px!important;text-align:left; }
  .quick-tile b { font-size:13px!important; }
  .quick-tile small { font-size:10px!important; }
  .mobile-workspace { display:flex!important;flex-direction:column;gap:14px; }
  .mobile-side-stack { display:flex!important;flex-direction:column;gap:12px; }
  .card,.stat,.quick-tile,.more-tile { border-radius:17px!important; }
  .card { padding:15px!important; }
  .bottom-nav {
    position:fixed!important;display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    align-items:stretch;gap:3px!important;
    left:8px!important;right:8px!important;bottom:calc(5px + env(safe-area-inset-bottom))!important;
    width:auto!important;height:var(--kz-mobile-nav)!important;
    padding:7px 7px!important;margin:0!important;
    border:1px solid var(--line-strong)!important;border-radius:19px!important;
    background:rgba(11,12,30,.96)!important;
    box-shadow:0 12px 40px rgba(0,0,0,.48),inset 0 1px rgba(255,255,255,.045)!important;
    backdrop-filter:blur(24px) saturate(150%)!important;
    z-index:120!important;
  }
  .bottom-nav button {
    display:flex!important;min-width:0!important;min-height:52px!important;
    padding:4px 2px!important;gap:3px!important;
    flex-direction:column!important;align-items:center!important;justify-content:center!important;
    border:1px solid transparent!important;border-radius:12px!important;
    color:#9ea8bf!important;font-size:9px!important;font-weight:800!important;
    line-height:1.05!important;white-space:nowrap!important;touch-action:manipulation;
  }
  .bottom-nav button .icon {
    display:grid!important;place-items:center;width:28px!important;height:25px!important;
    border-radius:8px!important;font-size:17px!important;line-height:1!important;
    background:transparent!important;color:inherit!important;
  }
  .bottom-nav button.active {
    color:var(--accent-ink)!important;background:var(--surface-2)!important;
    border-color:var(--line)!important;box-shadow:inset 0 1px rgba(255,255,255,.06)!important;
  }
  .bottom-nav button.active .icon {
    color:var(--accent-bright)!important;background:var(--surface-3)!important;
    box-shadow:0 0 15px var(--glow)!important;
  }
  #view-chat { display:flex;flex-direction:column;min-height:calc(100dvh - 58px - var(--kz-mobile-nav)); }
  #view-chat .view-head { flex-wrap:nowrap; }
  #view-chat .view-head h1 { font-size:26px!important; }
  #view-chat .view-head .row { gap:5px!important; }
  #view-chat .view-head .row button { min-height:38px!important;padding:7px 9px!important;font-size:10px!important; }
  #view-chat .messages { flex:1 1 auto;min-height:34vh;max-height:none!important;overscroll-behavior:contain; }
  #view-chat .composer {
    position:sticky!important;bottom:calc(var(--kz-mobile-nav) + env(safe-area-inset-bottom) + 10px)!important;
    z-index:55;margin:8px 0 0!important;padding:7px 0 5px!important;
    background:linear-gradient(180deg,transparent,rgba(8,8,23,.92) 19%)!important;
  }
  .composer-box { min-height:54px!important;gap:5px!important;padding:6px!important;border-radius:16px!important; }
  .composer-box textarea { min-height:40px!important;max-height:130px!important;padding:9px 7px!important;font-size:16px!important; }
  .composer-box button { min-width:40px!important;min-height:40px!important;border-radius:11px!important; }
  #send { min-width:62px!important;padding:0 10px!important;font-size:12px!important; }
  .hint { font-size:9px!important;line-height:1.35; }
  .filter-row { flex-wrap:wrap; }
  .filter-row>* { min-width:0!important;flex:1 1 46%; }
  .row { flex-wrap:wrap; }
  .row>* { max-width:100%; }
  input,select,textarea { font-size:16px!important; }
  .gallery { grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:9px!important; }
  .modal { padding:12px!important; }
  .modal .card { width:100%!important; }
  .project-list,.feature-list { gap:9px!important; }
  .platform-bars { width:100%; }
  .offline-banner { margin:8px 10px 0!important;border-radius:12px; }
}
@media (max-width:380px) {
  .app-header { padding-inline:10px!important; }
  .brand-sub { display:none!important; }
  .bottom-nav { left:5px!important;right:5px!important;padding-inline:4px!important; }
  .bottom-nav button { font-size:8px!important; }
  #chat-usage { font-size:9px!important; }
}
@media (prefers-reduced-motion:reduce) {
  .bottom-nav button,.quick-tile { transition:none!important; }
}


/* KAIZO 3.5 — mobile motion and touch polish. */
html[data-motion="on"] .hero-k {
  animation:kaizo35-core-breathe 4.2s ease-in-out infinite;
}
html[data-motion="on"] .hero-orbit::before {
  animation:kaizo35-grid-drift 22s linear infinite;
}
html[data-motion="on"] .hero-live span {
  animation:kaizo35-live-pulse 2.4s ease-in-out infinite;
}
@keyframes kaizo35-core-breathe {
  0%,100% { transform:translateY(0) scale(1); filter:saturate(1); }
  50% { transform:translateY(-3px) scale(1.035); filter:saturate(1.2); }
}
@keyframes kaizo35-grid-drift {
  from { background-position:0 0,0 0; }
  to { background-position:34px 34px,34px 34px; }
}
@keyframes kaizo35-live-pulse {
  0%,100% { opacity:.68; box-shadow:0 0 5px var(--glow); }
  50% { opacity:1; box-shadow:0 0 17px var(--glow); }
}
@media(max-width:760px) {
  .view-head { margin-bottom:14px!important; }
  .view-head button,.view-head .button,.view-head .primary,.view-head .ghost {
    min-height:42px!important;touch-action:manipulation;
  }
  .card,.quick-tile,.more-tile,.project-card,button { -webkit-tap-highlight-color:transparent; }
  .quick-tile:active,.more-tile:active,.bottom-nav button:active {
    transform:scale(.985);
  }
  .messages { scroll-padding-bottom:110px; }
  .modal { align-items:flex-end!important;padding:10px 10px calc(10px + env(safe-area-inset-bottom))!important; }
  .modal .card { max-height:86dvh;overflow-y:auto;overscroll-behavior:contain; }
  .gallery img,.gallery video { max-width:100%;height:auto;object-fit:cover; }
  .bottom-nav { touch-action:pan-x; }
}
@media (prefers-reduced-motion: reduce) {
  html[data-motion="on"] .hero-k,
  html[data-motion="on"] .hero-orbit::before,
  html[data-motion="on"] .hero-live span { animation:none!important; }
}
html[data-motion="off"] .hero-k,
html[data-motion="off"] .hero-orbit::before,
html[data-motion="off"] .hero-live span { animation:none!important; }


/* KAIZO FAMILY MOBILE 1.0 — clear invite confirmation and app installation. */
.family-login-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.family-login-actions .family-login-action,
.family-login-actions .family-install-action {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  white-space: normal;
  line-height: 1.3;
  text-align: center;
  justify-content: center;
}
.family-login-actions .family-login-action:disabled {
  opacity: .72;
  cursor: progress;
}
.family-invite-help {
  margin: 10px 0 4px;
  line-height: 1.5;
}
#login-modal .card > #invite-input {
  width: 100%;
  min-height: 48px;
  margin-top: 7px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .02em;
}
#login-modal .family-login-actions #login-error {
  min-height: 18px;
  overflow-wrap: anywhere;
}
@media (max-width: 520px) {
  #login-modal { padding: 12px; }
  #login-modal .card { padding: 19px; max-height: calc(100dvh - 24px); overflow-y: auto; }
  .family-login-actions .family-login-action,
  .family-login-actions .family-install-action { min-height: 52px; font-size: 14px; }
}


/* KAIZO FAMILY MOBILE 1.1 — feature clarity and touch layout */
.feature-summary {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
  margin:12px 0;
}
.feature-summary-item {
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width:0;
  padding:11px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:linear-gradient(145deg,var(--surface-2),var(--surface));
}
.feature-summary-item b {
  font-size:1.2rem;
  line-height:1.1;
  font-variant-numeric:tabular-nums;
}
.feature-summary-item span {
  color:var(--muted-2);
  font-size:.68rem;
  line-height:1.3;
}
.feature-filters { display:grid;grid-template-columns:1.2fr 1fr 1fr;gap:8px; }
.feature-filters select { min-width:0;width:100%; }
.feature-item { align-items:center; }
.feature-item .name { display:block; }
.feature-tags { display:flex;flex-wrap:wrap;gap:5px;margin-top:7px; }
.feature-tag {
  display:inline-flex;
  align-items:center;
  min-height:23px;
  max-width:100%;
  padding:3px 8px;
  border:1px solid var(--line);
  border-radius:999px;
  color:var(--muted);
  background:rgba(255,255,255,.035);
  font-size:.64rem;
  font-weight:650;
  line-height:1.25;
  white-space:normal;
}
.feature-tag.computer,.feature-platform-computer {
  color:#ffd78a;
  border-color:rgba(245,180,70,.34);
  background:rgba(176,113,31,.12);
}
.feature-tag.platform,.feature-platform-available {
  color:#b7e9ff;
  border-color:rgba(91,177,225,.28);
  background:rgba(54,139,184,.10);
}
.feature-tag.ok { color:#a7f3d0;border-color:rgba(52,211,153,.3);background:rgba(52,211,153,.08); }
.feature-tag.warn { color:#fcd58b;border-color:rgba(251,191,36,.3);background:rgba(251,191,36,.08); }
.feature-tag.free { color:var(--muted); }
.feature-status-dot {
  flex:0 0 8px;
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--muted-2);
}
.feature-status-dot.ok { background:#34d399;box-shadow:0 0 10px rgba(52,211,153,.35); }
.feature-status-dot.warn { background:#fbbf24;box-shadow:0 0 10px rgba(251,191,36,.28); }
.feature-status-dot.bad { background:#81899b; }
.feature-readonly-note { margin-top:14px;border-color:var(--line-strong); }
.feature-readonly-note strong { color:var(--text); }
.feature-readonly-note p { margin:7px 0 0;line-height:1.55; }
.detail-head { flex-wrap:wrap; }
.detail-head .badge { flex:0 0 auto; }
#view-chat .composer-box textarea { flex:1 1 0;min-width:0; }
#view-chat .composer-box #send { flex:0 0 auto; }

@media(max-width:760px) {
  .feature-summary { gap:6px;margin:10px 0; }
  .feature-summary-item { padding:9px 8px;border-radius:10px; }
  .feature-summary-item b { font-size:1.08rem; }
  .feature-summary-item span { font-size:.61rem; }
  .feature-filters { grid-template-columns:1fr;gap:7px; }
  .feature-item { gap:9px;padding:12px 10px; }
  .feature-item .id { min-width:27px;font-size:.64rem; }
  .feature-item .name { font-size:.84rem;line-height:1.35; }
  .feature-item .name small { font-size:.68rem;line-height:1.35;margin-top:3px; }
  .feature-tag { font-size:.61rem;padding:4px 7px; }
  .feature-status-dot { margin-left:0; }
  #view-features .view-head { align-items:center; }
  #view-chat .composer-box { gap:5px;padding:6px; }
  #view-chat .composer-box textarea { padding-inline:5px;font-size:16px; }
  #view-chat .composer-box #send { padding-inline:11px;min-height:40px; }
  #view-chat .composer { padding-bottom:2px; }
}
@media(max-width:360px) {
  .feature-summary-item span { font-size:.57rem; }
  .feature-item { gap:7px;padding-inline:8px; }
  #view-chat .composer-box #send { padding-inline:9px; }
}

/* Family Mobile home dashboard */
.family-mobile-dashboard {
  width:100%;
  max-width:820px;
  margin:12px auto 0;
  padding:clamp(18px,4vw,26px);
  border-color:rgba(139,92,246,.24);
  background:
    radial-gradient(ellipse at 100% 0%,rgba(139,92,246,.14),transparent 58%),
    linear-gradient(145deg,var(--surface-2),var(--surface));
}
.family-mobile-dashboard h2 { margin:6px 0 7px;font-size:1.22rem; }
.family-mobile-dashboard > p { max-width:58ch;line-height:1.55;margin:0; }
.family-dashboard-actions {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:9px;
  margin-top:18px;
}
.family-dashboard-actions button { min-width:0;min-height:46px;white-space:normal; }
.family-dashboard-note {
  margin-top:16px;
  padding:11px 13px;
  border:1px solid var(--line);
  border-radius:11px;
  color:var(--muted);
  background:rgba(255,255,255,.025);
  font-size:.76rem;
  line-height:1.5;
}
@media(max-width:420px) {
  .family-dashboard-actions { grid-template-columns:1fr 1fr;gap:7px; }
  .family-dashboard-actions button { padding:9px 8px;font-size:.78rem; }
}


/* KAIZO MOBILE THEME REPAIR — the selected palette now recolors the scene itself. */
html[data-color-theme="violet"] body { background-color:#080511!important; }
html[data-color-theme="violet"] body::after {
  background:conic-gradient(from 210deg at 50% 50%,transparent 0deg,rgba(177,80,255,.25) 48deg,transparent 96deg,rgba(73,155,246,.17) 150deg,transparent 210deg,rgba(236,77,190,.18) 286deg,transparent 360deg)!important;
}
html[data-color-theme="violet"] .ambient-a { background:radial-gradient(circle,rgba(183,82,255,.44),transparent 70%)!important; }
html[data-color-theme="violet"] .ambient-b { background:radial-gradient(circle,rgba(65,153,245,.27),transparent 70%)!important; }
html[data-color-theme="violet"] .ambient-c { background:radial-gradient(circle,rgba(235,76,190,.24),transparent 70%)!important; }

html[data-color-theme="cyan"] body { background-color:#041018!important; }
html[data-color-theme="cyan"] body::after {
  background:conic-gradient(from 210deg at 50% 50%,transparent 0deg,rgba(21,190,220,.24) 48deg,transparent 96deg,rgba(19,129,180,.18) 150deg,transparent 210deg,rgba(32,212,194,.15) 286deg,transparent 360deg)!important;
}
html[data-color-theme="cyan"] .ambient-a { background:radial-gradient(circle,rgba(19,181,211,.39),transparent 70%)!important; }
html[data-color-theme="cyan"] .ambient-b { background:radial-gradient(circle,rgba(35,133,204,.28),transparent 70%)!important; }
html[data-color-theme="cyan"] .ambient-c { background:radial-gradient(circle,rgba(36,215,195,.18),transparent 70%)!important; }

html[data-color-theme="blue"] body { background-color:#050c1b!important; }
html[data-color-theme="blue"] body::after {
  background:conic-gradient(from 210deg at 50% 50%,transparent 0deg,rgba(48,117,255,.25) 48deg,transparent 96deg,rgba(40,185,233,.18) 150deg,transparent 210deg,rgba(79,99,235,.17) 286deg,transparent 360deg)!important;
}
html[data-color-theme="blue"] .ambient-a { background:radial-gradient(circle,rgba(51,111,248,.42),transparent 70%)!important; }
html[data-color-theme="blue"] .ambient-b { background:radial-gradient(circle,rgba(33,172,229,.25),transparent 70%)!important; }
html[data-color-theme="blue"] .ambient-c { background:radial-gradient(circle,rgba(94,104,239,.20),transparent 70%)!important; }

html[data-color-theme="yellow"] body { background-color:#171104!important; }
html[data-color-theme="yellow"] body::after {
  background:conic-gradient(from 210deg at 50% 50%,transparent 0deg,rgba(223,158,37,.24) 48deg,transparent 96deg,rgba(211,116,34,.16) 150deg,transparent 210deg,rgba(243,202,91,.17) 286deg,transparent 360deg)!important;
}
html[data-color-theme="yellow"] .ambient-a { background:radial-gradient(circle,rgba(218,157,42,.39),transparent 70%)!important; }
html[data-color-theme="yellow"] .ambient-b { background:radial-gradient(circle,rgba(199,111,39,.23),transparent 70%)!important; }
html[data-color-theme="yellow"] .ambient-c { background:radial-gradient(circle,rgba(241,206,105,.17),transparent 70%)!important; }

html[data-color-theme="green"] body { background-color:#04140e!important; }
html[data-color-theme="green"] body::after {
  background:conic-gradient(from 210deg at 50% 50%,transparent 0deg,rgba(36,192,130,.24) 48deg,transparent 96deg,rgba(35,177,177,.17) 150deg,transparent 210deg,rgba(44,141,94,.18) 286deg,transparent 360deg)!important;
}
html[data-color-theme="green"] .ambient-a { background:radial-gradient(circle,rgba(35,192,125,.38),transparent 70%)!important; }
html[data-color-theme="green"] .ambient-b { background:radial-gradient(circle,rgba(24,165,163,.24),transparent 70%)!important; }
html[data-color-theme="green"] .ambient-c { background:radial-gradient(circle,rgba(74,161,96,.19),transparent 70%)!important; }

html[data-color-theme="monochrome"] body { background-color:#050505!important; }
html[data-color-theme="monochrome"] body::after {
  background:conic-gradient(from 210deg at 50% 50%,transparent 0deg,rgba(230,230,235,.16) 48deg,transparent 96deg,rgba(150,150,160,.12) 150deg,transparent 210deg,rgba(255,255,255,.10) 286deg,transparent 360deg)!important;
}
html[data-color-theme="monochrome"] .ambient-a { background:radial-gradient(circle,rgba(220,220,225,.20),transparent 70%)!important; }
html[data-color-theme="monochrome"] .ambient-b { background:radial-gradient(circle,rgba(140,140,150,.16),transparent 70%)!important; }
html[data-color-theme="monochrome"] .ambient-c { background:radial-gradient(circle,rgba(255,255,255,.10),transparent 70%)!important; }

html[data-color-theme] .app-header,
html[data-color-theme] .sidebar,
html[data-color-theme] .bottom-nav,
html[data-color-theme] .chat-list-mobile,
html[data-color-theme] #view-chat .mobile-chat-history {
  border-color:var(--line-strong)!important;
}
html[data-color-theme] .app-header {
  background:linear-gradient(115deg,var(--glass),var(--surface))!important;
}
html[data-color-theme] .sidebar,
html[data-color-theme] .bottom-nav {
  background:linear-gradient(160deg,var(--glass),var(--surface))!important;
}
html[data-color-theme] .card,
html[data-color-theme] .hero,
html[data-color-theme] .engine,
html[data-color-theme] .platform-note,
html[data-color-theme] .mobile-chat-history {
  background-color:var(--surface)!important;
  border-color:var(--line)!important;
}
html[data-color-theme] .msg.user {
  background:linear-gradient(135deg,var(--accent),var(--accent-2))!important;
  border-color:var(--line-strong)!important;
  color:#fff!important;
}
html[data-color-theme] .msg.assistant {
  background:linear-gradient(145deg,var(--surface-2),var(--glass))!important;
  border-color:var(--line)!important;
}
html[data-color-theme] .composer-box {
  background:linear-gradient(145deg,var(--surface-2),var(--glass))!important;
  border-color:var(--line-strong)!important;
}
html[data-color-theme] .composer-box:focus-within {
  border-color:var(--accent-bright)!important;
  box-shadow:0 0 0 3px var(--glow),0 18px 46px -24px rgba(0,0,0,.82)!important;
}
html[data-color-theme] .chat-entry.active {
  background:linear-gradient(100deg,var(--surface-3),var(--surface-2))!important;
  border-color:var(--line-strong)!important;
}
html[data-color-theme="monochrome"] .msg.user {
  background:linear-gradient(135deg,#55555d,#29292e)!important;
}

/* KAIZO CHAT WORKSPACE REFINEMENT — readable conversation, compact history, strong composer. */
#view-chat {
  gap:0;
}
#view-chat .view-head {
  align-items:center;
  padding:14px 16px;
  margin:0 0 12px;
  border:1px solid var(--line);
  border-radius:16px;
  background:linear-gradient(120deg,var(--surface-2),var(--glass));
  box-shadow:0 10px 28px rgba(0,0,0,.16);
}
#view-chat .view-head h1 {
  margin:2px 0 0;
  font-size:clamp(25px,3vw,32px);
  letter-spacing:-.035em;
}
#view-chat .view-head .eyebrow { margin-bottom:2px; }
#view-chat .mobile-chat-history {
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:14px;
  background:linear-gradient(145deg,var(--surface),var(--glass));
}
#view-chat .mobile-chat-history-head {
  display:flex;align-items:center;justify-content:space-between;
  gap:8px;margin:0 1px 6px;
}
#view-chat .mobile-chat-history-head .eyebrow {
  color:var(--accent-bright);
  font-size:9px;
}
#view-chat .messages {
  gap:15px;
  padding:clamp(13px,2.5vw,24px);
  border:1px solid var(--line);
  border-radius:20px;
  background:
    radial-gradient(ellipse at 12% 0%,var(--theme-glow-a),transparent 42%),
    linear-gradient(160deg,rgba(10,13,26,.50),rgba(5,8,18,.36));
  box-shadow:inset 0 1px rgba(255,255,255,.035),0 14px 38px rgba(0,0,0,.14);
  scrollbar-gutter:stable;
}
#view-chat .msg {
  width:fit-content;
  max-width:min(94%,880px);
  padding:15px 17px;
  border-radius:18px;
  line-height:1.65;
  box-shadow:0 9px 24px rgba(0,0,0,.15);
}
#view-chat .msg.user {
  align-self:flex-end;
  max-width:min(88%,760px);
  border-bottom-right-radius:6px;
}
#view-chat .msg.assistant {
  align-self:flex-start;
  max-width:min(97%,920px);
  border-bottom-left-radius:6px;
}
#view-chat .msg .msg-body {
  font-size:var(--font-size,15px);
  line-height:1.68;
}
#view-chat .msg .msg-body p { margin:.45em 0; }
#view-chat .msg .msg-body p:first-child { margin-top:0; }
#view-chat .msg .msg-body p:last-child { margin-bottom:0; }
#view-chat .composer {
  margin-top:11px;
  padding:8px 0 3px;
}
#view-chat .composer-box {
  min-height:62px;
  padding:8px;
  gap:8px;
  border-radius:18px;
  border-width:1px;
}
#view-chat .composer-box textarea {
  min-height:44px;
  padding:10px 9px;
  font-size:16px;
  line-height:1.45;
  background:transparent;
}
#view-chat .composer-box #send {
  min-height:44px;
  height:44px;
  padding:0 17px;
  border-radius:13px;
  font-size:13px;
  font-weight:850;
  box-shadow:0 7px 20px var(--glow);
}
#view-chat .hint {
  margin-top:7px;
  padding:0 8px;
  color:var(--muted-2);
  font-size:10px;
}
@media(max-width:760px) {
  #view-chat {
    gap:0;
  }
  #view-chat .view-head {
    padding:10px 11px;
    margin-bottom:8px;
    border-radius:14px;
  }
  #view-chat .view-head h1 { font-size:25px!important; }
  #view-chat .mobile-chat-history {
    max-height:86px!important;
    margin-bottom:8px!important;
    padding:6px 8px;
    overflow:hidden;
  }
  #view-chat .mobile-chat-history-head {
    min-height:17px;
    margin:0 1px 4px;
  }
  #view-chat .mobile-chat-history-head .small { display:none; }
  #view-chat .chat-list-mobile {
    display:flex;
    flex-direction:row;
    align-items:stretch;
    gap:7px;
    max-height:none!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    padding:3px 1px 6px;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:thin;
  }
  #view-chat .chat-list-mobile .chat-entry {
    flex:0 0 190px;
    min-width:190px;
    min-height:38px!important;
    padding:2px 4px;
  }
  #view-chat .messages {
    flex:1 1 auto;
    min-height:36vh!important;
    padding:12px 9px 16px;
    border-radius:17px;
  }
  #view-chat .msg {
    max-width:96%;
    padding:12px 13px;
    border-radius:15px;
  }
  #view-chat .msg.user { max-width:88%; }
  #view-chat .msg .msg-body { font-size:15px;line-height:1.62; }
  #view-chat .composer {
    position:sticky;
    bottom:calc(var(--kz-mobile-nav,74px) + env(safe-area-inset-bottom) + 7px);
    z-index:55;
    margin-top:8px;
    padding:7px 0 4px;
    background:linear-gradient(180deg,transparent,rgba(8,9,22,.94) 25%);
  }
  #view-chat .composer-box {
    min-height:56px;
    padding:6px;
    border-radius:16px;
  }
  #view-chat .composer-box textarea {
    min-height:42px;
    padding:9px 6px;
    font-size:16px;
  }
  #view-chat .composer-box #send {
    min-height:42px;
    height:42px;
    padding-inline:13px;
    font-size:12px;
  }
}
@media(max-width:380px) {
  #view-chat .chat-list-mobile .chat-entry { flex-basis:165px;min-width:165px; }
  #view-chat .composer-box #send { padding-inline:9px;min-width:54px; }
}
@media(prefers-reduced-motion:reduce) {
  #view-chat .msg { scroll-behavior:auto; }
}

/* KAIZO 3.5.9 — full-width assistant workspace, desktop dock and real theme variables. */
@media (min-width:900px) {
  body { padding-bottom:0!important; }
  .layout { width:100%!important;max-width:none!important;min-height:calc(100dvh - var(--header-h)); }
  .main { width:100%!important;max-width:none!important;min-width:0;padding:18px clamp(20px,2.4vw,46px) 118px!important; }
  .bottom-nav {
    display:flex!important;position:fixed!important;left:50%!important;right:auto!important;
    bottom:14px!important;transform:translateX(-50%)!important;
    width:min(790px,calc(100vw - 310px))!important;height:68px;
    padding:8px!important;gap:7px!important;justify-content:space-between;
    border:1px solid var(--line-strong)!important;border-radius:20px!important;
    background:var(--glass)!important;backdrop-filter:blur(24px) saturate(145%)!important;
    box-shadow:0 14px 42px rgba(0,0,0,.38),inset 0 1px rgba(255,255,255,.05)!important;
    z-index:120!important;
  }
  .bottom-nav button {
    display:flex!important;flex:1 1 0;min-width:0;min-height:48px;
    flex-direction:row!important;align-items:center;justify-content:center;
    gap:9px;padding:7px 10px;border-radius:13px;
    color:var(--muted);font-size:12px;font-weight:750;white-space:nowrap;
  }
  .bottom-nav button .icon {
    width:27px;height:27px;display:grid;place-items:center;
    border-radius:9px;font-size:18px;color:inherit;
  }
  .bottom-nav button.active {
    color:var(--accent-ink)!important;background:var(--surface-2)!important;
    box-shadow:inset 0 1px rgba(255,255,255,.07);
  }
  .bottom-nav button.active .icon { color:var(--accent-bright)!important;background:var(--surface-3); }
  #view-chat.active {
    display:flex!important;flex-direction:column;width:100%;
    height:calc(100dvh - var(--header-h) - 126px);min-height:440px;overflow:hidden;
  }
  #view-chat .mobile-chat-history { display:none!important; }
  #view-chat .messages {
    flex:1 1 auto;min-height:0;width:100%;max-height:none;overflow-y:auto;
    padding:clamp(18px,2.5vh,32px) clamp(20px,4vw,76px);
    border:0!important;border-radius:0!important;background:transparent!important;
    box-shadow:none!important;
  }
  #view-chat .msg.assistant {
    width:100%;max-width:min(100%,1120px);padding:8px 0;
    border:0!important;border-radius:0!important;background:transparent!important;
    box-shadow:none!important;
  }
  #view-chat .msg.user { max-width:min(84%,900px); }
  #view-chat .composer { width:min(100%,1120px);margin:10px auto 0;padding:8px 0 4px; }
  #view-chat .hint,#view-chat #chat-usage { width:100%;margin-inline:auto; }
  #view-chat .messages.welcome-mode { display:flex;align-items:center;justify-content:center; }
  #view-chat .welcome-stage {
    width:100%;max-width:1050px;min-height:100%;margin:auto;padding:28px 18px;
    border:0!important;border-radius:0!important;background:transparent!important;
    box-shadow:none!important;
  }
  #view-chat .welcome-orb { width:76px;height:76px; }
}
@media (min-width:761px) and (max-width:899px) {
  .layout { max-width:none;width:100%; }
  .main { max-width:none;width:100%; }
}
@media (max-width:760px) {
  .layout { width:100%;max-width:none; }
  .main { width:100%;max-width:none;padding-bottom:20px!important; }
  #view-chat.active {
    display:flex!important;flex-direction:column;
    height:calc(100dvh - 58px - var(--kz-mobile-nav) - env(safe-area-inset-bottom) - 22px);
    min-height:0;overflow:hidden;
  }
  #view-chat .messages {
    flex:1 1 0;min-height:0!important;max-height:none!important;
    border:0!important;border-radius:0!important;background:transparent!important;
    box-shadow:none!important;padding:12px 9px 16px;
  }
  #view-chat .composer { width:100%;margin-top:8px; }
  #view-chat .messages.welcome-mode { display:flex;align-items:center;justify-content:center; }
  #view-chat .welcome-stage {
    width:100%;max-width:100%;min-height:100%;padding:14px 7px;
    border:0!important;border-radius:0!important;background:transparent!important;
    box-shadow:none!important;
  }
}

/* Selected color palette overrides Free's old hard-coded grey-violet skin. */
html[data-color-theme] body[data-plan="free"] {
  color:var(--text)!important;
  background-color:var(--bg)!important;
  background-image:
    radial-gradient(ellipse 74% 48% at 8% -4%,var(--theme-glow-a),transparent 68%),
    radial-gradient(ellipse 56% 42% at 100% 18%,var(--theme-glow-b),transparent 70%),
    radial-gradient(ellipse 70% 56% at 54% 112%,var(--theme-glow-c),transparent 66%),
    linear-gradient(155deg,var(--bg) 0%,var(--bg-2) 100%)!important;
  background-attachment:fixed!important;
}
html[data-color-theme] body[data-plan="free"]::before,
html[data-color-theme] body[data-plan="free"]::after { display:block!important; }
html[data-color-theme] body[data-plan="free"] .ambient { display:block!important; }
html[data-color-theme] body[data-plan="free"] .app-header {
  background:linear-gradient(115deg,var(--glass),var(--surface))!important;
  border-color:var(--line)!important;backdrop-filter:blur(20px) saturate(140%)!important;
}
html[data-color-theme] body[data-plan="free"] .sidebar,
html[data-color-theme] body[data-plan="free"] .bottom-nav {
  background:linear-gradient(160deg,var(--glass),var(--surface))!important;
  border-color:var(--line)!important;backdrop-filter:blur(20px) saturate(140%)!important;
}
html[data-color-theme] body[data-plan="free"] .card,
html[data-color-theme] body[data-plan="free"] .hero,
html[data-color-theme] body[data-plan="free"] .engine,
html[data-color-theme] body[data-plan="free"] .platform-note {
  background:linear-gradient(145deg,var(--surface-2),var(--surface) 72%)!important;
  border-color:var(--line)!important;
}
html[data-color-theme] body[data-plan="free"] button.primary {
  background:linear-gradient(135deg,var(--accent),var(--accent-2))!important;
  border-color:var(--accent-bright)!important;color:#fff!important;
}
html[data-color-theme] body[data-plan="free"] button.secondary {
  background:var(--surface-2)!important;border-color:var(--line-strong)!important;color:var(--text)!important;
}
html[data-color-theme] body[data-plan="free"] .msg.user {
  background:linear-gradient(135deg,var(--accent),var(--accent-2))!important;
  border-color:var(--line-strong)!important;color:#fff!important;
}
html[data-color-theme] body[data-plan="free"] .msg.assistant,
html[data-color-theme] body[data-plan="free"] .composer-box {
  background:linear-gradient(145deg,var(--surface-2),var(--glass))!important;
  border-color:var(--line-strong)!important;
}
html[data-color-theme] body[data-plan="free"] input,
html[data-color-theme] body[data-plan="free"] textarea,
html[data-color-theme] body[data-plan="free"] select {
  background:var(--glass)!important;border-color:var(--line-strong)!important;color:var(--text)!important;
}
html[data-color-theme] body[data-plan="free"] .chat-chip.active,
html[data-color-theme] body[data-plan="free"] .sidebar button.active,
html[data-color-theme] body[data-plan="free"] .bottom-nav button.active {
  background:var(--surface-2)!important;border-color:var(--line-strong)!important;
  color:var(--accent-ink)!important;
}
html[data-color-theme="monochrome"] body[data-plan="free"] .msg.user {
  background:linear-gradient(135deg,#55555d,#29292e)!important;
}

/* Final refinements: the assistant is text-first, and utility settings respect every palette. */
:root { --header-h:68px; }
#view-chat .msg.assistant {
  width:100%;max-width:min(100%,1120px);align-self:stretch;
  padding:8px 0;border:0;border-radius:0;background:transparent;box-shadow:none;
}
html[data-color-theme] body[data-plan="free"] #view-chat .msg.assistant {
  background:transparent!important;border-color:transparent!important;box-shadow:none!important;
}
html[data-glass="off"] .card,
html[data-glass="off"] .hero,
html[data-glass="off"] .engine,
html[data-glass="off"] .sidebar,
html[data-glass="off"] .app-header,
html[data-glass="off"] .composer-box {
  backdrop-filter:none!important;
}
html[data-glass="off"] .card,
html[data-glass="off"] .engine {
  background:var(--surface-2)!important;
}
html[data-density="compact"] .view { padding:18px 20px 22px!important; }
@media(max-width:760px) {
  html[data-density="compact"] .view { padding:12px 10px 18px!important; }
  #view-chat .msg.assistant { max-width:100%;padding:7px 0; }
}

/* KAIZO FAMILY MOBILE 1.0 — real full-height chat viewport and bottom app navigation. */
:root {
  --kz-mobile-nav:74px;
  --kz-mobile-header:60px;
}
@media (max-width:760px) {
  html, body {
    width:100%;
    height:100%;
    min-height:100dvh;
    overflow:hidden!important;
    overscroll-behavior:none;
  }
  body { padding-bottom:0!important; }
  .app-header {
    position:relative!important;
    display:flex;
    flex:0 0 var(--kz-mobile-header);
    width:100%;
    height:var(--kz-mobile-header)!important;
    min-height:var(--kz-mobile-header)!important;
    max-height:var(--kz-mobile-header);
  }
  .layout {
    display:block!important;
    width:100%!important;
    height:calc(100dvh - var(--kz-mobile-header) - var(--kz-mobile-nav) - env(safe-area-inset-bottom,0px) - 5px)!important;
    min-height:0!important;
    max-height:none!important;
    overflow:hidden!important;
    padding:0!important;
    margin:0!important;
  }
  .main {
    display:block!important;
    width:100%!important;
    max-width:none!important;
    height:100%!important;
    min-width:0!important;
    min-height:0!important;
    max-height:100%!important;
    margin:0!important;
    padding:0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
    scrollbar-width:none;
  }
  .main::-webkit-scrollbar { display:none; }
  .view { min-height:0!important; }
  #view-chat.active {
    display:flex!important;
    flex-direction:column!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    overflow:hidden!important;
    gap:0!important;
    padding:8px 12px 6px!important;
    margin:0!important;
  }
  #view-chat .view-head {
    display:flex;
    flex:0 0 auto;
    align-items:center;
    gap:8px;
    margin:0 0 5px!important;
    padding:5px 3px 7px!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  #view-chat .view-head h1 {
    margin:0!important;
    font-size:23px!important;
  }
  #view-chat .view-head .row { gap:5px!important; }
  #view-chat .view-head .row button {
    min-height:34px!important;
    padding:5px 8px!important;
    font-size:10px!important;
  }
  #view-chat .mobile-chat-history {
    display:block!important;
    flex:0 0 auto;
    max-height:66px!important;
    min-height:0!important;
    overflow:hidden!important;
    margin:0 0 4px!important;
    padding:3px 5px!important;
    border:0!important;
    border-radius:10px!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  #view-chat .mobile-chat-history-head { min-height:14px;margin:0 2px 2px!important; }
  #view-chat .mobile-chat-history-head .small { display:none!important; }
  #view-chat .chat-list-mobile {
    display:flex!important;
    flex-direction:row!important;
    align-items:center;
    gap:6px;
    max-height:38px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    padding:2px 1px 4px!important;
  }
  #view-chat .chat-list-mobile .chat-entry {
    flex:0 0 174px;
    min-width:174px;
    min-height:32px!important;
    padding:0 3px!important;
  }
  #view-chat .messages {
    display:flex!important;
    flex:1 1 0!important;
    width:100%!important;
    height:0!important;
    min-height:0!important;
    max-height:none!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    gap:13px!important;
    padding:10px 7px 13px!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
    scrollbar-width:thin;
    overscroll-behavior:contain;
  }
  #view-chat .msg {
    flex:0 0 auto;
    min-width:0;
    max-width:94%;
    padding:11px 13px;
    border-radius:15px;
  }
  #view-chat .msg.assistant {
    align-self:stretch!important;
    width:100%!important;
    max-width:100%!important;
    padding:7px 2px!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  #view-chat .msg.user {
    align-self:flex-end!important;
    width:fit-content!important;
    max-width:88%!important;
  }
  #view-chat .msg .msg-body { width:100%;font-size:var(--font-size,15px);line-height:1.62; }
  #view-chat .composer {
    display:block;
    position:static!important;
    flex:0 0 auto!important;
    width:100%!important;
    margin:5px 0 0!important;
    padding:5px 0 0!important;
    background:transparent!important;
    z-index:5;
  }
  #view-chat .composer-box {
    width:100%;
    min-height:53px!important;
    padding:5px!important;
    gap:6px!important;
    border-radius:16px!important;
  }
  #view-chat .composer-box textarea {
    min-height:41px!important;
    max-height:22dvh!important;
    padding:8px 6px!important;
    font-size:16px!important;
    line-height:1.45;
  }
  #view-chat .composer-box .attach,
  #view-chat .composer-box .voice-dictate,
  #view-chat .composer-box #send {
    min-height:41px!important;
    height:41px!important;
  }
  #view-chat .composer-box #send { padding:0 12px!important; }
  #view-chat .composer .hint { display:none!important; }
  #view-chat #chat-usage { margin-top:3px!important;font-size:9px!important; }
  #view-chat .messages.welcome-mode {
    display:flex!important;
    flex-direction:column!important;
    align-items:stretch!important;
    justify-content:center!important;
    padding:8px 3px 15px!important;
  }
  #view-chat .welcome-stage {
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    max-width:none!important;
    min-height:100%!important;
    margin:0!important;
    padding:12px 5px!important;
    gap:10px!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  #view-chat .welcome-orb { width:70px!important;height:70px!important; }
  #view-chat .welcome-orb span { font-size:30px!important; }
  #view-chat .welcome-kicker { font-size:8px!important; }
  #view-chat .welcome-stage h2 { font-size:25px!important; }
  #view-chat .welcome-copy { max-width:420px;font-size:12px!important; }
  #view-chat .welcome-actions {
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    width:100%!important;
    max-width:470px!important;
    gap:7px!important;
  }
  #view-chat .welcome-action { min-height:40px!important;font-size:11px!important; }
  #view-chat .welcome-footnote { font-size:9px!important; }
  #view-chat.voice-mode { height:100%!important;min-height:0!important;padding-bottom:8px!important; }
  #view-chat.voice-mode .voice-stage { flex:1 1 0;min-height:0; }
  .bottom-nav {
    position:fixed!important;
    display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    align-items:stretch!important;
    gap:3px!important;
    left:8px!important;
    right:8px!important;
    bottom:calc(5px + env(safe-area-inset-bottom,0px))!important;
    width:auto!important;
    height:var(--kz-mobile-nav)!important;
    min-height:var(--kz-mobile-nav)!important;
    max-height:var(--kz-mobile-nav)!important;
    padding:6px 7px!important;
    margin:0!important;
    border:1px solid var(--line-strong)!important;
    border-radius:18px!important;
    background:var(--glass)!important;
    box-shadow:0 10px 34px rgba(0,0,0,.44),inset 0 1px rgba(255,255,255,.045)!important;
    backdrop-filter:blur(22px) saturate(145%)!important;
    z-index:120!important;
  }
  .bottom-nav button {
    display:flex!important;
    min-width:0!important;
    min-height:0!important;
    height:100%!important;
    padding:3px 1px!important;
    gap:3px!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    border:1px solid transparent!important;
    border-radius:12px!important;
    color:var(--muted)!important;
    font-size:9px!important;
    font-weight:800!important;
    line-height:1.05!important;
    white-space:nowrap!important;
    touch-action:manipulation;
  }
  .bottom-nav button .icon {
    display:grid!important;
    place-items:center;
    width:27px!important;
    height:24px!important;
    border-radius:8px!important;
    font-size:17px!important;
    background:transparent!important;
    color:inherit!important;
  }
  .bottom-nav button.active {
    color:var(--accent-ink)!important;
    background:var(--surface-2)!important;
    border-color:var(--line)!important;
    box-shadow:inset 0 1px rgba(255,255,255,.06)!important;
  }
  .bottom-nav button.active .icon {
    color:var(--accent-bright)!important;
    background:var(--surface-3)!important;
  }
}

/* Family Mobile compact header: keep identity and connection status readable. */
@media (max-width:760px) {
  .app-header {
    gap:8px!important;
    padding-inline:10px!important;
  }
  .app-header .brand {
    flex:1 1 auto!important;
    min-width:0!important;
    max-width:190px;
    gap:8px!important;
  }
  .app-header .brand-mark {
    flex:0 0 38px!important;
    width:38px!important;
    height:38px!important;
  }
  .app-header .brand-copy { min-width:0!important; }
  .app-header .brand-name {
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    font-size:14px!important;
  }
  .app-header .brand-sub {
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    font-size:7px!important;
  }
  .app-header .header-spacer { flex:1 1 0!important;min-width:0!important; }
  .app-header #account-badge,
  .app-header #install-btn { display:none!important; }
  .app-header #connection-badge {
    flex:0 0 auto;
    max-width:126px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    padding:6px 9px!important;
    font-size:9px!important;
  }
}


/* KAIZO FAMILY MOBILE v61 — adaptive viewport, composer clearance and chat drawer. */
.mobile-menu-toggle {
  display:none;
  flex:0 0 40px;
  width:40px;
  height:40px;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  color:var(--text);
  border:1px solid var(--line-strong);
  background:linear-gradient(145deg,rgba(255,255,255,.10),rgba(255,255,255,.035));
  box-shadow:inset 0 1px rgba(255,255,255,.10),0 5px 18px rgba(0,0,0,.20);
  font-size:18px;
  line-height:1;
  touch-action:manipulation;
}
.mobile-menu-toggle:active { transform:scale(.96); }

.mobile-drawer-backdrop {
  position:fixed;
  inset:0;
  z-index:300;
  background:rgba(1,3,10,.66);
  backdrop-filter:blur(5px);
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transition:opacity .18s ease,visibility .18s ease;
}
.mobile-drawer {
  position:fixed;
  z-index:301;
  top:0;
  left:0;
  display:flex;
  flex-direction:column;
  width:min(88vw,390px);
  height:var(--kz-viewport-height,100dvh);
  max-height:var(--kz-viewport-height,100dvh);
  padding:calc(12px + env(safe-area-inset-top,0px)) 14px calc(12px + env(safe-area-inset-bottom,0px));
  overflow:hidden;
  color:var(--text);
  background:linear-gradient(160deg,rgba(24,18,41,.985),rgba(9,12,24,.99));
  border-right:1px solid var(--line-strong);
  box-shadow:22px 0 70px rgba(0,0,0,.52);
  transform:translateX(-105%);
  visibility:hidden;
  pointer-events:none;
  transition:transform .2s ease,visibility .2s ease;
}
body.mobile-drawer-open .mobile-drawer-backdrop {
  opacity:1;
  visibility:visible;
  pointer-events:auto;
}
body.mobile-drawer-open .mobile-drawer {
  transform:translateX(0);
  visibility:visible;
  pointer-events:auto;
}
.mobile-drawer-head {
  display:flex;
  flex:0 0 auto;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:48px;
  margin-bottom:13px;
}
.mobile-drawer-brand { display:flex;align-items:center;gap:10px;min-width:0; }
.mobile-drawer-mark {
  display:grid;place-items:center;flex:0 0 38px;width:38px;height:38px;
  border-radius:13px;color:white;font-size:19px;font-weight:900;
  background:linear-gradient(145deg,#ba8bff,#7440d2 60%,#354d9a);
  box-shadow:0 7px 24px rgba(134,82,224,.35),inset 0 1px rgba(255,255,255,.3);
}
.mobile-drawer-brand b {display:block;font-size:14px;letter-spacing:.08em;}
.mobile-drawer-brand small {display:block;color:var(--muted);font-size:10px;margin-top:1px;}
.mobile-drawer-close {
  display:grid;place-items:center;flex:0 0 38px;width:38px;height:38px;
  border:1px solid var(--line-strong);border-radius:50%;
  color:var(--text-soft);background:rgba(255,255,255,.05);
  font-size:25px;line-height:1;
}
.mobile-drawer-new {
  flex:0 0 auto;width:100%;min-height:46px;margin-bottom:16px;
  border:1px solid rgba(192,153,255,.42);border-radius:13px;
  color:#fff;font-size:13px;font-weight:800;
  background:linear-gradient(110deg,rgba(132,80,218,.55),rgba(47,105,172,.28));
  box-shadow:inset 0 1px rgba(255,255,255,.12);
}
.mobile-drawer-section {display:flex;flex:1 1 0;flex-direction:column;min-height:0;margin-bottom:12px;}
.mobile-drawer-section-title {
  display:flex;flex:0 0 auto;align-items:center;justify-content:space-between;
  margin:0 3px 8px;color:var(--muted);font-size:9px;font-weight:900;letter-spacing:.15em;
}
.mobile-drawer-section-title span:last-child {
  display:inline-grid;place-items:center;min-width:22px;height:21px;padding:0 6px;
  border:1px solid var(--line);border-radius:99px;background:rgba(255,255,255,.05);
  letter-spacing:0;font-size:10px;
}
.mobile-drawer-chat-list {
  display:flex;flex:1 1 auto;flex-direction:column;gap:5px;
  min-height:70px;max-height:none;overflow-x:hidden;overflow-y:auto;
  padding:5px;border:1px solid var(--line);border-radius:14px;
  background:rgba(4,7,16,.36);overscroll-behavior:contain;
  scrollbar-width:thin;-webkit-overflow-scrolling:touch;
}
.mobile-drawer-chat-list .chat-entry {flex:0 0 auto;min-height:42px;grid-template-columns:minmax(0,1fr) 30px 30px;}
.mobile-drawer-chat-list .chat-entry-open {font-size:12px;padding:8px 7px;}
.mobile-drawer-chat-list .chat-entry-pin,
.mobile-drawer-chat-list .chat-entry-more {width:29px;height:30px;}
.mobile-drawer-navigation {flex:0 0 auto;display:grid;grid-template-columns:1fr 1fr;gap:5px;margin-top:2px;}
.mobile-drawer-navigation .mobile-drawer-section-title {grid-column:1/-1;}
.mobile-drawer-navigation button {
  display:flex;align-items:center;gap:8px;min-height:39px;padding:6px 10px;
  border:1px solid var(--line);border-radius:11px;
  color:var(--text-soft);text-align:left;font-size:12px;font-weight:700;
  background:rgba(255,255,255,.035);
}
.mobile-drawer-navigation button span {color:var(--text);font-size:12px;}
.mobile-drawer-navigation button:active {background:var(--surface-2);}
.mobile-drawer-foot {
  flex:0 0 auto;padding:10px 3px 0;border-top:1px solid var(--line);
  color:var(--muted-2);font-size:9px;letter-spacing:.04em;
}
#mobile-drawer[aria-hidden="true"] {pointer-events:none;}
#mobile-drawer-backdrop[aria-hidden="true"] {pointer-events:none;}

@media (max-width:1100px) {
  html[data-platform="mobile"] {
    --kz-mobile-header:60px;
    --kz-mobile-nav:70px;
  }
  html[data-platform="mobile"] body {
    display:flex!important;
    flex-direction:column!important;
    width:100%!important;
    height:var(--kz-viewport-height,100dvh)!important;
    min-height:0!important;
    max-height:var(--kz-viewport-height,100dvh)!important;
    padding:0!important;
    margin:0!important;
    overflow:hidden!important;
    overscroll-behavior:none;
  }
  html[data-platform="mobile"] .app-header {
    position:relative!important;
    display:flex!important;
    flex:0 0 var(--kz-mobile-header)!important;
    width:100%!important;
    height:var(--kz-mobile-header)!important;
    min-height:var(--kz-mobile-header)!important;
    max-height:var(--kz-mobile-header)!important;
    padding:0 10px!important;
    gap:8px!important;
  }
  html[data-platform="mobile"] .mobile-menu-toggle {display:flex!important;}
  html[data-platform="mobile"] .app-header .brand {
    flex:1 1 auto!important;min-width:0!important;max-width:230px!important;
    gap:8px!important;
  }
  html[data-platform="mobile"] .app-header .brand-copy {min-width:0!important;}
  html[data-platform="mobile"] .app-header .brand-name,
  html[data-platform="mobile"] .app-header .brand-sub {
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  }
  html[data-platform="mobile"] .app-header .brand-name {font-size:14px!important;}
  html[data-platform="mobile"] .app-header .brand-sub {font-size:7px!important;}
  html[data-platform="mobile"] .app-header .brand-mark {width:36px!important;height:36px!important;flex-basis:36px!important;}
  html[data-platform="mobile"] .app-header .header-spacer {flex:1 1 0!important;min-width:0!important;}
  html[data-platform="mobile"] .app-header #account-badge,
  html[data-platform="mobile"] .app-header #install-btn {display:none!important;}
  html[data-platform="mobile"] .app-header #connection-badge {
    flex:0 1 auto!important;max-width:112px!important;overflow:hidden;
    text-overflow:ellipsis;white-space:nowrap;padding:5px 8px!important;font-size:9px!important;
  }
  html[data-platform="mobile"] .layout {
    display:block!important;flex:0 0 auto!important;
    width:100%!important;
    height:calc(var(--kz-viewport-height,100dvh) - var(--kz-mobile-header) - var(--kz-mobile-nav) - env(safe-area-inset-bottom,0px) - 10px)!important;
    min-height:0!important;max-height:none!important;
    margin:0!important;padding:0!important;overflow:hidden!important;
  }
  html[data-platform="mobile"] .sidebar {display:none!important;}
  html[data-platform="mobile"] .main {
    display:block!important;width:100%!important;max-width:none!important;
    height:100%!important;min-width:0!important;min-height:0!important;max-height:100%!important;
    margin:0!important;padding:0!important;overflow-x:hidden!important;overflow-y:auto!important;
    overscroll-behavior:contain;scrollbar-width:none;
  }
  html[data-platform="mobile"] .main::-webkit-scrollbar {display:none;}
  html[data-platform="mobile"] .mobile-chat-history {display:none!important;}
  html[data-platform="mobile"] #view-chat.active {
    display:flex!important;flex-direction:column!important;
    width:100%!important;height:100%!important;min-height:0!important;max-height:100%!important;
    overflow:hidden!important;gap:0!important;
    padding:6px 10px 5px!important;margin:0!important;
  }
  html[data-platform="mobile"] #view-chat .view-head {
    display:flex!important;flex:0 0 auto!important;align-items:center!important;
    gap:7px!important;margin:0 0 4px!important;padding:3px 2px 6px!important;
    background:transparent!important;border:0!important;box-shadow:none!important;
  }
  html[data-platform="mobile"] #view-chat .view-head h1 {font-size:21px!important;margin:0!important;}
  html[data-platform="mobile"] #view-chat .view-head .row {gap:4px!important;}
  html[data-platform="mobile"] #view-chat .view-head .row button {
    min-height:32px!important;padding:4px 7px!important;font-size:9px!important;
  }
  html[data-platform="mobile"] #view-chat .messages {
    display:flex!important;flex:1 1 0!important;width:100%!important;height:0!important;
    min-height:0!important;max-height:none!important;overflow-x:hidden!important;overflow-y:auto!important;
    padding:8px 5px 10px!important;gap:11px!important;
    border:0!important;border-radius:0!important;background:transparent!important;box-shadow:none!important;
    overscroll-behavior:contain;
  }
  html[data-platform="mobile"] #view-chat .composer {
    display:block!important;position:static!important;flex:0 0 auto!important;
    width:100%!important;min-width:0!important;margin:4px 0 0!important;
    padding:4px 0 0!important;background:transparent!important;z-index:5;
  }
  html[data-platform="mobile"] #view-chat .composer-box {
    display:flex!important;align-items:flex-end!important;width:100%!important;min-width:0!important;
    min-height:52px!important;padding:5px!important;gap:5px!important;border-radius:15px!important;
  }
  html[data-platform="mobile"] #view-chat .composer-box textarea {
    flex:1 1 auto!important;min-width:0!important;width:0!important;
    min-height:40px!important;max-height:22dvh!important;padding:8px 6px!important;
    font-size:16px!important;line-height:1.4!important;overflow-y:auto!important;
  }
  html[data-platform="mobile"] #view-chat .composer-box .attach,
  html[data-platform="mobile"] #view-chat .composer-box .voice-dictate,
  html[data-platform="mobile"] #view-chat .composer-box #send {
    flex:0 0 auto!important;min-height:40px!important;height:40px!important;
  }
  html[data-platform="mobile"] #view-chat .composer-box #send {padding:0 10px!important;font-size:11px!important;}
  html[data-platform="mobile"] #view-chat .composer .hint {display:none!important;}
  html[data-platform="mobile"] #view-chat #chat-usage {margin:2px 2px 0!important;font-size:9px!important;line-height:1.2!important;}
  html[data-platform="mobile"] .bottom-nav {
    position:fixed!important;display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr))!important;
    align-items:stretch!important;gap:3px!important;left:8px!important;right:8px!important;
    bottom:calc(4px + env(safe-area-inset-bottom,0px))!important;width:auto!important;
    height:var(--kz-mobile-nav)!important;min-height:var(--kz-mobile-nav)!important;max-height:var(--kz-mobile-nav)!important;
    padding:5px 6px!important;margin:0!important;border:1px solid var(--line-strong)!important;
    border-radius:17px!important;background:var(--glass)!important;
    box-shadow:0 9px 30px rgba(0,0,0,.42),inset 0 1px rgba(255,255,255,.05)!important;
    backdrop-filter:blur(20px) saturate(140%)!important;z-index:120!important;
  }
  html[data-platform="mobile"] .bottom-nav button {
    display:flex!important;min-width:0!important;min-height:0!important;height:100%!important;
    padding:2px 1px!important;gap:3px!important;flex-direction:column!important;
    align-items:center!important;justify-content:center!important;border:1px solid transparent!important;
    border-radius:11px!important;color:var(--muted)!important;font-size:9px!important;
    font-weight:800!important;line-height:1.05!important;white-space:nowrap!important;
    touch-action:manipulation;
  }
  html[data-platform="mobile"] .bottom-nav button .icon {
    display:grid!important;place-items:center;width:25px!important;height:22px!important;
    border-radius:8px!important;font-size:16px!important;background:transparent!important;color:inherit!important;
  }
  html[data-platform="mobile"] .bottom-nav button.active {
    color:var(--accent-ink)!important;background:var(--surface-2)!important;
    border-color:var(--line)!important;box-shadow:inset 0 1px rgba(255,255,255,.06)!important;
  }
  html[data-platform="mobile"] .bottom-nav button.active .icon {
    color:var(--accent-bright)!important;background:var(--surface-3)!important;
  }
  html[data-platform="mobile"] body.keyboard-open .layout {
    height:calc(var(--kz-viewport-height,100dvh) - var(--kz-mobile-header) - 7px)!important;
    max-height:none!important;
  }
  html[data-platform="mobile"] body.keyboard-open .bottom-nav {display:none!important;}
  html[data-platform="mobile"] body.keyboard-open #view-chat.active {padding-bottom:4px!important;}
}

@media (horizontal-viewport-segments: 2) and (max-width:1100px) {
  html[data-platform="mobile"] .mobile-drawer {
    width:min(88vw,env(viewport-segment-width 0 0,390px));
    left:env(viewport-segment-left 0 0,0px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-drawer,.mobile-drawer-backdrop,.mobile-menu-toggle {transition:none!important;}
}


/* First-time family login must sit above navigation and remain usable on short phones. */
body.login-open .bottom-nav {display:none!important;}
@media (max-width:1100px) {
  html[data-platform="mobile"] .modal {
    z-index:500!important;
    padding:calc(7px + env(safe-area-inset-top,0px)) 10px calc(7px + env(safe-area-inset-bottom,0px))!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
  }
  html[data-platform="mobile"] .modal.show {
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
  }
  html[data-platform="mobile"] .modal .card {
    width:min(470px,100%)!important;
    max-height:calc(var(--kz-viewport-height,100dvh) - 14px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))!important;
    margin:auto!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
  }
  html[data-platform="mobile"] #login-modal .card {padding:14px 15px!important;border-radius:17px!important;}
  html[data-platform="mobile"] #login-modal .modal-mark {
    width:40px!important;height:40px!important;margin:0 auto 8px!important;
    border-radius:12px!important;font-size:20px!important;
  }
  html[data-platform="mobile"] #login-modal h2 {font-size:19px!important;line-height:1.2!important;margin-bottom:6px!important;}
  html[data-platform="mobile"] #login-modal #login-description {
    font-size:11px!important;line-height:1.4!important;margin-bottom:7px!important;
  }
  html[data-platform="mobile"] #login-modal #privacy-warning {
    padding:8px 9px!important;margin:6px 0!important;font-size:10px!important;line-height:1.38!important;
  }
  html[data-platform="mobile"] #login-modal label {margin:7px 0 4px!important;font-size:11px!important;}
  html[data-platform="mobile"] #login-modal #invite-input {
    min-height:41px!important;height:41px!important;padding:8px 10px!important;font-size:14px!important;
  }
  html[data-platform="mobile"] #login-modal .family-invite-help {
    margin:6px 0!important;font-size:10px!important;line-height:1.35!important;
  }
  html[data-platform="mobile"] #login-modal #google-login,
  html[data-platform="mobile"] #login-modal #login-retry,
  html[data-platform="mobile"] #login-modal .family-install-action {
    min-height:42px!important;padding:8px 10px!important;font-size:11px!important;
  }
}


/* Keep the user's last prompt available while a long assistant answer is on screen. */
.last-user-context { display:none; }
@media (max-width:1100px) {
  html[data-platform="mobile"] #view-chat .last-user-context:not([hidden]) {
    display:flex!important;
    flex:0 0 auto!important;
    align-items:center!important;
    gap:7px!important;
    width:100%!important;
    min-width:0!important;
    min-height:31px!important;
    max-height:31px!important;
    margin:0 0 5px!important;
    padding:3px 7px!important;
    overflow:hidden!important;
    border:1px solid var(--line)!important;
    border-radius:10px!important;
    background:var(--surface-2)!important;
  }
  html[data-platform="mobile"] .last-user-context-label {
    flex:0 0 auto!important;
    color:var(--accent-bright)!important;
    font-size:8px!important;
    font-weight:950!important;
    letter-spacing:.12em!important;
  }
  html[data-platform="mobile"] #last-user-context-button {
    display:flex!important;
    flex:1 1 auto!important;
    align-items:center!important;
    justify-content:space-between!important;
    gap:8px!important;
    width:100%!important;
    min-width:0!important;
    min-height:22px!important;
    max-height:22px!important;
    padding:0!important;
    overflow:hidden!important;
    color:var(--text-soft)!important;
    text-align:left!important;
    font-size:10px!important;
    line-height:1.25!important;
    background:transparent!important;
    border:0!important;
    box-shadow:none!important;
  }
  html[data-platform="mobile"] #last-user-context-text {
    display:block!important;
    flex:1 1 auto!important;
    min-width:0!important;
    overflow:hidden!important;
    white-space:nowrap!important;
    text-overflow:ellipsis!important;
  }
  html[data-platform="mobile"] .last-user-context-arrow {
    flex:0 0 auto!important;
    color:var(--accent-bright)!important;
    font-size:14px!important;
    font-weight:900!important;
  }
  html[data-platform="mobile"] #view-chat .messages {
    scroll-behavior:auto!important;
    scroll-padding-bottom:10px!important;
  }
}


/* KAIZO FAMILY v65: keep the invitation dialog inside narrow phone viewports. */
@media (max-width:1100px) {
  html[data-platform="mobile"] .modal {
    display:none;
    position:fixed!important;
    inset:0!important;
    width:100vw!important;
    max-width:100vw!important;
    height:var(--kz-viewport-height,100dvh)!important;
    max-height:var(--kz-viewport-height,100dvh)!important;
    box-sizing:border-box!important;
    padding:calc(10px + env(safe-area-inset-top,0px)) 12px calc(10px + env(safe-area-inset-bottom,0px))!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
  }
  html[data-platform="mobile"] .modal.show {
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
  }
  html[data-platform="mobile"] .modal .card {
    display:block!important;
    flex:0 1 auto!important;
    width:100%!important;
    min-width:0!important;
    max-width:460px!important;
    max-height:calc(var(--kz-viewport-height,100dvh) - 24px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))!important;
    box-sizing:border-box!important;
    margin:0 auto!important;
    padding:17px 15px!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
  }
  html[data-platform="mobile"] .modal .card *,
  html[data-platform="mobile"] .modal .card input,
  html[data-platform="mobile"] .modal .card button {
    box-sizing:border-box!important;
    min-width:0!important;
    max-width:100%!important;
    overflow-wrap:anywhere;
  }
  html[data-platform="mobile"] #login-modal .family-login-actions {
    display:flex!important;
    flex-direction:column!important;
    align-items:stretch!important;
    width:100%!important;
    gap:8px!important;
  }
  html[data-platform="mobile"] #login-modal .family-login-actions button {
    display:block!important;
    width:100%!important;
    min-height:44px!important;
    white-space:normal!important;
    line-height:1.35!important;
    padding:10px 12px!important;
  }
  html[data-platform="mobile"] #login-modal .family-login-actions button[hidden] {display:none!important;}
  html[data-platform="mobile"] #login-modal h2 {font-size:19px!important;line-height:1.25!important;}
  html[data-platform="mobile"] #login-modal p {line-height:1.4!important;overflow-wrap:anywhere;}
  html[data-platform="mobile"] .app-header #install-btn:not([hidden]) {
    display:inline-flex!important;
    flex:0 0 auto!important;
    align-items:center!important;
    justify-content:center!important;
    width:auto!important;
    max-width:100px!important;
    min-width:70px!important;
    min-height:34px!important;
    padding:5px 9px!important;
    margin:0!important;
    border-radius:999px!important;
    font-size:10px!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
  html[data-platform="mobile"] .app-header .brand {flex:1 1 auto!important;min-width:0!important;}
  html[data-platform="mobile"] .app-header .header-spacer {flex:0 1 8px!important;min-width:0!important;}
  html[data-platform="mobile"] .app-header #connection-badge {
    max-width:78px!important;
    flex:0 1 auto!important;
    font-size:8px!important;
    padding:4px 6px!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
  html[data-platform="mobile"] #view-settings #install-btn-settings {
    display:block!important;
    width:100%!important;
    min-height:46px!important;
    padding:10px 14px!important;
    white-space:normal!important;
  }
  html[data-platform="mobile"] #view-settings #download-mobile[hidden],
  html[data-platform="mobile"] #view-settings #download-mobile-help[hidden] {display:none!important;}
}
@media (max-width:420px) {
  html[data-platform="mobile"] .modal {padding-left:10px!important;padding-right:10px!important;}
  html[data-platform="mobile"] .modal .card {padding:15px 13px!important;}
  html[data-platform="mobile"] .app-header {gap:5px!important;padding-left:8px!important;padding-right:8px!important;}
  html[data-platform="mobile"] .app-header .brand-name {font-size:12px!important;}
  html[data-platform="mobile"] .app-header #install-btn:not([hidden]) {min-width:64px!important;max-width:74px!important;font-size:9px!important;}
}


/* Hard viewport width clamp for embedded Android browsers and narrow phones. */
@media (max-width:1100px) {
  html[data-platform="mobile"] .modal {
    left:0!important;
    right:0!important;
    width:100%!important;
    max-width:100%!important;
    padding-left:12px!important;
    padding-right:12px!important;
  }
  html[data-platform="mobile"] #login-modal .card {
    width:calc(100vw - 32px)!important;
    max-width:460px!important;
    min-width:0!important;
    margin-left:auto!important;
    margin-right:auto!important;
  }
  html[data-platform="mobile"] #login-modal .card > *,
  html[data-platform="mobile"] #login-modal .card p,
  html[data-platform="mobile"] #login-modal .card a,
  html[data-platform="mobile"] #login-modal .card label {
    max-width:100%!important;
    min-width:0!important;
    white-space:normal!important;
    overflow-wrap:anywhere!important;
  }
  html[data-platform="mobile"] #login-modal #invite-input {
    display:block!important;
    width:100%!important;
    max-width:100%!important;
  }
}
@media (max-width:420px) {
  html[data-platform="mobile"] #login-modal .card {
    width:calc(100vw - 24px)!important;
  }
}

/* Final clamp for invite screen on compact browsers with an oversized layout viewport. */
@media (max-width:1100px) {
  html[data-platform="mobile"] #login-modal .card {
    width:calc(100vw - 64px)!important;
    max-width:460px!important;
    min-width:256px!important;
    margin-inline:auto!important;
  }
}


/* KAIZO 3.5.4 - dashboard overlap guard: fluid columns, wrapping and safe card sizing. */
#view-home {
  width:100%;
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}
#view-home > * { min-width:0; max-width:100%; }
#view-home .hero {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  width:100%;
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}
#view-home .hero-copy {
  flex:1 1 360px;
  width:auto;
  min-width:0;
  max-width:100%;
}
#view-home .hero h1,
#view-home .hero p {
  max-width:100%;
  overflow-wrap:anywhere;
}
#view-home .hero .row {
  display:flex;
  flex-wrap:wrap;
  align-items:stretch;
  min-width:0;
  max-width:100%;
}
#view-home .hero .row > button {
  flex:0 1 auto;
  min-width:0;
  max-width:100%;
  white-space:normal;
  line-height:1.3;
}
#view-home .hero-orbit {
  flex:0 1 160px;
  min-width:0;
  max-width:100%;
}
#view-home .stats {
  grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr));
  min-width:0;
}
#view-home .mobile-workspace {
  grid-template-columns:minmax(0,1.35fr) minmax(280px,.85fr);
  width:100%;
  min-width:0;
  max-width:100%;
}
#view-home .mobile-launch-section,
#view-home .mobile-side-stack,
#view-home .mobile-side-stack > *,
#view-home .recent-panel,
#view-home .platform-note {
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}
#view-home .quick-grid {
  grid-template-columns:repeat(2,minmax(0,1fr));
  min-width:0;
}
#view-home .quick-tile {
  width:100%;
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
  overflow-wrap:anywhere;
}
#view-home .quick-tile b,
#view-home .quick-tile small {
  display:block;
  width:100%;
  min-width:0;
  max-width:100%;
  white-space:normal;
  overflow-wrap:anywhere;
  word-break:normal;
}
#view-home .quick-tile small { line-height:1.35; }
#view-home .section-head {
  min-width:0;
  flex-wrap:wrap;
  justify-content:space-between;
}
#view-home .section-head > div { min-width:0; max-width:100%; }
#view-home .recent-panel,
#view-home .platform-note {
  width:100%;
  margin-bottom:0;
}
#view-home .recent-list { width:100%; min-width:0; }
#view-home .recent-item {
  width:100%;
  min-width:0;
  flex-wrap:wrap;
}
#view-home .recent-item .recent-title {
  min-width:0;
  white-space:normal;
  overflow-wrap:anywhere;
  line-height:1.35;
  display:-webkit-box;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;
}
#view-home .recent-item .recent-time { margin-left:auto; flex:0 0 auto; }

@media (min-width:761px) and (max-width:1100px) {
  #view-home .mobile-workspace { grid-template-columns:minmax(0,1fr); gap:14px; }
  #view-home .mobile-side-stack { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #view-home .hero-orbit { flex-basis:130px; width:130px; height:130px; }
}
@media (max-width:760px) {
  #view-home .mobile-workspace { grid-template-columns:minmax(0,1fr); }
  #view-home .mobile-side-stack { grid-template-columns:minmax(0,1fr); }
  #view-home .hero { flex-direction:column; align-items:stretch; gap:8px; }
  #view-home .hero-copy { flex:0 1 auto; width:100%; }
  #view-home .hero-orbit {
    display:flex;
    width:100%;
    flex:0 0 76px;
    height:76px;
    margin-top:0;
  }
  #view-home .hero .row > button { flex:1 1 150px; }
  #view-home .quick-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:380px) {
  #view-home .quick-grid { grid-template-columns:minmax(0,1fr); }
  #view-home .hero .row > button { flex-basis:100%; }
}


/* KAIZO 3.5.4 - Family dashboard: prevent action buttons and note from colliding. */
#view-home .family-mobile-dashboard {
  width:100%;
  min-width:0;
  max-width:820px;
  box-sizing:border-box;
  overflow:visible;
}
#view-home .family-mobile-dashboard > * {
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}
#view-home .family-mobile-dashboard h2,
#view-home .family-mobile-dashboard > p {
  max-width:100%;
  overflow-wrap:anywhere;
}
#view-home .family-dashboard-actions {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  align-items:stretch;
  gap:10px;
  width:100%;
  min-width:0;
  max-width:100%;
}
#view-home .family-dashboard-actions button {
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-width:0;
  max-width:100%;
  min-height:48px;
  height:auto;
  padding:10px 12px;
  box-sizing:border-box;
  white-space:normal;
  overflow-wrap:anywhere;
  word-break:normal;
  text-align:center;
  line-height:1.25;
}
#view-home .family-dashboard-note {
  width:100%;
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
  overflow-wrap:anywhere;
  line-height:1.5;
}
@media (max-width:380px) {
  #view-home .family-dashboard-actions {
    grid-template-columns:minmax(0,1fr);
    gap:8px;
  }
  #view-home .family-dashboard-actions button {
    min-height:44px;
    padding:10px 12px;
  }
}


#view-home .mobile-workspace:has(> .family-mobile-dashboard) {
  grid-template-columns:minmax(0,1fr);
}
#view-home .mobile-workspace > .family-mobile-dashboard {
  grid-column:1 / -1;
  justify-self:stretch;
  width:100%;
}


#view-home .mobile-workspace > .family-mobile-dashboard {
  max-width:100%;
}


/* Kaizo 3.5 v80: stable sidebar chat rows and actions. */
@media (min-width: 900px) {
  .sidebar { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
  .sidebar > .side-label, .sidebar > button[data-view], .sidebar > .chat-history-title, .sidebar > .side-note { flex-shrink: 0; min-width: 0; }
  .sidebar > button[data-view] { min-height: 42px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar .chat-list { width: 100%; min-width: 0; flex: 0 0 auto; gap: 4px; overflow-x: hidden; }
  .sidebar .chat-entry { display: grid; grid-template-columns: minmax(0, 1fr) 28px 28px; align-items: center; gap: 3px; width: 100%; min-width: 0; min-height: 42px; height: 42px; padding: 3px; box-sizing: border-box; }
  .sidebar .chat-entry > .chat-entry-open { display: flex; align-items: center; justify-content: flex-start; width: 100%; min-width: 0; max-width: 100%; min-height: 0; height: 30px; margin: 0; padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; line-height: 1.25; }
  .sidebar .chat-entry > .chat-entry-pin { display: grid; place-items: center; justify-self: center; width: 26px; min-width: 26px; max-width: 26px; height: 28px; min-height: 28px; margin: 0; padding: 0; line-height: 1; }
  .sidebar .chat-entry > .chat-entry-menu-wrap { position: relative; display: grid; place-items: center; justify-self: center; width: 28px; min-width: 28px; height: 28px; min-height: 28px; margin: 0; padding: 0; }
  .sidebar .chat-entry .chat-entry-menu-wrap > .chat-entry-more { display: grid; place-items: center; width: 26px; min-width: 26px; max-width: 26px; height: 28px; min-height: 28px; margin: 0; padding: 0; line-height: 1; }
  .sidebar .chat-entry-menu { right: 0; left: auto; max-width: calc(100vw - 32px); white-space: normal; }
  .sidebar .side-spacer { flex: 1 0 12px; }
  .sidebar .side-note { flex: 0 0 auto; overflow-wrap: anywhere; }
}


/* First-run legal onboarding */
#terms-modal{z-index:1200}#terms-modal .terms-card{width:min(720px,calc(100vw - 28px));max-height:min(88vh,900px);overflow:auto;padding:26px}#terms-modal .terms-document{max-height:32vh;overflow:auto;padding:16px;margin:14px 0;border:1px solid var(--line-strong);border-radius:14px;background:var(--surface-2);line-height:1.55}#terms-modal .terms-document h3{margin-top:0}#terms-modal .terms-check{display:flex;align-items:flex-start;gap:10px;margin:12px 0;line-height:1.45}#terms-modal .terms-check input{flex:0 0 auto;margin-top:3px}#terms-confirm{width:100%;margin-top:12px;min-height:46px}#terms-confirm:disabled{opacity:.45;cursor:not-allowed}.sidebar [data-game-lab].active{border-color:var(--accent)!important;background:var(--surface-2);box-shadow:inset 3px 0 0 var(--accent-bright)}@media(max-width:760px){#terms-modal .terms-card{padding:19px 16px}#terms-modal .terms-document{max-height:27vh}}
