/* =========================================================================
   MyAI Personal Assistant
   Light glass interface on deep navy / electric blue / cyan.
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  --navy-950: #041240;
  --navy-900: #071a52;
  --navy-800: #0a2a86;
  --blue-600: #1462ff;
  --blue-500: #2b7cff;
  --cyan-400: #22c8f5;
  --cyan-300: #6fe3ff;

  --bg: #e8f0fd;
  --ink: #0a1637;
  --ink-2: #26345a;
  --muted: #5b6a8d;
  --line: rgba(20, 70, 180, 0.11);
  --line-strong: rgba(20, 70, 180, 0.2);

  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --glass-edge: rgba(255, 255, 255, 0.95);
  --field: #ffffff;
  --hover: rgba(20, 98, 255, 0.07);
  --active: rgba(20, 98, 255, 0.11);

  --grad-primary: linear-gradient(135deg, #2a74ff 0%, #0f55ea 55%, #0b45d0 100%);
  --grad-name: linear-gradient(92deg, #0f5bff 0%, #1f86ff 55%, #22b9f2 100%);
  --shadow-panel: 0 1px 1px rgba(10, 40, 120, 0.04), 0 14px 34px -14px rgba(18, 60, 170, 0.22);
  --shadow-lift: 0 18px 40px -16px rgba(18, 60, 170, 0.32);
  --glow: 0 10px 26px -8px rgba(20, 98, 255, 0.6);

  --r-xl: 26px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --header-h: 84px;
  --bn-h: 66px;
  --font: 'Plus Jakarta Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* tile colours: [deep, bright, tint] */
  --c-blue-1: #1460f5; --c-blue-2: #3b8bff; --c-blue-t: #e6efff;
  --c-purple-1: #5b3df2; --c-purple-2: #8a67ff; --c-purple-t: #efebff;
  --c-green-1: #10a14a; --c-green-2: #2fd06d; --c-green-t: #e4f8ec;
  --c-orange-1: #f2570f; --c-orange-2: #ff8b3d; --c-orange-t: #fff0e4;
  --c-pink-1: #e8246d; --c-pink-2: #ff5996; --c-pink-t: #ffe8f1;
  --c-yellow-1: #f08a00; --c-yellow-2: #ffc021; --c-yellow-t: #fff6de;
  --c-red-1: #e3263b; --c-red-2: #ff6168; --c-red-t: #ffeaea;
  --c-violet-1: #6c3ef0; --c-violet-2: #a07bff; --c-violet-t: #f1eaff;
  --c-magenta-1: #c21ee0; --c-magenta-2: #ec5cff; --c-magenta-t: #fbe9ff;
  --c-slate-1: #24356b; --c-slate-2: #4a63a8; --c-slate-t: #e8edf8;
  --c-indigo-1: #3346e0; --c-indigo-2: #6a7bff; --c-indigo-t: #e9ecff;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #050d2b;
  --ink: #e9f0ff;
  --ink-2: #c3d1f3;
  --muted: #8d9cc4;
  --line: rgba(120, 160, 255, 0.13);
  --line-strong: rgba(120, 160, 255, 0.24);
  --glass: rgba(14, 30, 82, 0.58);
  --glass-strong: rgba(16, 34, 92, 0.9);
  --glass-edge: rgba(130, 170, 255, 0.16);
  --field: rgba(8, 20, 60, 0.8);
  --hover: rgba(100, 160, 255, 0.1);
  --active: rgba(100, 160, 255, 0.16);
  --shadow-panel: 0 1px 1px rgba(0, 0, 0, 0.2), 0 18px 40px -18px rgba(0, 0, 0, 0.6);
  --shadow-lift: 0 18px 40px -16px rgba(0, 0, 0, 0.65);
  --grad-name: linear-gradient(92deg, #5aa2ff 0%, #4fc3ff 55%, #7ee8ff 100%);
  --c-slate-1: #3c5296; --c-slate-2: #8ea4e8;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 8% 12%, rgba(70, 140, 255, 0.2), transparent 62%),
    radial-gradient(760px 560px at 96% 92%, rgba(34, 200, 245, 0.16), transparent 62%),
    radial-gradient(700px 420px at 55% 55%, rgba(120, 170, 255, 0.12), transparent 70%),
    linear-gradient(180deg, #e7effe 0%, #f2f6ff 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(900px 520px at 8% 12%, rgba(30, 90, 255, 0.28), transparent 62%),
    radial-gradient(760px 560px at 96% 92%, rgba(20, 170, 230, 0.18), transparent 62%),
    linear-gradient(180deg, #061033 0%, #040b24 100%);
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
code { font-family: var(--mono); font-size: 0.88em; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--blue-600); color: #fff; padding: 10px 16px; border-radius: 10px; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid rgba(34, 200, 245, 0.75); outline-offset: 2px; border-radius: 8px; }
.ic { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.pad { padding: 12px 4px; }
.mono { font-family: var(--mono); font-size: 14px; }
.noscript { padding: 24px; text-align: center; }

/* ---------- Header ---------- */
.topbar {
  position: relative;
  z-index: 30;
  flex: none;
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 28px 0 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #fff;
  background:
    radial-gradient(520px 170px at 70% 20%, rgba(82, 170, 255, 0.55), transparent 70%),
    radial-gradient(420px 120px at 58% 110%, rgba(34, 200, 245, 0.42), transparent 70%),
    radial-gradient(300px 140px at 92% 0%, rgba(60, 120, 255, 0.5), transparent 70%),
    linear-gradient(100deg, #051446 0%, #08237a 38%, #0d49cf 66%, #0a2d94 100%);
  border-bottom: 1px solid rgba(120, 200, 255, 0.35);
  box-shadow: 0 10px 30px -12px rgba(8, 36, 140, 0.65);
  overflow: hidden;
}
.topbar::before { /* light streaks */
  content: '';
  position: absolute; inset: 0;
  background:
    linear-gradient(112deg, transparent 52%, rgba(255, 255, 255, 0.13) 57%, transparent 62%),
    linear-gradient(112deg, transparent 63%, rgba(120, 220, 255, 0.16) 66%, transparent 70%),
    linear-gradient(112deg, transparent 74%, rgba(255, 255, 255, 0.08) 76%, transparent 79%);
  pointer-events: none;
}
.topbar > * { position: relative; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 58px; height: 58px; display: grid; place-items: center; color: var(--cyan-300);
  filter: drop-shadow(0 0 10px rgba(80, 210, 255, 0.85)) drop-shadow(0 0 2px rgba(150, 230, 255, 0.9));
}
.brand-mark .ic { width: 52px; height: 52px; stroke-width: 1.55; }
.brand-mark.small { width: 34px; height: 34px; color: var(--blue-500); filter: drop-shadow(0 0 6px rgba(43, 124, 255, 0.5)); }
.brand-mark.small .ic { width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text strong { font-size: 38px; font-weight: 800; letter-spacing: -0.03em; }
.brand-text strong span {
  background: linear-gradient(180deg, #8eefff 0%, #34b8ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text small { font-size: 15px; font-weight: 500; margin-top: 4px; opacity: 0.92; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 44px; }
.theme-toggle {
  display: flex; gap: 6px; padding: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(140, 195, 255, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.theme-toggle button {
  width: 50px; height: 40px; border-radius: 999px; display: grid; place-items: center; color: rgba(255, 255, 255, 0.9);
  transition: background 0.2s, box-shadow 0.2s;
}
.theme-toggle button[aria-pressed="true"] {
  background: radial-gradient(circle at 50% 50%, rgba(110, 190, 255, 0.55), rgba(40, 110, 255, 0.35));
  box-shadow: 0 0 16px rgba(80, 170, 255, 0.7), inset 0 0 0 1px rgba(170, 220, 255, 0.5);
}
.theme-toggle .ic { width: 22px; height: 22px; }
.profile { display: flex; align-items: center; gap: 12px; color: #fff; padding: 6px 8px 6px 6px; border-radius: 999px; }
.profile:hover { background: rgba(255, 255, 255, 0.08); }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: #fff; color: var(--navy-900); display: grid; place-items: center; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18); }
.avatar .ic { width: 28px; height: 28px; stroke-width: 2.2; }
.profile-name { font-size: 19px; font-weight: 600; }
.profile-chev { width: 20px; height: 20px; }

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 328px;
  gap: 20px;
  padding: 14px 18px 16px 16px;
}
body:not([data-view="home"]):not([data-view="chat"]) .layout { grid-template-columns: 268px minmax(0, 1fr); }
body:not([data-view="home"]):not([data-view="chat"]) .rightbar { display: none; }

.sidebar, .rightbar, .main { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(20, 98, 255, 0.25) transparent; }
.main { outline: none; overscroll-behavior: contain; padding: 0 2px; overflow-x: hidden; }

.glass-panel, .panel, .sidebar {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-panel);
}

/* ---------- Sidebar ---------- */
.sidebar { border-radius: var(--r-xl); padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; }
.drawer-head { display: none; flex: none; }
.btn-new-chat {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  height: 54px; padding: 0 20px; border-radius: 14px;
  background: var(--grad-primary); color: #fff; font-weight: 600; font-size: 17px;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.15s, box-shadow 0.2s;
}
.btn-new-chat:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -8px rgba(20, 98, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn-new-chat .ic { width: 24px; height: 24px; }
.nav-list { flex: none; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 16px;
  min-height: 48px; padding: 0 14px; border-radius: 12px;
  color: var(--ink-2); font-size: 16.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item .ic { color: var(--ink); width: 23px; height: 23px; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--active); color: var(--blue-600); font-weight: 600; }
.nav-item.active .ic { color: var(--blue-600); }
:root[data-theme="dark"] .nav-item.active, :root[data-theme="dark"] .nav-item.active .ic { color: #7fb4ff; }

/* ---------- Tiles ---------- */
.tile {
  --t1: var(--c-blue-1); --t2: var(--c-blue-2); --tt: var(--c-blue-t);
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  color: var(--t1); background: var(--tt);
}
.tile .ic { width: 22px; height: 22px; }
.tile-xs { width: 24px; height: 24px; border-radius: 7px; } .tile-xs .ic { width: 14px; height: 14px; }
.tile-sm { width: 40px; height: 40px; }
.tile-md { width: 48px; height: 48px; border-radius: 13px; } .tile-md .ic { width: 26px; height: 26px; }
.tile-lg, .tile-xl {
  width: 54px; height: 54px; border-radius: 13px; color: #fff;
  background: linear-gradient(145deg, var(--t2) 0%, var(--t1) 100%);
  box-shadow: 0 8px 18px -8px var(--t1), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.tile-lg .ic { width: 28px; height: 28px; }
.tile-xl { width: 72px; height: 72px; border-radius: 18px; } .tile-xl .ic { width: 36px; height: 36px; }
.tile-md { color: #fff; background: linear-gradient(145deg, var(--t2), var(--t1)); box-shadow: 0 8px 18px -10px var(--t1); }
:root[data-theme="dark"] .tile:not(.tile-lg):not(.tile-xl):not(.tile-md) { background: color-mix(in srgb, var(--t1) 22%, transparent); color: var(--t2); }

.tile-blue { --t1: var(--c-blue-1); --t2: var(--c-blue-2); --tt: var(--c-blue-t); }
.tile-purple { --t1: var(--c-purple-1); --t2: var(--c-purple-2); --tt: var(--c-purple-t); }
.tile-green { --t1: var(--c-green-1); --t2: var(--c-green-2); --tt: var(--c-green-t); }
.tile-orange { --t1: var(--c-orange-1); --t2: var(--c-orange-2); --tt: var(--c-orange-t); }
.tile-pink { --t1: var(--c-pink-1); --t2: var(--c-pink-2); --tt: var(--c-pink-t); }
.tile-yellow { --t1: var(--c-yellow-1); --t2: var(--c-yellow-2); --tt: var(--c-yellow-t); }
.tile-red { --t1: var(--c-red-1); --t2: var(--c-red-2); --tt: var(--c-red-t); }
.tile-violet { --t1: var(--c-violet-1); --t2: var(--c-violet-2); --tt: var(--c-violet-t); }
.tile-magenta { --t1: var(--c-magenta-1); --t2: var(--c-magenta-2); --tt: var(--c-magenta-t); }
.tile-slate { --t1: var(--c-slate-1); --t2: var(--c-slate-2); --tt: var(--c-slate-t); }
.tile-indigo { --t1: var(--c-indigo-1); --t2: var(--c-indigo-2); --tt: var(--c-indigo-t); }

/* ---------- Home ---------- */
.home { display: flex; flex-direction: column; gap: 14px; padding-bottom: 10px; }
.hero { position: relative; border-radius: var(--r-xl); padding: 44px 14px 14px; overflow: hidden; }
.hero-glow {
  position: absolute; inset: 0 0 auto 0; height: 300px; pointer-events: none;
  background:
    radial-gradient(48% 70% at 0% 0%, rgba(40, 120, 255, 0.34), transparent 70%),
    radial-gradient(40% 80% at 100% 0%, rgba(30, 140, 255, 0.42), transparent 70%),
    radial-gradient(30% 50% at 82% 30%, rgba(34, 200, 245, 0.22), transparent 70%);
  filter: blur(6px);
}
.hero-glow::after { /* soft light ribbon across the top */
  content: ''; position: absolute; left: -10%; right: -10%; top: 18px; height: 120px;
  background: linear-gradient(100deg, transparent 10%, rgba(255, 255, 255, 0.55) 45%, rgba(170, 220, 255, 0.35) 60%, transparent 85%);
  border-radius: 50%; transform: rotate(-4deg); filter: blur(18px); opacity: 0.7;
}
:root[data-theme="dark"] .hero-glow::after { opacity: 0.12; }
.hero-head { position: relative; text-align: center; padding: 0 16px 34px; }
.greet { font-size: clamp(34px, 4.2vw, 62px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.05; color: var(--ink); }
.grad-text { background: var(--grad-name); -webkit-background-clip: text; background-clip: text; color: transparent; }
.greet-sub { margin-top: 12px; font-size: clamp(20px, 2.1vw, 33px); font-weight: 500; letter-spacing: -0.015em; color: var(--ink); }
.greet-desc { margin: 16px auto 0; max-width: 72ch; font-size: 17px; color: var(--ink-2); }

.feature-grid { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.feature, .tpl {
  --t1: var(--c-blue-1); --tt: var(--c-blue-t);
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 160px; padding: 18px 18px 16px; border-radius: 18px; text-align: left;
  background: linear-gradient(165deg, var(--tt) 0%, color-mix(in srgb, var(--tt) 45%, #ffffff) 100%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.feature:hover, .tpl:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.feature .tile, .tpl .tile { margin-bottom: 14px; }
.feature strong, .tpl strong { font-size: 17.5px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.feature-desc { font-size: 15.5px; color: var(--muted); line-height: 1.4; }
:root[data-theme="dark"] .feature, :root[data-theme="dark"] .tpl {
  background: linear-gradient(165deg, color-mix(in srgb, var(--t1) 24%, transparent), color-mix(in srgb, var(--t1) 8%, transparent));
  border-color: color-mix(in srgb, var(--t1) 30%, transparent);
  box-shadow: none;
}
.card-blue { --t1: var(--c-blue-1); --tt: var(--c-blue-t); }
.card-purple { --t1: var(--c-purple-1); --tt: var(--c-purple-t); }
.card-green { --t1: var(--c-green-1); --tt: var(--c-green-t); }
.card-orange { --t1: var(--c-orange-1); --tt: var(--c-orange-t); }
.card-pink { --t1: var(--c-pink-1); --tt: var(--c-pink-t); }
.card-yellow { --t1: var(--c-yellow-1); --tt: var(--c-yellow-t); }
.card-red { --t1: var(--c-red-1); --tt: var(--c-red-t); }
.card-violet { --t1: var(--c-violet-1); --tt: var(--c-violet-t); }
.card-slate { --t1: var(--c-slate-1); --tt: var(--c-slate-t); }

.home-extras { display: none; }

/* ---------- Composer ---------- */
.composer {
  padding: 6px; border-radius: 22px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-panel);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
:root[data-theme="dark"] .composer { background: rgba(20, 40, 100, 0.4); }
.composer-inner {
  background: var(--glass-strong); border-radius: 17px; padding: 16px 14px 12px 20px;
  box-shadow: 0 6px 20px -12px rgba(20, 60, 170, 0.35);
  border: 1px solid transparent; transition: border-color 0.2s, box-shadow 0.2s;
}
.composer-inner:focus-within { border-color: rgba(43, 124, 255, 0.45); box-shadow: 0 0 0 4px rgba(43, 124, 255, 0.12), 0 6px 20px -12px rgba(20, 60, 170, 0.35); }
.composer textarea {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent;
  font-size: 18px; line-height: 1.5; min-height: 46px; max-height: 240px; padding: 0 4px; color: var(--ink);
}
.composer textarea::placeholder { color: var(--muted); }
.composer-actions { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.grow { flex: 1; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 11px;
  color: var(--ink-2); font-size: 15px; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.chip-btn .ic { width: 21px; height: 21px; }
.chip-btn:hover { background: var(--hover); }
.chip-btn.on { background: rgba(20, 98, 255, 0.12); color: var(--blue-600); }
:root[data-theme="dark"] .chip-btn.on { color: #8ec0ff; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--active); color: var(--blue-600); font-size: 13.5px; font-weight: 600; }
.mode-pill .ic { width: 16px; height: 16px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; display: inline-grid; place-items: center; color: var(--ink-2); flex: none;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--hover); }
.mic-btn .ic { width: 26px; height: 26px; color: var(--blue-600); }
.mic-btn.recording { background: rgba(255, 70, 90, 0.12); }
.mic-btn.recording .ic { color: #e5263b; }
.mic-btn.recording::after { content: ''; position: absolute; }
.mic-btn.recording { animation: pulse 1.4s ease-out infinite; }
.send-btn {
  width: 62px; height: 52px; border-radius: 15px; display: grid; place-items: center; flex: none;
  background: var(--grad-primary); color: #fff;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.2s;
}
.send-btn .ic { width: 26px; height: 26px; stroke-width: 2.1; fill: rgba(255, 255, 255, 0.95); }
.send-btn:hover:not(:disabled) { transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.72; cursor: default; }
.send-btn.stop { background: linear-gradient(135deg, #0d1f5c, #1a3a99); }
.send-btn.stop .ic { fill: #fff; }
.att-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 5px 6px 5px 6px; border-radius: 10px; background: var(--hover); border: 1px solid var(--line); font-size: 13.5px;
}
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-weight: 500; }
.att-chip small { color: var(--muted); }
.att-chip button { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.att-chip button:hover { background: var(--active); }
.att-chip button .ic { width: 15px; height: 15px; }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229, 38, 59, 0.35); } 100% { box-shadow: 0 0 0 14px rgba(229, 38, 59, 0); } }

/* ---------- Model selector ---------- */
.model-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 2px 0; }
.model-label { font-size: 16.5px; font-weight: 600; color: var(--ink); }
.model-chips { display: flex; gap: 14px; flex: 1; min-width: 0; }
.model-chip {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; height: 60px; border-radius: 15px;
  background: var(--glass-strong); border: 1.5px solid var(--glass-edge); box-shadow: var(--shadow-panel);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.model-chip.active { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(43, 124, 255, 0.12), 0 10px 26px -12px rgba(20, 98, 255, 0.55); }
.mc-main { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 10px; padding: 0 4px 0 12px; border-radius: 14px 0 0 14px; }
.mc-label { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-chip.active .mc-label { color: var(--blue-600); }
:root[data-theme="dark"] .model-chip.active .mc-label { color: #8ec0ff; }
.mc-caret { width: 36px; height: 100%; display: grid; place-items: center; color: var(--muted); border-radius: 0 14px 14px 0; }
.mc-caret:hover, .mc-main:hover { background: var(--hover); }
.model-chip.more .mc-main { border-radius: 14px; padding-right: 14px; color: var(--ink-2); }
.model-chip.more .mc-main > .ic:first-child { color: var(--ink-2); }
.model-chip.more .mc-label { font-weight: 500; font-size: 15px; flex: 1; text-align: left; }
.mc-chev { width: 18px; height: 18px; color: var(--muted); }
.model-mobile { display: none; }
.model-hint { font-size: 12px; color: var(--muted); padding: 3px 8px; border-radius: 999px; border: 1px dashed var(--line-strong); }
.ptile { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 19px; }
.ptile .ic { width: 22px; height: 22px; }
.ptile-openai { background: linear-gradient(145deg, #3f86ff, #1250e6); color: #fff; box-shadow: 0 6px 14px -6px #1250e6; }
.ptile-google { background: #fff; border: 1px solid var(--line); }
.ptile-google b { background: conic-gradient(from -45deg, #ea4335 0 25%, #4285f4 0 50%, #34a853 0 75%, #fbbc05 0); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 22px; }
.ptile-anthropic { background: #f0dcc4; color: #2b1a0e; }
.ptile-generic { background: var(--active); color: var(--blue-600); }

/* ---------- Right sidebar panels ---------- */
.rightbar { display: flex; flex-direction: column; gap: 20px; }
.panel { border-radius: var(--r-lg); padding: 18px 18px 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.link-btn { color: var(--blue-600); font-weight: 600; font-size: 15.5px; padding: 4px 6px; border-radius: 8px; }
.link-btn:hover { background: var(--hover); }
:root[data-theme="dark"] .link-btn { color: #7fb4ff; }
.qt-list { display: flex; flex-direction: column; }
.qt-item {
  display: flex; align-items: center; gap: 18px; min-height: 54px; padding: 6px 4px; text-align: left;
  border-bottom: 1px solid var(--line); border-radius: 0; transition: background 0.15s;
}
.qt-item:last-child { border-bottom: 0; }
.qt-item:hover { background: var(--hover); border-radius: 10px; }
.qt-label { flex: 1; font-size: 16px; font-weight: 500; color: var(--ink); }
.qt-chev { width: 20px; height: 20px; color: var(--ink-2); }
.rc-list { display: flex; flex-direction: column; gap: 2px; }
.chat-row { display: flex; align-items: center; gap: 4px; border-radius: 12px; transition: background 0.15s; }
.chat-row:hover { background: var(--hover); }
.chat-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 9px 6px; }
.chat-row-ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: rgba(20, 98, 255, 0.08); color: var(--ink-2); }
.chat-row-ic.tile { border-radius: 11px; }
.chat-row-ic .ic { width: 21px; height: 21px; }
.chat-row-text { display: flex; flex-direction: column; min-width: 0; }
.chat-row-text strong { font-size: 15.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-text small { font-size: 13.5px; color: var(--muted); }
.kebab { width: 36px; height: 40px; }
.rc-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 18px 8px 14px; color: var(--muted); }
.rc-empty > .ic { width: 30px; height: 30px; color: var(--blue-500); }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; font-weight: 600; font-size: 15.5px; white-space: nowrap;
  transition: background 0.15s, transform 0.15s, box-shadow 0.2s;
}
.btn .ic { width: 20px; height: 20px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-sm .ic { width: 17px; height: 17px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--grad-primary); color: #fff; box-shadow: var(--glow); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-soft { background: rgba(20, 98, 255, 0.1); color: var(--blue-600); }
.btn-soft:hover { background: rgba(20, 98, 255, 0.16); }
:root[data-theme="dark"] .btn-soft { color: #9cc7ff; background: rgba(100, 160, 255, 0.14); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: #e3263b; color: #fff; }
.btn-danger:hover { background: #c81d31; }
.btn-danger-soft { background: rgba(227, 38, 59, 0.1); color: #d0182d; }
:root[data-theme="dark"] .btn-danger-soft { color: #ff8a95; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; border: 0; padding: 0; min-width: 0; }
.field > span, .field legend { font-size: 14px; font-weight: 600; color: var(--ink-2); padding: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; margin: 0; }
.input {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 12px;
  background: var(--field); border: 1px solid var(--line-strong); color: var(--ink); font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { resize: vertical; line-height: 1.5; }
.input:focus { outline: 0; border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(43, 124, 255, 0.15); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6a8d' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px; }
.seg { display: flex; gap: 6px; padding: 4px; border-radius: 13px; background: var(--hover); border: 1px solid var(--line); }
.seg-opt, .seg-btn { flex: 1; position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; }
.seg-opt span, .seg-btn {
  display: grid; place-items: center; min-height: 40px; padding: 0 12px; border-radius: 10px;
  font-size: 14.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg-opt input:checked + span, .seg-btn.on { background: var(--glass-strong); color: var(--blue-600); box-shadow: 0 4px 12px -6px rgba(20, 60, 170, 0.4); }
.seg-opt input:focus-visible + span { outline: 3px solid rgba(34, 200, 245, 0.75); }
:root[data-theme="dark"] .seg-opt input:checked + span, :root[data-theme="dark"] .seg-btn.on { color: #9cc7ff; }

/* ---------- Chat view ---------- */
.chat-view { height: 100%; display: flex; flex-direction: column; gap: 14px; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: var(--r-lg);
  background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-panel);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
.chat-head .back-btn { display: none; }
.chat-head-text { flex: 1; min-width: 0; }
.chat-title { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.chat-sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-wrap {
  position: relative; flex: 1; min-height: 0; border-radius: var(--r-xl);
  background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-panel);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); overflow: hidden;
}
.thread { height: 100%; overflow-y: auto; padding: 26px 28px 18px; display: flex; flex-direction: column; gap: 22px; scroll-behavior: auto; overscroll-behavior: contain; }
.jump-btn {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lift); color: var(--blue-600);
}
.chat-intro { margin: auto; max-width: 640px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 0; }
.chat-intro h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; }
.chat-intro p { color: var(--ink-2); font-size: 16.5px; }
.suggest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; margin-top: 16px; }
.suggest {
  text-align: left; padding: 13px 15px; border-radius: 14px; font-size: 15px; font-weight: 500; color: var(--ink-2);
  background: var(--glass-strong); border: 1px solid var(--line); transition: border-color 0.15s, background 0.15s;
}
.suggest:hover { border-color: rgba(43, 124, 255, 0.45); background: var(--field); }
.suggest.small { padding: 8px 12px; font-size: 13.5px; border-radius: 999px; }

.msg { display: flex; gap: 12px; max-width: 860px; width: 100%; margin: 0 auto; }
.msg-user { flex-direction: column; align-items: flex-end; }
.bubble {
  max-width: min(78%, 640px); padding: 13px 17px; border-radius: 20px 20px 6px 20px;
  background: var(--grad-primary); color: #fff; box-shadow: 0 10px 24px -14px rgba(20, 98, 255, 0.8);
}
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; }
.bubble .att-chip { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.msg-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.msg-ai { align-items: flex-start; }
.ai-avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #1c6dff, #0a2a86); box-shadow: 0 6px 16px -6px rgba(20, 98, 255, 0.7);
}
.ai-avatar .ic { width: 24px; height: 24px; stroke-width: 1.7; color: #b9f1ff; }
.ai-body { flex: 1; min-width: 0; }
.ai-meta { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.ai-meta span { color: var(--muted); font-size: 12.5px; padding: 1px 8px; border-radius: 999px; background: var(--hover); }
.msg-actions { display: flex; gap: 2px; margin-top: 6px; opacity: 0.85; }
.msg-user .msg-actions { opacity: 0; transition: opacity 0.15s; margin-top: 2px; }
.msg-user:hover .msg-actions, .msg-user:focus-within .msg-actions { opacity: 1; }
.act { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 9px; border-radius: 9px; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.act:hover { background: var(--hover); color: var(--ink); }
.act .ic { width: 17px; height: 17px; }
.act.copied { color: #10a14a; }
.typing { display: inline-flex; gap: 5px; padding: 12px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-500); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.is-streaming .md > :last-child::after { content: ''; display: inline-block; width: 8px; height: 18px; margin-left: 3px; vertical-align: -3px; background: var(--blue-500); border-radius: 2px; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.msg-error {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; padding: 12px 14px; border-radius: 14px;
  background: rgba(227, 38, 59, 0.07); border: 1px solid rgba(227, 38, 59, 0.22); color: #b4172a; font-size: 14.5px;
}
:root[data-theme="dark"] .msg-error { color: #ff9aa4; }
.msg-error > span { flex: 1; min-width: 180px; }
.msg-error.block { margin: 0 0 14px; }
.msg-note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.edit-box { width: min(100%, 640px); display: flex; flex-direction: column; gap: 8px; }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.source { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 5px 10px; border-radius: 999px; background: var(--hover); font-size: 13px; color: var(--blue-600); }
.source span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source .ic { width: 14px; height: 14px; }

/* Markdown */
.md { font-size: 16px; line-height: 1.65; color: var(--ink); overflow-wrap: anywhere; }
.md > * + * { margin-top: 0.75em; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; letter-spacing: -0.01em; margin-top: 1.1em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; }
.md ul, .md ol { padding-left: 1.4em; margin-bottom: 0; }
.md li + li { margin-top: 0.3em; }
.md a { color: var(--blue-600); text-decoration: underline; text-underline-offset: 2px; }
.md blockquote { margin-left: 0; padding: 4px 0 4px 14px; border-left: 3px solid var(--blue-500); color: var(--ink-2); }
.md :not(pre) > code { padding: 2px 6px; border-radius: 6px; background: rgba(20, 98, 255, 0.08); color: #0b3fb8; }
:root[data-theme="dark"] .md :not(pre) > code { color: #a8d0ff; background: rgba(100, 160, 255, 0.14); }
.md hr { border: 0; border-top: 1px solid var(--line-strong); }
.table-scroll { overflow-x: auto; max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.md table, .data-table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.md th, .md td, .data-table th, .data-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.md th, .data-table th { background: var(--hover); font-weight: 700; }
.code-block { border-radius: 14px; overflow: hidden; background: #0a1637; border: 1px solid rgba(80, 130, 255, 0.25); }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; background: rgba(255, 255, 255, 0.05); color: #a9bce8; font-size: 12.5px; font-family: var(--mono); }
.code-copy { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 8px; color: #c9d7f7; font-family: var(--font); font-size: 12.5px; }
.code-copy:hover { background: rgba(255, 255, 255, 0.1); }
.code-copy .ic { width: 15px; height: 15px; }
.code-copy.copied { color: #4ade80; }
.md pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: #dbe6ff; font-size: 13.5px; line-height: 1.6; }
.md pre code { font-family: var(--mono); background: none; padding: 0; color: inherit; }
/* highlight.js tokens (inline so no external stylesheet is needed) */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-type { color: #7cc4ff; }
.hljs-string, .hljs-attr-value, .hljs-template-tag, .hljs-regexp { color: #9be59b; }
.hljs-number, .hljs-literal, .hljs-symbol { color: #ffb86b; }
.hljs-comment, .hljs-quote { color: #7383aa; font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #6fe3ff; }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-variable, .hljs-params { color: #f2c6ff; }
.hljs-meta, .hljs-tag, .hljs-name { color: #ff8fb1; }
.hljs-addition { color: #9be59b; } .hljs-deletion { color: #ff8a8a; }

/* ---------- Pages (history, files, settings, tools) ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 6px 4px 28px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 10px; }
.page-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
.page-sub { color: var(--ink-2); margin-top: 4px; font-size: 16px; }
.page-title-row { display: flex; align-items: center; gap: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2, .small-head { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.small-head { margin-bottom: 10px; }
.search-box { position: relative; }
.search-box > .ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.search-box .input { padding-left: 46px; min-height: 52px; border-radius: 14px; background: var(--glass-strong); }
.search-box.compact .input { min-height: 46px; }
.history-list { padding: 10px 12px; }
.group-label { font-size: 13.5px; font-weight: 700; color: var(--muted); padding: 14px 8px 6px; }
.group-label:first-child { padding-top: 4px; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 36px 16px; }
.empty h3 { font-size: 19px; font-weight: 700; margin-top: 6px; }
.empty p { color: var(--muted); max-width: 42ch; }
.empty .btn { margin-top: 8px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.row-actions.start { justify-content: flex-start; }

/* Images */
.img-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; }
.img-form { padding: 20px; }
.idea-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; }
.img-preview { padding: 18px; display: flex; flex-direction: column; justify-content: center; min-height: 380px; }
.img-result { margin: 0; }
.img-result img { width: 100%; border-radius: 16px; box-shadow: var(--shadow-lift); }
.img-result figcaption { margin-top: 10px; font-size: 14px; color: var(--muted); }
.img-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted); }
.shimmer { width: 100%; aspect-ratio: 1; max-height: 340px; border-radius: 16px; background: linear-gradient(110deg, var(--hover) 30%, rgba(43, 124, 255, 0.22) 50%, var(--hover) 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.img-card { margin: 0; border-radius: 16px; overflow: hidden; background: var(--glass-strong); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-panel); }
.img-card img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; }
.img-card figcaption { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 12px; font-size: 13px; }
.img-card figcaption > span:first-child { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.img-card-acts { display: flex; } .img-card-acts .icon-btn { width: 36px; height: 36px; }

/* Analysis workspaces */
.an-layout { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 18px; align-items: start; }
.an-pick { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.an-ask { padding: 18px; display: flex; flex-direction: column; gap: 16px; min-height: 360px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  min-height: 210px; padding: 22px; border-radius: 18px; cursor: pointer;
  border: 2px dashed rgba(43, 124, 255, 0.35); background: rgba(43, 124, 255, 0.04);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.big { min-height: 300px; }
.dropzone:hover, .dropzone.over, .files-panel.over { border-color: var(--blue-500); background: rgba(43, 124, 255, 0.09); }
.dropzone strong { font-size: 16px; }
.dropzone small { color: var(--muted); }
.or-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or-row::before, .or-row::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }
.an-file { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--line); }
.pick-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick-text strong { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-text small { color: var(--muted); font-size: 13px; }
.doc-peek h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; overflow-wrap: anywhere; }
.doc-peek pre { margin: 10px 0 0; max-height: 260px; overflow: auto; padding: 14px; border-radius: 12px; background: var(--hover); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.doc-peek img { max-height: 300px; border-radius: 12px; margin: 0 auto; }
.doc-peek.center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 24px 0; }
.doc-peek .table-scroll { margin-top: 10px; max-height: 300px; overflow: auto; }
.an-input { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.an-input .input { flex: 1; resize: none; }

/* Voice */
.voice-panel { padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 760px; width: 100%; margin: 0 auto; }
.voice-top { align-self: stretch; display: flex; justify-content: flex-end; }
.voice-top .input { width: auto; }
.mic-hero {
  position: relative; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 35% 30%, #6aa6ff, #1462ff 55%, #0a2a86);
  box-shadow: 0 20px 44px -14px rgba(20, 98, 255, 0.85), inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
.mic-hero .ic { width: 52px; height: 52px; position: relative; }
.mic-hero:disabled { opacity: 0.5; }
.mic-rings { position: absolute; inset: 0; border-radius: 50%; }
.mic-hero.live { background: radial-gradient(circle at 35% 30%, #ff8a95, #e3263b 55%, #8a0f1e); box-shadow: 0 20px 44px -14px rgba(227, 38, 59, 0.8); }
.mic-hero.live .mic-rings { animation: rings 1.6s ease-out infinite; }
@keyframes rings { 0% { box-shadow: 0 0 0 0 rgba(227, 38, 59, 0.4), 0 0 0 0 rgba(227, 38, 59, 0.25); } 100% { box-shadow: 0 0 0 22px rgba(227, 38, 59, 0), 0 0 0 44px rgba(227, 38, 59, 0); } }
.voice-status { color: var(--muted); font-weight: 500; }
.voice-text { min-height: 180px; }
.voice-panel .row-actions { align-self: stretch; }

/* Files */
.files-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.files-tools > * { min-width: 0; max-width: 100%; }
.files-tools .seg { flex: 1 1 380px; }
.files-tools .search-box { flex: 1 1 240px; }
.files-panel { padding: 8px; }
.file-table { display: flex; flex-direction: column; }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) 100px 170px auto; align-items: center; gap: 14px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: 0; }
.file-row.head { font-size: 13px; font-weight: 700; color: var(--muted); padding-top: 8px; padding-bottom: 8px; }
.file-row:not(.head):hover { background: var(--hover); border-radius: 12px; }
.file-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-name > span { display: flex; flex-direction: column; min-width: 0; }
.file-name strong { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row > span:not(.file-name):not(.file-acts) { font-size: 14px; color: var(--ink-2); }
.file-acts { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.only-mobile { display: none; }
.storage-note { display: flex; align-items: center; gap: 8px; }
.storage-note .ic { width: 16px; height: 16px; }
.pick-list, .check-list { display: flex; flex-direction: column; gap: 6px; }
.pick-row, .check-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; border: 1px solid var(--line); }
.pick-row:hover, .check-row:hover { background: var(--hover); }
.pick-row input, .check-row input { width: 20px; height: 20px; accent-color: var(--blue-600); flex: none; }

/* Templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tpl { min-height: 160px; }

/* Settings */
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.set-card { padding: 20px; }
.set-card h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.set-card h2 .ic { width: 20px; height: 20px; color: var(--blue-600); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-text { display: flex; flex-direction: column; min-width: 0; }
.set-text strong { font-size: 15px; font-weight: 600; }
.set-text small { color: var(--muted); font-size: 13px; }
.set-state { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.set-state .ic { color: #10a14a; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; flex: none; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); transition: transform 0.2s; }
.switch:checked { background: var(--blue-600); }
.switch:checked::after { transform: translateX(20px); }
.conn-status { margin-top: 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.conn-status .ic { width: 18px; height: 18px; }
.conn-status.ok { color: #10a14a; } .conn-status.bad { color: #d0182d; }
.danger-zone h2 .ic { color: #e3263b; }
.steps { padding-left: 1.3em; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Overlays ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(4, 14, 50, 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 14, 50, 0.42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.2s;
}
.overlay.show { opacity: 1; }
.modal {
  width: min(520px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 22px; box-shadow: 0 30px 80px -20px rgba(4, 20, 80, 0.55);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  transform: translateY(10px) scale(0.98); transition: transform 0.22s;
}
:root[data-theme="dark"] .modal { background: rgba(12, 26, 72, 0.96); }
.overlay.show .modal { transform: none; }
.modal-wide { width: min(760px, 100%); }
.sheet-grip { display: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 8px 22px; }
.modal-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.modal-body { padding: 8px 22px 12px; overflow-y: auto; }
.modal-text { color: var(--ink-2); margin-bottom: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 18px; }
.menu-pop {
  position: fixed; z-index: 120; min-width: 230px; max-width: 320px; max-height: 70vh; overflow-y: auto; padding: 6px;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 16px; box-shadow: 0 20px 50px -14px rgba(4, 20, 80, 0.45);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  opacity: 0; transform: translateY(-4px); transition: opacity 0.14s, transform 0.14s;
}
:root[data-theme="dark"] .menu-pop { background: rgba(12, 26, 72, 0.97); }
.menu-pop.show { opacity: 1; transform: none; }
.menu-title { padding: 8px 12px 6px; font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-heading { padding: 10px 12px 4px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.menu-item { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 12px; border-radius: 10px; text-align: left; font-size: 15px; font-weight: 500; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item > .ic { width: 20px; height: 20px; color: var(--ink-2); }
.menu-item .ptile { width: 30px; height: 30px; font-size: 15px; border-radius: 8px; }
.menu-item .ptile .ic { width: 17px; height: 17px; }
.menu-label { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.menu-label small { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.menu-item.checked { color: var(--blue-600); }
.menu-check { width: 18px !important; height: 18px !important; color: var(--blue-600) !important; }
.menu-item.danger, .menu-item.danger > .ic { color: #d0182d; }
.menu-divider { height: 1px; margin: 6px 8px; background: var(--line-strong); }
.sheet-list { margin: 0 -10px; }
.toasts { position: fixed; z-index: 150; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 14px; font-size: 14.5px; font-weight: 500;
  background: #0b1a4d; color: #fff; box-shadow: 0 16px 40px -12px rgba(4, 20, 80, 0.6);
  opacity: 0; transform: translateY(10px); transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast .ic { width: 18px; height: 18px; color: var(--cyan-300); }
.toast-error .ic { color: #ff8a95; }
.toast-success .ic { color: #4ade80; }

/* ---------- Bottom nav (phones) ---------- */
.bottom-nav { display: none; }
.topbar .topbar-menu, .topbar .theme-flip { display: none; color: #fff; }

/* =========================================================================
   Responsive
   ========================================================================= */

/* Large laptops: tighten the right column */
@media (max-width: 1440px) {
  .layout { grid-template-columns: 248px minmax(0, 1fr) 300px; gap: 16px; }
  body:not([data-view="home"]):not([data-view="chat"]) .layout { grid-template-columns: 248px minmax(0, 1fr); }
  .feature { min-height: 160px; padding: 18px 16px 16px; }
  .feature strong { font-size: 17px; }
  .feature-desc { font-size: 14.5px; }
  .qt-item { gap: 14px; }
  .model-chips { gap: 10px; }
  .model-chip.more { flex: none; }
  .model-chip.more .mc-label { display: none; }
  .mc-caret { width: 30px; }
  .ptile { width: 34px; height: 34px; }
  .mc-main { gap: 8px; padding-left: 10px; }
  .topbar-right { gap: 28px; }
}

/* Small laptops: right column moves into the home page */
@media (max-width: 1279px) {
  .layout, body:not([data-view="home"]):not([data-view="chat"]) .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .rightbar { display: none; }
  .home-extras { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .model-chip { height: 58px; }
}

/* Phones and small tablets: app layout */
@media (max-width: 1023px) {
  :root { --header-h: 62px; }
  body { background-attachment: scroll; }
  .topbar { padding: env(safe-area-inset-top, 0px) 10px 0 6px; gap: 6px; }
  .topbar .topbar-menu { display: inline-grid; }
  .topbar-menu:hover { background: rgba(255, 255, 255, 0.1); }
  .brand { gap: 8px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-mark .ic { width: 34px; height: 34px; }
  .brand-text strong { font-size: 25px; }
  .brand-text small { font-size: 11px; margin-top: 2px; }
  .topbar-right { gap: 4px; }
  .theme-toggle { display: none; }
  .topbar .theme-flip { display: inline-grid; }
  .theme-flip:hover { background: rgba(255, 255, 255, 0.1); }
  .profile { padding: 4px; }
  .profile-name, .profile-chev { display: none; }
  .avatar { width: 38px; height: 38px; }
  .avatar .ic { width: 22px; height: 22px; }

  .layout, body:not([data-view="home"]):not([data-view="chat"]) .layout { display: block; padding: 0; position: relative; }
  .main { height: 100%; padding: 14px 14px calc(var(--bn-h) + env(safe-area-inset-bottom, 0px) + 18px); }

  /* Drawer */
  .sidebar {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(86vw, 320px);
    border-radius: 0 24px 24px 0; padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px calc(env(safe-area-inset-bottom, 0px) + 16px);
    background: var(--glass-strong); transform: translateX(-104%); transition: transform 0.26s cubic-bezier(.2, .8, .2, 1);
    visibility: hidden;
  }
  :root[data-theme="dark"] .sidebar { background: rgba(10, 22, 64, 0.97); }
  body.drawer-open .sidebar { transform: none; visibility: visible; box-shadow: 20px 0 60px -20px rgba(4, 20, 80, 0.5); }
  .drawer-head { display: flex; align-items: center; gap: 10px; padding: 0 0 4px 4px; }
  .drawer-head strong { font-size: 20px; font-weight: 800; flex: 1; }
  .nav-item { min-height: 50px; }

  /* Bottom navigation */
  .bottom-nav {
    position: fixed; z-index: 35; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    height: calc(var(--bn-h) + env(safe-area-inset-bottom, 0px)); padding: 0 6px env(safe-area-inset-bottom, 0px);
    background: var(--glass-strong); border-top: 1px solid var(--glass-edge);
    box-shadow: 0 -10px 30px -16px rgba(10, 40, 140, 0.35);
    -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  }
  :root[data-theme="dark"] .bottom-nav { background: rgba(8, 20, 60, 0.92); }
  .bn-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%; color: var(--muted); font-size: 11.5px; font-weight: 600; }
  .bn-item .ic { width: 24px; height: 24px; }
  .bn-item.active { color: var(--blue-600); }
  :root[data-theme="dark"] .bn-item.active { color: #8ec0ff; }
  .bn-fab {
    justify-self: center; width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; display: grid; place-items: center; color: #fff;
    background: var(--grad-primary); box-shadow: 0 12px 26px -8px rgba(20, 98, 255, 0.8), 0 0 0 5px var(--bg);
  }
  .bn-fab .ic { width: 28px; height: 28px; stroke-width: 2.4; }
  body[data-view="chat"] .bottom-nav { display: none; }

  /* Home */
  .hero { padding: 30px 12px 12px; border-radius: 24px; }
  .hero-head { padding: 0 6px 24px; }
  .greet-desc { font-size: 15px; margin-top: 12px; }
  .feature-grid { gap: 10px; }
  .feature { min-height: 0; padding: 15px 14px; border-radius: 16px; }
  .feature .tile { margin-bottom: 10px; width: 46px; height: 46px; }
  .feature .tile .ic { width: 24px; height: 24px; }
  .feature strong { font-size: 16px; }
  .feature-desc { font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .home-extras { grid-template-columns: 1fr; }

  /* Composer */
  .composer { padding: 4px; border-radius: 20px; }
  .composer-inner { padding: 12px 10px 8px 14px; border-radius: 16px; }
  .composer textarea { font-size: 16px; min-height: 28px; }
  .chip-btn { padding: 0 10px; height: 42px; }
  .send-btn { width: 52px; height: 48px; border-radius: 14px; }
  .send-btn .ic { width: 23px; height: 23px; }

  /* Model selector: single chip */
  .model-row { gap: 8px; }
  .model-label, .model-chips { display: none; }
  .model-mobile {
    display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px 0 6px; border-radius: 14px;
    background: var(--glass-strong); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-panel); font-weight: 600; font-size: 15px;
  }
  .model-mobile .ptile { width: 34px; height: 34px; font-size: 17px; }
  .model-mobile > .ic { width: 18px; height: 18px; color: var(--muted); }

  /* Chat: full screen, no bottom nav, composer above keyboard */
  body[data-view="chat"] .main { padding: 10px 10px calc(env(safe-area-inset-bottom, 0px) + 8px); }
  .chat-view { gap: 8px; }
  .chat-head { padding: 6px 6px 6px 4px; border-radius: 16px; gap: 8px; }
  .chat-head .back-btn { display: inline-grid; }
  .chat-head .tile { display: none; }
  .chat-title { font-size: 16.5px; }
  .chat-sub { font-size: 12.5px; }
  .thread-wrap { border-radius: 20px; }
  .thread { padding: 16px 12px 12px; gap: 18px; }
  .bubble { max-width: 88%; }
  .msg-user .msg-actions { opacity: 1; }
  .ai-avatar { width: 32px; height: 32px; border-radius: 10px; }
  .ai-avatar .ic { width: 20px; height: 20px; }
  .msg { gap: 9px; }
  .chat-intro h2 { font-size: 23px; }
  .chat-models .model-row { justify-content: center; }

  /* Pages */
  .page { padding: 0 0 12px; gap: 14px; }
  .page-head { padding-top: 2px; }
  .page-head h1 { font-size: 26px; }
  .page-sub { font-size: 14.5px; }
  .page-head .btn { width: 100%; }
  .img-layout, .an-layout, .set-grid { grid-template-columns: 1fr; }
  .img-preview { min-height: 280px; }
  .file-row { grid-template-columns: minmax(0, 1fr) auto; }
  .file-row.head, .hide-mobile { display: none !important; }
  .only-mobile { display: block; }
  .file-name small { color: var(--muted); font-size: 12.5px; }
  .file-acts .btn span { display: none; }
  .file-acts .btn { width: 40px; padding: 0; }
  .seg-scroll { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .seg-scroll::-webkit-scrollbar { display: none; }
  .seg-scroll .seg-btn { flex: none; }
  .files-tools .seg, .files-tools .search-box { flex-basis: 100%; }

  /* Overlays become bottom sheets */
  .overlay { place-items: end center; padding: 0; }
  .modal {
    width: 100%; max-height: 88vh; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(40px);
  }
  .sheet-grip { display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 10px auto 0; }
  .modal-head { padding-top: 6px; }
  .modal-foot .btn { flex: 1; }
  .toasts { bottom: calc(var(--bn-h) + env(safe-area-inset-bottom, 0px) + 14px); }
  body[data-view="chat"] .toasts { bottom: 150px; }
}

@media (max-width: 640px) {
  .feature { flex-direction: row; align-items: center; gap: 11px; padding: 12px; min-height: 66px; }
  .feature .tile { margin: 0; width: 42px; height: 42px; border-radius: 12px; }
  .feature .tile .ic { width: 22px; height: 22px; }
  .feature strong { font-size: 14.5px; line-height: 1.25; }
  .feature-desc { display: none !important; }
  .hero-head { padding-bottom: 20px; }
  .suggest-grid { grid-template-columns: 1fr; }
  .chip-btn span { display: none; }
  .chip-btn { width: 42px; padding: 0; justify-content: center; }
}

@media (max-width: 380px) {
  .feature-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .feature { padding: 13px 11px; }
  .feature strong { font-size: 15px; }
  .brand-text small { display: none; }
}

/* Landscape phones: keep the chat usable */
@media (max-height: 500px) and (max-width: 1023px) {
  .chat-models { display: none; }
  .thread { padding-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

body.offline .send-btn:not(.stop) { opacity: 0.6; }
