*, *::before, *::after {
  box-sizing: border-box;
}

[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;
  pointer-events: none;
}

:root {
  --bg: var(--tg-theme-bg-color, #060a12);
  --surface: var(--tg-theme-secondary-bg-color, #101826);
  --surface-elevated: color-mix(in srgb, var(--surface) 78%, #ffffff 22%);
  --chrome-bg: rgba(8, 13, 22, 0.34);
  --card-bg: rgba(16, 24, 38, 0.22);
  --bubble-assistant: rgba(16, 24, 38, 0.22);
  --bubble-user-a: rgba(56, 189, 248, 0.26);
  --bubble-user-b: rgba(139, 92, 246, 0.24);
  --sheet-bg: rgba(14, 20, 32, 0.72);
  --chrome-tint-a: rgba(56, 189, 248, 0.14);
  --chrome-tint-b: rgba(139, 92, 246, 0.16);
  --text: var(--tg-theme-text-color, #f4f8fd);
  --muted: var(--tg-theme-hint-color, #9fb4cc);
  --accent: var(--tg-theme-button-color, #38bdf8);
  --accent-2: #8b5cf6;
  --aurora-1: rgba(56, 189, 248, 0.85);
  --aurora-2: rgba(139, 92, 246, 0.88);
  --wallpaper-url: url("/static/bg-chat.jpg?v=8");
  --wallpaper-opacity: 0.9;
  --bubble-blur: 6px;
  --bubble-radius: 18px;
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-soft: color-mix(in srgb, var(--accent) 20%, color-mix(in srgb, var(--surface) 74%, transparent));
  --accent-border: color-mix(in srgb, var(--accent) 46%, transparent);
  --danger: #f05454;
  --warn: #f0a83b;
  --ok: #34c77b;
  --border: color-mix(in srgb, var(--text) 11%, transparent);
  --border-strong: color-mix(in srgb, var(--text) 18%, transparent);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.4, 0.64, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: dark light;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 820px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

/* --- Multi-Layer Ambient AI Wallpaper + Reactive Aurora + Particles --- */
.ambient-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-wallpaper {
  position: absolute;
  inset: -6%;
  background-color: var(--bg);
  background-image:
    var(--wallpaper-url),
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 52%),
    radial-gradient(circle at 86% 88%, color-mix(in srgb, var(--accent-2) 28%, transparent), transparent 54%);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: var(--wallpaper-opacity);
  transform: translate3d(0, 0, 0) scale(1.04);
  will-change: transform;
  animation: wallpaperBreathe 28s ease-in-out infinite alternate;
  transition: opacity 0.45s ease;
}

.app-shell.is-busy .bg-wallpaper {
  opacity: min(0.96, calc(var(--wallpaper-opacity) + 0.1));
}

@keyframes wallpaperBreathe {
  0% { transform: translate3d(-1%, -1%, 0) scale(1.03); }
  100% { transform: translate3d(1%, 1%, 0) scale(1.07); }
}

.bg-aurora {
  position: absolute;
  width: 78vmax;
  height: 78vmax;
  border-radius: 50%;
  opacity: 0.34;
  will-change: transform;
  transition: opacity 0.45s ease;
}

.bg-aurora-1 {
  top: -30vmax;
  left: -26vmax;
  background: radial-gradient(circle, var(--aurora-1) 0%, transparent 64%);
  animation: auroraFloat1 18s ease-in-out infinite alternate;
}

.bg-aurora-2 {
  bottom: -32vmax;
  right: -26vmax;
  background: radial-gradient(circle, var(--aurora-2) 0%, transparent 64%);
  animation: auroraFloat2 22s ease-in-out infinite alternate;
}

.app-shell.is-busy .bg-aurora {
  opacity: 0.48;
}

@keyframes auroraFloat1 {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(14vw, 10vh, 0); }
}

@keyframes auroraFloat2 {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-14vw, -12vh, 0); }
}

.bg-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  transform: translateZ(0);
}

.bg-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 48%, rgba(4, 7, 12, 0.08) 0%, rgba(4, 7, 12, 0.42) 100%);
}

/* Foreground Interactive FX Overlay Canvas (ABOVE cards & bubbles!) */
.fx-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 35;
  pointer-events: none;
  transform: translateZ(0);
}

/* Full-Screen Live Perimeter Aura when AI is working */
.busy-edge-glow {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  box-shadow:
    inset 0 0 28px color-mix(in srgb, var(--accent) 42%, transparent),
    inset 0 0 60px color-mix(in srgb, var(--accent-2) 26%, transparent);
  transition: opacity 0.35s ease;
}

.app-shell.is-busy .busy-edge-glow {
  opacity: 1;
  animation: edgePulse 1.8s ease-in-out infinite alternate;
}

@keyframes edgePulse {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

/* --- Compact Single-Row Living Liquid-Glass Topbar (GPU-light) --- */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top, 0px)) 12px 8px;
  min-height: 52px;
  background-color: var(--chrome-bg);
  background-image: linear-gradient(120deg, var(--chrome-tint-a), transparent 48%, var(--chrome-tint-b));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

@keyframes chromeFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes glossSweep {
  0% { transform: translateX(-140%) skewX(-22deg); }
  28%, 100% { transform: translateX(260%) skewX(-22deg); }
}

.topbar-energy-beam {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  opacity: 0;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 35%, var(--accent-2) 65%, transparent 100%);
  background-size: 200% 100%;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.app-shell.is-busy .topbar-energy-beam {
  opacity: 1;
  animation: beamSweep 1.6s linear infinite;
}

@keyframes beamSweep {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.dialog-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 4px 6px 4px 2px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.12s var(--ease-spring);
}

.dialog-trigger:active {
  background: var(--surface);
  transform: scale(0.985);
}

.scope-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  flex-shrink: 0;
}

.dialog-trigger-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.dialog-title {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dialog-subtitle {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.12s ease;
}

.status-chip:active, .quota-chip:active {
  transform: scale(0.95);
}

.quota-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

.quota-chip.quota-ok {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  color: var(--ok);
}

.quota-chip.quota-warn {
  border-color: color-mix(in srgb, var(--warn) 50%, transparent);
  color: var(--warn);
}

.quota-chip.quota-danger {
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
  color: var(--danger);
}

.quota-chip.quota-muted {
  color: var(--muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

.status-ok .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent);
}

.status-busy {
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  color: var(--warn);
}

.status-busy .status-dot {
  background: var(--warn);
  animation: pulseDot 1.2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 50%, transparent); }
  50% { transform: scale(1.18); box-shadow: 0 0 0 5px transparent; }
}

/* --- Banners & Floating Toast --- */
.unauth-banner {
  margin: 10px 12px 0;
  padding: 12px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  flex-shrink: 0;
}

.unauth-banner p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.toast-bar {
  position: fixed;
  top: calc(max(8px, env(safe-area-inset-top, 0px)) + 58px);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  max-width: min(90vw, 420px);
  padding: 9px 16px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-elevated) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--accent-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  pointer-events: none;
  animation: toastIn 0.24s var(--ease-spring);
}

.toast-bar.toast-error {
  border-color: color-mix(in srgb, var(--danger) 65%, transparent);
  color: #ffd9d9;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* --- Main Panels --- */
.panels {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

[role="tabpanel"] {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  animation: panelFadeIn 0.22s var(--ease-spring);
}

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-chat-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-body {
  padding: 14px 12px 24px;
}

/* --- HITL Banner --- */
.hitl-banner {
  margin: 8px 12px 0;
  padding: 9px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--warn) 15%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  animation: msgIn 0.22s var(--ease-spring);
}

.hitl-banner-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
}

.hitl-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
  animation: pulseDot 1.2s ease-in-out infinite;
}

/* --- Messages Area --- */
.messages-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.messages-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px 16px;
}

.empty-state {
  margin: auto;
  text-align: center;
  padding: 28px 20px;
  color: var(--muted);
  max-width: 290px;
  animation: msgIn 0.4s var(--ease-spring);
}

.empty-orb-wrap {
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-orb-wrap::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.32), rgba(139, 92, 246, 0.14) 55%, transparent 72%);
  filter: blur(12px);
  animation: orbGlow 3.2s ease-in-out infinite alternate;
}

.ai-core-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  mix-blend-mode: screen;
  animation: orbFloat 4.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  50% { transform: translateY(-6px) scale(1.04) rotate(6deg); }
}

@keyframes orbGlow {
  0% { opacity: 0.6; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1.12); }
}

.empty-state-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 5px;
}

.empty-state-sub {
  font-size: 13px;
  line-height: 1.48;
}

.msg {
  padding: 10px 13px;
  border-radius: var(--bubble-radius);
  max-width: 88%;
  word-break: break-word;
  font-size: 14.8px;
  line-height: 1.48;
  position: relative;
  contain: layout style;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.82);
  animation: msgIn 0.24s var(--ease-bounce);
}

.app-shell[data-action="glide"] .msg {
  animation: msgGlide 0.26s var(--ease-spring);
}
.app-shell[data-action="glitch"] .msg {
  animation: msgGlitch 0.3s steps(2, end);
}
.app-shell[data-action="zen"] .msg {
  animation: msgZen 0.44s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes msgGlide {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes msgGlitch {
  0% { opacity: 0; transform: translateX(-6px) skewX(-3deg); filter: brightness(1.45); }
  40% { opacity: 0.9; transform: translateX(4px) skewX(2deg); box-shadow: -3px 0 0 var(--accent), 3px 0 0 var(--accent-2); }
  75% { opacity: 1; transform: translateX(-1px) skewX(0); }
  100% { opacity: 1; transform: translateX(0); filter: none; }
}

@keyframes msgZen {
  from { opacity: 0; transform: scale(0.985); filter: blur(3px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--bubble-user-a), var(--bubble-user-b));
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--accent-2));
  border-bottom-right-radius: 5px;
}

.msg-user.msg-optimistic {
  opacity: 0.82;
}

.msg-assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  border: 1px solid var(--border-strong);
  border-bottom-left-radius: 5px;
  max-width: 93%;
}

.msg-assistant.msg-streaming {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--accent-2));
  box-shadow: 0 6px 24px rgba(56, 189, 248, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.msg-system {
  align-self: center;
  max-width: 90%;
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.msg-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.msg-meta-who {
  font-weight: 600;
  color: color-mix(in srgb, var(--text) 78%, var(--muted));
}

.msg-meta-tag {
  font-size: 10.5px;
  opacity: 0.85;
}

/* Living AI Thinking / Action State */
.thinking-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 2px;
}

.thinking-orb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.thinking-orb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  mix-blend-mode: screen;
  animation: orbSpinPulse 2.8s linear infinite;
}

@keyframes orbSpinPulse {
  0% { transform: rotate(0deg) scale(0.95); filter: brightness(1); }
  50% { transform: rotate(180deg) scale(1.1); filter: brightness(1.25); }
  100% { transform: rotate(360deg) scale(0.95); filter: brightness(1); }
}

.thinking-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 120px;
  flex: 1;
}

.thinking-label {
  font-size: 12.5px;
  font-weight: 550;
  background: linear-gradient(90deg, var(--text), var(--accent), var(--accent-2), var(--text));
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: textShimmer 2s linear infinite;
}

@keyframes textShimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.thinking-wave {
  height: 3px;
  width: 100%;
  max-width: 160px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  overflow: hidden;
  position: relative;
}

.thinking-wave::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 55%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: waveSlide 1.15s ease-in-out infinite alternate;
}

@keyframes waveSlide {
  from { transform: translateX(-20%); }
  to { transform: translateX(105%); }
}

/* Rich Markdown Styling */
.msg-body p { margin: 0 0 8px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body h3, .msg-body h4 {
  margin: 10px 0 6px;
  line-height: 1.3;
  font-weight: 650;
}
.msg-body h3:first-child, .msg-body h4:first-child { margin-top: 0; }
.msg-body h3 { font-size: 15.5px; }
.msg-body h4 { font-size: 14.5px; }
.msg-body ul, .msg-body ol {
  margin: 4px 0 8px 20px;
  padding: 0;
}
.msg-body li { margin-bottom: 3px; }
.msg-body blockquote {
  margin: 6px 0;
  padding: 5px 10px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 0 8px 8px 0;
  color: color-mix(in srgb, var(--text) 85%, var(--muted));
}
.msg-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.msg-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.msg-body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.8px;
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  padding: 1.5px 5px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.code-block-wrap {
  margin: 8px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, #000 18%);
}

.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.btn-copy-code {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-copy-code:active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.code-block-wrap pre {
  margin: 0;
  padding: 10px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.45;
  -webkit-overflow-scrolling: touch;
}

.code-block-wrap pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
}

.md-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.msg-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.msg-body th, .msg-body td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.msg-body th {
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  font-weight: 600;
}

.msg-body tr:last-child td {
  border-bottom: none;
}

/* Tool Call Accordions with Live Action Motion */
details.tool-call {
  margin: 4px 0 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 12px;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  animation: msgIn 0.22s var(--ease-spring);
}

details.tool-call.tool-running {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--accent-2));
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.16);
}

details.tool-call.tool-running::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(56, 189, 248, 0.14) 50%, transparent 65%);
  background-size: 220% 100%;
  animation: sheenSweep 1.4s linear infinite;
  pointer-events: none;
}

@keyframes sheenSweep {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

details.tool-call.tool-done {
  border-color: color-mix(in srgb, var(--ok) 32%, var(--border));
}

details.tool-call.tool-error {
  border-color: color-mix(in srgb, var(--danger) 48%, var(--border));
}

details.tool-call summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 550;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tool-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

details.tool-call summary::-webkit-details-marker { display: none; }

details.tool-call pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: color-mix(in srgb, var(--text) 85%, var(--muted));
}

.msg-attachments {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

/* Floating Scroll-to-Bottom FAB */
.scroll-fab {
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface-elevated) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
  cursor: pointer;
  z-index: 10;
  touch-action: manipulation;
  animation: msgIn 0.2s var(--ease-spring);
}

.scroll-fab svg { width: 18px; height: 18px; }
.scroll-fab:active { transform: scale(0.92); }

/* --- Sleek Single-Row Living Pill Composer --- */
.composer-dock {
  padding: 6px 10px 8px;
  background-color: var(--chrome-bg);
  background-image: linear-gradient(115deg, var(--chrome-tint-b), transparent 50%, var(--chrome-tint-a));
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.app-shell.kb-open .composer-dock {
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
}

.attachments-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%;
  width: 0%;
  transition: width 0.15s ease;
  animation: beamSweep 1.2s linear infinite;
}

.composer-pill {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  padding: 4px 5px 4px 6px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer-pill:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 26%, transparent), 0 4px 16px color-mix(in srgb, var(--accent) 20%, transparent);
}

@keyframes focusAura {
  from { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent), 0 4px 18px color-mix(in srgb, var(--accent) 18%, transparent); }
  to { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 28%, transparent), 0 4px 24px color-mix(in srgb, var(--accent-2) 24%, transparent); }
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { background: var(--bg); color: var(--text); transform: scale(0.92); }

.composer-pill textarea {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 7px 4px;
  min-height: 36px;
  max-height: 124px;
  resize: none;
  font: inherit;
  font-size: 15.5px;
  line-height: 1.38;
  outline: none;
  field-sizing: content;
}

.composer-pill textarea::placeholder {
  color: var(--muted);
}

.send-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.16s var(--ease-bounce), opacity 0.15s ease;
}

.send-btn.send-burst::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: burstRing 0.48s var(--ease-spring) forwards;
  pointer-events: none;
}

@keyframes burstRing {
  from { transform: scale(0.95); opacity: 0.9; }
  to { transform: scale(1.85); opacity: 0; }
}

.send-btn svg { width: 19px; height: 19px; }
.send-btn:active:not(:disabled) { transform: scale(0.88); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.send-btn-stop { background: var(--danger); color: #fff; box-shadow: 0 2px 12px rgba(240, 84, 84, 0.35); }

/* --- Thumb-Zone Living Liquid Bottom Navigation (GPU-light) --- */
.bottom-nav {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background-color: var(--chrome-bg);
  background-image: linear-gradient(120deg, var(--chrome-tint-a), transparent 48%, var(--chrome-tint-b));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

.nav-indicator {
  position: absolute;
  top: 6px;
  left: 8px;
  width: calc((100% - 16px) / 4);
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--bubble-user-a), var(--bubble-user-b));
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--accent-2));
  box-shadow: 0 2px 14px color-mix(in srgb, var(--accent) 24%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  pointer-events: none;
  z-index: 0;
  will-change: transform;
  transition: transform 0.28s var(--ease-bounce);
}

.app-shell.kb-open .bottom-nav {
  display: none;
}

.nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 44px;
  padding: 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease, transform 0.14s var(--ease-bounce);
}

.nav-item svg {
  width: 21px;
  height: 21px;
  transition: transform 0.24s var(--ease-bounce), filter 0.2s ease;
}

.nav-item:active {
  transform: scale(0.92);
}

.nav-item[aria-selected="true"] {
  color: var(--accent);
}

.nav-item[aria-selected="true"] svg {
  transform: translateY(-1px) scale(1.1);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent));
}

/* --- Controls, Cards & Secondary Tabs --- */
.stack { display: flex; flex-direction: column; gap: 12px; }

.card {
  background-color: var(--card-bg);
  background-image: linear-gradient(140deg, var(--chrome-tint-a), transparent 55%, var(--chrome-tint-b));
  contain: layout style;
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.theme-preview-window {
  min-height: 112px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.06) 0%, rgba(0, 0, 0, 0.36) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 8px 28px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

.preview-window-info {
  min-width: 0;
  flex: 1;
}

.preview-theme-name {
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}

.preview-theme-desc {
  font-size: 12px;
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  margin-top: 3px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
}

.styled-select, input[type="text"], .code-editor {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 42px;
  font: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.18s ease;
}

.styled-select:focus, input[type="text"]:focus, .code-editor:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 40px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s var(--ease-spring), opacity 0.12s ease, background 0.15s ease;
}

.btn:active:not(:disabled) { transform: scale(0.95); opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  will-change: transform;
  animation: glossSweep 4.5s ease-in-out infinite;
  pointer-events: none;
}
.btn-secondary { background: var(--card-bg); color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost { background: var(--card-bg); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warn); color: #121212; }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 12.5px; border-radius: 10px; }

.icon-btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

.mode-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.mode-btn {
  padding: 9px 6px;
  min-height: 36px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.mode-btn:active { transform: scale(0.96); }
.mode-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 36%, transparent);
}

.quota-item { display: flex; flex-direction: column; gap: 5px; }
.quota-row { display: flex; justify-content: space-between; font-size: 12.5px; gap: 8px; }
.bar-track {
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  overflow: hidden;
}
.bar-fill {
  position: relative;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ok), color-mix(in srgb, var(--ok) 70%, var(--accent)));
  transition: width 0.35s var(--ease-spring);
}
.bar-fill.warn {
  background: linear-gradient(90deg, var(--warn), #fcd34d);
}
.bar-fill.danger {
  background: linear-gradient(90deg, var(--danger), #fb7185);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 11px;
}
.metric-label { font-size: 11px; color: var(--muted); }
.metric-val { font-size: 14px; font-weight: 650; margin-top: 3px; }

.device-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.memory-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}
.memory-toolbar select { flex: 1; }

.code-editor {
  min-height: 290px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}

.commit-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

/* Shimmer Skeleton */
.skeleton {
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--text) 5%, transparent) 25%,
    color-mix(in srgb, var(--text) 11%, transparent) 50%,
    color-mix(in srgb, var(--text) 5%, transparent) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.25s infinite linear;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* --- Native Liquid-Glass Bottom-Sheet Menus (@starting-style) --- */
dialog.sheet-dialog {
  margin: auto auto 0;
  width: min(100vw, 560px);
  max-width: 100vw;
  max-height: 82dvh;
  background-color: var(--sheet-bg);
  background-image: linear-gradient(135deg, var(--chrome-tint-a), transparent 48%, var(--chrome-tint-b));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border-strong));
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -14px 44px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.22s ease,
    transform 0.26s var(--ease-spring),
    overlay 0.26s allow-discrete,
    display 0.26s allow-discrete;
}

dialog.sheet-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 1;
  transform: translateY(0);
}

@starting-style {
  dialog.sheet-dialog[open] {
    opacity: 0;
    transform: translateY(36px);
  }
}

dialog.sheet-dialog::backdrop {
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.22s ease, overlay 0.26s allow-discrete, display 0.26s allow-discrete;
}

dialog.sheet-dialog[open]::backdrop {
  opacity: 1;
}

@starting-style {
  dialog.sheet-dialog[open]::backdrop {
    opacity: 0;
  }
}

@media (min-width: 640px) {
  dialog.sheet-dialog {
    margin: auto;
    border-bottom: 1px solid var(--border-strong);
    border-radius: 20px;
    width: min(92vw, 480px);
    padding: 16px 18px 18px;
  }
  .sheet-handle { display: none; }
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 4px;
  flex-shrink: 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sheet-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

dialog.sheet-dialog h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.sheet-user-meta {
  margin-top: -4px;
}

.dialog-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 52dvh;
  padding: 2px 0;
}

.dialog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.dialog-item:active { transform: scale(0.985); }
.dialog-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dialog-item-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.dialog-item-title {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dialog-item-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.dialog-item-check {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}

.hitl-code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 11px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  margin: 0;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

.online-radar {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(52, 199, 123, 0.55);
  animation: radarPing 2s ease-out infinite;
}

.offline-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
  margin-right: 6px;
  vertical-align: middle;
}

@keyframes radarPing {
  0% { box-shadow: 0 0 0 0 rgba(52, 199, 123, 0.55); }
  75% { box-shadow: 0 0 0 7px rgba(52, 199, 123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 199, 123, 0); }
}

/* --- Theme Studio Grid & AI Generator --- */
.theme-pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border: 1px solid var(--border);
}

.themes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 11px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--card-bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s var(--ease-bounce), border-color 0.2s ease, box-shadow 0.2s ease;
}

.theme-card.active {
  background-image: linear-gradient(135deg, var(--chrome-tint-a), var(--chrome-tint-b));
}

.theme-card:active {
  transform: scale(0.96);
}

.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 16px color-mix(in srgb, var(--accent) 22%, transparent);
}

.theme-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.theme-swatch {
  width: 24px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

.theme-del-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-del-btn:active {
  color: var(--danger);
  border-color: var(--danger);
}

.theme-card-name {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-card-meta {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-gen-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.glass-slider-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 6px;
}

.glass-range {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.theme-gen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.toggle-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* =====================================================================
   STYLE IDENTITIES: Layout Geometry, Placement & Typography per Theme
   ===================================================================== */

/* --- Typography Identities --- */
.app-shell[data-font="mono"] {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
.app-shell[data-font="mono"] .msg {
  font-size: 13.6px;
  line-height: 1.5;
}

.app-shell[data-font="tech"] .dialog-title,
.app-shell[data-font="tech"] .card h2,
.app-shell[data-font="tech"] .preview-theme-name,
.app-shell[data-font="tech"] .nav-item span,
.app-shell[data-font="tech"] .btn {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.88em;
}

.app-shell[data-font="editorial"] .dialog-title,
.app-shell[data-font="editorial"] .card h2,
.app-shell[data-font="editorial"] .preview-theme-name,
.app-shell[data-font="editorial"] .msg-body h3,
.app-shell[data-font="editorial"] .msg-body h4 {
  font-family: Georgia, "Times New Roman", "Palatino Linotype", serif;
  letter-spacing: 0.015em;
}

/* --- Identity 1: FLOATING ISLANDS (Cosmic Warp, Fireflies) --- */
.app-shell[data-layout="floating"] .topbar {
  margin: max(8px, env(safe-area-inset-top, 0px)) 10px 4px;
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border-strong));
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.app-shell[data-layout="floating"] .topbar-energy-beam {
  left: 16px;
  right: 16px;
  border-radius: 999px;
}
.app-shell[data-layout="floating"] .composer-dock {
  background: transparent;
  background-image: none;
  border-top: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 4px 10px 6px;
}
.app-shell[data-layout="floating"] .composer-pill {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.app-shell[data-layout="floating"] .bottom-nav {
  margin: 4px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  padding: 6px 8px;
  border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border-strong));
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* --- Identity 2: TERMINAL CONSOLE LOG (Matrix) --- */
.app-shell[data-layout="terminal"]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.12) 3px
  );
}
.app-shell[data-layout="terminal"] .topbar,
.app-shell[data-layout="terminal"] .bottom-nav,
.app-shell[data-layout="terminal"] .composer-dock {
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
}
.app-shell[data-layout="terminal"] .scope-icon,
.app-shell[data-layout="terminal"] .card,
.app-shell[data-layout="terminal"] .theme-card,
.app-shell[data-layout="terminal"] .theme-preview-window,
.app-shell[data-layout="terminal"] .composer-pill,
.app-shell[data-layout="terminal"] .btn,
.app-shell[data-layout="terminal"] .nav-indicator,
.app-shell[data-layout="terminal"] .status-chip,
.app-shell[data-layout="terminal"] .quota-chip,
.app-shell[data-layout="terminal"] .mode-group,
.app-shell[data-layout="terminal"] .mode-btn,
.app-shell[data-layout="terminal"] .styled-select,
.app-shell[data-layout="terminal"] input[type="text"],
.app-shell[data-layout="terminal"] .send-btn {
  border-radius: 4px !important;
}
.app-shell[data-layout="terminal"] .messages-list {
  gap: 7px;
}
.app-shell[data-layout="terminal"] .msg {
  align-self: stretch !important;
  max-width: 100% !important;
  border-radius: 3px !important;
  border-left: 3px solid var(--accent);
}
.app-shell[data-layout="terminal"] .msg-user {
  border-left: 3px solid var(--accent-2);
}
.app-shell[data-layout="terminal"] .msg-user .msg-meta-who::before {
  content: "> ";
  color: var(--accent);
}
.app-shell[data-layout="terminal"] .msg-assistant .msg-meta-who::before {
  content: "[HUB] ";
  color: var(--accent);
}

/* --- Identity 3: CYBERPUNK TACTICAL HUD (Chamfered Cuts + Scanlines) --- */
.app-shell[data-layout="hud"]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(255, 255, 255, 0.025) 4px
  );
}
.app-shell[data-layout="hud"] .card,
.app-shell[data-layout="hud"] .theme-preview-window,
.app-shell[data-layout="hud"] .msg {
  border-radius: 4px;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.app-shell[data-layout="hud"] .theme-card,
.app-shell[data-layout="hud"] .btn,
.app-shell[data-layout="hud"] .composer-pill,
.app-shell[data-layout="hud"] .nav-indicator {
  border-radius: 4px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.app-shell[data-layout="hud"] .topbar {
  border-bottom: 2px solid color-mix(in srgb, var(--accent) 55%, var(--accent-2));
}
.app-shell[data-layout="hud"] .bottom-nav {
  border-top: 2px solid color-mix(in srgb, var(--accent-2) 55%, var(--accent));
}

/* --- Identity 4: FLUID ORGANIC WAVES (Ocean Pulse) --- */
.app-shell[data-layout="fluid"] .topbar {
  border-radius: 0 0 24px 24px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  box-shadow: 0 8px 26px color-mix(in srgb, var(--accent) 14%, transparent);
}
.app-shell[data-layout="fluid"] .bottom-nav {
  border-radius: 24px 24px 0 0;
  border-top: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  box-shadow: 0 -8px 26px color-mix(in srgb, var(--accent) 14%, transparent);
}
.app-shell[data-layout="fluid"] .msg-assistant {
  border-radius: 24px 24px 24px 6px;
}
.app-shell[data-layout="fluid"] .msg-user {
  border-radius: 24px 24px 6px 24px;
}
.app-shell[data-layout="fluid"] .card {
  border-radius: 24px;
}

/* --- Quick Action Chips, Voice Mic & Interactive Reply Actions --- */
.quick-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px 2px 2px;
  -webkit-overflow-scrolling: touch;
}
.quick-chips::-webkit-scrollbar { display: none; }

.app-shell.kb-open .quick-chips {
  display: none;
}

.q-chip {
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border-strong));
  background: var(--card-bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s var(--ease-bounce), border-color 0.15s ease, background 0.15s ease;
}

.q-chip:active {
  transform: scale(0.93);
  border-color: var(--accent);
  background: var(--bubble-user-a);
}

.mic-btn.recording {
  color: #fff;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(240, 84, 84, 0.7);
  animation: micPulse 1.1s ease-out infinite;
}

@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(240, 84, 84, 0.65); }
  70% { box-shadow: 0 0 0 10px rgba(240, 84, 84, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 84, 84, 0); }
}

.msg-footer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
}

.btn-speak-msg, .reply-action-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border-strong));
  background: color-mix(in srgb, var(--bg) 42%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s var(--ease-bounce), border-color 0.15s ease, background 0.15s ease;
}

.btn-speak-msg:active, .reply-action-chip:active {
  transform: scale(0.94);
  border-color: var(--accent);
}

.btn-speak-msg.playing {
  border-color: var(--accent);
  color: var(--accent);
}

/* =====================================================================
   SYMBIOTE OS — Next-Gen Spatial Core, Radial Gestures & Generative UI
   ===================================================================== */

.live-orb-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.live-orb-dot.status-busy {
  background: var(--warn);
  animation: pulseDot 1.2s ease-in-out infinite;
}

.view-switch {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
}

.vs-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s ease, color 0.18s ease;
}

.vs-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
}

.icon-refresh-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.25s var(--ease-spring), color 0.15s ease, border-color 0.15s ease;
}
.icon-refresh-btn svg { width: 15px; height: 15px; }
.icon-refresh-btn:active { color: var(--accent); border-color: var(--accent); transform: rotate(180deg) scale(0.92); }

/* 3-tab bottom nav geometry */
.bottom-nav-3 {
  grid-template-columns: repeat(3, 1fr);
}
.nav-indicator-3 {
  width: calc((100% - 16px) / 3);
}

/* --- Spatial Living Core View --- */
.core-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  gap: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.life-hud-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  width: 100%;
  flex-shrink: 0;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border-strong));
  background: var(--card-bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.14s var(--ease-bounce), border-color 0.18s ease, background 0.18s ease;
}
.hud-pill:active { transform: scale(0.94); }
.hud-pill[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--bubble-user-a);
  color: var(--text);
}

.core-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  min-height: 230px;
  user-select: none;
  -webkit-user-select: none;
}

.core-hit-target {
  position: relative;
  width: 210px;
  height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.22s var(--ease-bounce);
}
.core-hit-target:active { transform: scale(0.95); }
.core-hit-target.listening { transform: scale(1.06); }

.core-canvas {
  position: absolute;
  inset: 0;
  width: 210px;
  height: 210px;
  pointer-events: none;
}

.core-orb-img {
  width: 122px;
  height: 122px;
  border-radius: 50%;
  object-fit: contain;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: orbFloat 4.5s ease-in-out infinite;
  transition: transform 0.25s var(--ease-spring), filter 0.25s ease;
}

.core-hit-target.listening .core-orb-img {
  filter: saturate(1.5) brightness(1.25);
}

.app-shell.is-busy .core-orb-img {
  animation: orbSpinPulse 3s linear infinite;
}

.radial-hint {
  position: absolute;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  opacity: 0.36;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s var(--ease-bounce), border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}
.radial-up { top: 2px; left: 50%; transform: translateX(-50%); }
.radial-down { bottom: 34px; left: 50%; transform: translateX(-50%); }
.radial-left { left: 4px; top: 44%; transform: translateY(-50%); }
.radial-right { right: 4px; top: 44%; transform: translateY(-50%); }

.core-stage.dragging .radial-hint { opacity: 0.78; }
.radial-hint.armed {
  opacity: 1 !important;
  color: var(--text);
  border-color: var(--accent);
  background: var(--bubble-user-a);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 42%, transparent);
}
.radial-up.armed { transform: translateX(-50%) scale(1.12); }
.radial-down.armed { transform: translateX(-50%) scale(1.12); }
.radial-left.armed { transform: translateY(-50%) scale(1.12); }
.radial-right.armed { transform: translateY(-50%) scale(1.12); }

.core-orbit-tool {
  margin-top: 2px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  background: var(--bubble-user-a);
  font-size: 11.5px;
  font-weight: 600;
  animation: msgIn 0.2s var(--ease-spring);
}

.core-status-text {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}

.core-response-wrap {
  width: 100%;
  max-height: 44%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}

.core-response-card {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--bubble-radius);
  background: var(--card-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border-strong));
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  font-size: 14.2px;
  line-height: 1.46;
  animation: msgIn 0.26s var(--ease-bounce);
}

.core-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--muted);
}

.core-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mini-icon-btn {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 45%, transparent);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.mini-icon-btn.playing {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Generative Interactive Widgets --- */
.gen-widget {
  margin: 8px 0;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border-strong));
  background: color-mix(in srgb, var(--bg) 42%, transparent);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gen-widget-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* KPI Grid Widget */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}
.kpi-tile {
  padding: 9px 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 42%, transparent);
  border: 1px solid var(--border);
}
.kpi-label { font-size: 11px; color: var(--muted); }
.kpi-value { font-size: 17px; font-weight: 750; margin-top: 2px; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi-trend-up { color: var(--ok); font-weight: 650; }
.kpi-trend-down { color: var(--danger); font-weight: 650; }

/* Interactive Checklist Widget */
.w-checklist {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.w-check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 38%, transparent);
  border: 1px solid var(--border);
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.18s ease, border-color 0.18s ease;
}
.w-check-row.done {
  opacity: 0.55;
  text-decoration: line-through;
}
.w-check-box {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1.8px solid var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  color: var(--accent-text);
}
.w-check-row.done .w-check-box {
  background: var(--accent);
}

/* Visual Choice Cards Widget */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.choice-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 11px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border-strong));
  background: color-mix(in srgb, var(--surface) 44%, transparent);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.14s var(--ease-bounce), border-color 0.18s ease, background 0.18s ease;
}
.choice-card:active {
  transform: scale(0.95);
  border-color: var(--accent);
  background: var(--bubble-user-a);
}
.choice-icon { font-size: 20px; margin-bottom: 2px; }
.choice-title { font-size: 13px; font-weight: 650; }
.choice-sub { font-size: 11px; color: var(--muted); }

/* Live Circular Timer Widget */
.w-timer-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.w-timer-clock {
  font-size: 26px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
.w-timer-controls {
  display: flex;
  gap: 6px;
}

/* Life Drawer */
.life-add-row {
  display: flex;
  gap: 8px;
}
.life-add-row input { flex: 1; }
.life-sheet-body {
  max-height: 55dvh;
  overflow-y: auto;
}
.rem-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 42%, transparent);
  border: 1px solid var(--border);
  font-size: 13px;
}

/* =====================================================================
   AGY HUB v17 — Clean Full-Screen Canvas, Slide-Over Drawer & + Palette
   ===================================================================== */

.chat-canvas {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s var(--ease-bounce), border-color 0.18s ease;
}
.topbar-icon-btn svg { width: 18px; height: 18px; }
.topbar-icon-btn:active { transform: scale(0.92); border-color: var(--accent); }

.composer-dock-clean {
  position: relative;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.app-shell.kb-open .composer-dock-clean {
  padding-bottom: 6px;
}

.plus-btn svg {
  transition: transform 0.22s var(--ease-spring);
}
.plus-btn[aria-expanded="true"] {
  color: var(--accent);
}
.plus-btn[aria-expanded="true"] svg {
  transform: rotate(45deg);
}

/* Floating Command & Tools Palette above composer */
.plus-palette {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 6px);
  z-index: 30;
  padding: 8px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border-strong));
  background: var(--sheet-bg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  transform-origin: bottom left;
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  transition:
    opacity 0.2s var(--ease-spring),
    transform 0.28s var(--ease-spring),
    display 0.22s allow-discrete;
}
@starting-style {
  .plus-palette:not([hidden]) {
    opacity: 0;
    transform: translate3d(0, 12px, 0) scale(0.94);
  }
}
.plus-palette[hidden] {
  display: none;
  opacity: 0;
  transform: translate3d(0, 10px, 0) scale(0.95);
  pointer-events: none;
}

.pal-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 42%, transparent);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.24s var(--ease-spring), border-color 0.18s ease, background 0.18s ease;
}
.pal-item:active {
  transform: scale(0.95);
  border-color: var(--accent);
  background: var(--bubble-user-a);
  transition-duration: 0.08s;
}
.pal-icon { font-size: 18px; flex-shrink: 0; }
.pal-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pal-text strong {
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pal-text small {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact Quick Model Pill inside Composer */
.quick-model-pill {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  max-width: 96px;
  padding: 0 7px 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--bg) 56%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s var(--ease-bounce), border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.quick-model-pill:active {
  transform: scale(0.93);
}
.quick-model-pill[aria-expanded="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--bg));
}
.quick-model-pill .qm-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
}
.quick-model-pill[data-tier="eco"] .qm-dot {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.65);
}
.quick-model-pill[data-tier="bal"] .qm-dot {
  background: var(--accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 65%, transparent);
}
.quick-model-pill[data-tier="hi"] .qm-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.7);
}
.quick-model-pill .qm-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-model-pill .qm-chev {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  opacity: 0.72;
  transition: transform 0.2s var(--ease-spring);
}
.quick-model-pill[aria-expanded="true"] .qm-chev {
  transform: rotate(180deg);
  opacity: 1;
}

/* Floating Quick Model & Effort Popover above Composer */
.model-popover {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 6px);
  z-index: 31;
  padding: 10px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border-strong));
  background: var(--sheet-bg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform-origin: bottom right;
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  transition:
    opacity 0.2s var(--ease-spring),
    transform 0.28s var(--ease-spring),
    display 0.22s allow-discrete;
}
@starting-style {
  .model-popover:not([hidden]) {
    opacity: 0;
    transform: translate3d(0, 12px, 0) scale(0.94);
  }
}
.model-popover[hidden] {
  display: none;
  opacity: 0;
  transform: translate3d(0, 10px, 0) scale(0.95);
  pointer-events: none;
}

.mp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
}
.mp-title {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-effort-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.mp-effort-row[hidden] { display: none !important; }
.mp-eff-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  padding: 4px 8px;
  border-radius: 7px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.mp-eff-btn:active { transform: scale(0.93); }
.mp-eff-btn.active {
  background: var(--accent);
  color: #fff;
}

.mp-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mp-row {
  display: grid;
  gap: 6px;
}
.mp-row-3 { grid-template-columns: repeat(3, 1fr); }
.mp-row-2 { grid-template-columns: repeat(2, 1fr); }
.mp-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 42%, transparent);
  color: var(--text);
  text-align: left;
  font: inherit;
  min-width: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s var(--ease-bounce), border-color 0.16s ease, background 0.16s ease;
}
.mp-row-3 .mp-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 8px 8px;
}
.mp-item:active { transform: scale(0.95); }
.mp-item.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}
.mp-icon { font-size: 15px; flex-shrink: 0; line-height: 1; }
.mp-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}
.mp-meta strong {
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-meta small {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-all-btn {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 34%, transparent);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 11px;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.mp-all-btn:active {
  border-color: var(--accent);
  color: var(--text);
}

/* Slide-Over Navigation Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(2, 6, 14, 0.62);
  opacity: 1;
  transition: opacity 0.28s var(--ease-spring), display 0.28s allow-discrete;
}
@starting-style {
  .drawer-backdrop:not([hidden]) {
    opacity: 0;
  }
}
.drawer-backdrop[hidden] {
  display: none;
  opacity: 0;
  pointer-events: none;
}
.drawer-backdrop.dragging {
  transition: none !important;
}

.nav-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  width: min(88vw, 350px);
  display: flex;
  flex-direction: column;
  background: var(--sheet-bg);
  border-right: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border-strong));
  box-shadow: 12px 0 42px rgba(0, 0, 0, 0.6);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translate3d(-105%, 0, 0);
  transition: transform 0.34s var(--ease-spring);
  will-change: transform;
}
.nav-drawer.open {
  transform: translate3d(0, 0, 0);
}
.nav-drawer.dragging {
  transition: none !important;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.drawer-brand {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-tabs::-webkit-scrollbar { display: none; }

.d-tab {
  flex: none;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.d-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 24px;
}

.drawer-sec {
  animation: panelFadeIn 0.24s var(--ease-spring);
}
.drawer-sec[hidden] { display: none !important; }

/* Fluid spring touch response across controls & bubbles */
.msg {
  transition: transform 0.26s var(--ease-spring), filter 0.2s ease;
}
.msg:active {
  transform: scale(0.986);
  transition-duration: 0.08s;
}
.quick-model-pill,
.mp-item,
.mp-eff-btn,
.mp-all-btn,
.d-tab,
.dialog-item,
.topbar-icon-btn,
.dialog-trigger,
.partner-pill,
.quota-pill,
.icon-btn,
.send-btn,
.btn,
.mode-btn,
.sheet-action-btn,
.act-chip {
  transition-timing-function: var(--ease-spring);
  transition-duration: 0.24s;
}
.quick-model-pill:active,
.mp-item:active,
.mp-eff-btn:active,
.d-tab:active,
.dialog-item:active,
.topbar-icon-btn:active,
.dialog-trigger:active,
.partner-pill:active,
.quota-pill:active,
.icon-btn:active,
.send-btn:active,
.btn:active,
.mode-btn:active,
.sheet-action-btn:active,
.act-chip:active {
  transition-duration: 0.07s;
}

.drawer-actions-row {
  display: flex;
  gap: 8px;
}

/* Message subtle more button & Action Sheet */
.msg-meta-right-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.msg-more-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.72;
  touch-action: manipulation;
}
.msg-more-btn:active { opacity: 1; color: var(--accent); }

.sheet-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 52%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s var(--ease-bounce), border-color 0.16s ease;
}
.sheet-action-btn:active {
  transform: scale(0.97);
  border-color: var(--accent);
}

.empty-starters {
  width: 100%;
  max-width: 340px;
  margin-top: 10px;
}

/* =====================================================================
   LIVE CO-PRESENCE PILL, GLOBAL AI ACTIVITY TELEMETRY & TYPING STRIP
   ===================================================================== */

.partner-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(244, 114, 182, 0.45);
  background: rgba(244, 114, 182, 0.14);
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  animation: msgIn 0.22s var(--ease-spring);
  transition: transform 0.14s var(--ease-bounce), background 0.16s ease;
}
.partner-pill[hidden] { display: none !important; }
.partner-pill:active {
  transform: scale(0.92);
  background: rgba(244, 114, 182, 0.28);
}

.partner-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f472b6;
  box-shadow: 0 0 0 3px rgba(244, 114, 182, 0.28);
  animation: partnerPulse 1.8s ease-in-out infinite;
}
@keyframes partnerPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(244, 114, 182, 0.28); }
  50% { box-shadow: 0 0 0 6px rgba(244, 114, 182, 0); }
}

.live-activity-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 10px 2px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 44%, var(--border-strong));
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  animation: msgIn 0.22s var(--ease-spring);
}
.live-activity-bar[hidden] { display: none !important; }
.live-activity-bar.busy-other {
  border-color: rgba(244, 114, 182, 0.55);
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.14), rgba(251, 146, 60, 0.1));
}

.live-act-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.live-act-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-top-color: var(--accent);
  flex-shrink: 0;
  animation: spinAct 0.85s linear infinite;
}
.live-activity-bar.busy-other .live-act-spinner {
  border-color: rgba(244, 114, 182, 0.25);
  border-top-color: #f472b6;
}
@keyframes spinAct {
  to { transform: rotate(360deg); }
}

.live-act-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.live-act-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-act-detail {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-act-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.live-act-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fbbf24;
  font-size: 10.5px;
  font-weight: 700;
}
.live-act-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.partner-typing-bar {
  font-size: 11.5px;
  color: #f9a8d4;
  padding: 2px 10px 4px;
  font-weight: 550;
  animation: msgIn 0.18s ease;
}
.partner-typing-bar[hidden] { display: none !important; }

/* =====================================================================
   PEOPLE / PRESENCE (v19): last-seen, activity, today stats, offline pill
   ===================================================================== */
.partner-pill.offline {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  color: var(--muted);
}
.partner-pill.offline .partner-dot {
  background: var(--muted);
  box-shadow: none;
  animation: none;
}

.person-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--card-bg);
}
.person-card.is-online {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--border-strong));
}
.person-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  flex-shrink: 0;
}
.person-avatar .p-status {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--muted);
}
.person-card.is-online .p-status { background: var(--ok); }
.person-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.person-name { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.person-you {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  background: var(--bubble-user-a); color: var(--text);
}
.person-line { font-size: 12px; color: var(--muted); line-height: 1.4; }
.person-line strong { color: var(--text); font-weight: 650; }

/* =====================================================================
   CONNECTED PCs LIVE TELEMETRY (v23)
   ===================================================================== */
.pc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 4px;
}
.pc-toolbar-title {
  font-size: 15px;
  font-weight: 750;
  color: var(--text);
}

.pc-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--card-bg);
  transition: border-color 0.2s ease;
}
.pc-card.is-online {
  border-color: color-mix(in srgb, var(--ok) 48%, var(--border-strong));
}
.pc-card.is-offline {
  opacity: 0.82;
}

.pc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.pc-title-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.pc-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.pc-name-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pc-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 720;
  font-size: 14.5px;
  color: var(--text);
}
.pc-owner-tag {
  font-size: 10.5px;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--muted);
}
.pc-sub-meta {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-state-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--muted);
  white-space: nowrap;
}
.pc-state-pill.active {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}
.pc-state-pill.warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
}

.pc-activity-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 11px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid var(--border);
}
.pc-activity-kicker {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.pc-activity-main {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}
.pc-activity-extra {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}

.pc-bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.pc-bar-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pc-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
}
.pc-bar-label {
  color: var(--muted);
  font-weight: 600;
}
.pc-bar-val {
  color: var(--text);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.pc-bar-row .bar-track {
  height: 5px;
}

.pc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border: 1px solid var(--border);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pc-chip span {
  color: var(--muted);
  font-weight: 500;
}
.pc-chip-x {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  padding: 1px 3px;
  margin-left: 2px;
  cursor: pointer;
  border-radius: 999px;
}
.pc-chip-x:hover {
  color: #fca5a5;
  background: color-mix(in srgb, #ef4444 18%, transparent);
}

.pc-details {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  padding: 6px 9px;
}
.pc-details > summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pc-details > summary::-webkit-details-marker { display: none; }
.pc-details > summary::after {
  content: "▾";
  font-size: 11px;
  transition: transform 0.18s ease;
}
.pc-details[open] > summary::after {
  transform: rotate(180deg);
}
.pc-details-body {
  margin-top: 7px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pc-proc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  padding-top: 3px;
  border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
}
.pc-proc-name {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-proc-stat {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  flex-shrink: 0;
}
.pc-win-item {
  font-size: 11.5px;
  color: var(--text);
  padding: 3px 0;
  word-break: break-word;
}

.pc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}
.pc-foot-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pc-mini-btn {
  padding: 5px 9px;
  font-size: 11.5px;
  border-radius: 9px;
}

.pc-ctrl-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 6px;
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}
.pc-ctrl-kicker {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pc-ctrl-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.pc-ctrl-btn {
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}
.pc-ctrl-btn:active { transform: scale(0.96); }
.pc-ctrl-btn:disabled { opacity: 0.5; cursor: default; }
.pc-ctrl-btn.is-muted {
  border-color: color-mix(in srgb, #f59e0b 60%, var(--border));
  color: #fbbf24;
}
.pc-ctrl-btn.is-danger {
  border-color: color-mix(in srgb, #ef4444 50%, var(--border));
  color: #fca5a5;
}
.pc-vol-badge {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 7px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  color: var(--muted);
}

.pc-scene-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pc-scene-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent, #38bdf8) 32%, var(--border));
  background: color-mix(in srgb, var(--accent, #38bdf8) 10%, color-mix(in srgb, var(--bg) 85%, transparent));
  color: var(--text);
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.pc-scene-pill:active { transform: scale(0.96); }
.pc-scene-pill:disabled { opacity: 0.55; cursor: default; }
.pc-scene-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.pc-scene-del {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 5px;
  cursor: pointer;
  border-radius: 6px;
}
.pc-scene-del:hover { color: #fca5a5; }
.pc-scene-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pc-scene-preview {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  line-height: 1.45;
  white-space: pre-line;
}

.pc-games-search {
  width: 100%;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  color: var(--text);
  font-size: 12px;
}
.pc-games-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 250px;
  overflow-y: auto;
}
.pc-game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}
.pc-game-row.is-running {
  border-color: color-mix(in srgb, #22c55e 55%, var(--border));
  background: color-mix(in srgb, #22c55e 10%, color-mix(in srgb, var(--bg) 80%, transparent));
}
.pc-game-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pc-game-name {
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-game-meta {
  font-size: 10.5px;
  color: var(--muted);
}
.pc-game-btn {
  flex-shrink: 0;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
}

.pc-win-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 0;
  border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
}
.pc-win-title {
  font-size: 11.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.pc-win-acts {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.pc-win-btn {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  color: var(--muted);
  border-radius: 7px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}
.pc-win-btn:hover { color: var(--text); }
.pc-win-btn.is-danger:hover { color: #fca5a5; border-color: color-mix(in srgb, #ef4444 45%, var(--border)); }

.pc-scene-apps-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pc-app-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pc-app-check input { margin: 0; }

/* =====================================================================
   HUB (LOCAL / NO-LIMIT) vs GEMINI AI VISUAL DISTINCTION
   ===================================================================== */
:root {
  --hub-tone: #34d399;
  --ai-tone: #a78bfa;
  --ai-tone-2: #f472b6;
}

.kind-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  vertical-align: middle;
  flex-shrink: 0;
}
.kind-tag.hub {
  color: #6ee7b7;
  background: color-mix(in srgb, var(--hub-tone) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--hub-tone) 36%, transparent);
}
.kind-tag.ai {
  color: #ddd6fe;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ai-tone) 24%, transparent), color-mix(in srgb, var(--ai-tone-2) 18%, transparent));
  border: 1px solid color-mix(in srgb, var(--ai-tone) 48%, transparent);
}

.pal-section-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 1px;
  font-size: 10.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.pal-section-head.is-ai {
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px dashed color-mix(in srgb, var(--ai-tone) 35%, var(--border));
  color: #ddd6fe;
}

.pal-item.is-hub-action {
  border-color: color-mix(in srgb, var(--hub-tone) 26%, var(--border));
  background: color-mix(in srgb, var(--hub-tone) 6%, color-mix(in srgb, var(--bg) 48%, transparent));
}
.pal-item.is-ai-action {
  border-color: color-mix(in srgb, var(--ai-tone) 36%, var(--border));
  background: linear-gradient(145deg, color-mix(in srgb, var(--ai-tone) 12%, transparent), color-mix(in srgb, var(--bg) 48%, transparent));
}

.sheet-action-btn.is-hub-action {
  border-color: color-mix(in srgb, var(--hub-tone) 28%, var(--border));
}
.sheet-action-btn.is-ai-action {
  border-color: color-mix(in srgb, var(--ai-tone) 44%, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, var(--ai-tone) 14%, transparent), color-mix(in srgb, var(--surface) 56%, transparent));
}

.btn-ai {
  color: #f5f3ff;
  border: 1px solid color-mix(in srgb, var(--ai-tone) 55%, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, var(--ai-tone) 34%, transparent), color-mix(in srgb, var(--ai-tone-2) 24%, transparent));
}
.btn-ai:hover {
  border-color: var(--ai-tone);
}

.d-tab.d-tab-ai {
  color: #ddd6fe;
  border-color: color-mix(in srgb, var(--ai-tone) 34%, transparent);
  background: color-mix(in srgb, var(--ai-tone) 10%, transparent);
}
.d-tab.d-tab-ai.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--ai-tone) 36%, transparent), color-mix(in srgb, var(--ai-tone-2) 26%, transparent));
  border-color: var(--ai-tone);
  color: #fff;
}

.theme-gen-box.is-ai-card {
  margin-top: 6px;
  padding: 10px 11px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--ai-tone) 42%, var(--border));
  background: linear-gradient(155deg, color-mix(in srgb, var(--ai-tone) 11%, transparent), color-mix(in srgb, var(--bg) 55%, transparent));
}
.ai-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-quota-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  padding: 7px 11px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, #f59e0b 45%, var(--border));
  background: color-mix(in srgb, #f59e0b 11%, var(--sheet-bg));
  font-size: 11.5px;
}
.ai-qb-text {
  color: #fde68a;
  font-weight: 600;
}
.ai-qb-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.empty-hub-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 340px;
  margin-top: 10px;
}
.empty-tool-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 11px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 58%, transparent);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.16s ease;
}
.empty-tool-card:active { transform: scale(0.97); }
.empty-tool-card.is-hub {
  border-color: color-mix(in srgb, var(--hub-tone) 34%, var(--border));
  background: color-mix(in srgb, var(--hub-tone) 9%, color-mix(in srgb, var(--surface) 55%, transparent));
}
.empty-tool-card.is-ai {
  border-color: color-mix(in srgb, var(--ai-tone) 40%, var(--border));
  background: linear-gradient(145deg, color-mix(in srgb, var(--ai-tone) 12%, transparent), color-mix(in srgb, var(--surface) 55%, transparent));
}
.empty-tool-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.empty-tool-title {
  font-size: 12.5px;
  font-weight: 700;
}
.empty-tool-sub {
  font-size: 11px;
  color: var(--muted);
}

/* =====================================================================
   REMOTE SCREEN & INPUT CONTROLLER DIALOG
   ===================================================================== */
.remote-dialog {
  width: calc(100vw - 12px);
  max-width: 660px;
  height: 92dvh;
  max-height: 92dvh;
  margin: auto;
  padding: 10px 12px;
  border-radius: 20px;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}
.remote-dialog[open] {
  display: flex;
}
.remote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.remote-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.remote-head-left strong {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.remote-head-acts {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.remote-screen-wrap {
  position: relative;
  flex: 1;
  min-height: 150px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: #05080f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: manipulation;
}
.remote-screen-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}
.remote-screen-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.remote-mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  flex-shrink: 0;
}
.remote-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.remote-panel[hidden] {
  display: none;
}

.remote-touchpad {
  height: 112px;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  font-size: 11.5px;
  color: var(--muted);
  user-select: none;
  touch-action: none;
}
.remote-mouse-btns {
  display: flex;
  gap: 6px;
}

.remote-text-form {
  display: flex;
  gap: 6px;
}
.remote-text-form input {
  flex: 1;
  min-width: 0;
}
.remote-keys-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pad-bumpers {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.pad-main {
  display: grid;
  grid-template-columns: 110px 1fr 110px;
  align-items: center;
  justify-items: center;
  gap: 8px;
  padding: 4px 0;
}
.pad-btn {
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  color: var(--text);
  font-weight: 750;
  font-size: 12px;
  border-radius: 11px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.pad-btn.is-down, .pad-btn:active {
  background: var(--accent);
  color: #05080f;
  border-color: var(--accent);
}
.pad-wide { min-width: 54px; }
.pad-sm { font-size: 10.5px; padding: 7px 9px; }

.pad-dpad, .pad-abxy {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
  gap: 3px;
}
.pad-d-up, .pad-y { grid-column: 2; grid-row: 1; }
.pad-d-left, .pad-x { grid-column: 1; grid-row: 2; }
.pad-d-right, .pad-b { grid-column: 3; grid-row: 2; }
.pad-d-down, .pad-a { grid-column: 2; grid-row: 3; }
.pad-a { color: #86efac; }
.pad-b { color: #fca5a5; }
.pad-x { color: #93c5fd; }
.pad-y { color: #fde047; }

.pad-stick {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.pad-stick-knob {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 70%, #fff);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  transition: transform 0.06s linear;
}

@media (prefers-reduced-motion: reduce) {
  .bg-wallpaper, .bg-aurora, .ai-core-img, .thinking-orb img, .thinking-wave::after,
  .topbar-energy-beam, .online-radar, details.tool-call.tool-running::after,
  .topbar, .bottom-nav, .composer-dock, .card, .btn-primary, .btn-primary::before,
  .send-btn, .nav-indicator, .mode-btn.active, .bar-fill, dialog.sheet-dialog, .theme-card.active {
    animation: none !important;
  }
  .bg-particles, .fx-overlay { display: none; }
}
