:root {
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  color: #edf8f4;
  background: #07110f;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --bg: #07110f;
  --surface: #0c1916;
  --surface-2: #11231e;
  --surface-3: #172d27;
  --text: #edf8f4;
  --muted: #90aaa1;
  --faint: #607970;
  --line: rgba(184, 226, 211, 0.13);
  --accent: #76f7bd;
  --accent-strong: #31d990;
  --local: #78a8ff;
  --danger: #ff766f;
  --warning: #f3c96a;
  --radius-lg: 24px;
  --radius-md: 17px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 92% -8%, rgba(49, 217, 144, 0.16), transparent 34%),
    linear-gradient(180deg, #07110f 0%, #081410 100%);
}

button, textarea, select { font: inherit; }
button, select { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
button:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(118, 247, 189, 0.42); outline-offset: 2px; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(190px + env(safe-area-inset-bottom));
  position: relative;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 11px;
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 20;
  background: rgba(7, 17, 15, 0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand-mark, .section-icon {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(118, 247, 189, 0.09);
  border: 1px solid rgba(118, 247, 189, 0.18);
}

.brand-copy { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-copy strong { font-size: 16px; letter-spacing: -0.02em; }
.connection { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 5px; }
.connection.online { color: var(--accent); }

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
  display: grid;
  place-items: center;
}

.content { display: grid; gap: 14px; padding: 16px 0 24px; }

.hero-status, .engine-switch-card, .limit-card, .qwen-usage-card, .project-card, .short-limit, .queue-card, .answer-card, .activity-view, .answer-view {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.engine-switch-card {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(210px, 1.2fr);
  gap: 9px 14px;
  align-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(115deg, rgba(118, 247, 189, 0.07), rgba(188, 151, 255, 0.06)), var(--surface);
}
.engine-switch-card > div:first-child strong { display: block; font-size: 18px; letter-spacing: -0.03em; }
.engine-switch-card > small { grid-column: 1 / -1; color: var(--faint); font-size: 10px; }
.engine-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 4px; border: 1px solid var(--line); border-radius: 15px; background: #08130f; }
.engine-option { min-height: 46px; padding: 0 11px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 750; }
.engine-option > span, .engine-glyph { width: 24px; height: 24px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 8px; font: 800 11px/1 "SFMono-Regular", Consolas, monospace; }
.engine-kimi > span { color: var(--accent); background: rgba(118, 247, 189, 0.1); }
.engine-qwen > span, .engine-glyph.qwen { color: #d7c0ff; background: rgba(188, 151, 255, 0.12); }
.engine-option.active { color: var(--text); background: var(--surface-2); border-color: rgba(118, 247, 189, 0.2); box-shadow: 0 7px 20px rgba(0, 0, 0, 0.2); }
.engine-option.engine-qwen.active { border-color: rgba(188, 151, 255, 0.28); }
.app-shell[data-engine="qwen"] .brand-mark { color: #d7c0ff; border-color: rgba(188, 151, 255, 0.25); background: rgba(188, 151, 255, 0.09); }
.app-shell[data-engine="qwen"] .status-orbit { border-color: rgba(188, 151, 255, 0.32); }
.app-shell[data-engine="qwen"] .status-orbit span { background: #bc97ff; box-shadow: 0 0 0 7px rgba(188, 151, 255, 0.08), 0 0 24px rgba(188, 151, 255, 0.45); }

.hero-status {
  min-height: 210px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(118, 247, 189, 0.11), transparent 48%),
    var(--surface);
  overflow: hidden;
  position: relative;
}

.hero-status::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  right: -88px;
  top: -88px;
  border: 1px solid rgba(118, 247, 189, 0.12);
  border-radius: 50%;
}

.hero-status__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; position: relative; z-index: 1; }
.eyebrow { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 7px; }
h1, h2, p { margin-top: 0; }
.hero-status h1 { font-size: clamp(27px, 7vw, 38px); line-height: 1.04; letter-spacing: -0.055em; margin-bottom: 0; max-width: 270px; }

.chat-context { width: fit-content; max-width: 100%; margin-top: 18px; padding: 7px 10px; display: flex; align-items: center; gap: 7px; border-radius: 10px; color: var(--muted); background: rgba(118, 247, 189, 0.06); font-size: 11px; }
.chat-context span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-orbit { width: 52px; height: 52px; border: 1px solid rgba(118, 247, 189, 0.28); border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.status-orbit span { width: 13px; height: 13px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 7px rgba(118, 247, 189, 0.08), 0 0 24px rgba(118, 247, 189, 0.5); }
.state-paused .status-orbit span { background: var(--warning); box-shadow: 0 0 0 7px rgba(243, 201, 106, 0.08); }
.state-failed .status-orbit span { background: var(--danger); box-shadow: 0 0 0 7px rgba(255, 118, 111, 0.08); }

.current-prompt { color: #c9dcd5; line-height: 1.5; margin: 22px 0 16px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.live-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font: 12px/1.3 "SFMono-Regular", Consolas, monospace; }
.live-meta span { display: flex; align-items: center; gap: 5px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
.control-button { min-height: 48px; border-radius: 15px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; }
.control-button.primary { color: #062016; background: var(--accent); border-color: transparent; }
.control-button.danger { color: #ffd0cc; border-color: rgba(255, 118, 111, 0.25); background: rgba(255, 118, 111, 0.08); }
.ready-copy { margin-top: 28px; color: var(--muted); max-width: 480px; line-height: 1.5; }
.text-button { min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--accent); font-weight: 700; display: flex; gap: 7px; align-items: center; }

.limit-card { display: grid; grid-template-columns: 112px 1fr; gap: 20px; align-items: center; padding: 20px; border-radius: var(--radius-lg); background: var(--surface); }
.limit-ring { --remaining: 0deg; width: 108px; height: 108px; border-radius: 50%; background: conic-gradient(var(--accent) var(--remaining), var(--surface-3) 0); padding: 8px; position: relative; }
.limit-ring::before { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 28px rgba(118, 247, 189, 0.12); }
.limit-ring__inside { width: 100%; height: 100%; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #0a1714; }
.limit-ring strong { font: 700 24px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: -0.06em; }
.limit-ring span { color: var(--muted); font-size: 10px; margin-top: 5px; }
.limit-copy { min-width: 0; }
.limit-copy h2 { font-size: 20px; margin-bottom: 5px; letter-spacing: -0.03em; }
.limit-copy p { color: var(--muted); font-size: 12px; margin-bottom: 11px; }
.reset { color: var(--accent); font-size: 12px; }

.qwen-usage-card { padding: 20px; border-radius: var(--radius-lg); background: linear-gradient(145deg, rgba(188, 151, 255, 0.09), transparent 55%), var(--surface); }
.qwen-usage-head { display: flex; align-items: center; gap: 11px; }
.qwen-usage-head .engine-glyph { width: 42px; height: 42px; border-radius: 13px; font-size: 17px; }
.qwen-usage-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.03em; }
.qwen-usage-head .eyebrow { margin-bottom: 3px; }
.qwen-plan-line { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 16px; color: var(--muted); font-size: 10px; }
.plan-badge, .snapshot-state { padding: 4px 7px; border: 1px solid rgba(188, 151, 255, 0.18); border-radius: 999px; background: rgba(188, 151, 255, 0.08); color: #dccbff; font-weight: 700; }
.snapshot-state { border-color: rgba(96, 214, 153, 0.2); background: rgba(96, 214, 153, 0.08); color: #a8e8c7; }
.snapshot-state.stale { border-color: rgba(244, 185, 89, 0.22); background: rgba(244, 185, 89, 0.08); color: #f1ca86; }
.qwen-limit-list { display: grid; gap: 10px; margin-top: 12px; }
.qwen-limit-window { padding: 13px; border: 1px solid rgba(188, 151, 255, 0.14); border-radius: 14px; background: rgba(188, 151, 255, 0.04); }
.qwen-limit-row, .qwen-limit-meta, .local-usage-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qwen-limit-row span { color: var(--text); font-size: 12px; font-weight: 650; }
.qwen-limit-row strong { color: #e1d3ff; font: 750 14px/1 "SFMono-Regular", Consolas, monospace; }
.qwen-progress { height: 7px; margin: 10px 0 8px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.qwen-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #9c72eb, #c9aaff); box-shadow: 0 0 14px rgba(188, 151, 255, 0.3); }
.qwen-limit-meta { align-items: flex-end; color: var(--muted); font-size: 10px; }
.qwen-limit-meta small { color: var(--faint); font-size: 9px; text-align: right; }
.quota-freshness { margin: 9px 2px 0; color: var(--faint); font-size: 9px; }
.qwen-quota-empty { display: flex; gap: 8px; margin-top: 14px; padding: 11px; border-radius: 12px; background: rgba(244, 185, 89, 0.07); color: #d9bd8d; font-size: 10px; line-height: 1.4; }
.local-usage-label { margin-top: 17px; color: var(--muted); font-size: 10px; }
.local-usage-label small { color: var(--faint); font-size: 9px; }
.usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 17px; }
.usage-grid > div { min-width: 0; padding: 12px; border: 1px solid rgba(188, 151, 255, 0.13); border-radius: 13px; background: rgba(188, 151, 255, 0.045); }
.usage-grid span, .usage-grid small { display: block; color: var(--muted); font-size: 10px; }
.usage-grid strong { display: block; margin: 5px 0 4px; overflow: hidden; color: #e1d3ff; font: 750 17px/1.1 "SFMono-Regular", Consolas, monospace; text-overflow: ellipsis; }
.qwen-usage-card > p { margin: 13px 0 0; color: var(--faint); font-size: 10px; line-height: 1.45; }

.project-card { padding: 20px; border-radius: var(--radius-lg); background: var(--surface); }
.section-heading { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.section-heading h2 { font-size: 19px; margin: 0; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.section-heading .eyebrow { margin-bottom: 3px; }
.project-card label { color: var(--muted); display: block; font-size: 12px; margin-bottom: 7px; }
.project-card select { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); color: var(--text); background: var(--surface-2); }
.project-card small, .composer small { display: block; color: var(--faint); font-size: 11px; margin-top: 8px; }
.project-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 0; }
.project-meta div { min-width: 0; padding-top: 12px; border-top: 1px solid var(--line); }
.project-meta dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
.project-meta dd { margin: 5px 0 0; font: 12px/1.4 "SFMono-Regular", Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.short-limit, .queue-card { padding: 18px; border-radius: var(--radius-md); background: var(--surface); }
.short-limit > div:first-child { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.short-limit span, .short-limit small { color: var(--muted); }
.short-limit strong { color: var(--accent); }
.mini-progress { height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 11px 0 8px; }
.mini-progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.section-heading.compact { margin-bottom: 10px; }
.section-heading.compact h2 { flex: 1; font-size: 16px; }
.section-heading.compact > span { min-width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; color: var(--accent); background: rgba(118, 247, 189, 0.08); font-size: 12px; }
.queue-card ol { margin: 0; padding-left: 22px; color: #bdd1c9; }
.queue-card li { padding: 8px 0; line-height: 1.4; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.queue-card li:last-child { border-bottom: 0; }

.activity-view, .answer-view { min-height: 430px; padding: 20px; border-radius: var(--radius-lg); background: var(--surface); }
.chats-view { min-height: 430px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.chats-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.chats-heading h1 { margin: 0; font-size: 31px; letter-spacing: -0.05em; }
.new-chat-button { min-height: 44px; padding: 0 14px; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 13px; color: #052117; background: var(--accent); font-weight: 750; }
.source-legend { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.source-legend span { min-height: 27px; padding: 0 9px; display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; font-size: 10px; }
.source-legend .server { color: var(--accent); background: rgba(118, 247, 189, 0.07); }
.source-legend .local { color: var(--local); background: rgba(120, 168, 255, 0.08); }
.conversation-list { display: grid; gap: 9px; }
.conversation-card { width: 100%; min-height: 112px; padding: 0; display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 14px; overflow: hidden; text-align: left; color: var(--text); border: 1px solid var(--line); border-radius: 17px; background: #091512; }
.conversation-card:hover { border-color: rgba(118, 247, 189, 0.27); }
.conversation-card:focus-visible { outline-offset: 3px; }
.conversation-card.active { border-color: rgba(118, 247, 189, 0.38); background: #0d1d18; }
.source-rail { align-self: stretch; background: var(--accent); }
.source-local .source-rail { background: var(--local); }
.conversation-main { min-width: 0; padding: 14px 0; display: flex; flex-direction: column; }
.conversation-kicker { display: flex; justify-content: space-between; gap: 10px; color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }
.conversation-kicker > span { display: flex; align-items: center; gap: 4px; color: var(--accent); }
.source-local .conversation-kicker > span { color: var(--local); }
.conversation-main > strong { margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; letter-spacing: -0.02em; }
.conversation-summary { margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { margin-top: 9px; overflow: hidden; color: var(--faint); font: 10px/1.2 "SFMono-Regular", Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.conversation-open { min-width: 48px; padding: 0 13px 0 4px; display: grid; place-items: center; color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }
.conversation-card.active .conversation-open { color: var(--accent); }
.view-heading h1 { font-size: 31px; letter-spacing: -0.05em; margin-bottom: 24px; }
.live-monitor { margin: -7px 0 22px; padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: #091512; }
.live-monitor.active { border-color: rgba(118, 247, 189, 0.28); background: linear-gradient(120deg, rgba(118, 247, 189, 0.09), transparent 58%), #091512; }
.live-monitor__signal { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.live-monitor__signal span { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-monitor.active .live-monitor__signal span { background: var(--accent); box-shadow: 0 0 0 5px rgba(118, 247, 189, 0.08), 0 0 18px rgba(118, 247, 189, 0.55); animation: signal-pulse 1.8s ease-in-out infinite; }
.live-monitor__signal small { font: 700 9px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: 0.1em; text-transform: uppercase; }
.live-monitor > strong { display: block; margin-top: 11px; font-size: 17px; letter-spacing: -0.025em; }
.live-monitor__meta { margin-top: 9px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.live-monitor__meta b { color: var(--accent); font: 700 13px/1.4 "SFMono-Regular", Consolas, monospace; }
.live-monitor.idle .live-monitor__meta b { color: var(--muted); }
.live-monitor__meta span { color: var(--muted); font-size: 11px; line-height: 1.45; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; position: relative; padding-bottom: 19px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 12px; top: 24px; bottom: 0; width: 1px; background: var(--line); }
.timeline-marker { width: 26px; height: 26px; border: 1px solid rgba(118, 247, 189, 0.24); color: var(--accent); border-radius: 9px; display: grid; place-items: center; background: #0b1a16; z-index: 1; }
.timeline-marker span { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.timeline time { color: var(--faint); font: 10px/1 "SFMono-Regular", Consolas, monospace; }
.timeline p { color: #c1d4cd; font-size: 13px; line-height: 1.5; margin: 5px 0 0; overflow-wrap: anywhere; }
.live-label { align-self: start; color: #082318; background: var(--accent); border-radius: 7px; padding: 4px 6px; font: 700 8px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: 0.08em; }
.live-label.saved { color: var(--muted); background: var(--surface-3); }
.system-event .timeline-marker { color: var(--warning); border-color: rgba(243, 201, 106, 0.2); }

.history-source { margin-bottom: 16px; padding: 12px 13px; display: flex; gap: 10px; align-items: center; border-radius: 14px; }
.history-source.local { color: var(--local); border: 1px solid rgba(120, 168, 255, 0.18); background: rgba(120, 168, 255, 0.07); }
.history-source div { min-width: 0; display: flex; flex-direction: column; }
.history-source strong { font-size: 12px; }
.history-source span { margin-top: 3px; color: #9db6de; font-size: 10px; line-height: 1.4; }
.transcript { display: grid; gap: 12px; }
.message-bubble { max-width: 92%; padding: 14px 15px; border-radius: 17px; border: 1px solid var(--line); background: #091512; }
.message-bubble.role-user { margin-left: auto; border-color: rgba(118, 247, 189, 0.2); background: rgba(118, 247, 189, 0.08); }
.message-bubble > div { display: flex; justify-content: space-between; gap: 14px; color: var(--accent); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.message-bubble time { color: var(--faint); font: 9px/1.2 "SFMono-Regular", Consolas, monospace; letter-spacing: 0; text-transform: none; }
.message-bubble p { margin: 9px 0 0; color: #cee1da; font-size: 13px; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty-state { min-height: 280px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: var(--muted); }
.empty-state svg { color: var(--accent); margin-bottom: 15px; }
.empty-state h2 { color: var(--text); font-size: 18px; margin-bottom: 7px; }
.empty-state p { max-width: 320px; font-size: 13px; line-height: 1.5; }
.limit-error, .error-banner { display: flex; gap: 12px; align-items: flex-start; border: 1px solid rgba(255, 118, 111, 0.24); background: rgba(255, 118, 111, 0.08); color: #ffd1ce; }
.limit-error { padding: 18px; border-radius: var(--radius-md); }
.limit-error p { color: #d99f9b; margin: 4px 0 0; font-size: 12px; }
.error-banner { margin-top: 10px; padding: 12px; border-radius: 14px; font-size: 12px; }
.error-banner span { flex: 1; line-height: 1.4; }
.error-banner button { color: #ffd1ce; background: transparent; border: 0; padding: 2px; font-weight: 700; }

.composer {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  width: min(calc(100% - 24px), 736px);
  padding: 11px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(12, 25, 22, 0.95);
  backdrop-filter: blur(20px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.44);
}
.composer[hidden] { display: none; }
.app-shell.composer-hidden { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
.composer label { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; margin: 0 0 7px 3px; }
.composer-row { display: grid; grid-template-columns: 1fr 46px; gap: 8px; align-items: end; }
.composer textarea { width: 100%; min-height: 46px; max-height: 110px; resize: vertical; padding: 12px 13px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: #091512; line-height: 1.35; }
.composer textarea::placeholder { color: var(--faint); }
.composer-row button { width: 46px; height: 46px; border-radius: 14px; border: 0; display: grid; place-items: center; color: #052117; background: var(--accent); }

.bottom-nav {
  position: fixed;
  z-index: 31;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding: 5px max(12px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(7, 17, 15, 0.97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(20px);
}
.bottom-nav button { min-height: 54px; border: 0; border-radius: 14px; color: var(--faint); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; }
.bottom-nav button.active { color: var(--accent); background: rgba(118, 247, 189, 0.07); }
.toast { position: fixed; z-index: 50; left: 50%; top: calc(82px + env(safe-area-inset-top)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 11px 15px; display: flex; gap: 8px; align-items: center; border-radius: 13px; color: #082218; background: var(--accent); box-shadow: var(--shadow); font-size: 13px; font-weight: 700; }

.loading-shell { padding-top: calc(24px + env(safe-area-inset-top)); }
.skeleton { border-radius: 15px; background: linear-gradient(90deg, #0c1b17 25%, #142922 50%, #0c1b17 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-title { width: 150px; height: 42px; margin-bottom: 20px; }
.skeleton-card { height: 230px; margin-bottom: 14px; }
.skeleton-card.short { height: 150px; }
.spin { animation: spin 0.8s linear infinite; }

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes signal-pulse { 50% { opacity: 0.55; transform: scale(0.82); } }

@media (min-width: 680px) {
  .app-shell { padding-left: 24px; padding-right: 24px; }
  .content { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .engine-switch-card, .hero-status, .activity-view, .answer-view { grid-column: 1 / -1; }
  .chats-view { grid-column: 1 / -1; }
  .queue-card { grid-column: 1 / -1; }
  .activity-view, .answer-view { min-height: 520px; }
}

@media (max-width: 520px) {
  .engine-switch-card { grid-template-columns: minmax(0, 1fr); }
  .engine-switch-card > small { grid-column: auto; }
}

.engine-badge { width: 17px; height: 17px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 6px; font: 800 9px/1 "SFMono-Regular", Consolas, monospace; }
.engine-badge.engine-kimi { color: var(--accent); background: rgba(118, 247, 189, 0.12); }
.engine-badge.engine-qwen { color: #d7c0ff; background: rgba(188, 151, 255, 0.14); }

.chats-search { display: block; margin-bottom: 12px; }
.chats-search .input-shell { display: flex; align-items: center; gap: 9px; padding: 0 14px; min-height: 46px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--faint); }
.chats-search .input-shell:focus-within { border-color: rgba(118, 247, 189, 0.35); color: var(--accent); }
.chats-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 15px; }
.chats-search input::placeholder { color: var(--faint); }

.chats-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.filter-chip { min-height: 34px; padding: 0 14px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease; }
.filter-chip.active { color: #062016; background: var(--accent); border-color: transparent; }
.filter-chip.engine-qwen.active { color: #1b1030; background: #d7c0ff; }

.conversation-card.filtered-out { display: none; }
.chats-empty { margin-top: 8px; }

.handoff-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 16px; margin-bottom: 18px; border: 1px solid rgba(188, 151, 255, 0.24); border-radius: 17px; background: rgba(188, 151, 255, 0.06); }
.handoff-copy { display: flex; align-items: flex-start; gap: 11px; color: #d7c0ff; }
.handoff-copy svg { flex: 0 0 auto; margin-top: 2px; }
.handoff-copy strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 3px; }
.handoff-copy span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.handoff-card .control-button { flex: 0 0 auto; }
.handoff-card.opinion-card { border-color: rgba(118, 247, 189, 0.24); background: rgba(118, 247, 189, 0.05); }
.handoff-card.opinion-card .handoff-copy { color: var(--accent); }

.context-card textarea { width: 100%; min-height: 96px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; line-height: 1.5; resize: vertical; outline: none; }
.context-card textarea:focus { border-color: rgba(118, 247, 189, 0.35); }
.context-card textarea::placeholder { color: var(--faint); }
.context-hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 0 0 12px; }
.context-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

@media (max-width: 380px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .limit-card { grid-template-columns: 92px 1fr; gap: 14px; padding: 16px; }
  .limit-ring { width: 90px; height: 90px; }
  .limit-ring strong { font-size: 20px; }
  .limit-copy h2 { font-size: 17px; }
  .bottom-nav button span { font-size: 9px; }
}

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