:root {
  --bg: #ffffff; --side: #f0f4f9; --surface: #f0f4f9; --surface-2: #e9eef6; --line: #dde3ea;
  --text: #1f1f1f; --muted: #5f6368; --accent: #0b57d0; --accent-soft: #d3e3fd; --orange: #f05a28;
  --user: #e9eef6; --shadow: 0 1px 3px rgba(60,64,67,.15), 0 4px 12px rgba(60,64,67,.08);
  --radius: 24px; --sub: #c4c7c5; --glow: .55; --font: "Inter", "Hind Siliguri", system-ui, sans-serif;
}
:root[data-theme="dark"] { --bg: #131314; --side: #1b1b1c; --surface: #1e1f20; --surface-2: #282a2c; --line: #3c4043;
  --text: #e3e3e3; --muted: #9aa0a6; --accent: #a8c7fa; --accent-soft: #1f3760; --user: #282a2c;
  --shadow: 0 1px 3px rgba(0,0,0,.5); --sub: #444746; --glow: .95; color-scheme: dark; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }

.app { display: grid; grid-template-columns: 280px 1fr; height: 100vh; transition: grid-template-columns .2s ease; }
.app.collapsed { grid-template-columns: 72px 1fr; }

/* ---------- sidebar ---------- */
.sidebar { background: var(--side); display: flex; flex-direction: column; padding: 12px; gap: 6px; min-width: 0; overflow: hidden; }
.side-top { display: flex; align-items: center; height: 40px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.new-chat { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 16px; border: 0; border-radius: 22px;
  background: var(--surface-2); color: var(--text); font-weight: 500; width: fit-content; margin: 6px 0 4px; }
.new-chat:hover { box-shadow: var(--shadow); }
.side-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px; border-radius: 19px; color: var(--muted); }
.side-search:focus-within { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.side-search input { border: 0; background: transparent; outline: 0; color: var(--text); width: 100%; font: inherit; }
.side-label { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 2px; font-size: 13px; font-weight: 500; color: var(--muted); }
.arch { font-size: 12px; display: flex; gap: 4px; align-items: center; cursor: pointer; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 2px; }
.conv { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 20px; cursor: pointer; position: relative; }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--accent-soft); }
.conv .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.conv .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #9aa0a6; }
.conv .more { opacity: 0; width: 28px; height: 28px; }
.conv:hover .more { opacity: 1; }
.dot.s-researching, .dot.s-queued { background: #f9ab00; animation: pulse 1.2s infinite; }
.dot.s-waiting { background: #f05a28; }
.dot.s-confirmed { background: #0b57d0; }
.dot.s-draft, .dot.s-updated { background: #1e8e3e; }
.dot.s-published { background: #a142f4; }
@keyframes pulse { 50% { opacity: .35; } }
.queue-box { background: var(--bg); border-radius: 16px; padding: 10px 12px; font-size: 13px; }
.queue-box ol { margin: 4px 0 0; padding-left: 18px; }
.side-bottom { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; border-top: 1px solid var(--line); }
.side-item { display: flex; align-items: center; gap: 14px; height: 40px; padding: 0 12px; border: 0; background: transparent; border-radius: 20px; color: var(--text); font-size: 14px; text-align: left; }
.side-item:hover { background: var(--surface-2); }
.operator { font-size: 12px; color: var(--muted); padding: 6px 12px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app.collapsed .new-chat span, .app.collapsed .side-search, .app.collapsed .side-label, .app.collapsed .conv-list,
.app.collapsed .side-item span, .app.collapsed .operator, .app.collapsed .queue-box { display: none; }
.app.collapsed .new-chat { width: 44px; padding: 0; justify-content: center; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 600; }
.brand img { width: 40px; height: 40px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: var(--surface); color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.ghost-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line);
  background: transparent; color: var(--text); text-decoration: none; font-size: 14px; }
.ghost-btn:hover { background: var(--surface); }
.ghost-btn svg { width: 18px; height: 18px; }
.banner { margin: 0 auto 6px; max-width: 760px; width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px; background: #fef7e0; color: #5f4b00; font-size: 14px; }
[data-theme="dark"] .banner { background: #3b3000; color: #fde293; }

.scroller { flex: 1; overflow-y: auto; padding: 8px 16px 24px; }
.empty { max-width: 760px; margin: 9vh auto 0; }
.hello { font-size: 48px; line-height: 1.15; font-weight: 600; margin: 0; letter-spacing: -.5px;
  background: linear-gradient(74deg, #4285f4 0%, #9b72cb 25%, #d96570 50%, #f05a28 75%);
  -webkit-background-clip: text; background-clip: text; color: transparent; width: fit-content; }
.sub { font-size: 40px; line-height: 1.2; font-weight: 500; color: var(--sub); margin: 4px 0 40px; letter-spacing: -.5px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sub.small { font-size: 14px; font-weight: 400; color: var(--muted); margin: 16px 0 0; letter-spacing: 0; }
.card { position: relative; text-align: left; border: 0; border-radius: 16px; background: var(--surface); padding: 16px 16px 48px; min-height: 128px;
  display: flex; flex-direction: column; gap: 6px; }
.card:hover { background: var(--surface-2); }
.card b { font-weight: 500; }
.card span { color: var(--muted); font-size: 13px; }
.card i { position: absolute; right: 12px; bottom: 12px; width: 36px; height: 36px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-style: normal; }

.messages { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.msg { display: flex; gap: 16px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--user); padding: 12px 18px; border-radius: 24px 4px 24px 24px; max-width: 75%; white-space: pre-wrap; word-wrap: break-word; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; overflow: hidden; }
.avatar img { width: 100%; height: 100%; }
.msg.bot .content { flex: 1; min-width: 0; padding-top: 4px; }
.msg.bot.note .content { color: var(--muted); }
.content p { margin: 0 0 10px; }
.content p:last-child { margin-bottom: 0; }
.content a { color: var(--accent); }
.content code { background: var(--surface); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.content ul, .content ol { padding-left: 22px; margin: 6px 0; }
.content table, .tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; margin: 10px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.content th, .tbl th { background: var(--surface); font-weight: 600; text-align: left; }
.content th, .content td, .tbl th, .tbl td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.content tr:last-child td, .tbl tr:last-child td { border-bottom: 0; }
.content strong { font-weight: 600; }
.imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.imgs img { max-height: 160px; border-radius: 12px; border: 1px solid var(--line); }
.msg.user .imgs { justify-content: flex-end; }

.thinking .content { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spark { width: 32px; height: 32px; border-radius: 50%; background: conic-gradient(#4285f4, #9b72cb, #d96570, #f05a28, #4285f4); animation: spin 1.4s linear infinite;
  -webkit-mask: radial-gradient(circle, transparent 54%, #000 56%); mask: radial-gradient(circle, transparent 54%, #000 56%); }
@keyframes spin { to { transform: rotate(360deg); } }
.shimmer { background: linear-gradient(90deg, var(--muted) 25%, var(--text) 50%, var(--muted) 75%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: sh 1.6s linear infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- composer ---------- */
.composer-wrap { padding: 0 16px 10px; isolation: isolate; }
.quick { max-width: 760px; margin: 0 auto 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick .q { width: 100%; font-size: 13px; color: var(--muted); }
.qchip { border: 1px solid var(--line); background: var(--bg); border-radius: 18px; padding: 6px 14px; font-size: 13.5px; }
.qchip:hover { background: var(--surface); border-color: var(--accent); }
.composer { position: relative; max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 10px 10px 8px 20px; transition: background .15s; }
.composer:focus-within { background: var(--surface-2); }
.composer textarea { width: 100%; border: 0; outline: 0; background: transparent; resize: none; font: inherit; color: var(--text); padding: 8px 0 4px; max-height: 220px; }
.composer-bar { display: flex; align-items: center; gap: 6px; margin-left: -10px; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 17px; border: 0; background: transparent; color: var(--muted); font-size: 13.5px; }
.pill:hover { background: var(--bg); }
.pill .dot { width: 9px; height: 9px; border-radius: 50%; background: #1e8e3e; }
.pill.live { color: #b3261e; }
.pill.live .dot { background: #b3261e; }
.meter { font-size: 12px; color: var(--muted); margin-right: 6px; }
.send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.send:disabled { opacity: .3; cursor: default; }
.send .i-stop { display: none; }
.busy .send { background: var(--text); }
.busy .send .i-send { display: none; }
.busy .send .i-stop { display: block; fill: currentColor; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 6px; }
.thumb { position: relative; }
.thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); font-size: 12px; line-height: 1; }
.disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* ---------- drawer / menus ---------- */
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: var(--bg); box-shadow: -8px 0 24px rgba(0,0,0,.12);
  transform: translateX(105%); transition: transform .22s ease; display: flex; flex-direction: column; z-index: 30; }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 24px; }
.drawer-head h2 { margin: 0; font-size: 20px; font-weight: 500; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 24px 24px; font-size: 14px; }
.drawer-body h3 { font-size: 15px; font-weight: 600; }
.drawer-body pre { white-space: pre-wrap; font-size: 12px; background: var(--surface); padding: 12px; border-radius: 12px; }
.muted { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field input[type=text] { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 14px; font: inherit; }
.seg { display: inline-flex; background: var(--surface); border-radius: 20px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 16px; border-radius: 17px; }
.seg button.on { background: var(--bg); box-shadow: var(--shadow); }
.primary { height: 40px; padding: 0 22px; border-radius: 20px; border: 0; background: var(--accent); color: #fff; font-weight: 500; }
[data-theme="dark"] .primary { color: #062e6f; }
.menu { position: fixed; z-index: 40; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; min-width: 140px; }
.menu button { border: 0; background: transparent; text-align: left; padding: 8px 12px; border-radius: 8px; }
.menu button:hover { background: var(--surface); }
.drop-hint { position: fixed; inset: 12px; border: 2px dashed var(--accent); border-radius: 24px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent); font-size: 20px; z-index: 50; pointer-events: none; }
.scrim { display: none; }
.mobile-only { display: none; }

@media (max-width: 900px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 290px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .app.side-open .sidebar { transform: none; }
  .app.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 15; }
  .mobile-only { display: inline-grid; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .hello { font-size: 34px; } .sub { font-size: 28px; }
  .meter { display: none; }
}

/* ---------- thinking (live panel + saved "Show thinking") ---------- */
.thinking .content { display: block; }
.think { margin: 0 0 12px; border-radius: 16px; background: var(--surface); padding: 10px 16px; font-size: 13.5px; }
.think.live { background: transparent; padding: 4px 0; }
.think summary { cursor: pointer; list-style: none; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.think summary::-webkit-details-marker { display: none; }
.think summary::after { content: "⌄"; margin-left: 4px; transition: transform .15s; }
.think[open] summary::after { transform: rotate(180deg); }
.think.live summary { font-size: 15px; }
.secs { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.steps { list-style: none; margin: 10px 0 4px; padding: 0 0 0 2px; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; }
.steps .tick { width: 18px; height: 18px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 11px; margin-top: 2px;
  background: #e6f4ea; color: #1e8e3e; }
.steps li.active .tick { background: transparent; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.steps .st { color: var(--text); }
.steps li.done .st { color: var(--muted); }
.det { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 2px; word-break: break-word; }
.thoughts { margin-top: 10px; border-left: 2px solid var(--line); padding-left: 12px; color: var(--muted); font-size: 13px; }
.thought { margin-bottom: 8px; }
.thought p { margin: 0 0 4px; }
.thought strong { color: var(--text); font-weight: 600; }
[data-theme="dark"] .steps .tick { background: #0f5223; color: #81c995; }

/* ---------- glow behind the chat box (blue -> purple -> red -> orange -> yellow -> green) ---------- */
.composer::before { content: ""; position: absolute; inset: -3px; border-radius: inherit; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, #4285f4, #9b72cb, #d96570, #f05a28, #fbbc04, #34a853, #4285f4);
  background-size: 200% 100%; filter: blur(26px); opacity: var(--glow); animation: glow 8s linear infinite; transition: opacity .2s, inset .2s; }
.composer:focus-within::before { inset: -8px; opacity: calc(var(--glow) + .15); }
@keyframes glow { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .composer::before { animation: none; } }
.theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: block; }
[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* ---------- start-page cards: soft moving glow, brighter on hover, staggered entrance ---------- */
.cards { isolation: isolate; }
.card { transition: transform .2s, background .15s; animation: rise .45s ease-out both; }
.card::before { content: ""; position: absolute; inset: 6px; border-radius: inherit; z-index: -1; pointer-events: none;
  background: linear-gradient(120deg, #4285f4, #9b72cb, #d96570, #f05a28, #fbbc04, #34a853, #4285f4);
  background-size: 300% 300%; filter: blur(16px); opacity: calc(var(--glow) * .4);
  animation: glow 10s linear infinite; transition: opacity .2s, inset .2s; }
.card:hover { transform: translateY(-3px); }
.card:hover::before { inset: -2px; opacity: var(--glow); }
.card:nth-child(2) { animation-delay: .06s; } .card:nth-child(2)::before { animation-delay: -1.6s; }
.card:nth-child(3) { animation-delay: .12s; } .card:nth-child(3)::before { animation-delay: -3.2s; }
.card:nth-child(4) { animation-delay: .18s; } .card:nth-child(4)::before { animation-delay: -4.8s; }
.card:nth-child(5) { animation-delay: .24s; } .card:nth-child(5)::before { animation-delay: -6.4s; }
.card:nth-child(6) { animation-delay: .30s; } .card:nth-child(6)::before { animation-delay: -8s; }
.card i { transition: transform .25s; }
.card:hover i { transform: scale(1.15) rotate(-6deg); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .card, .card::before { animation: none; } .card:hover { transform: none; } }
/* The card is its own stacking context (transform), so its background moves to ::after, above the glow. */
.card, .card:hover { background: transparent; }
.card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1; background: var(--surface); transition: background .15s; }
.card:hover::after { background: var(--surface-2); }
/* Card icons: one glow colour each, same order as the gradient */
.card i svg { width: 18px; height: 18px; }
.card:nth-child(1) i { color: #4285f4; } .card:nth-child(2) i { color: #9b72cb; } .card:nth-child(3) i { color: #d96570; }
.card:nth-child(4) i { color: #f05a28; } .card:nth-child(5) i { color: #f9ab00; } .card:nth-child(6) i { color: #34a853; }
/* The logo is white on dark: in the light theme it sits on a dark disc */
:root:not([data-theme="dark"]) .brand img, :root:not([data-theme="dark"]) .avatar img { background: #111; border-radius: 50%; }
/* User bubble: limit the column, not the bubble, so short words don't wrap ("can cel") */
.msg.user > div { max-width: 75%; }
.msg.user .bubble { max-width: none; }
/* Animated logo in front of "Hello, name"; the gradient moves to the text span */
.hello { display: flex; align-items: center; gap: 12px; background: none; color: inherit; width: auto; }
.hello span { background: linear-gradient(74deg, #4285f4 0%, #9b72cb 25%, #d96570 50%, #f05a28 75%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.hello-logo { width: 64px; height: 64px; flex: none; margin-left: -6px; }
@media (max-width: 900px) { .hello-logo { width: 46px; height: 46px; } }

/* ---------- server mode: users + portal browser ---------- */
.drawer.wide { width: min(1100px, 100vw); }
.u-act { white-space: nowrap; }
.u-act button, .pv-bar button, .pv-type button { height: 30px; padding: 0 10px; margin: 2px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.pv-bar { display: flex; align-items: center; gap: 4px; margin: 8px 0; flex-wrap: wrap; }
.pv-bar span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.pv-screen { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; min-height: 120px; }
.pv-screen img { display: block; width: 100%; height: auto; cursor: crosshair; }
.pv-screen #pvMsg { position: absolute; left: 12px; top: 10px; background: var(--bg); padding: 2px 8px; border-radius: 8px; }
.pv-screen #pvMsg:empty { display: none; }
.pv-type { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.pv-type input { flex: 1; min-width: 160px; height: 36px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); padding: 0 12px; font: inherit; }
.pv-type button { height: 36px; }
