
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; touch-action: pan-x pan-y; }

/* ── THEME TOKENS ─────────────────────────────────────────────── */
:root {
  --bg:              #212121;
  --bg-sidebar:      #171717;
  --bg-elevated:     #2f2f2f;
  --bg-input:        #2f2f2f;
  --bg-msg-user:     #2f2f2f;
  --surface-1:       rgba(255,255,255,0.025);
  --surface-2:       rgba(255,255,255,0.045);
  --surface-raised:  #1b1b1b;
  --border:          rgba(255,255,255,0.1);
  --border-input:    rgba(255,255,255,0.2);
  --text:            #ececec;
  --text-muted:      #8e8ea0;
  --text-faint:      #5c5c6b;
  --accent:          #ff4d67;
  --accent-hover:    #e33d59;
  --workspace-glow:  rgba(255,77,103,0.16);
  --accent-rgb:      255,77,103;
  --accent-deep-rgb: 161,18,57;
  --accent-gradient: linear-gradient(135deg, #ff6a6f 0%, #ff4d67 42%, #b31239 100%);
  --accent-soft-bg:  rgba(255,77,103,0.08);
  --accent-soft-border: rgba(255,77,103,0.22);
  --accent-soft-fill: rgba(255,77,103,0.16);
  --accent-ring:     rgba(255,77,103,0.14);
  --accent-gradient-soft: linear-gradient(180deg, rgba(255,77,103,0.16), rgba(161,18,57,0.08));
  --accent-radial-soft: radial-gradient(circle at top right, rgba(255,77,103,0.12), transparent 42%);
  --send-bg:         #ececec;
  --send-fg:         #212121;
  --send-disabled:   #444;
  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       16px;
  --radius-xl:       24px;
  --sidebar-w:       260px;
  --artifact-w:      44vw;
  --mono:            "SF Mono","Fira Code",Consolas,monospace;
  --shadow-md:       0 4px 24px rgba(0,0,0,0.35);
  --shadow-lg:       0 8px 40px rgba(0,0,0,0.5);
  --topbar-h:        71px;
  --app-height:      100svh;
  --safe-area-top:   0px;
  --safe-area-right: 0px;
  --safe-area-bottom: 0px;
  --safe-area-left:  0px;
  --safe-area-top:   constant(safe-area-inset-top);
  --safe-area-right: constant(safe-area-inset-right);
  --safe-area-bottom: constant(safe-area-inset-bottom);
  --safe-area-left:  constant(safe-area-inset-left);
  --safe-area-top:   env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left:  env(safe-area-inset-left, 0px);
  --viewport-top-inset: 0px;
  --viewport-bottom-inset: 0px;
  --resolved-safe-top: max(var(--safe-area-top), var(--viewport-top-inset));
  --resolved-safe-bottom: max(var(--safe-area-bottom), var(--viewport-bottom-inset));
  --glow-safe-bottom: min(12px, var(--resolved-safe-bottom));
}

html[data-theme="light"] {
  --bg:              #ffffff;
  --bg-sidebar:      #f9f9f9;
  --bg-elevated:     #f4f4f5;
  --bg-input:        #ffffff;
  --bg-msg-user:     #f4f4f5;
  --surface-1:       rgba(15,23,42,0.028);
  --surface-2:       rgba(15,23,42,0.05);
  --surface-raised:  #ffffff;
  --border:          rgba(0,0,0,0.1);
  --border-input:    rgba(0,0,0,0.2);
  --text:            #0d0d0d;
  --text-muted:      #6b6b80;
  --text-faint:      #a0a0b0;
  --workspace-glow:  rgba(255,77,103,0.1);
  --send-bg:         #0d0d0d;
  --send-fg:         #ffffff;
  --send-disabled:   #ccc;
  --shadow-md:       0 4px 24px rgba(0,0,0,0.1);
  --shadow-lg:       0 8px 40px rgba(0,0,0,0.18);
}

/* ── RESET ───────────────────────────────────────────────────── */
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  height: var(--app-height, 100svh);
  overflow: hidden;
  display: flex;
  font-family: "Inter","Segoe UI",sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.6;
  touch-action: pan-x pan-y;
}

.hidden { display: none !important; }

/* ── LAYOUT ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100svh);
  overflow: hidden;
  z-index: 20;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.sidebar.collapsed {
  transform: translateX(-110%);
  opacity: 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  pointer-events: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 24;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(5, 8, 13, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 30;
  }
  .sidebar:not(.collapsed) { box-shadow: var(--shadow-lg); }
}

.app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: var(--app-height, 100svh);
  overflow: hidden;
}

/* ── SIDEBAR INTERNALS ───────────────────────────────────────── */
.sidebar-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.75rem) 0.75rem 0.5rem;
}
.sidebar-close-btn { margin-right: auto; }
.sidebar-close-btn {
  /* ensure fixed-position override doesn't inherit layout margins */
  margin-right: 0 !important;
  margin-left: 0 !important;
}

.new-chat-btn {
  display: flex;
  margin-left: auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.new-chat-btn:hover { background: var(--bg-elevated); }
.new-chat-btn svg { flex-shrink: 0; opacity: 0.7; }

.sidebar-section {
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}
.sidebar-section-label {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 0.35rem;
}
.sidebar-select-group { display: flex; flex-direction: column; gap: 0.3rem; }
.sidebar-select-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0 0.35rem;
}
.sidebar-select {
  width: 100%;
  padding: 0.6rem 2.2rem 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8ea0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}
.sidebar-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.sidebar-spacer { flex: 1; }

.chatroom-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.14) transparent;
}

.chatroom-list::-webkit-scrollbar { width: 6px; }
.chatroom-list::-webkit-scrollbar-track { background: transparent; }
.chatroom-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
  border: 1px solid transparent;
  background-clip: padding-box;
}
html[data-theme="light"] .chatroom-list { scrollbar-color: rgba(0,0,0,0.16) transparent; }
html[data-theme="light"] .chatroom-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.16); }
.chatroom-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }
html[data-theme="light"] .chatroom-list::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.24); }
.chatroom-list::-webkit-scrollbar-button { display: none; height: 0; }

.chatroom-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chatroom-item:hover { background: var(--bg-elevated); }

.chatroom-item.active {
  background: var(--bg-elevated);
  border-color: var(--border-input);
}

.chatroom-item-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.chatroom-item-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatroom-item-meta {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.chatroom-item-spinner-logo {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
  fill: currentColor;
  color: var(--text-muted);
  animation: sidebarLogoSpin 1.25s linear infinite;
}

@keyframes sidebarLogoSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.sidebar-footer {
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.sidebar-account-card {
  display: flex;
  flex-direction: column;
  gap: 0.68rem;
  padding: 0.72rem 0.78rem;
  margin-bottom: 0.3rem;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.05);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb),0.08), transparent 38%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 74%, transparent), color-mix(in srgb, var(--bg-elevated) 98%, transparent));
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}
.sidebar-account-head {
  display: flex;
  align-items: center;
  gap: 0.62rem;
}
.sidebar-account-copy {
  min-width: 0;
  flex: 1;
}
.sidebar-account-kicker {
  display: none;
}
.sidebar-account-name {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.12;
  font-weight: 600;
}
.sidebar-account-email {
  margin: 0.1rem 0 0;
  color: var(--text-muted);
  font-size: 0.73rem;
  line-height: 1.34;
  word-break: break-word;
}
.sidebar-account-avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb),0.16), rgba(var(--accent-deep-rgb),0.06)),
    rgba(255,255,255,0.02);
  border: 1px solid rgba(var(--accent-rgb),0.12);
  flex-shrink: 0;
}
.sidebar-quota-card {
  display: flex;
  flex-direction: column;
  gap: 0.34rem;
  padding: 0.56rem 0;
  border-radius: 0;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.sidebar-quota-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
}
.sidebar-quota-label {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.sidebar-quota-value {
  color: var(--text);
  font-weight: 600;
  font-size: 0.74rem;
}
.sidebar-quota-secondary-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sidebar-quota-secondary-value {
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 600;
}
.sidebar-quota-secondary-meta {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.65rem;
  line-height: 1.2;
}
.sidebar-account-actions {
  display: flex;
  gap: 0.38rem;
  align-items: center;
}
.sidebar-account-btn {
  flex: 1 1 0;
  min-height: 2rem;
  padding: 0.5rem 0.72rem;
  border-radius: 10px;
  font-size: 0.82rem;
}
.sidebar-account-ghost {
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  font-size: 0.8rem;
}
.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.sidebar-footer-btn:hover { background: var(--bg-elevated); color: var(--text); }
.sidebar-footer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.sidebar-footer-btn.active {
  background: var(--accent-gradient-soft);
  color: var(--text);
}
.sidebar-footer-btn svg { flex-shrink: 0; }
.toolbar-action-btn,
#account-logout-btn,
#settings-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.toolbar-action-btn svg,
#account-logout-btn svg,
#settings-logout-btn svg {
  flex-shrink: 0;
}

.sidebar-footer-btn-label {
  min-width: 0;
  white-space: nowrap;
}
.sidebar-btn-count {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.38rem;
  border-radius: 999px;
  background: rgba(var(--accent-rgb),0.18);
  color: var(--text);
  font-size: 0.73rem;
  font-weight: 700;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ── TOP BAR ─────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--resolved-safe-top) + 0.9rem) max(1rem, var(--safe-area-right)) 0.65rem max(1rem, var(--safe-area-left));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  height: calc(var(--topbar-h) + var(--resolved-safe-top) + 0.25rem);
}
.topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.topbar-settings {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.topbar-select-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.topbar-select {
  min-width: 150px;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8ea0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
}
.topbar-model-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.48rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.topbar-badge:hover,
.topbar-badge[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--border-input);
}

.topbar-badge-text {
  white-space: nowrap;
}

.topbar-badge-chevron {
  color: currentColor;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.topbar-badge[aria-expanded="true"] .topbar-badge-chevron {
  transform: rotate(180deg);
}

.topbar-settings-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 30;
  min-width: 240px;
  padding: 0.8rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px) saturate(140%);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.chatroom-context-menu {
  position: fixed;
  z-index: 60;
  min-width: 220px;
  padding: 0.55rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px) saturate(140%);
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.chatroom-context-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chatroom-context-menu-item:hover {
  background: var(--bg-elevated);
}

.chatroom-context-menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chatroom-context-menu-item:disabled:hover {
  background: transparent;
}

.chatroom-context-menu-item-danger {
  color: #fb7185;
}

.chatroom-context-menu-item-danger:hover {
  background: rgba(251, 113, 133, 0.12);
  color: #ff94a3;
}

.chatroom-context-menu-separator {
  height: 1px;
  margin: 0.2rem 0;
  background: var(--border);
}

.chatroom-action-modal {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(16px) saturate(140%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.chatroom-action-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.chatroom-action-shell {
  width: min(100%, 460px);
  border-radius: 24px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  box-shadow: var(--shadow-lg);
  padding: 1.15rem;
  transform: translateY(10px) scale(0.985);
  transition: transform 0.18s ease;
}

.chatroom-action-modal.visible .chatroom-action-shell {
  transform: translateY(0) scale(1);
}

.theme-onboarding-modal {
  position: fixed;
  inset: 0;
  z-index: 330;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(circle at top, rgba(var(--accent-rgb), 0.16), transparent 28%),
    rgba(5, 8, 13, 0.64);
  backdrop-filter: blur(16px) saturate(138%);
}

.theme-onboarding-shell {
  width: min(100%, 780px);
  max-height: min(92svh, 760px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: 28px;
  border: 1px solid color-mix(in srgb, var(--border) 86%, rgba(255, 255, 255, 0.08));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 96%, transparent), color-mix(in srgb, var(--bg-elevated) 94%, transparent));
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.28);
  padding: 1.4rem;
}

.theme-onboarding-header {
  text-align: center;
  margin-bottom: 1.15rem;
}

.theme-onboarding-kicker {
  margin: 0 0 0.4rem;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
}

.theme-onboarding-title {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.theme-onboarding-copy {
  margin: 0.55rem auto 0;
  max-width: 34rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.theme-onboarding-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  min-height: 0;
}

.theme-onboarding-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding: 1rem;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  outline: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.theme-onboarding-card:hover,
.theme-onboarding-card:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
}

.theme-onboarding-card.active {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background: color-mix(in srgb, var(--accent) 11%, var(--surface-raised));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.16);
}

.theme-onboarding-preview {
  position: relative;
  height: 7rem;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(17, 17, 20, 0.14);
}

.theme-onboarding-preview-default {
  background:
    radial-gradient(circle at top left, rgba(255, 77, 103, 0.22), transparent 36%),
    linear-gradient(180deg, rgba(34, 36, 42, 0.98), rgba(18, 20, 26, 0.98));
}

.theme-preview-chip,
.theme-preview-line,
.theme-preview-box,
.theme-preview-grid {
  position: absolute;
  display: block;
}

.theme-preview-chip {
  top: 1rem;
  left: 1rem;
  width: 4.2rem;
  height: 1rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff6a6f 0%, #ff4d67 42%, #b31239 100%);
}

.theme-preview-line {
  left: 1rem;
  right: 1rem;
  height: 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.theme-preview-line:nth-of-type(2) {
  top: 3.4rem;
}

.theme-preview-line.short {
  top: 5.2rem;
  right: 35%;
}

.theme-onboarding-preview-blocky {
  background:
    repeating-linear-gradient(45deg, #efefef 0, #efefef 1.2px, #f9f9f9 0, #f9f9f9 50%);
  background-size: 12px 12px;
}

.theme-preview-grid {
  inset: 0;
  border: 2px solid #000;
  opacity: 0.14;
}

.theme-preview-box {
  left: 1rem;
  top: 1rem;
  width: calc(100% - 2rem);
  height: 2.2rem;
  border: 2px solid #000;
  background: #fff;
  box-shadow: -3px 3px 0 0 rgba(0, 0, 0, 0.16);
}

.theme-preview-box.dark {
  top: 4.4rem;
  width: 38%;
  background: #000;
}

.theme-preview-chip,
.theme-preview-line {
  border-radius: 999px;
}

.theme-preview-box {
  border-radius: 10px;
}

.theme-onboarding-card-copy h3 {
  margin: 0;
  font-size: 1rem;
}

.theme-onboarding-card-copy p {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.theme-onboarding-select-btn {
  align-self: flex-start;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  color: var(--text);
  font-weight: 700;
}

.theme-onboarding-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.2rem;
  position: sticky;
  bottom: 0;
  padding-top: 0.85rem;
  background: linear-gradient(180deg, rgba(0,0,0,0), color-mix(in srgb, var(--bg-elevated) 94%, transparent) 32%);
}

.theme-onboarding-status {
  margin: 0;
  color: var(--text-muted);
}

.theme-onboarding-confirm {
  flex: 0 0 auto;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 340;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  background:
    radial-gradient(circle at top, rgba(16, 163, 127, 0.12), transparent 32%),
    rgba(5, 8, 13, 0.58);
  backdrop-filter: blur(16px) saturate(135%);
}

.auth-shell {
  position: relative;
  width: min(100%, 420px);
  max-height: min(100%, 760px);
  overflow: auto;
  border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--border) 86%, rgba(255, 255, 255, 0.06));
  background: color-mix(in srgb, var(--surface-raised) 97%, transparent);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  padding: 1.6rem 1.35rem 1.25rem;
  text-align: center;
}

.auth-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.auth-header-copy {
  min-width: 0;
  width: 100%;
}

.auth-title {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.auth-copy {
  margin: 0.38rem auto 0;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 30ch;
}

.auth-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  flex-shrink: 0;
}

.auth-provider-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.8rem 0 1rem;
  color: var(--text-muted, rgba(255,255,255,0.6));
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1 1 0;
  height: 1px;
  background: var(--border);
  opacity: 0.7;
}
.auth-divider span {
  padding: 0 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted, rgba(255,255,255,0.7));
}

.auth-provider-btn {
  min-height: 4.25rem;
  padding: 0.7rem 0.55rem;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--border) 88%, rgba(255, 255, 255, 0.06));
  background: color-mix(in srgb, var(--bg-elevated) 82%, rgba(255, 255, 255, 0.015));
  color: var(--text);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-align: center;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

.auth-provider-btn:hover,
.auth-provider-btn.active {
  transform: translateY(-1px);
  border-color: rgba(16, 163, 127, 0.34);
  background: linear-gradient(180deg, rgba(16, 163, 127, 0.12), rgba(16, 163, 127, 0.04));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

.auth-provider-btn.unavailable {
  opacity: 0.72;
  border-style: dashed;
}

.auth-provider-btn.unavailable:hover {
  transform: none;
  box-shadow: none;
}

.auth-provider-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-provider-icon svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

#auth-provider-auoura .auth-provider-icon svg,
#auth-provider-google .auth-provider-icon svg,
#auth-provider-apple .auth-provider-icon svg {
  transform-origin: center;
}

#auth-provider-auoura .auth-provider-icon svg {
  transform: scale(1.08);
}

#auth-provider-google .auth-provider-icon svg {
  transform: scale(1.16);
}

#auth-provider-apple .auth-provider-icon svg {
  transform: scale(1.28);
}

.auth-provider-icon-auoura {
  color: var(--text);
}

.auth-provider-copy {
  margin: 0.85rem auto 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  min-height: 1.3em;
  max-width: 28ch;
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
  margin-top: 0.95rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.36rem;
  align-items: stretch;
  text-align: left;
}

.auth-field span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

.auth-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--border) 90%, rgba(255, 255, 255, 0.04));
  background: color-mix(in srgb, var(--bg) 94%, rgba(255, 255, 255, 0.02));
  color: var(--text);
  font: inherit;
  padding: 0.84rem 0.95rem;
}

.auth-input:focus {
  outline: none;
  border-color: rgba(16, 163, 127, 0.4);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.auth-code-input {
  text-align: center;
  letter-spacing: 0.24em;
  font-weight: 700;
}

.auth-submit {
  width: 100%;
  min-height: 2.95rem;
  border-radius: 14px;
  margin-top: 0.12rem;
}

.auth-message {
  margin: 0.8rem 0 0;
  padding: 0.72rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(16, 163, 127, 0.22);
  background: rgba(16, 163, 127, 0.08);
  color: var(--text);
  font-size: 0.84rem;
  text-align: center;
}

.auth-message.error {
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.1);
}

.auth-footnote {
  margin: 0.8rem auto 0;
  color: var(--text-faint);
  font-size: 0.75rem;
  line-height: 1.4;
  max-width: 28ch;
  text-align: center;
}

.auth-mode-row {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.84rem;
  text-align: center;
}

.auth-mode-toggle,
.auth-back-btn {
  border: none;
  padding: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 640px) {
  .auth-shell {
    width: min(100%, 100vw - 1rem);
    max-height: min(100%, calc(100svh - 1rem));
    padding: 1.2rem 1rem 1rem;
    border-radius: 20px;
  }

  .auth-provider-switch {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .auth-provider-btn {
    min-height: 4rem;
    padding-inline: 0.45rem;
  }

  .auth-copy {
    max-width: none;
  }
}

@media (max-width: 460px) {
  .auth-modal {
    align-items: flex-end;
    padding: 0.75rem;
  }

  .auth-shell {
    width: 100%;
    max-height: min(100%, calc(100svh - 1.5rem));
    border-radius: 18px;
    padding: 1rem 0.9rem 0.9rem;
  }

  .auth-provider-switch {
    grid-template-columns: 1fr;
  }

  .auth-provider-btn {
    min-height: 3.2rem;
    flex-direction: row;
    justify-content: center;
    gap: 0.55rem;
  }

  .auth-title {
    font-size: 1.2rem;
  }

  .auth-copy,
  .auth-provider-copy,
  .auth-footnote {
    font-size: 0.78rem;
  }
}

.chatroom-action-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.chatroom-action-header-copy {
  min-width: 0;
}

.chatroom-action-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chatroom-action-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.chatroom-action-close {
  flex-shrink: 0;
}

.chatroom-action-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.chatroom-action-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 1rem;
}

.chatroom-action-input-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chatroom-action-input {
  width: 100%;
  padding: 0.78rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chatroom-action-input:focus {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12);
}

html[data-theme="light"] .chatroom-action-input:focus {
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.chatroom-action-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 1.1rem;
}

.chatroom-action-cancel {
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.chatroom-action-cancel:hover {
  background: var(--bg-elevated);
  border-color: var(--border-input);
}

.chatroom-action-cancel:active {
  transform: scale(0.98);
}

.chatroom-action-confirm {
  min-width: 112px;
}

.chatroom-action-confirm-danger {
  background: #ef4444;
}

.chatroom-action-confirm-danger:hover {
  background: #dc2626;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}
.topbar-status-text { display: none; }
@media (min-width: 600px) { .topbar-status-text { display: inline; } }

/* ── STATUS DOT ──────────────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}
.status-dot.connected { background: var(--accent); }

/* ── ICON BTN ────────────────────────────────────────────────── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-elevated); color: var(--text); }

/* ── WORKSPACE ───────────────────────────────────────────────── */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── CHAT COLUMN ─────────────────────────────────────────────── */
.chat-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.memory-page {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 18%, transparent), transparent 28%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 96%, #000 4%), var(--bg));
}

.memory-page-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  min-height: 100%;
}

.memory-toolbar,
.memory-page-body,
.memory-board-panel,
.memory-detail-panel {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(135%);
}

.memory-toolbar {
  display: flex;
  align-items: end;
  gap: 0.9rem;
  padding: 0.95rem 1rem;
  border-radius: 20px;
  flex-wrap: wrap;
}

.memory-toolbar-field,
.memory-form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.memory-toolbar-field span,
.memory-form-field span {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.memory-toolbar-field { min-width: min(320px, 100%); flex: 1; }

.memory-input,
.memory-select,
.memory-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  padding: 0.8rem 0.9rem;
}

.memory-textarea {
  resize: vertical;
  min-height: 120px;
}

.memory-toolbar-check,
.memory-form-check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.memory-health {
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--accent-soft-border);
  background: var(--accent-soft-bg);
  color: var(--text);
}

.memory-page-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  min-height: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

.memory-board-panel,
.memory-detail-panel {
  min-width: 0;
  min-height: 0;
  padding: 1rem;
  border-radius: 28px;
}

.memory-board-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.memory-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.memory-stat-card {
  padding: 0.95rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-1), rgba(var(--accent-rgb),0.06));
}

.memory-stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
}

.memory-stat-label {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.memory-list {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: minmax(96px, auto);
  gap: 0.85rem;
  max-height: calc(100vh - 310px);
  overflow: auto;
  padding-right: 0.15rem;
  align-content: start;
}

.memory-list-item {
  width: 100%;
  grid-column: span 4;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 94%, transparent), color-mix(in srgb, var(--surface-1) 88%, transparent)),
    var(--accent-radial-soft);
  color: var(--text);
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 144px;
}

.memory-list-item:hover,
.memory-list-item.active {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb),0.16), rgba(var(--accent-deep-rgb),0.08)),
    color-mix(in srgb, var(--surface-raised) 88%, transparent);
  transform: translateY(-1px);
}

.memory-list-item[data-memory-size="wide"] { grid-column: span 8; }
.memory-list-item[data-memory-size="tall"] { grid-row: span 2; }
.memory-list-item[data-memory-size="hero"] { grid-column: span 8; grid-row: span 2; }

.memory-list-item-top,
.memory-form-row,
.memory-form-actions,
.memory-list-item-badges {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.memory-list-item-top {
  justify-content: space-between;
  align-items: flex-start;
}

.memory-list-item-title {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.25;
}

.memory-list-item-updated,
.memory-record-meta {
  color: var(--text-faint);
  font-size: 0.78rem;
}

.memory-list-item-type {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.memory-list-item-badges { margin: 0.45rem 0 0.35rem; }

.memory-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.memory-badge-highlight {
  background: rgba(var(--accent-rgb),0.16);
  color: var(--text);
}

.memory-list-item-summary,
.memory-empty-state {
  margin: 0;
  color: var(--text-muted);
}

.memory-list-item-details {
  margin: 0.55rem 0 0;
  color: color-mix(in srgb, var(--text-muted) 88%, var(--text));
  font-size: 0.88rem;
}

.memory-list-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  color: var(--text-faint);
  font-size: 0.76rem;
}

.memory-empty-state {
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: var(--surface-1);
}

.memory-list > .memory-empty-state {
  grid-column: 1 / -1;
}

.memory-form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.memory-form-row > * {
  flex: 1;
  min-width: 0;
}

.memory-form-actions {
  align-items: center;
}

.memory-delete-btn {
  color: #fda4af;
}

html[data-theme="light"] .memory-page {
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb),0.12), transparent 28%),
    linear-gradient(180deg, #fcfcfb, #f7f8f6);
}

html[data-theme="light"] .memory-health {
  background: rgba(var(--accent-rgb),0.06);
}

.settings-page {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 12%, transparent), transparent 30%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 97%, #000 3%), var(--bg));
}

.settings-page-shell {
  --settings-shell-max-width: 1360px;
  --settings-panel-max-width: 980px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding: 1.5rem 1.25rem;
  width: min(100%, var(--settings-shell-max-width));
  min-height: 100%;
  margin: 0 auto;
  overflow: visible;
}

.settings-tabs,
.settings-card {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 90%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(135%);
}

.settings-tabs {
  width: min(100%, var(--settings-panel-max-width));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 18px;
}

.settings-tab-btn {
  min-height: 2.65rem;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 750;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.settings-tab-btn:hover {
  color: var(--text);
  background: rgba(var(--accent-rgb),0.08);
}

.settings-tab-btn.active,
.settings-tab-btn[aria-selected="true"] {
  color: var(--text);
  background: rgba(var(--accent-rgb),0.14);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 8px 18px rgba(var(--accent-rgb),0.12);
}

.settings-tab-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 62%, transparent);
  outline-offset: 2px;
}

.settings-card-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

.settings-card-title {
  margin: 0;
  line-height: 1.1;
}
.settings-card-copy {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  width: 100%;
  justify-items: center;
  justify-content: center;
  align-content: start;
  flex: 0 0 auto;
}

.settings-card {
  width: 100%;
  max-width: var(--settings-panel-max-width);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.15rem 1.15rem 1.05rem;
  border-radius: 24px;
  text-align: center;
  min-height: 0;
  overflow: visible;
}

.settings-billing-panel {
  width: 100%;
  max-width: 1320px;
  justify-self: center;
}

.settings-tab-panel[hidden] {
  display: none;
}

.settings-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.settings-field span {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.settings-input,
.settings-value {
  min-height: 3rem;
  display: flex;
  align-items: center;
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.settings-input {
  width: 100%;
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.settings-input:focus {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.settings-input:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.settings-provider-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}

.settings-location-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.7rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  text-align: left;
}

.settings-location-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

.settings-location-copy {
  min-width: 0;
}

.settings-location-copy strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
}

.settings-location-copy p {
  margin: 0.3rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.settings-location-switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.settings-location-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.settings-location-track {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  transition: background 0.2s ease;
}

.settings-location-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}

.settings-location-input:checked + .settings-location-track {
  background: rgba(var(--accent-rgb), 0.68);
}

.settings-location-input:checked + .settings-location-track::after {
  transform: translateX(18px);
}

.settings-location-details {
  padding-top: 0.2rem;
}

.settings-provider-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.settings-accent-preview-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.7rem;
}

.settings-theme-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.7rem;
}

.settings-theme-option {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  min-height: 9.4rem;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 94%, transparent), color-mix(in srgb, var(--surface-1) 88%, transparent)),
    var(--accent-radial-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.settings-theme-option:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
}

.settings-theme-option.active,
.settings-theme-option[aria-checked="true"] {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 14%, var(--surface-raised)), color-mix(in srgb, var(--accent) 8%, var(--surface-1)));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent) inset, 0 14px 28px rgba(0,0,0,0.16);
}

.settings-theme-option-preview {
  position: relative;
  width: 100%;
  height: 4.25rem;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(17, 17, 20, 0.14);
}

.settings-theme-option-preview-default {
  background:
    radial-gradient(circle at top left, rgba(255, 77, 103, 0.22), transparent 36%),
    linear-gradient(180deg, rgba(34, 36, 42, 0.98), rgba(18, 20, 26, 0.98));
}

.settings-theme-option-preview-blocky {
  background: repeating-linear-gradient(45deg, #efefef 0, #efefef 1.2px, #f9f9f9 0, #f9f9f9 50%);
  background-size: 12px 12px;
}

.settings-theme-option-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.settings-theme-option-copy {
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.settings-accent-option {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.settings-accent-option:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
}

.settings-accent-option.active {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--border));
  background: linear-gradient(180deg, rgba(var(--accent-rgb),0.1), color-mix(in srgb, var(--surface-raised) 88%, transparent));
}

.settings-accent-option-bar {
  width: 100%;
  height: 0.7rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.settings-accent-option-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.settings-accent-option-dot {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.14);
  flex-shrink: 0;
}

.settings-accent-option-label {
  font-size: 0.86rem;
  font-weight: 600;
}

.settings-segmented {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.settings-segment-btn {
  min-width: 110px;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.settings-segment-btn.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
  background: rgba(var(--accent-rgb),0.12);
}

.settings-card-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: center;
}

.settings-save-status {
  margin: -0.1rem 0 0;
  min-height: 1.2rem;
  color: var(--text-muted);
  text-align: center;
}

.settings-save-status.error {
  color: #ff8686;
}

.settings-muted-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.settings-billing-panel {
  padding: 2rem;
}

.settings-billing-layout {
  --billing-bg: var(--bg);
  --billing-panel: color-mix(in srgb, var(--surface-raised) 94%, transparent);
  --billing-panel-strong: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  --billing-ink: var(--text);
  --billing-muted: var(--text-muted);
  --billing-line: var(--border);
  --billing-shadow: 0 18px 44px rgba(0,0,0,0.28);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 404px);
  gap: 24px;
  align-items: start;
  color: var(--billing-ink);
  font-family: "Inter","Segoe UI",sans-serif;
  letter-spacing: normal;
}

.settings-billing-layout button {
  font: inherit;
  color: inherit;
}

.settings-billing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
  grid-column: 1 / -1;
  align-items: end;
}

.settings-billing-kicker,
.settings-billing-section-label,
.settings-billing-stat-label {
  margin: 0;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.settings-billing-title {
  margin: 18px 0 14px;
  color: var(--billing-ink);
  text-transform: uppercase;
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.settings-billing-copy {
  max-width: 720px;
  margin: 0;
  color: var(--billing-ink);
  font-size: 16px;
  line-height: 1.65;
}

.settings-billing-mfa-card,
.settings-billing-stat-card,
.settings-billing-side-card,
.settings-pack-card {
  background: var(--billing-panel);
  border: 1px solid var(--billing-line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.settings-billing-mfa-card {
  padding: 1rem 1.05rem;
  border-radius: 18px;
  font-size: 0.84rem;
  line-height: 1.5;
  text-transform: none;
  color: var(--text-muted);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb),0.07), transparent 40%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 88%, transparent), color-mix(in srgb, var(--bg-elevated) 96%, transparent));
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.settings-billing-status {
  grid-column: 1 / -1;
  padding: 18px 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--billing-line));
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb),0.12), rgba(var(--accent-rgb),0.04)),
    var(--billing-panel);
  color: var(--billing-ink);
  text-align: left;
  text-transform: none;
  font-size: 0.9rem;
  line-height: 1.5;
  border-radius: 18px;
}

.settings-billing-status.error {
  border-color: rgba(239,68,68,0.32);
  background:
    linear-gradient(180deg, rgba(239,68,68,0.16), rgba(239,68,68,0.05)),
    var(--billing-panel);
}

.settings-billing-main {
  min-width: 0;
  width: 100%;
  position: relative;
}

.settings-billing-main.mfa-locked > :not(.settings-billing-gate) {
  opacity: 0.35;
  filter: grayscale(0.12);
  pointer-events: none;
  user-select: none;
}

.settings-billing-gate {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: start center;
  justify-items: center;
  padding: 12px 28px 28px;
  text-align: center;
}

.settings-billing-mfa-card-gate {
  max-width: 420px;
  width: min(100%, 420px);
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-top: clamp(12px, 4vh, 44px);
}

.settings-billing-gate-copy {
  margin: 0;
}

.settings-billing-gate-btn {
  min-width: 210px;
  color: #fff !important;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0 rgba(0,0,0,0.2);
  box-shadow: 0 10px 24px rgba(var(--accent-rgb), 0.28);
}

.settings-billing-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 34px;
}

.settings-billing-stat-card {
  min-height: 186px;
  padding: 28px 26px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.018), rgba(255,255,255,0.01)),
    var(--billing-panel);
}

.settings-billing-stat-value {
  display: block;
  margin-top: 24px;
  font-size: clamp(1.35rem, 2.2vw, 1.9rem);
  line-height: 1;
  text-transform: uppercase;
}

.settings-billing-stat-copy,
.settings-pack-copy,
.settings-billing-note,
.settings-billing-empty-copy {
  margin: 18px 0 0;
  color: var(--billing-muted);
  font-size: 15px;
  line-height: 1.55;
}

.settings-billing-empty-copy {
  max-width: 280px;
  margin: 0;
}

.settings-billing-section-label {
  margin-bottom: 18px;
}

.settings-billing-pack-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.settings-pack-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 300px;
  padding: 42px 28px 34px;
  text-align: center;
  cursor: pointer;
  overflow: visible;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.008)),
    var(--billing-panel);
  transition: transform 160ms ease, box-shadow 160ms ease, border-width 160ms ease;
}

.settings-pack-card:hover,
.settings-pack-card.active {
  box-shadow: var(--billing-shadow);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--billing-line));
}

.settings-pack-card:focus-visible {
  outline: 4px solid var(--billing-ink);
  outline-offset: 4px;
}

.settings-coin-stage {
  position: relative;
  width: 170px;
  height: 130px;
  margin-bottom: 34px;
  overflow: visible;
}

.settings-coin {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  width: 86px;
  height: 50px;
  overflow: visible;
  background: none;
  border: 0;
  box-shadow: none;
  transition: transform 220ms ease, filter 220ms ease;
}

.settings-coin-svg {
  width: 86px;
  height: 50px;
  display: block;
  overflow: visible;
}

.settings-coin-shadow,
.settings-stack-shadow {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: 64px;
  height: 12px;
  background: rgba(0,0,0,0.58);
  border-radius: 50%;
  transition: transform 220ms ease, opacity 220ms ease, filter 220ms ease;
  pointer-events: none;
}

.settings-coin-stack {
  position: absolute;
  left: 50%;
  bottom: 22px;
  width: 86px;
  height: 80px;
  overflow: visible;
}

.settings-coin-stack .settings-coin {
  position: absolute;
  left: 0;
  bottom: 0;
  transform: none;
  width: 86px;
  height: 50px;
  overflow: visible;
  transition: transform 220ms ease, filter 220ms ease;
}

.settings-coin-stack .settings-coin:nth-child(1) {
  bottom: 0;
  z-index: 1;
}

.settings-coin-stack .settings-coin:nth-child(2) {
  bottom: 16px;
  z-index: 2;
}

.settings-coin-stack .settings-coin:nth-child(3) {
  bottom: 32px;
  z-index: 3;
}

.settings-coin-stack .settings-coin:nth-child(4) {
  bottom: 48px;
  z-index: 4;
}

.settings-pack-card.single:hover .settings-coin,
.settings-pack-card.single.active .settings-coin {
  transform: translate(-50%, -24px);
}

.settings-pack-card.single:hover .settings-coin-shadow,
.settings-pack-card.single.active .settings-coin-shadow {
  transform: translateX(-50%) scale(1.45, 0.55);
  opacity: 0.45;
  filter: blur(2.5px);
}

.settings-pack-card.medium .settings-coin-stack:first-of-type {
  transform: translateX(-50%) translateX(-22px);
}

.settings-pack-card.medium .settings-coin-stack:nth-of-type(2) {
  transform: translateX(-50%) translate(32px, 20px);
}

.settings-pack-card.large .settings-coin-stack:nth-of-type(1) {
  transform: translateX(-50%) translate(-56px, 20px);
}

.settings-pack-card.large .settings-coin-stack:nth-of-type(2) {
  transform: translateX(-50%) translate(0, -8px);
}

.settings-pack-card.large .settings-coin-stack:nth-of-type(3) {
  transform: translateX(-50%) translate(56px, 20px);
}

.settings-pack-card:hover .settings-coin-stack,
.settings-pack-card.active .settings-coin-stack,
.settings-pack-card.is-settling .settings-coin-stack {
  filter: none !important;
}

@keyframes settings-float-svg-2 {
  0%, 14%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
  86% { transform: translateY(0); }
}

@keyframes settings-float-svg-3 {
  0%, 14%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
  86% { transform: translateY(0); }
}

@keyframes settings-float-svg-4 {
  0%, 14%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
  86% { transform: translateY(0); }
}

.settings-pack-card:hover .settings-coin-stack .settings-coin:nth-child(1) .settings-coin-svg,
.settings-pack-card.active .settings-coin-stack .settings-coin:nth-child(1) .settings-coin-svg,
.settings-pack-card.is-settling .settings-coin-stack .settings-coin:nth-child(1) .settings-coin-svg {
  transform: translateY(0);
  animation: none !important;
}

.settings-pack-card:hover .settings-coin-stack .settings-coin:nth-child(2) .settings-coin-svg,
.settings-pack-card.active .settings-coin-stack .settings-coin:nth-child(2) .settings-coin-svg {
  animation: settings-float-svg-2 2800ms cubic-bezier(0.37, 0, 0.63, 1) infinite;
}

.settings-pack-card.is-settling .settings-coin-stack .settings-coin:nth-child(2) .settings-coin-svg {
  animation: settings-float-svg-2 2800ms cubic-bezier(0.37, 0, 0.63, 1) 1;
}

.settings-pack-card:hover .settings-coin-stack .settings-coin:nth-child(3) .settings-coin-svg,
.settings-pack-card.active .settings-coin-stack .settings-coin:nth-child(3) .settings-coin-svg {
  animation: settings-float-svg-3 2800ms cubic-bezier(0.37, 0, 0.63, 1) infinite;
}

.settings-pack-card.is-settling .settings-coin-stack .settings-coin:nth-child(3) .settings-coin-svg {
  animation: settings-float-svg-3 2800ms cubic-bezier(0.37, 0, 0.63, 1) 1;
}

.settings-pack-card:hover .settings-coin-stack .settings-coin:nth-child(4) .settings-coin-svg,
.settings-pack-card.active .settings-coin-stack .settings-coin:nth-child(4) .settings-coin-svg {
  animation: settings-float-svg-4 2800ms cubic-bezier(0.37, 0, 0.63, 1) infinite;
}

.settings-pack-card.is-settling .settings-coin-stack .settings-coin:nth-child(4) .settings-coin-svg {
  animation: settings-float-svg-4 2800ms cubic-bezier(0.37, 0, 0.63, 1) 1;
}

.settings-pack-inner {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 160ms ease;
}

.settings-pack-card:hover .settings-pack-inner,
.settings-pack-card.active .settings-pack-inner,
.settings-pack-card.is-settling .settings-pack-inner {
  transform: translateY(-1px);
}

/* For medium (500K) and large (1M) packs: lift and hold while hovered/active,
   then transition back down when unhovered/unselected. This overrides
   the default floating animations so the coin graphics move up and stay. */
.settings-pack-card.medium:hover .settings-pack-inner,
.settings-pack-card.medium.active .settings-pack-inner,
.settings-pack-card.large:hover .settings-pack-inner,
.settings-pack-card.large.active .settings-pack-inner {
  transform: translateY(-10px);
  transition: transform 280ms cubic-bezier(.22,1,.36,1);
}

.settings-pack-card.medium:hover .settings-pack-inner,
.settings-pack-card.medium.active .settings-pack-inner,
.settings-pack-card.large:hover .settings-pack-inner,
.settings-pack-card.large.active .settings-pack-inner {
  transform: translateY(-10px);
  transition: transform 280ms cubic-bezier(.22,1,.36,1);
}

/* Precise per-coin lifts and is-settling overrides to prevent play-through animations.
   Coins will translate up and hold while hovered or active, then smoothly
   transition back when unhovered/unselected without replaying keyframe floats. */

/* Medium / Large: per-coin static lifts while hovered/active */
.settings-pack-card.medium:hover .settings-coin-stack .settings-coin:nth-child(1) .settings-coin-svg,
.settings-pack-card.medium.active .settings-coin-stack .settings-coin:nth-child(1) .settings-coin-svg,
.settings-pack-card.large:hover .settings-coin-stack .settings-coin:nth-child(1) .settings-coin-svg,
.settings-pack-card.large.active .settings-coin-stack .settings-coin:nth-child(1) .settings-coin-svg {
  transform: translateY(-6px) !important;
  animation: none !important;
  transition: transform 260ms cubic-bezier(.22,1,.36,1) !important;
}
.settings-pack-card.medium:hover .settings-coin-stack .settings-coin:nth-child(2) .settings-coin-svg,
.settings-pack-card.medium.active .settings-coin-stack .settings-coin:nth-child(2) .settings-coin-svg,
.settings-pack-card.large:hover .settings-coin-stack .settings-coin:nth-child(2) .settings-coin-svg,
.settings-pack-card.large.active .settings-coin-stack .settings-coin:nth-child(2) .settings-coin-svg {
  transform: translateY(-10px) !important;
  animation: none !important;
  transition: transform 280ms cubic-bezier(.22,1,.36,1) !important;
}
.settings-pack-card.medium:hover .settings-coin-stack .settings-coin:nth-child(3) .settings-coin-svg,
.settings-pack-card.medium.active .settings-coin-stack .settings-coin:nth-child(3) .settings-coin-svg,
.settings-pack-card.large:hover .settings-coin-stack .settings-coin:nth-child(3) .settings-coin-svg,
.settings-pack-card.large.active .settings-coin-stack .settings-coin:nth-child(3) .settings-coin-svg {
  transform: translateY(-14px) !important;
  animation: none !important;
  transition: transform 300ms cubic-bezier(.22,1,.36,1) !important;
}
.settings-pack-card.medium:hover .settings-coin-stack .settings-coin:nth-child(4) .settings-coin-svg,
.settings-pack-card.medium.active .settings-coin-stack .settings-coin:nth-child(4) .settings-coin-svg,
.settings-pack-card.large:hover .settings-coin-stack .settings-coin:nth-child(4) .settings-coin-svg,
.settings-pack-card.large.active .settings-coin-stack .settings-coin:nth-child(4) .settings-coin-svg {
  transform: translateY(-18px) !important;
  animation: none !important;
  transition: transform 320ms cubic-bezier(.22,1,.36,1) !important;
}

/* Also cover the single coin stage (non-stacked) */
.settings-pack-card.medium:hover .settings-coin-stage > .settings-coin .settings-coin-svg,
.settings-pack-card.medium.active .settings-coin-stage > .settings-coin .settings-coin-svg,
.settings-pack-card.large:hover .settings-coin-stage > .settings-coin .settings-coin-svg,
.settings-pack-card.large.active .settings-coin-stage > .settings-coin .settings-coin-svg {
  transform: translateY(-12px) !important;
  animation: none !important;
  transition: transform 280ms cubic-bezier(.22,1,.36,1) !important;
}

/* Prevent 'is-settling' from playing float keyframe animations; instead
   allow a smooth transform back to the resting position. */
.settings-pack-card.is-settling.medium .settings-coin-stack .settings-coin-svg,
.settings-pack-card.is-settling.large .settings-coin-stack .settings-coin-svg,
.settings-pack-card.is-settling.medium .settings-coin-stage > .settings-coin .settings-coin-svg,
.settings-pack-card.is-settling.large .settings-coin-stage > .settings-coin .settings-coin-svg {
  animation: none !important;
  transition: transform 300ms cubic-bezier(.22,1,.36,1) !important;
}

.settings-pack-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
}

.settings-pack-price {
  margin-top: 16px;
  font-size: 1rem;
  font-weight: 800;
  color: color-mix(in srgb, var(--text) 92%, var(--accent));
}

.settings-pack-card:hover .settings-coin-stage > .settings-coin-stack:nth-of-type(2),
.settings-pack-card:hover .settings-coin-stage > .settings-coin-stack:nth-of-type(3),
.settings-pack-card.active .settings-coin-stage > .settings-coin-stack:nth-of-type(2),
.settings-pack-card.active .settings-coin-stage > .settings-coin-stack:nth-of-type(3),
.settings-pack-card.is-settling .settings-coin-stage > .settings-coin-stack:nth-of-type(2),
.settings-pack-card.is-settling .settings-coin-stage > .settings-coin-stack:nth-of-type(3) {
  filter: none !important;
}

@keyframes settings-float-vertical {
  0%, 14%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
  86% { transform: translateY(0); }
}

.settings-pack-card.single:hover .settings-coin-svg,
.settings-pack-card.single.active .settings-coin-svg {
  animation: settings-float-vertical 2800ms cubic-bezier(0.37, 0, 0.63, 1) infinite;
}

.settings-pack-card.single.is-settling .settings-coin-svg {
  animation: settings-float-vertical 2800ms cubic-bezier(0.37, 0, 0.63, 1) 1;
}

.settings-checkout-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: auto;
  max-width: 100%;
  align-self: flex-start;
  margin-top: 36px;
  min-height: 2rem;
  padding: 0.5rem 0.72rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff !important;
  font-size: 0.82rem;
  line-height: 1.2;
  font-weight: 600;
  gap: 0.5rem;
  box-shadow: none;
}

.settings-checkout-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: none;
}

.settings-checkout-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.settings-billing-main.mfa-locked .settings-checkout-btn,
.settings-billing-main.mfa-locked .settings-pack-card {
  pointer-events: none;
}

.settings-checkout-arrow {
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.9;
}

.settings-billing-note {
  text-transform: none;
  font-size: 0.82rem;
}

.settings-billing-sidebar {
  display: grid;
  grid-template-rows: 1fr 1fr;
  border: 1px solid var(--billing-line);
  border-radius: 24px;
  overflow: hidden;
  width: 100%;
  align-self: start;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.018), rgba(255,255,255,0.008)),
    var(--billing-panel);
}

.settings-billing-sidebar.mfa-locked {
  opacity: 0.35;
  filter: grayscale(0.12);
  pointer-events: none;
  user-select: none;
}

.settings-billing-side-card {
  border: 0;
  padding: 36px 26px 28px;
  min-width: 0;
}

.settings-billing-side-card + .settings-billing-side-card {
  border-top: 1px solid var(--billing-line);
}

.settings-billing-side-title {
  margin: 0 0 28px;
  font-size: 1rem;
  text-transform: uppercase;
}

.settings-billing-side-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.settings-billing-method,
.settings-billing-history-item,
.settings-billing-empty-state {
  min-height: 266px;
  display: grid;
  place-items: center;
  padding: 28px;
  border: 1px dashed color-mix(in srgb, var(--border) 94%, rgba(var(--accent-rgb),0.16));
  text-align: center;
  text-transform: none;
  border-radius: 18px;
}

.settings-billing-method,
.settings-billing-history-item {
  min-height: auto;
  place-items: stretch;
  text-align: left;
  border-style: solid;
  background: var(--billing-panel-strong);
}

.settings-billing-method-copy,
.settings-billing-history-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.settings-billing-method-title,
.settings-billing-history-title {
  font-weight: 600;
  text-transform: uppercase;
}

.settings-billing-method-meta,
.settings-billing-history-meta {
  color: var(--billing-muted);
  font-size: 0.8rem;
  line-height: 1.35;
  text-transform: none;
}

.settings-billing-method-row,
.settings-billing-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

@media (max-width: 1400px) {
  .settings-billing-layout {
    grid-template-columns: 1fr;
  }

  .settings-billing-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }

  .settings-billing-side-card + .settings-billing-side-card {
    border-top: 0;
    border-left: 1px solid var(--billing-line);
  }

  .settings-billing-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-billing-pack-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .settings-billing-hero,
  .settings-billing-stats,
  .settings-billing-pack-grid,
  .settings-billing-sidebar {
    grid-template-columns: 1fr;
  }

  .settings-billing-side-card + .settings-billing-side-card {
    border-left: 0;
    border-top: 1px solid var(--billing-line);
  }

  .settings-pack-card {
    min-height: 0;
  }
}

.settings-billing-history-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  background: rgba(var(--accent-rgb),0.12);
  color: var(--billing-ink);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
}

.settings-mfa-panel {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.settings-mfa-setup {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 0.95rem;
  align-items: start;
}

.settings-mfa-qr-card {
  grid-row: 1 / span 3;
  align-self: stretch;
}

.settings-mfa-setup > .settings-field {
  min-width: 0;
}

.settings-mfa-qr-card {
  position: relative;
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem;
  border-radius: 22px;
  border: 1px solid rgba(var(--accent-rgb),0.24);
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb),0.12), rgba(var(--accent-rgb),0.035)),
    color-mix(in srgb, var(--surface-raised) 92%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 18px 44px rgba(0,0,0,0.28),
    0 0 0 1px rgba(255,255,255,0.025);
  overflow: hidden;
}

.settings-mfa-qr-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb),0.16), transparent 34%),
    linear-gradient(90deg, transparent, rgba(255,255,255,0.045), transparent);
  opacity: 0.72;
}

.settings-mfa-qr-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.settings-mfa-qr-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(var(--accent-rgb),0.56);
}

.settings-mfa-qr-stage {
  position: relative;
  z-index: 1;
  width: min(292px, 100%);
  margin: 0 auto;
  padding: 0.7rem;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.025)),
    rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.08);
}

.settings-mfa-qr {
  min-height: 236px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.72rem;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.7),
    0 12px 28px rgba(0,0,0,0.28);
  color: #111;
}

.settings-mfa-qr canvas,
.settings-mfa-qr img,
.settings-mfa-qr svg {
  width: min(248px, 100%) !important;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  image-rendering: auto;
}

.settings-mfa-qr .settings-mfa-stylized-qr {
  display: block;
  border-radius: 18px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 10px 26px rgba(0,0,0,0.12);
}

.settings-mfa-qr-logo-frame {
  position: relative;
  width: min(248px, 100%);
  display: grid;
  place-items: center;
}

.settings-mfa-qr-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background:
    radial-gradient(circle at 32% 24%, rgba(255,255,255,0.42), transparent 36%),
    linear-gradient(135deg, rgba(var(--accent-rgb),1), rgba(var(--accent-deep-rgb),1));
  border: 4px solid #fff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.32),
    0 6px 14px rgba(0,0,0,0.18),
    0 0 20px rgba(var(--accent-rgb),0.2);
  transform: translate(-50%, -50%);
}

.settings-mfa-qr-logo svg {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

html[data-visual-theme="blocky"] .settings-mfa-qr-logo {
  color: #fff;
  background: #000;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.16),
    0 6px 14px rgba(0,0,0,0.14);
}

html[data-theme="dark"][data-visual-theme="blocky"] .settings-mfa-qr-logo {
  color: #000;
  background: #fff;
  border-color: #111;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 6px 14px rgba(255,255,255,0.08);
}

.settings-mfa-secret {
  display: block;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(var(--accent-rgb),0.2);
  background: rgba(var(--accent-rgb),0.07);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}

.settings-mfa-backup-codes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.settings-mfa-backup-code {
  padding: 0.72rem 0.8rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  text-align: center;
}

.settings-billing-list,
.settings-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.settings-billing-item,
.settings-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 84%, transparent);
  text-align: left;
}

.settings-billing-item-copy,
.settings-history-item-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.settings-billing-item-title,
.settings-history-item-title {
  font-weight: 600;
}

.settings-billing-item-meta,
.settings-history-item-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.settings-billing-item-action {
  flex-shrink: 0;
}

.settings-history-item-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  background: rgba(var(--accent-rgb),0.12);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.settings-empty-state {
  padding: 1rem;
  border-radius: 16px;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .memory-page-body {
    grid-template-columns: 1fr;
  }

  .memory-list {
    max-height: none;
  }

  .settings-field-grid,
  .settings-stat-grid,
  .settings-pack-grid {
    grid-template-columns: 1fr;
  }

  .settings-accent-preview-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-mfa-setup {
    grid-template-columns: 1fr;
  }

  .settings-mfa-backup-codes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-mfa-qr-card {
    grid-row: auto;
  }

  .settings-billing-layout,
  .settings-billing-hero {
    grid-template-columns: 1fr;
  }

  .settings-billing-sidebar {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }

  .settings-billing-side-card + .settings-billing-side-card {
    border-top: 0;
    border-left: 1.5px solid var(--billing-line);
  }
}

@media (max-width: 720px) {
  .memory-page-shell {
    padding: 0.85rem;
  }

  .memory-toolbar,
  .memory-board-panel {
    border-radius: 18px;
    padding: 0.9rem;
  }

  .memory-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .memory-list-item {
    grid-column: span 3;
  }

  .memory-list-item[data-memory-size="wide"],
  .memory-list-item[data-memory-size="hero"] {
    grid-column: span 6;
  }

  .settings-page-shell {
    padding: 0.85rem;
    gap: 0.75rem;
  }

  .settings-card {
    border-radius: 18px;
    padding: 0.9rem;
  }

  .settings-tabs {
    border-radius: 16px;
  }

  .settings-accent-preview-list {
    grid-template-columns: 1fr;
  }

  .settings-billing-item,
  .settings-history-item,
  .settings-billing-method-row,
  .settings-billing-history-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-billing-panel {
    padding: 1.25rem;
  }

  .settings-billing-stats,
  .settings-billing-pack-grid,
  .settings-billing-sidebar {
    grid-template-columns: 1fr;
  }

  .settings-billing-side-card + .settings-billing-side-card {
    border-left: 0;
    border-top: 1.5px solid var(--billing-line);
  }
}

/* ── MESSAGES ────────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; }
html[data-theme="light"] .messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }

/* ── WELCOME STATE ───────────────────────────────────────────── */
.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem 1rem;
  gap: 0.9rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}
.welcome-logo {
  position: relative;
  color: var(--text);
  margin-bottom: 1rem;
  isolation: isolate;
  border-radius: 32px;
  overflow: hidden;
  -webkit-clip-path: inset(0 round 32px);
  clip-path: inset(0 round 32px);
}

.welcome-logo::before {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,255,255,0.18), transparent 58%),
    radial-gradient(circle at 50% 70%, rgba(255,255,255,0.06), transparent 72%);
  filter: blur(26px);
  opacity: 0.75;
  z-index: -1;
}

.logo-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 168px;
  height: 168px;
  padding: 28px;
  border-radius: 40px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.018)),
    radial-gradient(circle at top, rgba(255,255,255,0.07), transparent 60%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 24px 60px rgba(0,0,0,0.28);
  backdrop-filter: blur(24px) saturate(140%);
  overflow: hidden;
  will-change: transform;
  isolation: isolate;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.logo-wrapper::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 34px;
  background:
    radial-gradient(circle at 24% 28%, rgba(112, 255, 201, 0.34), transparent 34%),
    radial-gradient(circle at 76% 30%, rgba(255, 183, 77, 0.32), transparent 36%),
    radial-gradient(circle at 52% 76%, rgba(162, 140, 255, 0.34), transparent 38%);
  filter: blur(18px) saturate(1.25);
  opacity: 0.95;
  pointer-events: none;
  z-index: 0;
}

html[data-theme="light"] .logo-wrapper {
  border-color: rgba(15,23,42,0.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(248,250,252,0.82)),
    radial-gradient(circle at top, rgba(255,255,255,0.92), transparent 65%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.95),
    0 28px 60px rgba(15,23,42,0.08);
}

html[data-theme="light"] .logo-wrapper::after {
  opacity: 0.82;
  filter: blur(16px) saturate(1.4);
}

.logo-svg {
  position: relative;
  z-index: 2;
  width: 130px;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 18px rgba(255,255,255,0.06));
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

html[data-theme="light"] .logo-svg {
  filter: drop-shadow(0 10px 20px rgba(15,23,42,0.08));
}

.logo-orb {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 999px;
  opacity: 0.52;
  filter: blur(24px) saturate(1.35);
  mix-blend-mode: screen;
  pointer-events: none;
  will-change: transform;
  z-index: 1;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.orb-a {
  width: 82px;
  height: 82px;
  background: radial-gradient(circle at 35% 35%, rgba(112, 255, 201, 0.95), rgba(31, 184, 205, 0.22) 58%, transparent 74%);
}

.orb-b {
  width: 94px;
  height: 94px;
  background: radial-gradient(circle at 42% 38%, rgba(255, 183, 77, 0.92), rgba(255, 103, 132, 0.2) 58%, transparent 76%);
}

.orb-c {
  width: 76px;
  height: 76px;
  background: radial-gradient(circle at 45% 35%, rgba(162, 140, 255, 0.92), rgba(122, 92, 255, 0.2) 58%, transparent 74%);
}

html[data-theme="light"] .logo-orb {
  opacity: 0.52;
  mix-blend-mode: screen;
  filter: blur(22px) saturate(1.45);
}

.petal {
  transform-origin: center;
  will-change: transform, opacity;
  transition: none;
}

.welcome-heading {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.03em;
  max-width: 12ch;
  line-height: 1.08;
  opacity: 0;
  transform: translateY(12px);
  animation: welcomeTitleReveal 1.1s cubic-bezier(0.2, 0.9, 0.4, 1.1) forwards;
  animation-delay: 0.55s;
}
.welcome-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
  max-width: 460px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(8px);
  animation: welcomeSubtitleReveal 1s ease-out forwards;
  animation-delay: 0.85s;
}

@keyframes welcomeTitleReveal {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes welcomeSubtitleReveal {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.75rem;
  width: 100%;
  max-width: 560px;
}
.suggestion-pill {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.suggestion-pill:hover { background: var(--bg); color: var(--text); border-color: var(--border-input); }
.suggestion-pill svg { flex-shrink: 0; opacity: 0.6; }

svg { shape-rendering: geometricPrecision; }

/* ── MESSAGE ROWS ────────────────────────────────────────────── */
.message-row {
  width: 100%;
  padding: 1.25rem 1rem 0;
}
.message-row:last-child { padding-bottom: 0.75rem; }

.message-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.message-row.role-user .message-inner {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 3px;
  letter-spacing: 0;
}
.msg-avatar svg {
  display: block;
}
.role-user .msg-avatar    { background: var(--text); color: var(--bg); }
.role-assistant .msg-avatar { background: var(--accent); color: #fff; }
.role-block .msg-avatar   { background: #ef4444; color: #fff; }

.msg-content { flex: 1; min-width: 0; }
.role-user .msg-content { text-align: right; }

.msg-bubble {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-lg);
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  display: inline-block;
  max-width: 100%;
}
.role-user .msg-bubble {
  background: var(--bg-msg-user);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}
.role-assistant .msg-bubble {
  background: transparent;
  padding: 0.1rem 0;
  border-radius: 0;
  border: none;
  display: block;
}
.role-block .msg-bubble {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-lg);
}

.msg-meta {
  font-size: 0.76rem;
  color: var(--text-faint);
  margin-top: 0.35rem;
}

/* System pills */
.message-system { text-align: center; padding: 0.75rem 1.5rem; }
.message-system-inner {
  display: inline-block;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── MARKDOWN ────────────────────────────────────────────────── */
.msg-bubble p, .artifact-markdown p { margin: 0 0 0.75rem; }
.msg-bubble :last-child, .artifact-markdown :last-child { margin-bottom: 0; }

:where(.msg-bubble, .artifact-markdown) a:not(.message-inline-source-card) {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 58%, transparent);
  text-underline-offset: 0.14em;
}

:where(.msg-bubble, .artifact-markdown) a:not(.message-inline-source-card):hover {
  color: var(--accent-hover);
}

.msg-bubble ul, .msg-bubble ol,
.artifact-markdown ul, .artifact-markdown ol {
  margin: 0 0 0.75rem;
  padding-left: 1.4rem;
}
.msg-bubble li, .artifact-markdown li { margin-bottom: 0.25rem; }

.msg-bubble h1, .msg-bubble h2, .msg-bubble h3,
.artifact-markdown h1, .artifact-markdown h2, .artifact-markdown h3 {
  margin: 1.1rem 0 0.45rem;
  font-weight: 600;
  line-height: 1.3;
}
.msg-bubble h1, .artifact-markdown h1 { font-size: 1.3rem; }
.msg-bubble h2, .artifact-markdown h2 { font-size: 1.1rem; }
.msg-bubble h3, .artifact-markdown h3 { font-size: 0.975rem; }

.msg-bubble hr, .artifact-markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.msg-bubble blockquote, .artifact-markdown blockquote {
  margin: 0 0 0.75rem;
  padding-left: 0.9rem;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.msg-bubble code, .artifact-markdown code {
  padding: 0.13rem 0.38rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  font-family: var(--mono);
  font-size: 0.875em;
}
html[data-theme="light"] .msg-bubble code,
html[data-theme="light"] .artifact-markdown code {
  background: rgba(0,0,0,0.07);
}

.msg-bubble pre, .artifact-markdown pre, .artifact-code-pane pre {
  margin: 0.75rem 0;
  border-radius: var(--radius-md);
  background: #0d0d0d;
  border: 1px solid rgba(255,255,255,0.06);
  overflow: auto;
}
html[data-theme="light"] .msg-bubble pre,
html[data-theme="light"] .artifact-markdown pre {
  background: #1a1a2e;
}

.msg-bubble pre code, .artifact-markdown pre code, .artifact-code-pane pre code {
  display: block;
  padding: 1rem;
  background: transparent;
  border-radius: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #e8eaf6;
}

/* Source links */
.message-inline-sources {
  margin-top: 0.8rem;
  padding: 0.7rem;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  border: 1px solid var(--border);
}
.message-inline-sources-title {
  margin-bottom: 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.message-inline-sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
}
.message-inline-source-card {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
  padding: 0.8rem 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 92%, transparent), color-mix(in srgb, var(--bg-elevated) 92%, transparent));
  color: var(--text);
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.message-inline-source-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
}
.message-inline-source-name {
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.message-inline-source-host {
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
img.message-inline-image {
  display: inline-block;
  max-width: min(100%, 420px);
  height: auto;
  margin: 0.2rem 0;
  border-radius: 14px;
  vertical-align: middle;
  background: color-mix(in srgb, var(--surface-raised) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
}
.message-inline-image-figure {
  margin: 0.95rem 0;
  padding: 0.75rem;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  border: 1px solid var(--border);
}
.message-inline-image-figure > a,
.message-inline-image-figure > img {
  display: block;
}
.message-inline-image-figure img.message-inline-image {
  width: 100%;
  max-width: 100%;
  margin: 0;
}
.message-inline-image-caption {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}
.message-inline-image-inline-note {
  display: inline-flex;
  align-items: center;
  margin-left: 0.45rem;
  padding: 0.16rem 0.48rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.2;
  vertical-align: middle;
}
.message-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.6rem;
}
.message-source {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
}
.message-source img { width: 16px; height: 16px; display: block; }
.message-source:hover { filter: brightness(1.15); transform: translateY(-1px); }

.favicon-popover {
  position: absolute;
  min-width: 220px;
  max-width: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.favicon-popover.hidden { display: none; }
.favicon-popover .favicon-popover-title { font-weight: 700; margin-bottom: 6px; }
.favicon-popover .favicon-popover-url { font-size: 0.82rem; color: var(--text-faint); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.favicon-popover .favicon-popover-actions { text-align: center; }
.favicon-popover .favicon-popover-open { display: inline-block; margin: 0 auto; background: var(--accent); color: white; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; }

.message-reasoning { display: none; } /* superseded by .reasoning-panel */
.message-reasoning-body { display: none; }

.reasoning-panel {
  margin-top: 0.55rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: transparent;
  box-shadow: none;
  backdrop-filter: blur(18px);
}

.reasoning-panel--minimized {
  box-shadow: none;
}

.reasoning-panel-header {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.62rem 0.72rem;
  cursor: pointer;
  user-select: none;
}

.reasoning-header-content {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 0.18rem;
}

.reasoning-header-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  min-width: 0;
}

.reasoning-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.reasoning-panel-title {
  min-width: 0;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.reasoning-status-chip,
.reasoning-confidence-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border-input);
  background: transparent;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.reasoning-status-chip {
  color: var(--text-muted);
}

.reasoning-confidence-badge {
  color: var(--text-muted);
}

.reasoning-panel-preview {
  min-width: 0;
  font-size: 0.69rem;
  line-height: 1.35;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reasoning-toggle-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border-input);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: rotate(180deg);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.reasoning-toggle-btn:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text);
}

.reasoning-toggle-btn.reasoning-toggle-collapsed {
  transform: rotate(0deg);
}

.reasoning-panel-body {
  display: grid;
  gap: 0.42rem;
  padding: 0 0.72rem 0.72rem;
  max-height: 280px;
  overflow: auto;
  opacity: 1;
  transition: max-height 0.22s ease, opacity 0.18s ease, padding 0.18s ease;
}

.reasoning-panel-body--collapsed {
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.reasoning-panel-body::-webkit-scrollbar {
  width: 4px;
}

.reasoning-panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.reasoning-panel-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}

.reasoning-filewrite-panel {
  margin: 0.15rem 0 0.2rem;
  padding: 0.85rem 0.9rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 92%, transparent), color-mix(in srgb, var(--surface-1) 86%, transparent)),
    var(--accent-radial-soft);
  box-shadow: var(--shadow-sm);
}

.reasoning-filewrite-copy {
  display: grid;
  gap: 0.16rem;
  margin-bottom: 0.7rem;
}

.reasoning-filewrite-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.reasoning-filewrite-subtitle {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-faint);
}

.reasoning-filewrite-loading {
  gap: 0.6rem;
}

.reasoning-activity-log {
  display: grid;
  gap: 0.38rem;
}

.reasoning-activity {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr);
  gap: 0.55rem;
  padding: 0.52rem 0.58rem;
  border-radius: 12px;
  border: 1px solid var(--border-input);
  background: linear-gradient(135deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018));
}

.reasoning-activity--running {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border-input));
}

.reasoning-activity-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 9px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
}

.reasoning-activity-copy {
  min-width: 0;
}

.reasoning-activity-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.reasoning-activity-label {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 650;
  min-width: 0;
  overflow-wrap: anywhere;
}

.reasoning-activity-status {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.reasoning-activity-detail {
  margin-top: 0.18rem;
  color: var(--text-muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.reasoning-highlights {
  display: grid;
  gap: 0.35rem;
}

.reasoning-highlight {
  display: flex;
  align-items: flex-start;
  gap: 0.48rem;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border-input);
  background: transparent;
}

.reasoning-highlight-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin-top: 0.33rem;
  border-radius: 999px;
  background: var(--text-faint);
}

.reasoning-highlight-copy {
  flex: 1;
  min-width: 0;
}

.reasoning-highlight-meta {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  margin-bottom: 0.14rem;
  flex-wrap: wrap;
}

.reasoning-highlight-step {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.reasoning-highlight-confidence {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.34rem;
  border-radius: 999px;
  border: 1px solid var(--border-input);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.58rem;
  font-weight: 700;
}

.reasoning-highlight-text {
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text);
}

.reasoning-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.35rem;
}

.reasoning-meta-chip {
  display: grid;
  gap: 0.08rem;
  padding: 0.42rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border-input);
  background: transparent;
}

.reasoning-meta-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text-muted);
}

.reasoning-meta-value {
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--text);
}

html[data-theme="light"] .reasoning-toggle-btn:hover {
  background: rgba(15,23,42,0.04);
}

@media (max-width: 640px) {
  .reasoning-panel-header {
    padding: 0.58rem 0.64rem;
  }

  .reasoning-panel-body {
    padding: 0 0.64rem 0.64rem;
  }

  .reasoning-panel-preview {
    white-space: normal;
  }

  .reasoning-meta-grid {
    grid-template-columns: 1fr;
  }

  .fusion-ask-modal.is-visible {
    max-height: var(--ask-modal-max-height, min(82svh, 720px));
    padding: 0.72rem;
    gap: 0.65rem;
  }

  .fusion-ask-modal-card .fusion-inline-option-list {
    grid-template-columns: 1fr;
  }

  .fusion-ask-modal-card .fusion-inline-prompt-textarea {
    min-height: 56px;
  }
}

.message-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.55rem;
}

.message-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.message-nav-label {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.message-edit-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.message-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.message-edit-actions .message-edit-btn {
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  flex-shrink: 0;
}

.message-edit-actions .message-edit-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.message-edit-actions .message-edit-btn:hover {
  color: var(--text);
  border-color: var(--border-input);
  background: var(--bg-elevated);
}

.message-editing-box {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.45rem;
}

.message-editing-box textarea {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 0.8rem;
  resize: vertical;
}

.msg-bubble-editing {
  width: min(100%, 680px);
  padding: 0;
  overflow: hidden;
}

.message-editing-textarea {
  display: block;
  width: 100%;
  min-height: 110px;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  padding: 0.9rem 1rem;
}

.message-editing-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

/* Artifact cards in messages */
.artifact-card-list { display: grid; gap: 0.6rem; margin-top: 0.6rem; }
.artifact-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: inherit;
}
.artifact-card:hover { border-color: var(--accent); }
.artifact-card-title { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.artifact-card-meta  { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artifact-card-cta   { font-size: 0.8rem; color: var(--accent); font-weight: 500; margin-top: 0.1rem; }

@keyframes artifact-pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.artifact-card-pop-in {
  animation: artifact-pop-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Wrapper and actions for artifact cards to host control buttons */
.artifact-card-wrapper { display: flex; flex-direction: column; align-items: flex-start; }
.artifact-card-actions { margin-top: 0.45rem; display: flex; gap: 0.5rem; }
.artifact-continue-btn { padding: 0.45rem 0.85rem; font-size: 0.86rem; border-radius: 10px; }

/* ── ARTIFACT CREATION CARD ─────────────────────────────────── */
.artifact-loading-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.65rem;
}
.artifact-loading-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-input);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 92%, transparent), color-mix(in srgb, var(--surface-1) 86%, transparent)),
    var(--accent-radial-soft);
  padding: 0.75rem 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.artifact-loading-icon-shell {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  isolation: isolate;
  transform: translateZ(0);
}

.artifact-loading-icon-shell::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-right-color: rgba(255,255,255,0.22);
  animation: artifact-ring-spin 0.95s linear infinite;
  animation-delay: var(--artifact-spinner-delay, 0s);
  will-change: transform;
  transform-origin: center;
  backface-visibility: hidden;
}

.artifact-loading-logo {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  opacity: 0.92;
  transform: translateZ(0);
}

.artifact-loading-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes artifact-ring-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.artifact-loading-copy {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 0.14rem;
}

.artifact-loading-topline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex-wrap: wrap;
}

.artifact-loading-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.artifact-loading-type {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.38rem;
  border-radius: 999px;
  border: 1px solid var(--border-input);
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.artifact-loading-title {
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artifact-loading-sublabel {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="light"] .artifact-loading-bar {
  background:
    radial-gradient(circle at top left, rgba(var(--accent-rgb), 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(244,246,248,0.92));
}

/* ── THINKING BAR ────────────────────────────────────────────── */
.thinking-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}
.thinking-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.thinking-dots { display: flex; gap: 4px; }
.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: thinking-pulse 1.2s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinking-pulse {
  0%, 80%, 100% { transform: scale(0.75); opacity: 0.35; }
  40%  { transform: scale(1); opacity: 1; }
}
.thinking-label { font-size: 0.85rem; color: var(--text-muted); }

/* ── INPUT AREA ──────────────────────────────────────────────── */
.input-area {
  padding: 0.75rem max(1rem, var(--safe-area-right)) calc(0.9rem + var(--resolved-safe-bottom)) max(1rem, var(--safe-area-left));
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
  flex-shrink: 0;
}
.input-container { max-width: 700px; margin: 0 auto; }

.input-shell {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-xl);
  padding: 0.85rem 0.85rem 0.75rem 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-shell:focus-within {
  border-color: rgba(255,255,255,0.28);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
html[data-theme="light"] .input-shell:focus-within {
  border-color: rgba(0,0,0,0.25);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.12);
}

.input-field {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.55;
  resize: none;
  max-height: 200px;
  outline: none;
  padding: 0;
  /* hide scrollbar up/down arrow buttons */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.input-field::placeholder { color: var(--text-faint); }
.input-field::-webkit-scrollbar { width: 4px; }
.input-field::-webkit-scrollbar-track { background: transparent; }
.input-field::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.input-field::-webkit-scrollbar-button { display: none; height: 0; }

/* Row that wraps the upload prefix button + textarea + send button */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  width: 100%;
}
.input-row .input-field { flex: 1; }

/* Upload button sitting to the left of the textarea */
.attach-prefix-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  /* sits flush with last line of textarea text */
  padding: 0;
  line-height: 1;
}
.attach-prefix-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-input);
}
.attach-prefix-btn.has-files {
  color: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  max-width: min(100%, 320px);
  padding: 0.42rem 0.55rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.attachment-chip-uploading,
.attachment-chip-processing {
  border-color: rgba(var(--accent-rgb), 0.32);
}

.attachment-chip-failed {
  border-color: rgba(239, 68, 68, 0.45);
}

.attachment-thumb,
.attachment-file-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
}

.attachment-thumb {
  object-fit: cover;
  background: rgba(255,255,255,0.06);
}

.attachment-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.attachment-chip-main {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.attachment-chip-name,
.attachment-chip-meta,
.attachment-chip-error {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip-name {
  color: var(--text);
  font-weight: 600;
}

.attachment-chip-meta {
  color: var(--text-faint);
}

.attachment-chip-error {
  color: var(--danger, #ef4444);
}

.attachment-chip button {
  border: none;
  background: rgba(255,255,255,0.05);
  color: inherit;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 999px;
}

.attachment-chip-remove {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.input-area.auoura-composer.is-dragging-files .glow-box {
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.38), 0 18px 50px rgba(0,0,0,0.55);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.composer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.composer-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;

/* Disabled state for tool buttons (visual + non-interactive) */
.composer-tool-btn.disabled {
  opacity: 0.45;
  filter: grayscale(30%);
  pointer-events: none;
  cursor: default;
}
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.composer-tool-btn:hover,
.composer-tool-btn.active {
  background: var(--bg-elevated);
  border-color: var(--border-input);
  color: var(--text);
}

.input-actions { display: flex; align-items: center; flex-shrink: 0; }

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  padding: 0;
  line-height: 1;
  background: var(--send-bg);
  color: var(--send-fg);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.send-btn:hover:not(:disabled) { transform: scale(1.06); }
.send-btn:disabled { background: var(--send-disabled); color: var(--text-faint); cursor: not-allowed; }
.send-btn-cancel {
  background: var(--danger, #ef4444) !important;
  color: #fff !important;
  animation: cancel-pulse 1.6s ease-in-out infinite;
}
.send-btn-cancel:hover { transform: scale(1.08); opacity: 0.92; }
@keyframes cancel-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50%       { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ── COMPOSER ORB — absolutely centred so toggle widths can't shift it ── */
.composer-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.composer-orb-wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 1;
}

.composer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  margin-left: auto;
}

.orb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  color: #ffffff;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.orb-btn svg { width: 30px; height: 30px; display: block; }
.orb-btn:hover { opacity: 0.7; }

/* Spin during generation */
.orb-btn.orb-spinning {
  color: #ffffff;
  filter: drop-shadow(0 0 5px rgba(255,255,255,0.35));
}
.orb-btn.orb-spinning svg {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: orb-spin 1.4s linear infinite;
}
@keyframes orb-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Flash red when risk is detected */
.orb-btn.orb-risk {
  animation: orb-risk-flash 0.45s ease-in-out 5;
  color: var(--danger, #ef4444);
}
@keyframes orb-risk-flash {
  0%, 100% { opacity: 1;   filter: drop-shadow(0 0 0px #ef4444); }
  50%       { opacity: 0.2; filter: drop-shadow(0 0 10px #ef4444); }
}

/* Glow twice when generation completes */
.orb-btn.orb-done {
  animation: orb-done-glow 1.4s ease-in-out 1 forwards;
  color: #ffffff;
}
@keyframes orb-done-glow {
  0%   { filter: drop-shadow(0 0 0px #fff);  opacity: 1; }
  20%  { filter: drop-shadow(0 0 14px #fff); opacity: 1; }
  40%  { filter: drop-shadow(0 0 2px #fff);  opacity: 0.55; }
  60%  { filter: drop-shadow(0 0 14px #fff); opacity: 1; }
  80%  { filter: drop-shadow(0 0 2px #fff);  opacity: 0.55; }
  100% { filter: drop-shadow(0 0 0px #fff);  opacity: 1; }
}

/* Risk popover — pops up from the orb */
.input-footer {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0.25rem 0;
  font-size: 0.73rem;
  color: var(--text-faint);
  border: none !important;
  border-left: none !important;
  border-bottom: none !important;
  box-shadow: none !important;
}

/* ── AUOURA COMPOSER ────────────────────────────────────────── */
.input-area.auoura-composer {
  --composer-bg: #000;
  --composer-panel: #111317;
  --composer-panel-2: #0d0f12;
  --composer-border: rgba(255,255,255,0.08);
  --composer-text: #fff;
  --composer-muted: rgba(255,255,255,0.62);
  --composer-cyan: 0, 255, 255;
  width: min(920px, 100%);
  margin: auto auto 0;
  --composer-panel-clearance: 0px;
  /* Anchor composer to the viewport bottom; internal padding handles safe-area */
  padding: 0 max(0.75rem, var(--safe-area-right)) calc(0.95rem) max(0.75rem, var(--safe-area-left));
  background: transparent !important;
  box-sizing: border-box;
  position: sticky;
  bottom: 0;
  z-index: 12;
}

@media (max-width: 900px) {
  .input-area.auoura-composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0; /* keep flush to viewport bottom */
    padding: 0 max(0.75rem, var(--safe-area-right)) calc(0.95rem) max(0.75rem, var(--safe-area-left));
    width: 100%;
    z-index: 999;
  }

  .input-area.auoura-composer .input-container {
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: 920px;
    margin: 0 auto;
  }

  .messages {
    padding-bottom: calc(6.5rem + constant(safe-area-inset-bottom));
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px));
  }
}

.input-area.auoura-composer .input-container {
  max-width: 920px;
  margin: 0 auto;
}

/* Ensure internal composer card honors the safe-area inset so visible card sits above home indicator */
.input-area.auoura-composer .glow-box {
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

.input-area.auoura-composer * {
  box-sizing: border-box;
}

.input-area.auoura-composer .input-shell {
  position: relative;
  width: 100%;
  gap: 0;
  padding: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.input-area.auoura-composer .input-glow-wrapper {
  position: relative;
  width: 100%;
  border-radius: 26px;
  isolation: isolate;
}

.input-area.auoura-composer .halo {
  position: absolute;
  inset: -16px;
  border-radius: 28px;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 50% 50%, var(--halo-c1, rgba(var(--accent-rgb), 0.18)), var(--halo-c2, rgba(var(--accent-rgb), 0.08)) 38%, transparent 72%);
  filter: blur(28px);
  opacity: var(--halo, 0);
  transform: scale(1);
  transition: opacity 0.28s ease, transform 0.28s ease, background 0.2s linear;
  will-change: opacity, transform, background;
}

.input-area.auoura-composer .glow {
  position: absolute;
  inset: -6px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(circle at var(--x, 5%) var(--y, 9%), var(--gc1, rgba(var(--accent-rgb),0.95)) 0%, var(--gc2, rgba(var(--accent-rgb),0.45)) 18%, transparent 48%);
  filter: blur(calc(10px + 6px * var(--g, 0)));
  opacity: calc(var(--g, 0) * 1);
  transition: background 0.16s linear, opacity 0.12s linear;
  will-change: opacity, filter, background-position;
}

.input-area.auoura-composer .glow-box {
  position: relative;
  z-index: 2;
  overflow: hidden;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(20, 22, 26, 0.98), rgba(12, 14, 18, 0.98));
  border: none;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55);
  transition: padding 0.24s ease, box-shadow 0.24s ease, transform 0.24s ease;
}

.input-area.auoura-composer .glow-box.fusion-ask-open {
  padding-top: 0.85rem;
  box-shadow: 0 20px 56px rgba(0,0,0,0.58);
}

/* Tighter spacing when running as a homescreen/standalone app */
body.is-standalone-app .input-area.auoura-composer {
  padding-bottom: 0; /* composer anchored flush */
}
body.is-standalone-app .input-area.auoura-composer .glow-box {
  /* use a clamped safe inset to avoid large PWA shell gaps */
  padding-bottom: calc(0.25rem + var(--glow-safe-bottom));
}
body.is-standalone-app .input-area.auoura-composer .composer-orb-wrap {
  top: auto;
  bottom: calc(0.125rem + var(--glow-safe-bottom));
  transform: translateX(-50%);
}
body.is-standalone-app .messages {
  /* smaller final gap to counter iOS homescreen shell inflation */
  padding-bottom: calc(var(--composer-height) + var(--glow-safe-bottom) - 0.25rem);
}

/* When the orb style panel is open allow the panel to overflow the glow box
   so it isn't clipped on desktop (desktop behaviour previously relied on
   the mobile fixed layout). */
.input-area.auoura-composer.orb-panel-open .glow-box {
  overflow: visible;
}

.input-area.auoura-composer .attachment-list {
  gap: 0.5rem;
  padding: 12px 12px 0;
}

.input-area.auoura-composer .attachment-chip {
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.78);
}

.input-area.auoura-composer .input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 14px 12px;
}

.input-area.auoura-composer .input-field {
  flex: 1;
  min-width: 0;
  min-height: 23px;
  max-height: min(240px, 34vh);
  overflow: hidden;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--composer-text);
  font-size: 16px;
  line-height: 1.45;
  caret-color: rgb(0,255,255);
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.input-area.auoura-composer .input-field::placeholder {
  color: rgba(255,255,255,0.48);
}

.input-area.auoura-composer .attach-prefix-btn,
.input-area.auoura-composer .send-btn,
.input-area.auoura-composer .composer-tool-btn,
.input-area.auoura-composer .orb-btn,
.input-area.auoura-composer .risk-popover-dismiss {
  appearance: none;
  border: 0;
  outline: none;
  background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.9);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.input-area.auoura-composer .attach-prefix-btn,
.input-area.auoura-composer .send-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.input-area.auoura-composer .attach-prefix-btn:hover,
.input-area.auoura-composer .send-btn:hover,
.input-area.auoura-composer .composer-tool-btn:hover,
.input-area.auoura-composer .orb-btn:hover {
  background: rgba(255,255,255,0.07);
  transform: translateY(-1px);
}

.input-area.auoura-composer .send-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.input-area.auoura-composer .composer-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 14px;
}

.input-area.auoura-composer .composer-toolbar-left,
.input-area.auoura-composer .composer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.input-area.auoura-composer .composer-toolbar-left {
  flex: 1 1 0;
  position: relative;
}

.input-area.auoura-composer .composer-toolbar-right {
  flex: 1 1 0;
  justify-content: flex-end;
}

.input-area.auoura-composer .composer-tool-btn {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
}

.input-area.auoura-composer .composer-tool-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-area.auoura-composer .conversation-todo-btn {
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  flex: 0 0 auto;
}

.input-area.auoura-composer .conversation-todo-btn.hidden {
  display: none !important;
}

.input-area.auoura-composer .conversation-todo-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: min(520px, calc(100vw - 24px));
  max-height: min(72svh, 560px);
  overflow: visible;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.14), transparent 38%),
    linear-gradient(180deg, rgba(17,19,23,0.98), rgba(10,12,15,0.98));
  box-shadow: 0 24px 60px rgba(0,0,0,0.48);
  backdrop-filter: blur(18px);
  z-index: 30;
}

.input-area.auoura-composer .conversation-todo-panel.hidden {
  display: none !important;
}

.input-area.auoura-composer .conversation-todo-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.input-area.auoura-composer .conversation-todo-panel-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.input-area.auoura-composer .conversation-todo-summary {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.input-area.auoura-composer .conversation-todo-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.input-area.auoura-composer .conversation-todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 11px;
  min-height: 100%;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.input-area.auoura-composer .conversation-todo-item input {
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.input-area.auoura-composer .conversation-todo-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.input-area.auoura-composer .conversation-todo-text {
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.4;
  word-break: break-word;
}

.input-area.auoura-composer .conversation-todo-item.is-completed .conversation-todo-text,
.input-area.auoura-composer .conversation-todo-item.is-cancelled .conversation-todo-text {
  text-decoration: line-through;
  opacity: 0.7;
}

.input-area.auoura-composer .conversation-todo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.input-area.auoura-composer .conversation-todo-status,
.input-area.auoura-composer .conversation-todo-priority {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.48rem;
  font-size: 0.67rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  color: var(--text-muted);
}

.input-area.auoura-composer .conversation-todo-status--completed {
  background: rgba(74, 222, 128, 0.14);
  color: #9ae6b4;
}

.input-area.auoura-composer .conversation-todo-status--in_progress {
  background: rgba(96, 165, 250, 0.16);
  color: #93c5fd;
}

.input-area.auoura-composer .conversation-todo-status--cancelled {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
}

html[data-theme="light"] .input-area.auoura-composer .conversation-todo-panel {
  border-color: rgba(15,23,42,0.08);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.1), transparent 38%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(245,247,250,0.96));
  box-shadow: 0 18px 42px rgba(15,23,42,0.12);
}

html[data-theme="light"] .input-area.auoura-composer .conversation-todo-item {
  background: rgba(15,23,42,0.03);
  border-color: rgba(15,23,42,0.06);
}

html[data-theme="light"] .input-area.auoura-composer .conversation-todo-status,
html[data-theme="light"] .input-area.auoura-composer .conversation-todo-priority {
  background: rgba(15,23,42,0.06);
  color: rgba(15,23,42,0.68);
}

.input-area.auoura-composer .composer-tool-btn.active {
  background: rgba(0,255,255,0.08);
  border-color: rgba(0,255,255,0.16);
  box-shadow: 0 0 0 1px rgba(0,255,255,0.06) inset;
}

.input-area.auoura-composer .composer-orb-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 3;
}

@media (max-width: 900px) {
  /* Lower the orb on small screens so it's closer to the bottom of the glow-box */
  .input-area.auoura-composer .composer-orb-wrap {
    top: auto;
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
  }
}

.input-area.auoura-composer .orb-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}

.input-area.auoura-composer .orb-btn.orb-panel-open {
  background: linear-gradient(180deg, rgba(var(--accent-rgb),0.22), rgba(var(--accent-rgb),0.08));
  border-color: rgba(var(--accent-rgb), 0.36);
  box-shadow: 0 14px 42px rgba(0,0,0,0.42), 0 0 0 1px rgba(var(--accent-rgb), 0.16);
  transform: translateY(-1px);
}

.input-area.auoura-composer .orb-btn.orb-panel-spin-open {
  animation: orb-panel-spin-open 0.72s cubic-bezier(0.22, 1, 0.36, 1) 1;
}

.input-area.auoura-composer .orb-btn.orb-panel-spin-close {
  animation: orb-panel-spin-close 0.72s cubic-bezier(0.22, 1, 0.36, 1) 1;
}

@keyframes orb-panel-spin-open {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes orb-panel-spin-close {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

.input-area.auoura-composer .orb-style-panel {
  position: absolute;
  /* Position above the orb by default on desktop */
  bottom: calc(100% + 14px);
  top: auto;
  left: 50%;
  width: min(370px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  padding: 16px;
  border-radius: 24px;
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.14), transparent 36%),
    linear-gradient(180deg, rgba(17,19,23,0.98), rgba(10,12,15,0.98));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  transform: translateX(-50%);
  z-index: 6;
  backdrop-filter: blur(18px);
}

.input-area.auoura-composer .orb-style-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.input-area.auoura-composer .orb-style-panel-kicker,
.input-area.auoura-composer .orb-style-control-label,
.input-area.auoura-composer .orb-style-control-copy {
  margin: 0;
}

.input-area.auoura-composer .orb-style-panel-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
}

.input-area.auoura-composer .orb-style-panel-title {
  margin: 4px 0 0;
  font-size: 0.98rem;
  line-height: 1.2;
  color: rgba(255,255,255,0.95);
}

.input-area.auoura-composer .orb-style-control {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  min-width: 0;
}

.input-area.auoura-composer .orb-style-control + .orb-style-control {
  margin-top: 10px;
}

.input-area.auoura-composer .orb-style-control-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.input-area.auoura-composer .orb-style-control-head > div {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.input-area.auoura-composer .orb-style-control-label-row {
  position: relative;
  display: inline-block;
}

.input-area.auoura-composer .orb-style-control-label {
  margin: 0;
  display: inline-block;
}

.input-area.auoura-composer .orb-style-control-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
}

.input-area.auoura-composer .orb-style-control-copy {
  margin-top: 3px;
  font-size: 0.73rem;
  line-height: 1.35;
  color: rgba(255,255,255,0.52);
}

.input-area.auoura-composer .fusion-permission-row,
.composer-overlay-root .fusion-permission-row,
.input-area.auoura-composer .fusion-memory-row,
.composer-overlay-root .fusion-memory-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-width: 0;
}

.input-area.auoura-composer .fusion-permission-row:last-child,
.composer-overlay-root .fusion-permission-row:last-child,
.input-area.auoura-composer .fusion-memory-row:last-child,
.composer-overlay-root .fusion-memory-row:last-child {
  border-bottom: none;
}

.input-area.auoura-composer .fusion-permission-name,
.composer-overlay-root .fusion-permission-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.input-area.auoura-composer .fusion-permission-select,
.composer-overlay-root .fusion-permission-select {
  flex-shrink: 0;
  min-width: 88px;
  background: var(--input-bg, #1a1a2e);
  border: 1px solid var(--border, #2a2a3e);
  border-radius: 4px;
  color: inherit;
  padding: 2px 4px;
  font-size: 11px;
}

.input-area.auoura-composer .fusion-memory-info,
.composer-overlay-root .fusion-memory-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
  overflow: hidden;
}

.input-area.auoura-composer .fusion-memory-key,
.composer-overlay-root .fusion-memory-key,
.input-area.auoura-composer .fusion-memory-meta,
.composer-overlay-root .fusion-memory-meta,
.input-area.auoura-composer .fusion-memory-value,
.composer-overlay-root .fusion-memory-value {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.input-area.auoura-composer .fusion-memory-key,
.composer-overlay-root .fusion-memory-key {
  font-size: 12px;
  font-weight: 600;
}

.input-area.auoura-composer .fusion-memory-meta,
.composer-overlay-root .fusion-memory-meta,
.input-area.auoura-composer .fusion-memory-value,
.composer-overlay-root .fusion-memory-value {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.input-area.auoura-composer .fusion-memory-delete,
.composer-overlay-root .fusion-memory-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 2px;
  font-size: 11px;
  line-height: 1;
}

#fusion-permissions-list,
#fusion-memory-list,
.composer-overlay-root #fusion-permissions-list,
.composer-overlay-root #fusion-memory-list {
  display: grid;
  gap: 6px;
  max-height: min(38vh, 340px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  min-width: 0;
}

.input-area.auoura-composer .orb-style-info-btn {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.74);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.input-area.auoura-composer .orb-style-info-btn:hover,
.input-area.auoura-composer .orb-style-info-btn[aria-expanded="true"] {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.32);
  color: rgba(255,255,255,0.96);
  transform: translateY(-1px);
}

.input-area.auoura-composer .orb-style-slider {
  --selected-index: 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  min-height: 60px;
  padding: 8px 10px;
  border-radius: 18px;
  outline: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.input-area.auoura-composer .orb-style-slider.is-dragging {
  cursor: grabbing;
}

.input-area.auoura-composer .orb-style-slider::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  height: 2px;
  border-radius: 999px;
  /* Subtle track for the slider to make the UI cleaner */
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  transform: translateY(-50%);
  z-index: 0;
}

.input-area.auoura-composer .orb-style-slider::after {
  content: "";
  position: absolute;
  top: 50%;
  /* Prefer an explicit indicator position provided from JS which accounts
     for padding and grid gaps; fall back to the old percentage calculation. */
  left: var(--indicator-left, calc(12.5% + (var(--selected-index) * 25%)));
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(var(--accent-rgb),0.28), rgba(var(--accent-rgb),0.12));
  border: 1px solid rgba(var(--accent-rgb),0.44);
  box-shadow: 0 14px 26px rgba(0,0,0,0.32);
  transform: translate(-50%, -50%);
  transition: left 0.22s ease, background 0.22s ease, border-color 0.22s ease;
  z-index: 1; /* sit below the stop icons */
  pointer-events: none; /* allow clicks to reach the buttons */
}

.input-area.auoura-composer .orb-style-slider.orb-style-slider-no-indicator-motion::after {
  transition: background 0.22s ease, border-color 0.22s ease;
}

.input-area.auoura-composer .orb-style-slider:focus-visible {
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.22), 0 0 0 4px rgba(var(--accent-rgb), 0.12);
}

.input-area.auoura-composer .orb-style-stop {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: color 0.18s ease, transform 0.18s ease;
}

.input-area.auoura-composer .orb-style-stop:hover,
.input-area.auoura-composer .orb-style-stop.is-active {
  color: rgba(255,255,255,0.96);
  transform: translateY(-1px);
}

.input-area.auoura-composer .orb-style-stop {
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-area.auoura-composer .orb-style-stop svg {
  width: 18px;
  height: 18px;
  display: block;
  margin: 0;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

/* Ensure inline SVG strokes use the button color so currentColor works reliably */
.input-area.auoura-composer .orb-style-stop svg,
.input-area.auoura-composer .orb-style-stop svg path,
.input-area.auoura-composer .orb-style-stop svg line,
.input-area.auoura-composer .orb-style-stop svg circle {
  color: inherit;
  stroke: currentColor;
}

/* If an icon uses fill rather than stroke, make it visible too */
.input-area.auoura-composer .orb-style-stop svg[fill]:not([fill="none"]) path,
.input-area.auoura-composer .orb-style-stop svg[fill]:not([fill="none"]) circle {
  fill: currentColor;
}

/* Position the info button outside the centered label without affecting layout */
.input-area.auoura-composer .orb-style-control-label-row .orb-style-info-btn {
  position: absolute;
  left: 100%;
  margin-left: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.input-area.auoura-composer .orb-style-control-copy {
  text-align: center;
}

/* Center header text and hide the assistant-only title */
.input-area.auoura-composer .orb-style-panel {
  text-align: center;
}

.input-area.auoura-composer .orb-style-panel-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.input-area.auoura-composer .orb-style-panel-title {
  display: none;
}

.input-area.auoura-composer .orb-style-stop:hover svg {
  background: rgba(255,255,255,0.05);
}

.input-area.auoura-composer .orb-style-stop.is-active svg {
  background: linear-gradient(180deg, rgba(var(--accent-rgb),0.18), rgba(var(--accent-rgb),0.08));
  box-shadow: 0 8px 18px rgba(0,0,0,0.28);
}

/* Slightly reduce the hover lift to keep things stable visually */
.input-area.auoura-composer .orb-style-stop:hover,
.input-area.auoura-composer .orb-style-stop.is-active {
  transform: translateY(-0.6px);
}

/* Mobile: make orb panel tab buttons wrap and size-friendly */
@media (max-width: 520px) {
  .input-area.auoura-composer .orb-style-panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .input-area.auoura-composer .orb-style-stop {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    padding: 8px 10px;
  }
  .input-area.auoura-composer .orb-style-control-head {
    flex-direction: column;
    align-items: stretch;
  }
}

.input-area.auoura-composer .orb-style-info-popover {
  padding: 12px 13px;
  border-radius: 16px;
  background: rgba(6,7,9,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.86);
}

.input-area.auoura-composer .orb-style-info-title {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.96);
}

.input-area.auoura-composer .orb-style-info-copy {
  margin: 0;
  font-size: 0.73rem;
  line-height: 1.45;
  color: rgba(255,255,255,0.65);
}

.input-area.auoura-composer .risk-popover {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 88vw);
  overflow: hidden;
  border-radius: 18px;
  background: rgba(18, 20, 24, 0.98);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 18px 50px rgba(0,0,0,0.6);
  z-index: 5;
}

.input-area.auoura-composer .risk-popover-header,
.input-area.auoura-composer .risk-popover-body {
  padding: 12px 14px;
}

/* ── AUOURA TOPBAR SPIN (scoped) ───────────────────────────────── */
.topbar { position: relative; }
.topbar .topbar-brand { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; width: max-content; z-index: 6; pointer-events: auto; }
.auoura-topbar-scene { display: flex; justify-content: center; align-items: center; gap: 6px; user-select: none; perspective: 600px; }
.auoura-topbar-scene .letter-wrap { perspective: 600px; display: inline-flex; align-items: center; justify-content: center; }
.auoura-topbar-scene .letter { font-size: clamp(16px, 3vw, 22px); font-weight: 600; font-family: var(--font-sans, Inter, sans-serif); color: var(--text); display: inline-block; cursor: default; transition: color 0.18s, text-shadow 0.18s; will-change: transform; transform-style: preserve-3d; line-height: 1; padding: 2px 1px; backface-visibility: visible; -webkit-backface-visibility: visible; }
.auoura-topbar-scene .letter.spinning { color: color-mix(in srgb, var(--accent) 78%, #9fd9ff); text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.22); }

@media (max-width: 720px) {
  .topbar .topbar-brand { position: static; transform: none; margin-left: 0; }
  .auoura-topbar-scene .letter { font-size: 14px; }
}

.input-area.auoura-composer .risk-popover-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.input-area.auoura-composer .risk-popover-title {
  font-size: 13px;
  font-weight: 700;
  flex: 1;
}

.input-area.auoura-composer .risk-popover-dismiss {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 14px;
  background: rgba(255,255,255,0.05);
}

.input-area.auoura-composer .risk-popover-reason,
.input-area.auoura-composer .risk-popover-tier {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255,255,255,0.82);
}

.input-area.auoura-composer .risk-popover-hazards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.input-area.auoura-composer .input-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 0 14px 14px;
  color: rgba(255,255,255,0.58);
  font-size: 12px;
  line-height: 1.4;
  border: none !important;
  border-left: none !important;
  border-bottom: none !important;
  box-shadow: none !important;
}

.input-area.auoura-composer .input-hint {
  display: block;
  width: 100%;
  margin-top: 8px;
  text-align: center;
  margin-left: auto;
  margin-right: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="light"] .input-area.auoura-composer {
  --composer-bg: #ffffff;
  --composer-panel: #ffffff;
  --composer-panel-2: #f7f7f8;
  --composer-border: rgba(0,0,0,0.08);
  --composer-text: #0b0b0b;
  --composer-muted: rgba(0,0,0,0.62);
  --composer-cyan: 0, 122, 255;
}

html[data-theme="light"] .input-area.auoura-composer .glow-box {
  background: linear-gradient(180deg, #f4f6f8, #eef0f2);
  border: none !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}

html[data-theme="light"] .input-area.auoura-composer .attach-prefix-btn,
html[data-theme="light"] .input-area.auoura-composer .send-btn,
html[data-theme="light"] .input-area.auoura-composer .composer-tool-btn,
html[data-theme="light"] .input-area.auoura-composer .orb-btn,
html[data-theme="light"] .input-area.auoura-composer .risk-popover-dismiss {
  color: rgba(0,0,0,0.88);
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.06);
}

html[data-theme="light"] .input-area.auoura-composer .attach-prefix-btn:hover,
html[data-theme="light"] .input-area.auoura-composer .send-btn:hover,
html[data-theme="light"] .input-area.auoura-composer .composer-tool-btn:hover,
html[data-theme="light"] .input-area.auoura-composer .orb-btn:hover {
  background: rgba(0,0,0,0.07);
  transform: translateY(-1px);
}

html[data-theme="light"] .input-area.auoura-composer .composer-tool-btn.active {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.12);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.04) inset;
}

html[data-theme="light"] .input-area.auoura-composer .input-footer {
  color: rgba(0,0,0,0.6);
}

html[data-theme="light"] .input-area.auoura-composer .orb-btn {
  background: linear-gradient(180deg, rgba(0,0,0,0.07), rgba(0,0,0,0.03));
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 8px 30px rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.88);
}

html[data-theme="light"] .input-area.auoura-composer .orb-btn.orb-panel-open {
  background: linear-gradient(180deg, rgba(var(--accent-rgb),0.16), rgba(var(--accent-rgb),0.06));
  border-color: rgba(var(--accent-rgb),0.24);
  box-shadow: 0 16px 36px rgba(0,0,0,0.1), 0 0 0 1px rgba(var(--accent-rgb),0.1);
}

html[data-theme="light"] .input-area.auoura-composer .orb-btn svg {
  fill: currentColor;
  color: inherit;
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-panel {
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.1), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(244,246,248,0.98));
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 22px 48px rgba(16,24,40,0.12);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-panel-kicker {
  color: rgba(0,0,0,0.36);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-panel-title,
html[data-theme="light"] .input-area.auoura-composer .orb-style-control-label {
  color: rgba(0,0,0,0.92);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-control {
  background: rgba(255,255,255,0.78);
  border-color: rgba(0,0,0,0.06);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-control-copy {
  color: rgba(0,0,0,0.5);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-info-btn {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.62);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-info-btn:hover,
html[data-theme="light"] .input-area.auoura-composer .orb-style-info-btn[aria-expanded="true"] {
  color: rgba(0,0,0,0.9);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-slider::before {
  background: linear-gradient(90deg, rgba(0,0,0,0.08), rgba(0,0,0,0.16), rgba(0,0,0,0.08));
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-stop {
  color: rgba(0,0,0,0.44);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-stop:hover,
html[data-theme="light"] .input-area.auoura-composer .orb-style-stop.is-active {
  color: rgba(0,0,0,0.94);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-info-popover {
  background: rgba(255,255,255,0.9);
  border-color: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.8);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-stop svg {
  background: rgba(0,0,0,0.03);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-stop.is-active svg {
  background: linear-gradient(180deg, rgba(var(--accent-rgb),0.12), rgba(var(--accent-rgb),0.06));
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-info-title {
  color: rgba(0,0,0,0.94);
}

html[data-theme="light"] .input-area.auoura-composer .orb-style-info-copy {
  color: rgba(0,0,0,0.62);
}

@media (max-width: 720px) {
  .input-area.auoura-composer .orb-style-panel {
    position: fixed;
    left: max(8px, calc(var(--safe-area-left) + 8px));
    right: max(8px, calc(var(--safe-area-right) + 8px));
    top: auto;
    bottom: calc(var(--composer-panel-clearance) + 8px);
    width: auto;
    max-width: none;
    transform: none;
    border-radius: 24px;
    padding: 16px;
  }

  .input-area.auoura-composer .orb-style-panel-header {
    margin-bottom: 14px;
  }

  .input-area.auoura-composer .orb-style-panel-kicker {
    font-size: 0.63rem;
    letter-spacing: 0.12em;
  }

  .input-area.auoura-composer .orb-style-control {
    gap: 8px;
    padding: 10px;
    border-radius: 16px;
  }

  .input-area.auoura-composer .orb-style-control + .orb-style-control {
    margin-top: 8px;
  }

  .input-area.auoura-composer .orb-style-control-head > div {
    align-items: stretch;
  }

  .input-area.auoura-composer .orb-style-control-label-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  .input-area.auoura-composer .orb-style-control-label-row .orb-style-info-btn {
    position: static;
    margin-left: 0;
    top: auto;
    left: auto;
    transform: none;
  }

  .input-area.auoura-composer .orb-style-control-copy {
    margin-top: 2px;
    font-size: 0.68rem;
    line-height: 1.3;
  }

  .input-area.auoura-composer .orb-style-slider {
    min-height: 54px;
    padding: 6px 4px;
    gap: 4px;
  }

  .input-area.auoura-composer .orb-style-slider::before {
    left: 12px;
    right: 12px;
  }

  .input-area.auoura-composer .orb-style-slider::after {
    width: 32px;
    height: 32px;
  }

  .input-area.auoura-composer .orb-style-stop {
    min-height: 34px;
  }

  .input-area.auoura-composer .orb-style-stop svg {
    width: 16px;
    height: 16px;
    padding: 6px;
  }
}

html[data-theme="light"] .input-area.auoura-composer .input-field::placeholder {
  color: rgba(0,0,0,0.5);
}

html[data-theme="light"] .welcome-logo svg path,
html[data-theme="light"] .welcome-logo svg circle,
html[data-theme="light"] .welcome-logo svg rect {
  fill: #ffffff !important;
  stroke: #000 !important;
  stroke-width: 1.6px !important;
  stroke-linejoin: round !important;
  stroke-linecap: round !important;
}

/* ── ARTIFACT PANEL ──────────────────────────────────────────── */
.artifact-backdrop {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.artifact-panel {
  position: relative;
  width: var(--artifact-w);
  min-width: 360px;
  max-width: min(1100px, 82vw);
  flex-shrink: 0;
  background: linear-gradient(180deg, #1c1c1e, #0f0f0f);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-left: 1px solid rgba(255,255,255,0.06);
  transition: width 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
  font-family: system-ui, sans-serif;
  container-type: inline-size;
  container-name: artifact-panel;
}
.artifact-panel.panel-hidden {
  width: 0;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  border-left: none;
  overflow: hidden;
}

.artifact-panel-resizer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 12px;
  cursor: ew-resize;
  touch-action: none;
  z-index: 4;
}

.artifact-panel-resizer::after {
  content: "";
  position: absolute;
  top: 24px;
  bottom: 24px;
  left: 5px;
  width: 2px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  opacity: 0.72;
  transition: background 0.16s ease, opacity 0.16s ease;
}

.artifact-panel-resizer:hover::after,
.artifact-panel-resizer:active::after {
  background: rgba(255,255,255,0.28);
  opacity: 1;
}

.artifact-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  min-width: 0;
}
.artifact-panel-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.artifact-panel-title {
  font-size: 0.88rem;
  font-weight: 650;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artifact-panel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.artifact-meta-chip {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
}
.artifact-panel-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.artifact-panel-counts {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}
.artifact-close-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.artifact-close-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.artifact-workspace {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  padding: 4px;
  gap: 2px;
}

.artifact-project-shell {
  width: 260px;
  min-width: 180px;
  max-width: 500px;
  padding: 8px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.06);
}

.projectName {
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 4px;
}

.projectTitle {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.projectSub {
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 10px;
}

.artifact-project-tree {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.artifact-project-tree::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.artifact-project-tree::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}

.treeItem {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.85;
  color: #fff;
  user-select: none;
}

.treeItem:hover {
  background: rgba(255,255,255,0.06);
  opacity: 1;
}

.treeItem.active {
  background: rgba(10,132,255,0.2);
  color: #0a84ff;
}

.folderRow {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.caret {
  font-size: 16px;
  width: 16px;
  flex: 0 0 16px;
  text-align: center;
}

.children {
  margin-left: 14px;
  display: none;
  flex-direction: column;
  gap: 4px;
}

.children.open {
  display: flex;
}

.artifact-resizer {
  width: 2px;
  flex: 0 0 2px;
  cursor: col-resize;
}

.artifact-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}

.artifact-tabs {
  display: flex;
  padding: 6px 8px;
  gap: 6px;
  flex-shrink: 0;
}

.artifact-tabs .tab {
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.7;
  background: transparent;
  color: #fff;
  font-family: inherit;
}

.artifact-tabs .tab:hover {
  background: rgba(255,255,255,0.06);
  opacity: 1;
}

.artifact-tabs .tab.active {
  background: rgba(255,255,255,0.08);
  opacity: 1;
}

.artifact-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px;
  margin: 0 6px 6px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.artifact-toolbar button {
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: none;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 13px;
}

.artifact-toolbar button:hover {
  background: rgba(255,255,255,0.12);
}

.artifact-toolbar button svg,
.deviceToggle button svg {
  width: 16px;
  height: 16px;
  fill: white;
}

.deviceToggle {
  display: none;
  gap: 6px;
  margin-left: auto;
}

.artifact-main.previewMode .deviceToggle {
  display: flex;
}

.deviceToggle button.active {
  background: #0a84ff;
}

.artifact-code-pane,
.previewWrapper {
  flex: 1;
  min-height: 0;
}

.artifact-code-pane {
  overflow: auto;
  padding: 14px;
  margin: 0 2px 2px;
  font-family: Menlo, monospace;
  background: #0a0a0a;
  border-radius: 14px;
  color: #f4f4f4;
  white-space: pre;
}

.artifact-code-pane code {
  display: block;
  min-height: 100%;
  white-space: pre;
  font: inherit;
  color: inherit;
  tab-size: 2;
}

.previewWrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 2px 2px;
}

.previewWrapper iframe {
  border: none;
  background: #fff;
  border-radius: 14px;
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 1100px) {
  .artifact-panel {
    position: fixed;
    right: 0;
    top: 52px;
    bottom: 0;
    z-index: 30;
    width: min(90vw, 520px);
    min-width: 0;
    max-width: min(90vw, 520px);
    box-shadow: var(--shadow-lg);
  }

  .artifact-panel.panel-hidden {
    transform: translateX(110%);
    width: min(90vw, 520px);
    max-width: min(90vw, 520px);
    opacity: 0;
  }

  .artifact-panel-resizer {
    display: none;
  }
}

@media (max-width: 640px) {
  .artifact-panel {
    top: 0;
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.06);
    border-radius: 0;
  }

  .artifact-panel.panel-hidden {
    width: 100vw;
  }

  .artifact-workspace {
    padding: 4px;
  }

  .artifact-project-shell {
    width: 240px;
    min-width: 180px;
  }
}

@container artifact-panel (max-width: 760px) {
  .artifact-workspace {
    flex-direction: column;
    padding: 6px;
    gap: 6px;
  }

  .artifact-project-shell {
    width: 100% !important;
    min-width: 0;
    max-width: none;
    max-height: min(32vh, 240px);
  }

  .artifact-resizer {
    display: none;
  }

  .artifact-tabs,
  .artifact-toolbar {
    flex-wrap: wrap;
  }

  .artifact-toolbar .deviceToggle {
    margin-left: 0 !important;
  }
}

/* ── FAILSAFE OVERLAY ────────────────────────────────────────── */

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn-primary {
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-wide { width: 100%; margin-top: 0.25rem; }

.chatroom-action-confirm.btn-primary {
  min-width: 112px;
}

.chatroom-action-confirm.btn-primary:hover {
  background: var(--accent-hover);
}

.chatroom-action-confirm.btn-primary.chatroom-action-confirm-danger {
  background: #ef4444;
}

.chatroom-action-confirm.btn-primary.chatroom-action-confirm-danger:hover {
  background: #dc2626;
}

/* ── TOAST ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  max-width: 380px;
  text-align: center;
  transition: opacity 0.25s, transform 0.25s;
}
.toast-success { border-color: rgba(34,197,94,0.4); color: #4ade80; }
.toast-warning { border-color: rgba(245,158,11,0.4); color: #fbbf24; }
.toast-error   { border-color: rgba(239,68,68,0.4);  color: #f87171; }
.toast-fade    { opacity: 0; transform: translateY(6px); }

/* Ensure toast icons (e.g., lightning) use theme text color, not tone color */
.toast .toast-icon {
  display: inline-block;
  vertical-align: -0.125em;
  width: 1em;
  height: 1em;
  margin: 0 0.35em;
  color: var(--text);
}
.toast .toast-icon svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 30;
  }
  .sidebar:not(.collapsed) { box-shadow: var(--shadow-lg); }
  .sidebar.collapsed { opacity: 0; }
}
@media (min-width: 961px) {
  body:not(.sidebar-collapsed) #sidebar-open { display: none; }
}
@media (max-width: 640px) {
  .settings-theme-options,
  .theme-onboarding-options {
    grid-template-columns: 1fr;
  }

  .theme-onboarding-modal {
    padding: 0.75rem;
    align-items: flex-end;
  }

  .theme-onboarding-shell {
    width: 100%;
    max-height: min(100%, calc(100svh - 1.5rem));
    overflow: hidden;
    padding: 0.9rem;
    border-radius: 22px;
  }

  .theme-onboarding-header {
    margin-bottom: 0.85rem;
  }

  .theme-onboarding-title {
    font-size: 1.5rem;
  }

  .theme-onboarding-options {
    gap: 0.7rem;
  }

  .theme-onboarding-card {
    gap: 0.55rem;
    padding: 0.75rem;
    border-radius: 20px;
  }

  .theme-onboarding-preview {
    height: 4.5rem;
  }

  .theme-onboarding-card-copy h3 {
    font-size: 0.9rem;
  }

  .theme-onboarding-card-copy p {
    font-size: 0.82rem;
  }

  .theme-onboarding-select-btn {
    padding: 0.6rem 0.85rem;
    font-size: 0.82rem;
  }

  .theme-onboarding-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    margin-top: 0.7rem;
  }

  .theme-onboarding-confirm {
    width: 100%;
  }

  .theme-onboarding-status {
    text-align: center;
  }

  .sidebar-footer {
    padding: 0.65rem;
    gap: 0.35rem;
  }

  .sidebar-account-card {
    gap: 0.56rem;
    padding: 0.66rem;
    margin-bottom: 0.18rem;
    border-radius: 16px;
  }

  .sidebar-account-head {
    gap: 0.56rem;
  }

  .sidebar-account-kicker {
    display: none;
  }

  .sidebar-account-name {
    font-size: 0.84rem;
  }

  .sidebar-account-email,
  .sidebar-quota-meta {
    font-size: 0.69rem;
    line-height: 1.24;
  }

  .sidebar-account-avatar {
    width: 1.95rem;
    height: 1.95rem;
    font-size: 0.72rem;
  }

  .sidebar-quota-card {
    gap: 0.28rem;
    padding: 0.48rem 0 0.02rem;
  }

  .sidebar-quota-head {
    font-size: 0.68rem;
    gap: 0.38rem;
  }

  .sidebar-quota-meter {
    height: 0.26rem;
  }

  .sidebar-quota-summary {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-quota-secondary-pill {
    padding: 0.14rem 0.36rem;
  }

  .sidebar-quota-secondary-meta {
    font-size: 0.62rem;
  }

  .sidebar-account-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.32rem;
  }

  .sidebar-account-btn,
  .sidebar-account-ghost {
    width: 100%;
    min-height: 1.95rem;
    font-size: 0.78rem;
  }

  .sidebar-account-btn {
    padding: 0.5rem 0.78rem;
  }

  .sidebar-account-ghost {
    min-width: 0;
  }

  .auth-provider-switch {
    grid-template-columns: 1fr;
  }

  .suggestion-grid { grid-template-columns: 1fr; }
  .input-area:not(.auoura-composer) { padding: 0.6rem 0.75rem 0.8rem; }
  .welcome-state { padding: 1.5rem 1rem 0.5rem; }
  .logo-wrapper {
    width: 132px;
    height: 132px;
    padding: 22px;
    border-radius: 32px;
  }

  .orb-a {
    width: 64px;
    height: 64px;
  }

  .orb-b {
    width: 72px;
    height: 72px;
  }

  .orb-c {
    width: 58px;
    height: 58px;
  }

  .logo-svg { width: 92px; }
  .message-row { padding: 0.9rem 0.75rem 0; }
  .topbar {
    height: auto;
    align-items: stretch;
    gap: 0.75rem;
    flex-direction: column;
  }
  .topbar-left {
    width: 100%;
    justify-content: center;
    position: relative;
    min-height: 2rem;
  }
  #sidebar-open {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
      z-index: 40;
      touch-action: manipulation;
  }
  .topbar .topbar-brand {
    position: static;
    left: auto;
    transform: none;
    margin: 0 auto;
    width: auto;
    max-width: calc(100% - 3rem);
  }
  .topbar-right,
  .topbar-settings,
  .topbar-settings-menu {
    width: 100%;
  }
  .topbar-right {
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .topbar-settings-menu {
    left: 0;
    right: auto;
    min-width: 0;
  }
  .topbar-select {
    min-width: 0;
    width: 100%;
  }
  .topbar-select-wrap {
    flex: 1 1 150px;
  }
  .input-area:not(.auoura-composer) .composer-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .input-area:not(.auoura-composer) .composer-toolbar-left {
    justify-content: space-between;
  }
}

@media (max-width: 720px) {
  .input-area.auoura-composer {
    width: 100%;
    padding: 0 8px max(14px, var(--resolved-safe-bottom) + 14px);
    box-shadow: none;
  }

  .message-row {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .message-inner {
    width: 100%;
    gap: 0.6rem;
  }

  .msg-content {
    min-width: 0;
  }

  .input-area.auoura-composer .input-glow-wrapper {
    border-radius: 24px;
  }

  .input-area.auoura-composer .glow-box {
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(20, 22, 26, 0.98), rgba(12, 14, 18, 0.98));
    box-shadow: 0 14px 34px rgba(0,0,0,0.34);
  }

  .input-area.auoura-composer .attachment-list {
    gap: 0.4rem;
    padding: 9px 10px 0;
  }

  .input-area.auoura-composer .attachment-chip {
    padding: 0.34rem 0.46rem;
    border-radius: 12px;
    font-size: 0.7rem;
  }

  .input-area.auoura-composer .input-row {
    gap: 8px;
    padding: 10px 10px 7px;
    align-items: flex-end;
  }

  .input-area.auoura-composer .input-field {
    min-height: 34px;
    max-height: 32vh;
    overflow-y: auto;
    font-size: 16px;
    line-height: 1.35;
    padding: 4px 0;
  }

  .input-area.auoura-composer .attach-prefix-btn,
  .input-area.auoura-composer .send-btn,
  .input-area.auoura-composer .orb-btn {
    width: 36px;
    height: 36px;
  }

  .input-area.auoura-composer .composer-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    padding: 6px 10px 9px;
  }

  .input-area.auoura-composer .composer-toolbar-left,
  .input-area.auoura-composer .composer-toolbar-right {
    gap: 6px;
    min-width: 0;
  }

  .input-area.auoura-composer .composer-toolbar-left {
    justify-content: flex-start;
    grid-column: 1;
    justify-self: start;
  }

  .input-area.auoura-composer .composer-toolbar-right {
    justify-content: flex-end;
    grid-column: 3;
    justify-self: end;
  }

  .input-area.auoura-composer .composer-orb-wrap {
    position: static;
    transform: none;
    grid-column: 2;
    justify-self: center;
  }

  .input-area.auoura-composer .composer-tool-btn {
    padding: 7px 9px;
    border-radius: 12px;
    font-size: 12px;
    min-width: 0;
    max-width: 100%;
  }

  .input-area.auoura-composer .composer-toolbar-left > *,
  .input-area.auoura-composer .composer-toolbar-right > * {
    flex: 0 1 auto;
    min-width: 0;
    width: auto;
  }

  .input-area.auoura-composer .input-footer {
    padding: 0 8px 10px;
    font-size: 11px;
    justify-content: center;
  }

  .input-area.auoura-composer .input-hint {
    margin-top: 4px;
    max-width: 100%;
    text-align: center;
  }

  .input-area.auoura-composer .halo,
  .input-area.auoura-composer .glow {
    display: block;
  }

  .input-area.auoura-composer .halo {
    inset: -12px;
    border-radius: 26px;
    filter: blur(22px);
    opacity: calc(var(--halo, 0) * 0.82);
  }

  .input-area.auoura-composer .glow {
    inset: -5px;
    border-radius: 22px;
    filter: blur(calc(8px + 4px * var(--g, 0)));
    opacity: calc(var(--g, 0) * 0.82);
  }
}

@media (max-width: 480px) {
  .input-area.auoura-composer {
    padding-left: 6px;
    padding-right: 6px;
  }

  .welcome-state {
    padding: 0.9rem 0.75rem 0.25rem;
    gap: 0.55rem;
  }

  .welcome-logo {
    margin-bottom: 0.35rem;
  }

  .logo-wrapper {
    width: 112px;
    height: 112px;
    padding: 18px;
    border-radius: 28px;
  }

  .welcome-heading {
    font-size: clamp(1.25rem, 5vw, 1.6rem);
    max-width: 15ch;
  }

  .suggestion-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 0.4rem;
  }

  .suggestion-pill {
    align-items: flex-start;
    padding: 0.58rem 0.7rem;
    font-size: 0.76rem;
    gap: 0.45rem;
  }

  .input-area.auoura-composer .orb-style-panel {
    left: max(6px, calc(var(--safe-area-left) + 6px));
    right: max(6px, calc(var(--safe-area-right) + 6px));
    padding: 10px;
    border-radius: 20px;
  }

  .input-area.auoura-composer .orb-panel-home,
  .composer-overlay-root .orb-panel-home {
    grid-template-columns: 1fr;
  }

  .input-area.auoura-composer .orb-panel-menu-card,
  .composer-overlay-root .orb-panel-menu-card {
    min-height: 96px;
    padding: 0.85rem;
  }

  .input-area.auoura-composer .orb-style-panel-header {
    margin-bottom: 8px;
  }

  .input-area.auoura-composer .orb-style-control {
    gap: 6px;
    padding: 9px;
    border-radius: 15px;
  }

  .input-area.auoura-composer .orb-style-control + .orb-style-control {
    margin-top: 6px;
  }

  .input-area.auoura-composer .orb-style-control-copy {
    font-size: 0.64rem;
  }

  .input-area.auoura-composer .orb-style-info-btn {
    width: 22px;
    height: 22px;
    font-size: 0.72rem;
  }

  .input-area.auoura-composer .orb-style-slider {
    min-height: 50px;
    padding: 5px 4px;
  }

  .input-area.auoura-composer .orb-style-slider::after {
    width: 30px;
    height: 30px;
  }

  .input-area.auoura-composer .orb-style-stop {
    min-height: 32px;
  }

  .input-area.auoura-composer .orb-style-stop svg {
    width: 14px;
    height: 14px;
    padding: 5px;
  }

  .input-area.auoura-composer .input-glow-wrapper {
    border-radius: 22px;
  }

  .input-area.auoura-composer .glow-box {
    border-radius: 20px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.28);
  }

  .input-area.auoura-composer .input-row {
    gap: 6px;
    padding: 8px 8px 6px;
  }

  .input-area.auoura-composer .input-field {
    min-height: 34px;
    font-size: 16px;
  }

  .input-area.auoura-composer .composer-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    padding: 5px 8px 8px;
  }

  .input-area.auoura-composer .composer-orb-wrap {
    position: static;
    transform: none;
    grid-column: 2;
    justify-self: center;
    margin: 0;
  }

  .input-area.auoura-composer .composer-toolbar-left,
  .input-area.auoura-composer .composer-toolbar-right {
    width: auto;
    min-width: 0;
  }

  .input-area.auoura-composer .composer-toolbar-left > *,
  .input-area.auoura-composer .composer-toolbar-right > * {
    flex: 0 1 auto;
    min-width: 0;
    width: auto;
  }

  .input-area.auoura-composer .composer-tool-btn {
    width: auto;
    justify-content: center;
  }

  .composer-overlay-root .conversation-todo-panel {
    max-height: min(78svh, 640px);
    padding: 10px;
  }

  .composer-overlay-root .conversation-todo-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .composer-overlay-root .conversation-todo-item {
    gap: 8px;
    padding: 8px 9px;
    border-radius: 12px;
  }

  .composer-overlay-root .conversation-todo-text {
    font-size: 0.77rem;
    line-height: 1.3;
  }

  .composer-overlay-root .conversation-todo-meta {
    gap: 5px;
  }

  .composer-overlay-root .conversation-todo-status,
  .composer-overlay-root .conversation-todo-priority {
    font-size: 0.62rem;
    padding: 0.18rem 0.42rem;
  }

  .input-area.auoura-composer .conversation-todo-panel {
    position: fixed;
    left: max(8px, calc(var(--safe-area-left) + 8px));
    right: max(8px, calc(var(--safe-area-right) + 8px));
    bottom: calc(var(--resolved-safe-bottom) + 88px);
    width: auto;
    max-height: min(78svh, 640px);
    padding: 10px;
  }

  .input-area.auoura-composer .conversation-todo-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .input-area.auoura-composer .conversation-todo-item {
    gap: 8px;
    padding: 8px 9px;
    border-radius: 12px;
  }

  .input-area.auoura-composer .conversation-todo-text {
    font-size: 0.77rem;
    line-height: 1.3;
  }

  .input-area.auoura-composer .conversation-todo-meta {
    gap: 5px;
  }

  .input-area.auoura-composer .conversation-todo-status,
  .input-area.auoura-composer .conversation-todo-priority {
    font-size: 0.62rem;
    padding: 0.18rem 0.42rem;
  }

  .input-area.auoura-composer .attachment-list {
    padding: 6px 6px 0;
  }

  .input-area.auoura-composer .input-footer {
    justify-content: center;
    padding: 0 6px 9px;
  }

  .input-area.auoura-composer .input-hint {
    margin-top: 0;
    text-align: center;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .input-area.auoura-composer .send-btn svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 360px) {
  .input-area.auoura-composer {
    padding-left: 4px;
    padding-right: 4px;
    padding-bottom: calc(var(--resolved-safe-bottom) + 4px);
  }

  .input-area.auoura-composer .glow-box {
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.24);
  }

  .input-area.auoura-composer .attachment-list {
    gap: 0.3rem;
    padding: 5px 5px 0;
  }

  .input-area.auoura-composer .attachment-chip {
    padding: 0.3rem 0.42rem;
    font-size: 0.68rem;
  }

  .input-area.auoura-composer .input-row {
    gap: 5px;
    padding: 5px 5px 4px;
  }

  .input-area.auoura-composer .attach-prefix-btn,
  .input-area.auoura-composer .send-btn,
  .input-area.auoura-composer .orb-btn {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .input-area.auoura-composer .composer-toolbar {
    gap: 5px;
    padding: 4px 6px 6px;
  }

  .input-area.auoura-composer .composer-tool-btn {
    padding: 7px 8px;
    font-size: 11px;
  }

  .composer-overlay-root .conversation-todo-panel {
    padding: 8px;
  }

  .composer-overlay-root .conversation-todo-list {
    grid-template-columns: 1fr;
  }

  .input-area.auoura-composer .conversation-todo-panel {
    padding: 8px;
  }

  .input-area.auoura-composer .conversation-todo-list {
    grid-template-columns: 1fr;
  }

  .input-area.auoura-composer .input-footer {
    padding: 0 5px 6px;
    font-size: 10px;
  }
}

/* Final override: keep orb centered by using a 3-column grid on very small screens */
@media (max-width: 420px) {
  .input-area.auoura-composer .composer-toolbar {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 6px !important;
  }

  .input-area.auoura-composer .composer-toolbar-left {
    grid-column: 1;
    justify-self: start;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  .input-area.auoura-composer .composer-orb-wrap {
    grid-column: 2;
    justify-self: center;
    position: static !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  .input-area.auoura-composer .composer-toolbar-right {
    grid-column: 3;
    justify-self: end;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  /* Prevent children from becoming full-width under other responsive rules */
  .input-area.auoura-composer .composer-toolbar-left > *,
  .input-area.auoura-composer .composer-toolbar-right > * {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    width: auto !important;
  }

  .input-area.auoura-composer .composer-tool-btn {
    width: auto !important;
    justify-content: center !important;
    padding: 6px 8px !important;
    min-width: 0 !important;
  }

  .input-area.auoura-composer .composer-tool-btn > * {
    flex: 0 0 auto !important;
  }

  .input-area.auoura-composer #search-mode-label .tool-name,
  .input-area.auoura-composer #reasoning-mode-label .tool-name,
  .input-area.auoura-composer #model-select-label .tool-name {
    display: none !important;
  }

  .input-area.auoura-composer .orb-btn { width: 36px !important; height: 36px !important; }
}

/* ── AUTHORITATIVE MOBILE / HOMESCREEN LAYOUT ───────────────── */
:root {
  --layout-safe-top: 0px;
  --layout-safe-bottom: 0px;
  --layout-header-boost: 0px;
  --composer-height: 168px;
}

body.is-standalone-app {
  --layout-header-boost: 18px;
}

.app-shell {
  position: relative;
  isolation: isolate;
}

.composer-overlay-root {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
}

.composer-overlay-root[aria-hidden="true"] {
  visibility: hidden;
}

.composer-overlay-root .orb-style-panel-overlay {
  --composer-bg: #000;
  --composer-panel: #111317;
  --composer-panel-2: #0d0f12;
  --composer-border: rgba(255,255,255,0.08);
  --composer-text: #fff;
  --composer-muted: rgba(255,255,255,0.62);
  position: fixed;
  top: var(--panel-top, auto);
  right: var(--panel-right, auto);
  bottom: var(--panel-bottom, auto);
  left: var(--panel-left, 50%);
  width: var(--panel-width, min(370px, calc(100vw - 28px)));
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 16px;
  transform: var(--panel-transform, translateX(-50%));
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.14), transparent 36%),
    linear-gradient(180deg, rgba(17,19,23,0.98), rgba(10,12,15,0.98));
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  backdrop-filter: blur(18px);
  z-index: 999999;
  pointer-events: auto;
}

.composer-overlay-root .conversation-todo-panel {
  position: fixed;
  top: var(--todo-panel-top, auto);
  right: var(--todo-panel-right, auto);
  bottom: var(--todo-panel-bottom, auto);
  left: var(--todo-panel-left, 50%);
  width: var(--todo-panel-width, min(520px, calc(100vw - 24px)));
  max-width: calc(100vw - 24px);
  max-height: min(72svh, 560px);
  overflow: auto;
  margin: 0;
  padding: 12px;
  transform: var(--todo-panel-transform, translateX(-50%));
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.14), transparent 38%),
    linear-gradient(180deg, rgba(17,19,23,0.98), rgba(10,12,15,0.98));
  box-shadow: 0 24px 60px rgba(0,0,0,0.48);
  backdrop-filter: blur(18px);
  pointer-events: auto;
  z-index: 999998;
}

.composer-overlay-root .conversation-todo-panel.hidden {
  display: none !important;
}

.composer-overlay-root .conversation-todo-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.composer-overlay-root .conversation-todo-panel-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.composer-overlay-root .conversation-todo-summary {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.composer-overlay-root .conversation-todo-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.composer-overlay-root .conversation-todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 11px;
  min-height: 100%;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.composer-overlay-root .conversation-todo-item input {
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.composer-overlay-root .conversation-todo-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.composer-overlay-root .conversation-todo-text {
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.4;
  word-break: break-word;
}

.composer-overlay-root .conversation-todo-item.is-completed .conversation-todo-text,
.composer-overlay-root .conversation-todo-item.is-cancelled .conversation-todo-text {
  text-decoration: line-through;
  opacity: 0.7;
}

.composer-overlay-root .conversation-todo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.composer-overlay-root .conversation-todo-status,
.composer-overlay-root .conversation-todo-priority {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.48rem;
  font-size: 0.67rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  color: var(--text-muted);
}

.composer-overlay-root .conversation-todo-status--completed {
  background: rgba(74, 222, 128, 0.14);
  color: #9ae6b4;
}

.composer-overlay-root .conversation-todo-status--in_progress {
  background: rgba(96, 165, 250, 0.16);
  color: #93c5fd;
}

.composer-overlay-root .conversation-todo-status--cancelled {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
}

html[data-theme="light"] .composer-overlay-root .conversation-todo-panel {
  border-color: rgba(15,23,42,0.08);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.1), transparent 38%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(245,247,250,0.96));
  box-shadow: 0 18px 42px rgba(15,23,42,0.12);
}

html[data-theme="light"] .composer-overlay-root .conversation-todo-item {
  background: rgba(15,23,42,0.03);
  border-color: rgba(15,23,42,0.06);
}

html[data-theme="light"] .composer-overlay-root .conversation-todo-status,
html[data-theme="light"] .composer-overlay-root .conversation-todo-priority {
  background: rgba(15,23,42,0.06);
  color: rgba(15,23,42,0.68);
}

.composer-overlay-root .orb-style-panel-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.composer-overlay-root .orb-style-panel-kicker,
.composer-overlay-root .orb-style-control-label,
.composer-overlay-root .orb-style-control-copy {
  margin: 0;
}

.composer-overlay-root .orb-style-panel-kicker {
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
}

.composer-overlay-root .orb-style-control-copy {
  font-size: 0.68rem;
  line-height: 1.3;
  color: rgba(255,255,255,0.52);
}

.composer-overlay-root .orb-style-info-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.74);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1;
}

.composer-overlay-root .orb-style-slider {
  --selected-index: 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  min-height: 60px;
  padding: 8px 10px;
  border-radius: 18px;
  outline: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.composer-overlay-root .orb-style-slider.is-dragging {
  cursor: grabbing;
}

.composer-overlay-root .orb-style-slider::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  transform: translateY(-50%);
  z-index: 0;
}

.composer-overlay-root .orb-style-slider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: var(--indicator-left, calc(12.5% + (var(--selected-index) * 25%)));
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(var(--accent-rgb),0.28), rgba(var(--accent-rgb),0.12));
  border: 1px solid rgba(var(--accent-rgb),0.44);
  box-shadow: 0 14px 26px rgba(0,0,0,0.32);
  transform: translate(-50%, -50%);
  transition: left 0.22s ease, background 0.22s ease, border-color 0.22s ease;
  z-index: 1;
  pointer-events: none;
}

.composer-overlay-root .orb-style-stop {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: color 0.18s ease, transform 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer-overlay-root .orb-style-stop:hover,
.composer-overlay-root .orb-style-stop.is-active {
  color: rgba(255,255,255,0.96);
  transform: translateY(-1px);
}

.composer-overlay-root .orb-style-stop svg {
  /* Show the same stop icons the desktop panel uses so the overlay matches visually */
  display: block !important;
  width: 18px !important;
  height: 18px !important;
  margin: 0 !important;
  padding: 8px !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,0.03) !important;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease !important;
}

.composer-overlay-root .orb-style-panel-title {
  display: none;
}

/* Ensure overlay MCP list matches desktop: 4x2 grid with scrolling */
.composer-overlay-root .orb-mcp-server-list {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(108px, auto);
  gap: 8px;
  align-items: start;
  max-height: min(352px, 52vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.composer-overlay-root .orb-mcp-server-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.06);
  min-height: 108px;
  box-sizing: border-box;
  overflow: visible;
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
  position: relative;
}

/* Overlay server name: allow two-line clamp like desktop */
.composer-overlay-root .orb-mcp-server-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  line-height: 1.08;
  color: rgba(255,255,255,0.92) !important;
}

.composer-overlay-root .orb-style-info-popover {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(6,7,9,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.86);
}

/* Overlay: ensure toggles align to tile right and info centers */
.composer-overlay-root .orb-mcp-server-toggle {
  position: absolute;
  right: 8px;
  top: 8px;
  transform: none;
}
.composer-overlay-root .orb-mcp-server-info {
  text-align: center;
  width: 100%;
  padding: 0 6px;
}

html[data-theme="light"] .composer-overlay-root .orb-style-panel-overlay {
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.1), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(244,246,248,0.98));
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 22px 48px rgba(16,24,40,0.12);
}

html[data-theme="light"] .composer-overlay-root .orb-style-panel-kicker,
html[data-theme="light"] .composer-overlay-root .orb-style-control-copy {
  color: rgba(0,0,0,0.5);
}

html[data-theme="light"] .composer-overlay-root .orb-style-control-label,
html[data-theme="light"] .composer-overlay-root .orb-style-stop:hover,
html[data-theme="light"] .composer-overlay-root .orb-style-stop.is-active {
  color: rgba(0,0,0,0.92);
}

html[data-theme="light"] .composer-overlay-root .orb-style-control {
  background: rgba(255,255,255,0.78);
  border-color: rgba(0,0,0,0.06);
}

html[data-theme="light"] .composer-overlay-root .orb-style-info-btn,
html[data-theme="light"] .composer-overlay-root .orb-style-stop svg {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.62);
}

html[data-theme="light"] .composer-overlay-root .orb-style-info-popover {
  background: rgba(255,255,255,0.9);
  border-color: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.8);
}

.theme-onboarding-modal {
  z-index: 1400 !important;
}

body.theme-onboarding-open .app-shell,
body.theme-onboarding-open #sidebar {
  pointer-events: none;
}

body.theme-onboarding-open .composer-overlay-root {
  opacity: 0;
}

@media (max-width: 900px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: calc(64px + max(var(--resolved-safe-top), var(--layout-safe-top)) + var(--layout-header-boost));
    height: auto;
    padding:
      calc(max(var(--resolved-safe-top), var(--layout-safe-top)) + var(--layout-header-boost) + 0.75rem)
      max(0.9rem, var(--safe-area-right))
      0.75rem
      max(0.9rem, var(--safe-area-left));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(18px) saturate(140%);
  }

  .topbar-left {
    width: 100%;
    min-height: 2.25rem;
    justify-content: center;
    position: relative;
  }

  #sidebar-open {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
  }

@media (max-width: 960px) {
  .sidebar-toggle-btn {
    width: 2.55rem;
    height: 2.55rem;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    background:
      radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.12), transparent 52%),
      color-mix(in srgb, var(--bg-elevated) 88%, transparent);
    color: var(--text);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
    backdrop-filter: blur(16px) saturate(135%);
    -webkit-backdrop-filter: blur(16px) saturate(135%);
    transition:
      transform 0.18s ease,
      background 0.18s ease,
      border-color 0.18s ease,
      box-shadow 0.18s ease,
      color 0.18s ease;
  }

  .sidebar-toggle-btn:hover,
  .sidebar-toggle-btn:focus-visible {
    background:
      radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.18), transparent 56%),
      color-mix(in srgb, var(--bg-elevated) 96%, transparent);
    border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
    color: var(--text);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
    outline: none;
  }

  .sidebar-toggle-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
  }

  .sidebar-toggle-btn svg {
    width: 18px;
    height: 18px;
  }

  html[data-theme="light"] .sidebar-toggle-btn {
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  }

  html[data-visual-theme="blocky"] body .sidebar-toggle-btn {
    width: 2.45rem !important;
    height: 2.45rem !important;
    padding: 0.4rem !important;
    border-radius: 10px !important;
    border: 2px solid var(--border) !important;
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--bg-elevated) 100%, transparent), color-mix(in srgb, var(--surface-1) 100%, var(--bg-elevated))) !important;
    color: var(--text) !important;
    box-shadow: var(--shadow-md) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  html[data-visual-theme="blocky"] body .sidebar-toggle-btn:hover,
  html[data-visual-theme="blocky"] body .sidebar-toggle-btn:focus-visible {
    border-color: var(--border) !important;
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--accent-soft-fill) 60%, var(--bg-elevated)), var(--bg-elevated)) !important;
    box-shadow: -2px 2px 0 0 rgba(var(--accent-rgb), 0.16) !important;
  }

  html[data-visual-theme="blocky"] body .sidebar-toggle-btn:active {
    box-shadow: -1px 1px 0 0 rgba(var(--accent-rgb), 0.14) !important;
  }

  html[data-visual-theme="blocky"] body #sidebar-open.sidebar-toggle-btn:hover,
  html[data-visual-theme="blocky"] body #sidebar-open.sidebar-toggle-btn:focus-visible {
    transform: translateY(calc(-50% - 1px)) !important;
  }

  html[data-visual-theme="blocky"] body #sidebar-open.sidebar-toggle-btn:active {
    transform: translateY(-50%) scale(0.97) !important;
  }

  html[data-visual-theme="blocky"] body #sidebar-close.sidebar-toggle-btn:hover,
  html[data-visual-theme="blocky"] body #sidebar-close.sidebar-toggle-btn:focus-visible {
    transform: translateY(-1px) !important;
  }

  html[data-visual-theme="blocky"] body #sidebar-close.sidebar-toggle-btn:active {
    transform: scale(0.97) !important;
  }

  #sidebar-open {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    touch-action: manipulation;
  }

  #sidebar-close {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    z-index: 1;
    display: inline-flex;
    margin-right: auto !important;
  }

  /* Default: hide the close button; show it when sidebar is open */
  #sidebar-close { display: none; }
  body:not(.sidebar-collapsed) #sidebar-open { display: none; }
  body:not(.sidebar-collapsed) #sidebar-close { display: inline-flex; }
}

  .topbar .topbar-brand {
    position: static;
    left: auto;
    transform: none;
    width: auto;
    max-width: calc(100% - 3rem);
    margin: 0 auto;
  }

  .workspace {
    min-height: 0;
    overflow: hidden;
  }

  .chat-column {
    padding-bottom: calc(var(--composer-height) + max(var(--resolved-safe-bottom), var(--layout-safe-bottom)));
  }

  .messages {
    padding-bottom: 1rem !important;
  }

  .welcome-state {
    padding-bottom: 1.25rem;
  }

  .input-area.auoura-composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    margin: 0;
    z-index: 60;
    padding:
      0
      max(8px, var(--safe-area-right))
      max(8px, max(var(--resolved-safe-bottom), var(--layout-safe-bottom)))
      max(8px, var(--safe-area-left));
    background: linear-gradient(to top, color-mix(in srgb, var(--bg) 96%, transparent), transparent 65%);
  }

  .input-area.auoura-composer .input-container {
    max-width: 840px;
    margin: 0 auto;
    padding: 0 4px;
  }

  .input-area.auoura-composer .input-glow-wrapper {
    border-radius: 24px;
  }

  .input-area.auoura-composer .glow-box {
    overflow: hidden;
    border-radius: 22px;
    box-shadow: 0 18px 42px rgba(0,0,0,0.3);
  }

  .input-area.auoura-composer .input-row {
    gap: 8px;
    padding: 10px 10px 8px;
    align-items: flex-end;
  }

  .input-area.auoura-composer .composer-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 10px 10px !important;
  }

  .input-area.auoura-composer .composer-toolbar-left,
  .input-area.auoura-composer .composer-toolbar-right {
    min-width: 0;
    gap: 6px !important;
  }

  .input-area.auoura-composer .composer-toolbar-left {
    grid-column: 1;
    justify-self: start;
  }

  .input-area.auoura-composer .composer-toolbar-right {
    grid-column: 3;
    justify-self: end;
  }

  .input-area.auoura-composer .composer-orb-wrap {
    position: static !important;
    grid-column: 2;
    justify-self: center;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    margin: 0 !important;
  }

  .input-area.auoura-composer .composer-tool-btn {
    max-width: 100%;
    min-width: 0 !important;
    padding: 7px 9px !important;
    font-size: 12px !important;
  }

  .input-area.auoura-composer #search-mode-label .tool-name,
  .input-area.auoura-composer #reasoning-mode-label .tool-name,
  .input-area.auoura-composer #model-select-label .tool-name {
    display: none !important;
  }

  .input-area.auoura-composer .composer-tool-btn > *,
  .input-area.auoura-composer .composer-toolbar-left > *,
  .input-area.auoura-composer .composer-toolbar-right > * {
    min-width: 0;
  }

  .input-area.auoura-composer .orb-btn,
  .input-area.auoura-composer .attach-prefix-btn,
  .input-area.auoura-composer .send-btn {
    width: 38px;
    height: 38px;
  }

  .input-area.auoura-composer .input-footer {
    padding: 0 10px 10px;
  }

  .input-area.auoura-composer .input-hint {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .theme-onboarding-modal {
    align-items: flex-end;
    padding:
      max(0.75rem, max(var(--resolved-safe-top), var(--layout-safe-top)))
      max(0.75rem, var(--safe-area-right))
      max(0.75rem, max(var(--resolved-safe-bottom), var(--layout-safe-bottom)))
      max(0.75rem, var(--safe-area-left));
  }

  .theme-onboarding-shell {
    width: min(100%, 34rem);
    max-height: calc(var(--app-height) - max(var(--resolved-safe-top), var(--layout-safe-top)) - 1rem);
    overflow-y: auto;
    border-radius: 24px;
  }
}

/* =======================================
   Orb Panel Tabbed Interface
   ======================================= */

.input-area.auoura-composer .orb-panel-nav,
.composer-overlay-root .orb-panel-nav {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
}

.input-area.auoura-composer .orb-panel-back,
.composer-overlay-root .orb-panel-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.88);
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.input-area.auoura-composer .orb-panel-home,
.composer-overlay-root .orb-panel-home {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.input-area.auoura-composer .orb-panel-menu-card,
.composer-overlay-root .orb-panel-menu-card {
  display: grid;
  gap: 0.35rem;
  align-content: start;
  min-width: 0;
  min-height: 112px;
  padding: 0.95rem 0.9rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025)),
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.14), transparent 40%);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.input-area.auoura-composer .orb-panel-menu-card:hover,
.composer-overlay-root .orb-panel-menu-card:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03)),
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.2), transparent 44%);
}

.input-area.auoura-composer .orb-panel-menu-icon,
.composer-overlay-root .orb-panel-menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(var(--accent-rgb), 0.12);
  color: rgba(255, 255, 255, 0.92);
}

.input-area.auoura-composer .orb-panel-menu-label,
.composer-overlay-root .orb-panel-menu-label {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
}

.input-area.auoura-composer .orb-panel-menu-copy,
.composer-overlay-root .orb-panel-menu-copy {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.input-area.auoura-composer .orb-panel-tabs {
  display: flex;
  gap: 2px;
  margin: 0 0 10px;
  padding: 0;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.12);
  list-style: none;
}

.input-area.auoura-composer .orb-panel-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px 6px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.45);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
}

.input-area.auoura-composer .orb-panel-tab:hover {
  color: rgba(255, 255, 255, 0.75);
}

.input-area.auoura-composer .orb-panel-tab.active {
  color: var(--accent, rgb(255, 77, 103));
  border-bottom-color: var(--accent, rgb(255, 77, 103));
}

.input-area.auoura-composer .orb-panel-tab svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.input-area.auoura-composer .orb-panel-tab.active svg {
  opacity: 1;
}

.composer-overlay-root .orb-panel-tabs {
  display: flex;
  gap: 2px;
  margin: 0 0 10px;
  padding: 0;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.12);
  list-style: none;
}

.composer-overlay-root .orb-panel-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px 6px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.45);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
}

.composer-overlay-root .orb-panel-tab:hover {
  color: rgba(255, 255, 255, 0.75);
}

.composer-overlay-root .orb-panel-tab.active {
  color: var(--accent, rgb(255, 77, 103));
  border-bottom-color: var(--accent, rgb(255, 77, 103));
}

.composer-overlay-root .orb-panel-tab svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.composer-overlay-root .orb-panel-tab.active svg {
  opacity: 1;
}

.input-area.auoura-composer .orb-panel-content {
  display: block;
}

.input-area.auoura-composer .orb-panel-content.hidden {
  display: none;
}

.composer-overlay-root .orb-panel-content {
  display: block;
}

.composer-overlay-root .orb-panel-content:not(.active),
.composer-overlay-root .orb-panel-content.hidden {
  display: none;
}

.input-area.auoura-composer .orb-files-open-btn,
.composer-overlay-root .orb-files-open-btn {
  margin-top: 10px;
  width: 100%;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.18), rgba(var(--accent-deep-rgb), 0.18));
  color: rgba(255, 255, 255, 0.94);
  padding: 0.72rem 0.9rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
}
.input-area.auoura-composer .orb-files-open-btn:hover,
.composer-overlay-root .orb-files-open-btn:hover {
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.28), rgba(var(--accent-deep-rgb), 0.28));
  border-color: rgba(var(--accent-rgb), 0.55);
}

/* Bento grid for files & projects */
.input-area.auoura-composer .orb-files-section-list,
.composer-overlay-root .orb-files-section-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.input-area.auoura-composer .orb-files-summary-card,
.composer-overlay-root .orb-files-summary-card {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
  padding: 0.8rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.input-area.auoura-composer .orb-files-summary-card strong,
.composer-overlay-root .orb-files-summary-card strong {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-area.auoura-composer .orb-files-summary-card span,
.composer-overlay-root .orb-files-summary-card span,
.input-area.auoura-composer .orb-files-empty,
.composer-overlay-root .orb-files-empty {
  margin: 0;
  font-size: 0.73rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.input-area.auoura-composer .orb-files-item,
.composer-overlay-root .orb-files-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  width: 100%;
  padding: 0.72rem 0.8rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
  min-width: 0;
}
.input-area.auoura-composer .orb-files-item:hover,
.composer-overlay-root .orb-files-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.input-area.auoura-composer .orb-files-item-name,
.composer-overlay-root .orb-files-item-name {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 550;
}

.input-area.auoura-composer .orb-files-item-meta,
.composer-overlay-root .orb-files-item-meta {
  color: var(--text-faint);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* MCP server list */
.input-area.auoura-composer .orb-mcp-control {
  margin-bottom: 14px;
}

.input-area.auoura-composer .orb-mcp-server-list {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(108px, auto);
  gap: 8px;
  align-items: start;
  max-height: min(352px, 52vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px; /* avoid scrollbar overlapping content */
}

.input-area.auoura-composer .orb-mcp-empty {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  padding: 16px 8px;
  margin: 0;
}

.input-area.auoura-composer .orb-mcp-add-btn {
  display: inline;
  background: none;
  border: none;
  color: var(--accent, rgb(255, 77, 103));
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}

.input-area.auoura-composer .orb-mcp-add-btn:hover {
  opacity: 0.8;
}

.input-area.auoura-composer .orb-mcp-server-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  width: 100%;
  min-height: 108px;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.12s ease;
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
  position: relative;
}

.input-area.auoura-composer .orb-mcp-server-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.input-area.auoura-composer .orb-mcp-server-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.input-area.auoura-composer .orb-mcp-server-icon img {
  width: 20px;
  height: 20px;
  display: block;
  opacity: 0.9;
}

.input-area.auoura-composer .orb-mcp-server-info {
  flex: none;
  min-width: 0;
  width: 100%;
  text-align: center;
  padding: 0 6px;
  margin-top: 6px;
}

.input-area.auoura-composer .orb-mcp-server-name {
  font-size: 0.78rem;
  font-weight: 600;
  margin: 0 0 2px;
  color: rgba(255, 255, 255, 0.9);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  text-overflow: ellipsis;
  line-height: 1.08;
}

.input-area.auoura-composer .orb-mcp-server-url {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.35);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Strong override for the primary MCP list element to avoid theme/CSS specificity issues */
#orb-mcp-server-list,
#orb-mcp-server-list.orb-mcp-server-list {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  grid-auto-rows: minmax(108px, auto) !important;
  gap: 8px !important;
  align-items: start !important;
  max-height: min(352px, 52vh) !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  padding-right: 4px !important;
}

.input-area.auoura-composer .orb-mcp-server-toggle {
  flex-shrink: 0;
  position: absolute;
  right: 8px;
  top: 8px;
  transform: none;
}

/* ===== Modern, robust MCP panel styles (state-of-the-art) ===== */
/* Intent: consistent 4x2 visible grid with scroll, stacked tile layout,
   toggle always top-right, no overlap, good spacing and touch targets. */

/* Tile: accessible focus + larger hit area */
.input-area.auoura-composer .orb-mcp-server-item,
.composer-overlay-root .orb-mcp-server-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 12px 12px 12px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.06);
  min-height: 108px;
  box-sizing: border-box;
  position: relative;
  overflow: visible;
}

/* Icon centered, visible behind toggle if needed */
.input-area.auoura-composer .orb-mcp-server-icon,
.composer-overlay-root .orb-mcp-server-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.06);
  z-index: 1;
}

/* Info block under icon */
.input-area.auoura-composer .orb-mcp-server-info,
.composer-overlay-root .orb-mcp-server-info {
  width: 100%;
  text-align: center;
  padding: 0 6px;
}

.input-area.auoura-composer .orb-mcp-server-name,
.composer-overlay-root .orb-mcp-server-name {
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0;
  color: var(--composer-text, #fff);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  /* Standard property for compatibility */
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  line-height: 1.08;
}

.input-area.auoura-composer .orb-mcp-server-url,
.composer-overlay-root .orb-mcp-server-url {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.42);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-area.auoura-composer .orb-mcp-toggle-wrap.orb-mcp-server-toggle,
.composer-overlay-root .orb-mcp-toggle-wrap.orb-mcp-server-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: 20px;
  margin-top: 2px;
  padding: 0;
  z-index: 12;
}

/* Remove button: bottom-right inside tile */
.input-area.auoura-composer .orb-mcp-server-remove,
.composer-overlay-root .orb-mcp-server-remove {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 11;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.62);
  font-size: 0.85rem;
  padding: 6px;
  border-radius: 8px;
}

/* Focus and accessible states */
.input-area.auoura-composer .orb-mcp-server-item:focus-within,
.composer-overlay-root .orb-mcp-server-item:focus-within {
  outline: 3px solid rgba(255,255,255,0.06);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

/* Small screens: keep the desktop tile styling, but let the grid flow to
   fewer columns so the cards never collide. */
@media (max-width: 640px) {
  .input-area.auoura-composer .orb-mcp-server-list,
  .composer-overlay-root .orb-mcp-server-list,
  #orb-mcp-server-list {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: minmax(108px, auto) !important;
    gap: 8px !important;
    align-items: start !important;
    max-height: min(352px, 52vh) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-right: 4px !important;
  }
  .input-area.auoura-composer .orb-mcp-server-item,
  .composer-overlay-root .orb-mcp-server-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    min-height: 108px !important;
    padding: 12px !important;
    background: rgba(255,255,255,0.03) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    box-shadow: 0 6px 12px rgba(0,0,0,0.08) !important;
  }

  .input-area.auoura-composer .orb-mcp-server-info,
  .composer-overlay-root .orb-mcp-server-info {
    flex: none !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 6px !important;
    margin-top: 6px !important;
    text-align: center !important;
  }

  .input-area.auoura-composer .orb-mcp-server-toggle,
  .composer-overlay-root .orb-mcp-server-toggle {
    position: absolute !important;
    width: auto !important;
    height: auto !important;
    right: 8px !important;
    top: 8px !important;
  }

  #orb-mcp-server-list.orb-mcp-server-list {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: minmax(108px, auto) !important;
    max-height: min(352px, 52vh) !important;
  }
}

/* Ensure overlay panel width can contain tiles cleanly on small viewports */
.composer-overlay-root .orb-style-panel-overlay {
  width: calc(100vw - 32px) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  max-width: 720px;
  max-height: calc(100svh - var(--panel-bottom, 24px) - 12px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Ensure the main orb panel uses the same visual tokens */
.input-area.auoura-composer .orb-style-panel-overlay {
  background: var(--composer-panel, linear-gradient(180deg, rgba(17,19,23,0.98), rgba(10,12,15,0.98))) !important;
}

.input-area.auoura-composer .orb-mcp-server-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.25);
  cursor: pointer;
  padding: 6px;
  font-size: 0.7rem;
  line-height: 1;
  border-radius: 6px;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  transition: color 0.15s ease, background 0.15s ease;
}

.input-area.auoura-composer .orb-mcp-server-remove:hover {
  color: var(--accent, rgb(255, 77, 103));
  background: rgba(var(--accent-rgb, 255, 77, 103), 0.1);
}

/* Location consent toggle */
.input-area.auoura-composer .orb-mcp-location-row {
  margin-top: 8px;
}

.input-area.auoura-composer .orb-mcp-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}

.input-area.auoura-composer .orb-mcp-toggle-label {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.8);
  flex: 1;
}

.input-area.auoura-composer .orb-mcp-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.input-area.auoura-composer .orb-mcp-toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.input-area.auoura-composer .orb-mcp-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: transform 0.2s ease, background 0.2s ease;
}

.input-area.auoura-composer .orb-mcp-toggle-input:checked + .orb-mcp-toggle-track {
  background: var(--accent, rgb(255, 77, 103));
}

.input-area.auoura-composer .orb-mcp-toggle-input:checked + .orb-mcp-toggle-track::after {
  transform: translateX(14px);
  background: #fff;
}

.composer-overlay-root .orb-mcp-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}

.composer-overlay-root .orb-mcp-toggle-label {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.8);
  flex: 1;
}

.composer-overlay-root .orb-mcp-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.composer-overlay-root .orb-mcp-toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.composer-overlay-root .orb-mcp-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: transform 0.2s ease, background 0.2s ease;
}

.composer-overlay-root .orb-mcp-toggle-input:checked + .orb-mcp-toggle-track {
  background: var(--accent, rgb(255,77,103));
}

.composer-overlay-root .orb-mcp-toggle-input:checked + .orb-mcp-toggle-track::after {
  transform: translateX(14px);
  background: #fff;
}

.input-area.auoura-composer .orb-mcp-location-details {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.input-area.auoura-composer .orb-mcp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-area.auoura-composer .orb-mcp-field span {
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
}

.input-area.auoura-composer .orb-mcp-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.input-area.auoura-composer .orb-mcp-input:focus {
  border-color: var(--accent, rgb(255, 77, 103));
}

.input-area.auoura-composer .orb-mcp-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

/* Supervisor tab */
.input-area.auoura-composer .orb-supervisor-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.input-area.auoura-composer .orb-supervisor-stat {
  text-align: center;
  padding: 10px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.input-area.auoura-composer .orb-supervisor-stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.2;
}

.input-area.auoura-composer .orb-supervisor-stat-label {
  display: block;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
  letter-spacing: 0.03em;
}

.input-area.auoura-composer .orb-supervisor-note {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.35);
  margin: 10px 0 0;
  text-align: center;
  line-height: 1.4;
}

/* Hide non-active tab panels */
.input-area.auoura-composer .orb-panel-content:not(.active) {
  display: none;
}

/* Light mode overrides */
html[data-theme="light"] .input-area.auoura-composer .orb-panel-tab {
  color: rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] .input-area.auoura-composer .orb-panel-back,
html[data-theme="light"] .composer-overlay-root .orb-panel-back,
html[data-theme="light"] .input-area.auoura-composer .orb-panel-menu-card,
html[data-theme="light"] .composer-overlay-root .orb-panel-menu-card,
html[data-theme="light"] .input-area.auoura-composer .orb-files-summary-card,
html[data-theme="light"] .composer-overlay-root .orb-files-summary-card,
html[data-theme="light"] .input-area.auoura-composer .orb-files-item,
html[data-theme="light"] .composer-overlay-root .orb-files-item {
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .input-area.auoura-composer .orb-panel-back,
html[data-theme="light"] .composer-overlay-root .orb-panel-back,
html[data-theme="light"] .input-area.auoura-composer .orb-files-item,
html[data-theme="light"] .composer-overlay-root .orb-files-item,
html[data-theme="light"] .input-area.auoura-composer .orb-files-summary-card,
html[data-theme="light"] .composer-overlay-root .orb-files-summary-card {
  background: rgba(0, 0, 0, 0.03);
  color: rgba(0, 0, 0, 0.86);
}

html[data-theme="light"] .input-area.auoura-composer .orb-panel-menu-card,
html[data-theme="light"] .composer-overlay-root .orb-panel-menu-card {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.035), rgba(0, 0, 0, 0.02)),
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.1), transparent 40%);
}

html[data-theme="light"] .input-area.auoura-composer .orb-panel-menu-copy,
html[data-theme="light"] .composer-overlay-root .orb-panel-menu-copy,
html[data-theme="light"] .input-area.auoura-composer .orb-files-summary-card span,
html[data-theme="light"] .composer-overlay-root .orb-files-summary-card span,
html[data-theme="light"] .input-area.auoura-composer .orb-files-empty,
html[data-theme="light"] .composer-overlay-root .orb-files-empty,
html[data-theme="light"] .input-area.auoura-composer .orb-files-item-meta,
html[data-theme="light"] .composer-overlay-root .orb-files-item-meta {
  color: rgba(0, 0, 0, 0.5);
}

html[data-theme="light"] .input-area.auoura-composer .orb-panel-tab:hover {
  color: rgba(0, 0, 0, 0.7);
}

html[data-theme="light"] .input-area.auoura-composer .orb-panel-tab.active {
  color: var(--accent, rgb(255, 77, 103));
}

html[data-theme="light"] .composer-overlay-root .orb-panel-tabs {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .composer-overlay-root .orb-panel-tab {
  color: rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] .composer-overlay-root .orb-panel-tab:hover {
  color: rgba(0, 0, 0, 0.7);
}

html[data-theme="light"] .composer-overlay-root .orb-panel-tab.active {
  color: var(--accent, rgb(255, 77, 103));
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-empty {
  color: rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-empty {
  color: rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-server-item {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-server-item {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-server-item:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-server-item:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-server-name {
  color: rgba(0, 0, 0, 0.85) !important;
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-server-url {
  display: none !important;
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-server-icon {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.02)) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-toggle-label {
  color: rgba(0, 0, 0, 0.8) !important;
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-toggle-track {
  background: rgba(0, 0, 0, 0.15) !important;
}

html[data-theme="light"] .composer-overlay-root .orb-mcp-toggle-track::after {
  background: rgba(255, 255, 255, 0.9) !important;
}

html[data-theme="light"] .settings-location-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .settings-location-copy p {
  color: rgba(0, 0, 0, 0.6);
}

html[data-theme="light"] .settings-location-track {
  background: rgba(0, 0, 0, 0.14);
}

html[data-theme="light"] .settings-location-track::after {
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.14);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-server-name {
  color: rgba(0, 0, 0, 0.85);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-server-url {
  color: rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-server-icon {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.02));
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-toggle-label {
  color: rgba(0, 0, 0, 0.8);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-toggle-track {
  background: rgba(0, 0, 0, 0.15);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-toggle-track::after {
  background: rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-location-details {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-input {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.9);
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-input:focus {
  border-color: var(--accent, rgb(255, 77, 103));
}

html[data-theme="light"] .input-area.auoura-composer .orb-mcp-input::placeholder {
  color: rgba(0, 0, 0, 0.3);
}

html[data-theme="light"] .input-area.auoura-composer .orb-supervisor-stat {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .input-area.auoura-composer .orb-supervisor-stat-value {
  color: rgba(0, 0, 0, 0.85);
}

html[data-theme="light"] .input-area.auoura-composer .orb-supervisor-note {
  color: rgba(0, 0, 0, 0.4);
}

html[data-theme="light"] .input-area.auoura-composer .orb-panel-tabs {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* Mobile adjustments */
@media (max-width: 720px) {
  .input-area.auoura-composer .orb-panel-home,
  .composer-overlay-root .orb-panel-home {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
  .input-area.auoura-composer .orb-panel-tab {
    font-size: 0.65rem;
    padding: 6px 4px;
  }
  .composer-overlay-root .orb-panel-tab {
    font-size: 0.65rem;
    padding: 6px 4px;
  }
  .input-area.auoura-composer .orb-panel-tab svg {
    width: 10px;
    height: 10px;
  }
  .composer-overlay-root .orb-panel-tab svg {
    width: 10px;
    height: 10px;
  }
  .input-area.auoura-composer .orb-supervisor-summary {
    grid-template-columns: 1fr;
  }
  .input-area.auoura-composer .orb-files-section-list,
  .composer-overlay-root .orb-files-section-list {
    grid-template-columns: 1fr;
  }
}

/* Mobile MCP: preserve desktop tile styling and only reduce grid density. */
@media (max-width: 640px) {
  .input-area.auoura-composer .orb-mcp-server-list,
  .composer-overlay-root .orb-mcp-server-list,
  #orb-mcp-server-list {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: minmax(108px, auto) !important;
    gap: 8px !important;
    align-items: start !important;
    max-height: min(352px, 52vh) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-right: 4px !important;
  }

  .input-area.auoura-composer .orb-mcp-server-item,
  .composer-overlay-root .orb-mcp-server-item,
  #orb-mcp-server-list .orb-mcp-server-item {
    min-height: 108px !important;
  }
}

/* Weather card in message bubbles */
.weather-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  margin: 8px 0;
  border-radius: 12px;
  background: rgba(var(--accent-rgb), 0.06);
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  font-family: inherit;
}

.weather-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.weather-card-header svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--accent, rgb(255, 77, 103));
}

.weather-card-location {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.weather-card-temp-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.weather-card-temp {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.95);
}

.weather-card-conditions {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

.weather-card-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.weather-card-detail {
  text-align: center;
  padding: 6px 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.weather-card-detail-label {
  display: block;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.weather-card-detail-value {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 2px;
}

.weather-card-forecast {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.weather-card-day {
  text-align: center;
  padding: 6px 2px;
}

.weather-card-day-name {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}

.weather-card-day-temps {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.weather-card-day-icon {
  display: block;
  margin: 2px auto;
  width: 18px;
  height: 18px;
  color: var(--accent, rgb(255, 77, 103));
}

/* Light mode weather card */
html[data-theme="light"] .weather-card {
  background: rgba(var(--accent-rgb), 0.04);
  border-color: rgba(var(--accent-rgb), 0.12);
}

html[data-theme="light"] .weather-card-location {
  color: rgba(0, 0, 0, 0.85);
}

html[data-theme="light"] .weather-card-temp {
  color: rgba(0, 0, 0, 0.9);
}

html[data-theme="light"] .weather-card-conditions {
  color: rgba(0, 0, 0, 0.55);
}

html[data-theme="light"] .weather-card-detail {
  background: rgba(0, 0, 0, 0.03);
}

html[data-theme="light"] .weather-card-detail-value {
  color: rgba(0, 0, 0, 0.8);
}

html[data-theme="light"] .weather-card-forecast {
  border-top-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .weather-card-day-name {
  color: rgba(0, 0, 0, 0.5);
}

html[data-theme="light"] .weather-card-day-temps {
  color: rgba(0, 0, 0, 0.75);
}

/* MCP add/edit form modal */
.mcp-form-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.mcp-form-overlay.open {
  display: flex;
}

.mcp-form-shell {
  width: min(420px, 100%);
  background: var(--bg, #0f0f0f);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.mcp-form-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.mcp-form-kicker {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  margin: 0 0 2px;
}

.mcp-form-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.mcp-form-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 4px;
  font-size: 1.1rem;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}

.mcp-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.mcp-form-field > span {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.03em;
}

.mcp-form-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.mcp-form-input:focus {
  border-color: var(--accent, rgb(255, 77, 103));
}

.mcp-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.mcp-form-submit {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent, rgb(255, 77, 103));
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.mcp-form-cancel {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

html[data-theme="light"] .mcp-form-shell {
  background: #f5f5f7;
  border-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .mcp-form-kicker {
  color: rgba(0, 0, 0, 0.4);
}

html[data-theme="light"] .mcp-form-title {
  color: rgba(0, 0, 0, 0.85);
}

html[data-theme="light"] .mcp-form-input {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.85);
}

html[data-theme="light"] .mcp-form-cancel {
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.5);
}

/* ── Model toggle logo ───────────────────────────────────────── */
#model-select-btn.model-logo-toggle {
  display: inline-flex;
  position: relative;
  min-width: min(82px, 24vw);
  padding: 0.06rem 0.1rem;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.96);
  box-shadow: none;
}

html[data-visual-theme="blocky"] #model-select-btn.model-logo-toggle {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #fff !important;
}

#model-select-btn.model-logo-toggle:hover,
#model-select-btn.model-logo-toggle.active,
#model-select-btn.model-logo-toggle:focus-visible {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: #fff;
}

html[data-visual-theme="blocky"] #model-select-btn.model-logo-toggle:hover,
html[data-visual-theme="blocky"] #model-select-btn.model-logo-toggle.active,
html[data-visual-theme="blocky"] #model-select-btn.model-logo-toggle:focus-visible {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #fff !important;
}

#model-select-btn .model-logo-svg {
  width: min(82px, 24vw);
  max-width: 100%;
  height: auto;
  overflow: visible;
  display: block;
}

#model-select-btn .model-logo-pill {
  opacity: 0;
  transition: opacity 0.25s ease;
}

#model-select-btn:hover .model-logo-pill,
#model-select-btn:focus-visible .model-logo-pill {
  opacity: 0;
}

#model-select-btn .model-logo-word {
  transform-origin: center;
  transition: opacity 0.4s cubic-bezier(0.4,0,0.2,1), transform 0.4s cubic-bezier(0.4,0,0.2,1);
  will-change: opacity, transform;
}

#model-select-btn .model-select-a11y {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html[data-theme="light"] #model-select-btn.model-logo-toggle {
  color: rgba(12,18,28,0.92);
}

html[data-theme="light"][data-visual-theme="blocky"] #model-select-btn.model-logo-toggle,
html[data-theme="light"][data-visual-theme="blocky"] #model-select-btn.model-logo-toggle:hover,
html[data-theme="light"][data-visual-theme="blocky"] #model-select-btn.model-logo-toggle.active,
html[data-theme="light"][data-visual-theme="blocky"] #model-select-btn.model-logo-toggle:focus-visible {
  color: #000 !important;
}

html[data-theme="light"] #model-select-btn.model-logo-toggle:hover,
html[data-theme="light"] #model-select-btn.model-logo-toggle.active,
html[data-theme="light"] #model-select-btn.model-logo-toggle:focus-visible {
  color: rgba(12,18,28,0.98);
}

html[data-theme="light"] #model-select-btn:hover .model-logo-pill,
html[data-theme="light"] #model-select-btn:focus-visible .model-logo-pill {
  opacity: 0;
}

/* ── Model badge on assistant messages ───────────────────────── */
.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.4;
}
.model-badge-axis,
.model-badge-fusion { background: linear-gradient(135deg, #0f172a, #334155); color: #fff; }
.model-badge-nova,
.model-badge-flow { background: linear-gradient(135deg, #1d4ed8, #38bdf8); color: #fff; }

/* ── Agentic tool call cards ─────────────────────────────────── */
.tool-call-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--bg-elevated, #1e1e2e);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  font-size: 13px;
  margin: 6px 0;
  width: fit-content;
  max-width: 100%;
  transition: opacity 0.3s;
}
.tool-call-card--running .tool-call-spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--accent, #7c3aed);
  border-top-color: transparent;
  border-radius: 50%;
  animation: tool-card-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes tool-card-spin { to { transform: rotate(360deg); } }
.tool-call-card--done { opacity: 0.65; }
.tool-call-done { color: #22c55e; font-weight: 700; }

.fusion-inline-panel {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.85rem;
}

.fusion-inline-brief-message {
  margin: 0;
  color: var(--text);
}

.fusion-inline-brief-message > :first-child {
  margin-top: 0;
}

.fusion-inline-brief-message > :last-child {
  margin-bottom: 0;
}

.fusion-ask-modal {
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 0;
  display: grid;
  gap: 0.8rem;
  padding: 0 0.9rem;
  border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.12), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 94%, transparent), color-mix(in srgb, var(--surface-1) 92%, transparent));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
  pointer-events: auto;
  overflow: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  opacity: 0;
  transform: var(--ask-modal-position-transform, translateX(0)) translateY(-10px);
  transition: max-height 0.34s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease, transform 0.24s ease, padding 0.24s ease;
}

.composer-overlay-root .fusion-ask-modal {
  position: fixed;
  top: var(--ask-modal-top, auto);
  right: var(--ask-modal-right, auto);
  bottom: var(--ask-modal-bottom, auto);
  left: var(--ask-modal-left, 50%);
  width: var(--ask-modal-width, min(760px, calc(100vw - 24px)));
  max-width: calc(100vw - 24px);
  margin: 0;
  z-index: 999999;
  pointer-events: auto;
}

.fusion-ask-modal.is-visible {
  opacity: 1;
  max-height: var(--ask-modal-max-height, min(78svh, 640px));
  padding: 0.9rem;
  transform: var(--ask-modal-position-transform, translateX(0)) translateY(0);
  overflow: auto;
}

.fusion-ask-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 0.35rem;
  background: inherit;
}

.fusion-ask-modal-copy {
  display: grid;
  gap: 0.14rem;
  min-width: 0;
}

.fusion-ask-modal-kicker {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.fusion-ask-modal-title {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.2;
  color: var(--text);
}

.fusion-ask-modal-status {
  flex-shrink: 0;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.fusion-ask-modal-stack {
  display: grid;
  gap: 0.8rem;
}

.fusion-ask-modal-card {
  margin: 0;
}

.fusion-ask-modal-card .fusion-inline-prompt-form {
  margin-top: 0.65rem;
  gap: 0.65rem;
}

.fusion-ask-modal-card .fusion-inline-option-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 0.55rem 0.75rem;
  align-items: start;
  margin-top: 0.65rem;
}

.fusion-ask-modal-card .fusion-inline-prompt-textarea {
  min-height: 72px;
}

html[data-theme="light"] .fusion-ask-modal {
  border-color: rgba(0, 0, 0, 0.08);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.08), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 246, 248, 0.96));
  box-shadow: 0 22px 48px rgba(16, 24, 40, 0.14);
}

html[data-theme="light"] .input-area.auoura-composer .glow-box.fusion-ask-open {
  box-shadow: 0 18px 42px rgba(16, 24, 40, 0.12);
}

.fusion-inline-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 92%, transparent), color-mix(in srgb, var(--surface-1) 86%, transparent)),
    var(--accent-radial-soft);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}

.fusion-inline-card--waiting {
  border-color: rgba(245, 158, 11, 0.35);
}

.fusion-inline-card--error {
  border-color: rgba(248, 113, 113, 0.35);
}

.fusion-inline-card--success {
  border-color: rgba(34, 197, 94, 0.35);
}

.fusion-inline-card-head,
.fusion-inline-actions,
.fusion-inline-option,
.fusion-inline-option-list {
  display: flex;
  gap: 0.6rem;
}

.fusion-inline-card-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.fusion-inline-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.fusion-inline-card-status {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.fusion-inline-card-summary,
.fusion-inline-card-context {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.fusion-inline-card-context {
  margin-top: 0.45rem;
}

.fusion-inline-card-body {
  margin: 0.75rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: rgba(15, 23, 42, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: 0.78rem/1.45 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.fusion-inline-card--send-message {
  gap: 0.7rem;
}

.fusion-inline-sendmessage-body {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  color: var(--text);
}

.fusion-inline-sendmessage-body > :first-child {
  margin-top: 0;
}

.fusion-inline-sendmessage-body > :last-child {
  margin-bottom: 0;
}

.fusion-inline-actions {
  flex-wrap: wrap;
  margin-top: 0.85rem;
  position: sticky;
  bottom: 0;
  padding-top: 0.75rem;
  background: linear-gradient(180deg, rgba(0,0,0,0), color-mix(in srgb, var(--surface-1) 94%, transparent) 36%);
}

.fusion-inline-action {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.fusion-inline-action:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: rgba(var(--accent-rgb), 0.12);
}

.fusion-inline-action--primary {
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.24), rgba(var(--accent-deep-rgb), 0.22));
  border-color: rgba(var(--accent-rgb), 0.45);
}

.fusion-inline-action--danger {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.fusion-inline-card-perm-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.45rem 0 0;
}

.fusion-inline-card-perm-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.fusion-inline-card-perm-name {
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}

.fusion-inline-card-perm-target {
  color: var(--text-muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fusion-inline-continuing {
  font-size: 0.82rem;
  color: var(--text-faint);
  font-style: italic;
  padding: 0.2rem 0;
}

.fusion-inline-prompt-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.fusion-inline-option-list {
  flex-direction: column;
  align-items: flex-start;
  margin-top: 0.75rem;
}

.fusion-inline-option {
  align-items: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.fusion-inline-prompt-textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  color: var(--text);
  padding: 0.75rem 0.9rem;
  font: inherit;
}

/* MCP panel active badge */
.mcp-active-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
}
