:root {
  --orange-50: #fff7ed;
  --orange-100: #ffedd5;
  --orange-200: #fed7aa;
  --orange-300: #fdba74;
  --orange-400: #fb923c;
  --orange-500: #f97316;
  --orange-600: #ea580c;
  --orange-700: #c2410c;
  --cream-50: #fffcf7;
  --cream-100: #faf5eb;
  --cream-200: #f0e7d2;
  --neutral-0: #ffffff;
  --neutral-50: #fafaf9;
  --neutral-100: #f5f5f4;
  --neutral-200: #e7e5e4;
  --neutral-300: #d6d3d1;
  --neutral-400: #a8a29e;
  --neutral-500: #78716c;
  --neutral-700: #44403c;
  --neutral-800: #292524;
  --neutral-900: #1c1917;
  --neutral-950: #0e0c0b;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --bg: var(--cream-50);
  --bg-alt: var(--cream-100);
  --bg-hi: var(--cream-200);
  --ink: var(--neutral-900);
  --ink-2: var(--neutral-700);
  --muted: var(--neutral-500);
  --line: var(--neutral-200);
  --line-soft: var(--neutral-100);
  --accent: var(--orange-500);
  --accent-2: var(--orange-600);
  --r: 0.75rem;
  --r-md: 1rem;
  --r-lg: 1.25rem;
  --r-xl: 1.75rem;
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.06);
  --shadow: 0 4px 12px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 8px 24px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 16px 40px rgba(28, 25, 23, 0.1);
  --shadow-glow: 0 8px 32px rgba(249, 115, 22, 0.28);
  --shadow-glow-soft: 0 4px 16px rgba(249, 115, 22, 0.16);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur: 0.18s;
  --dur-md: 0.28s;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--neutral-950);
    --bg-alt: var(--neutral-900);
    --bg-hi: var(--neutral-800);
    --ink: var(--neutral-50);
    --ink-2: #e7e5e4;
    --muted: var(--neutral-400);
    --line: var(--neutral-800);
    --line-soft: var(--neutral-900);
  }
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
}
body {
  font-family: "Inter", "SF Pro Text", system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  outline-color: var(--accent);
}
/* iOS zoom guard: any text input <16px makes Safari zoom the page on focus.
   Force >=16px on touch/small screens so focusing a field never zooms. */
@media (max-width: 640px) {
  input, textarea, select { font-size: 16px; }
}
button {
  cursor: pointer;
  touch-action: manipulation;
}
::selection {
  background: var(--orange-200);
  color: var(--neutral-900);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.125rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(24px);
  -webkit-backdrop-filter: saturate(160%) blur(24px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-600));
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.0625rem;
  font-weight: 800;
  box-shadow: var(--shadow-glow-soft);
}
.brand-title {
  font-weight: 800;
}
.tier-badge {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.1875rem 0.4375rem;
  border-radius: 0.375rem;
  background: var(--orange-100);
  color: var(--orange-700);
  margin-left: 0.375rem;
}
@media (prefers-color-scheme: dark) {
  .tier-badge {
    background: rgba(249, 115, 22, 0.16);
    color: var(--orange-300);
  }
}
.topbar-actions {
  display: flex;
  gap: 0.375rem;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-alt);
  color: var(--ink-2);
  transition:
    transform var(--dur) var(--ease),
    background var(--dur),
    color var(--dur);
}
.icon-btn:hover {
  background: var(--orange-100);
  color: var(--orange-600);
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
@media (prefers-color-scheme: dark) {
  .icon-btn:hover {
    background: rgba(249, 115, 22, 0.15);
    color: var(--orange-300);
  }
}

.main {
  flex: 1;
  padding: 1.125rem 1.125rem 1.25rem;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  overflow-x: hidden;
}
.screen {
  display: none;
  animation: fadeUp var(--dur-md) var(--ease);
}
.screen.active {
  display: block;
}

/* Segmented control + sub-screens (nav-simplify reorg).
   Lets one top-level screen hold several former screens as tabs. */
.seg {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin: 0 0 1.125rem;
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--line-soft);
  border-radius: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 5;
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  backdrop-filter: saturate(1.2) blur(8px);
}
.seg-btn {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: color var(--dur-sm, 0.15s) var(--ease, ease),
    background var(--dur-sm, 0.15s) var(--ease, ease);
  white-space: nowrap;
}
.seg-btn:active {
  transform: scale(0.97);
}
.seg-btn.active {
  background: var(--orange-500, #f97316);
  color: #fff;
  box-shadow: 0 1px 4px rgba(249, 115, 22, 0.35);
}
.subscreen {
  display: none;
  animation: fadeUp var(--dur-md) var(--ease);
}
.subscreen.active {
  display: block;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.screen-h1 {
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 0.375rem;
}
.screen-sub {
  color: var(--muted);
  font-size: 0.9375rem;
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    135deg,
    var(--orange-500) 0%,
    var(--orange-400) 50%,
    var(--orange-600) 100%
  );
  color: white;
  border-radius: var(--r-xl);
  padding: 1.625rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-glow);
}
.hero::before {
  content: "";
  position: absolute;
  inset: auto -20% -60% auto;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18) 0%, transparent 65%);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  top: -30%;
  left: -15%;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  pointer-events: none;
}
.hero h1 {
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 0.375rem;
  position: relative;
}
.hero p {
  font-size: 0.9375rem;
  line-height: 1.55;
  opacity: 0.94;
  margin: 0 0 1.125rem;
  position: relative;
  font-weight: 500;
}
.hero-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: relative;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6875rem 1.0625rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.005em;
  line-height: 1;
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur),
    background var(--dur),
    color var(--dur),
    border-color var(--dur);
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-glow-soft);
}
.btn-primary:hover {
  background: var(--accent-2);
  box-shadow: var(--shadow-glow);
}
.btn-on-orange {
  background: white;
  color: var(--accent-2);
  box-shadow: var(--shadow);
}
.btn-on-orange:hover {
  box-shadow: var(--shadow-lg);
}
.btn-ghost-light {
  background: rgba(255, 255, 255, 0.16);
  color: white;
  backdrop-filter: blur(8px);
}
.btn-ghost-light:hover {
  background: rgba(255, 255, 255, 0.26);
}
.btn-soft {
  background: var(--bg-alt);
  color: var(--ink);
  border: 1px solid var(--line-soft);
}
.btn-soft:hover {
  border-color: var(--orange-200);
}
.btn-danger {
  background: transparent;
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.08);
}
.btn-sm {
  padding: 0.5rem 0.8125rem;
  font-size: 0.8125rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 1.75rem 0 0.75rem;
}
.section-head h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
}
.section-head .link {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
}
.section-head .link:hover {
  color: var(--accent-2);
}

.cards {
  display: grid;
  gap: 0.625rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 1rem;
  transition:
    transform var(--dur) var(--ease),
    border-color var(--dur),
    box-shadow var(--dur);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--orange-200);
  box-shadow: var(--shadow);
}
.card:active {
  transform: translateY(0);
}
.card .emoji {
  font-size: 1.75rem;
  display: block;
  margin-bottom: 0.25rem;
  line-height: 1;
}
.card .name {
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--ink);
}
.card .tagline {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.35;
  margin: 0;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  transition:
    background var(--dur),
    border-color var(--dur);
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.list-item:hover {
  background: var(--bg-hi);
  border-color: var(--orange-200);
}
.list-item .li-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--orange-100);
  color: var(--orange-700);
  display: grid;
  place-items: center;
  font-size: 1.0625rem;
}
@media (prefers-color-scheme: dark) {
  .list-item .li-icon {
    background: rgba(249, 115, 22, 0.16);
    color: var(--orange-300);
  }
}
.list-item .li-body {
  flex: 1;
  min-width: 0;
}
.list-item .li-title {
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.005em;
  margin: 0 0 0.0625rem;
}
.list-item .li-sub {
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 0;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-hi);
  font-size: 0.6875rem;
  font-weight: 600;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  position: relative;
}
.dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--green);
  opacity: 0.3;
  animation: pulse 2s ease-out infinite;
}
.dot.stale {
  background: var(--muted);
}
.dot.stale::after {
  animation: none;
  opacity: 0;
}
@keyframes pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  background: var(--bg-alt);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
}
.empty-emoji {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.625rem;
  opacity: 0.7;
}
.empty-title {
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
}
.empty-body {
  font-size: 0.8125rem;
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.45;
}

.chat-screen {
  display: none;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.chat-screen.active {
  display: flex;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}
.chat-header h1 {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  -webkit-overflow-scrolling: touch;
}
.bubble {
  max-width: 84%;
  padding: 0.6875rem 0.9375rem;
  border-radius: 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: bubbleIn 0.2s var(--ease-spring);
}
/* User input is plain text — preserve their line breaks. */
.bubble.user {
  white-space: pre-wrap;
}
/* Assistant content is rendered markdown HTML; pre-wrap would preserve the
   newlines BETWEEN block elements and create spurious blank gaps. Let the
   block elements own their own spacing. Thinking placeholder stays pre-wrap. */
.bubble.assistant {
  white-space: normal;
}
.bubble.thinking {
  white-space: pre-wrap;
}
@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: white;
  border-bottom-right-radius: 0.375rem;
  box-shadow: var(--shadow-glow-soft);
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 0.375rem;
}
/* Inline images (e.g. agent screenshots rendered from ![](url)). Keep them
   contained to the bubble width, rounded, with a little breathing room. */
.bubble.assistant img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  margin: 0.5rem 0;
}
.bubble.thinking {
  color: var(--muted);
  font-style: italic;
}
.bubble.thinking::after {
  content: "•••";
  animation: dots 1.2s ease-in-out infinite;
  display: inline-block;
  margin-left: 0.25rem;
  opacity: 0.6;
}
@keyframes dots {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}
.chat-input-wrap {
  padding: 0.625rem 0.75rem 0.875rem;
  border-top: 1px solid var(--line-soft);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-suggest {
  display: flex;
  gap: 0.375rem;
  padding: 0 0 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-suggest::-webkit-scrollbar {
  display: none;
}
.chip {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4375rem 0.6875rem;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--ink-2);
  border: 1px solid var(--line-soft);
  transition:
    background var(--dur),
    border-color var(--dur);
  cursor: pointer;
}
.chip:hover {
  background: var(--bg-hi);
  border-color: var(--orange-200);
}
.chat-input {
  display: flex;
  gap: 0.375rem;
  align-items: flex-end;
}
.chat-input textarea {
  flex: 1;
  min-height: 42px;
  max-height: 140px;
  padding: 0.6875rem 1rem;
  border-radius: 1.25rem;
  resize: none;
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  /* 16px min: iOS Safari auto-zooms the whole page on focus for inputs <16px.
     Keep at 1rem so tapping the chat box never zooms/jumps on mobile. */
  font-size: 1rem;
  line-height: 1.4;
  outline: none;
  transition: border-color var(--dur);
}
.chat-input textarea:focus {
  border-color: var(--orange-300);
}
.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition:
    transform var(--dur) var(--ease),
    background var(--dur);
  box-shadow: var(--shadow-glow-soft);
}
.send-btn:hover {
  background: var(--accent-2);
}
.send-btn:active {
  transform: scale(0.92);
}
.send-btn:disabled {
  background: var(--neutral-300);
  cursor: not-allowed;
  box-shadow: none;
}
.send-btn svg {
  width: 18px;
  height: 18px;
}

.skill-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1rem;
}
.search-box {
  position: relative;
}
.search-box svg {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 0.6875rem 1rem 0.6875rem 2.375rem;
  border-radius: var(--r-md);
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--dur);
}
.search-box input:focus {
  border-color: var(--orange-300);
}
.domain-chips {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}
.domain-chips::-webkit-scrollbar {
  display: none;
}
.chip-toggle {
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.4375rem 0.8125rem;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--ink-2);
  border: 1px solid var(--line-soft);
  transition: all var(--dur);
  cursor: pointer;
}
.chip-toggle.on {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-glow-soft);
}

.skill-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 520px) {
  .skill-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 720px) {
  .skill-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.skill-card {
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 0.875rem;
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
  transition: all var(--dur);
  text-align: left;
  width: 100%;
  position: relative;
  cursor: pointer;
}
.skill-card:hover {
  border-color: var(--orange-200);
}
.skill-card.enabled {
  border-color: var(--accent);
  background: var(--orange-50);
}
@media (prefers-color-scheme: dark) {
  .skill-card.enabled {
    background: rgba(249, 115, 22, 0.06);
  }
}
.skill-card .se {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.skill-card .sb {
  flex: 1;
  min-width: 0;
}
.skill-card .sn {
  font-weight: 600;
  font-size: 0.875rem;
  margin: 0 0 0.125rem;
  letter-spacing: -0.005em;
}
.skill-card .st {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  margin: 0;
}
.skill-card .check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: all var(--dur);
}
.skill-card.enabled .check {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.skill-card .check svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity var(--dur);
}
.skill-card.enabled .check svg {
  opacity: 1;
}

.setting-group {
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  margin-bottom: 0.875rem;
  overflow: hidden;
}
.setting-group-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0.375rem 0.375rem;
  margin-top: 1.5rem;
}
.setting-group-title:first-child {
  margin-top: 0;
}
.setting {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  min-height: 56px;
}
.setting:last-child {
  border-bottom: none;
}
.setting-body {
  flex: 1;
  min-width: 0;
}
.setting-label {
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.005em;
  margin: 0;
}
.setting-sub {
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 0.0625rem 0 0;
  line-height: 1.35;
}

.toggle {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--neutral-300);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--dur) var(--ease-spring);
  box-shadow: var(--shadow-sm);
}
.toggle.on {
  background: var(--accent);
}
.toggle.on::after {
  transform: translateX(18px);
}
@media (prefers-color-scheme: dark) {
  .toggle {
    background: var(--neutral-700);
  }
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  padding: 0.875rem 1rem 1rem;
}
.plan-card {
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.875rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  transition: all var(--dur);
  text-align: left;
  cursor: pointer;
  position: relative;
}
.plan-card:hover {
  border-color: var(--orange-300);
}
.plan-card.active {
  border-color: var(--accent);
  background: var(--orange-50);
  box-shadow: var(--shadow-glow-soft);
}
@media (prefers-color-scheme: dark) {
  .plan-card.active {
    background: rgba(249, 115, 22, 0.08);
  }
}
.plan-card.popular::before {
  content: "POPULAR";
  position: absolute;
  top: -8px;
  right: 0.625rem;
  background: var(--accent);
  color: white;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.1875rem 0.375rem;
  border-radius: 0.25rem;
  box-shadow: var(--shadow-glow-soft);
}
.plan-card .pn {
  font-weight: 700;
  font-size: 0.9375rem;
  text-transform: capitalize;
  letter-spacing: -0.005em;
}
.plan-card .pp {
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
}
.plan-card .pp small {
  font-size: 0.6875rem;
  color: var(--muted);
  font-weight: 500;
}
.plan-card .pf {
  font-size: 0.6875rem;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 0.125rem;
}
.check-corner {
  position: absolute;
  top: 0.4375rem;
  right: 0.4375rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
}
.check-corner svg {
  width: 10px;
  height: 10px;
}

.link-code-display {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--accent);
  padding: 0.875rem 1rem;
  background: var(--orange-50);
  border: 1.5px dashed var(--orange-300);
  border-radius: var(--r-md);
  text-align: center;
  margin: 0.75rem 1rem;
}
@media (prefers-color-scheme: dark) {
  .link-code-display {
    background: rgba(249, 115, 22, 0.08);
  }
}
.link-code-meta {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 0.875rem;
  padding: 0 1rem;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  gap: 0.125rem;
  padding: 0.4375rem 0.5rem;
  padding-bottom: max(0.4375rem, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(160%) blur(24px);
  -webkit-backdrop-filter: saturate(160%) blur(24px);
  border-top: 1px solid var(--line-soft);
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.4375rem 0.375rem;
  border-radius: 0.625rem;
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: 1;
  max-width: 90px;
  transition: color var(--dur);
}
.nav-btn svg {
  width: 22px;
  height: 22px;
  transition: transform var(--dur) var(--ease-spring);
}
.nav-btn.active {
  color: var(--accent);
}
.nav-btn.active svg {
  transform: scale(1.08);
}
.nav-btn:active {
  transform: scale(0.92);
}
.has-bottom-nav {
  padding-bottom: 5.5rem;
}

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
  display: none;
  padding: env(safe-area-inset-top) 1.25rem env(safe-area-inset-bottom);
  animation: fadeIn 0.25s var(--ease);
}
.onboarding.show {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.onb-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 2rem 0 1.5rem;
}
.onb-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 2rem;
}
.onb-brand .brand-mark {
  width: 48px;
  height: 48px;
  font-size: 1.375rem;
  border-radius: 12px;
}
.onb-brand .brand-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.onb-h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-align: center;
  margin: 0 0 0.5rem;
}
.onb-sub {
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
  margin: 0 0 2.25rem;
  line-height: 1.45;
}
.onb-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.onb-card {
  background: var(--bg-alt);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 1.125rem;
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  transition:
    transform var(--dur) var(--ease),
    border-color var(--dur),
    box-shadow var(--dur);
  cursor: pointer;
}
.onb-card:hover {
  transform: translateY(-2px);
  border-color: var(--orange-300);
  box-shadow: var(--shadow);
}
.onb-card.featured {
  border-color: var(--accent);
  background: var(--orange-50);
  box-shadow: var(--shadow-glow-soft);
}
@media (prefers-color-scheme: dark) {
  .onb-card.featured {
    background: rgba(249, 115, 22, 0.08);
  }
}
.onb-card .e {
  font-size: 1.875rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.125rem;
}
.onb-card .b {
  flex: 1;
  min-width: 0;
}
.onb-card .t {
  font-weight: 700;
  font-size: 1.0625rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.015em;
}
.onb-card .d {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
  margin: 0;
}
.onb-card .arr {
  font-size: 1.125rem;
  color: var(--muted);
  align-self: center;
  flex-shrink: 0;
}
.onb-foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: auto;
  padding-top: 1.5rem;
  line-height: 1.5;
}
.onb-foot a {
  color: var(--accent);
  font-weight: 500;
}


/* --- Login/onboarding v2: one clear primary path + inline email --- */
.onb-primary {
  display: flex; align-items: center; gap: 0.875rem;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-lg);
  padding: 1.125rem 1.25rem;
  box-shadow: var(--shadow-glow-soft);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur);
}
.onb-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.onb-primary:active { transform: translateY(0); }
.onb-primary .e { font-size: 1.75rem; line-height: 1; flex-shrink: 0; }
.onb-primary .b { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.onb-primary .t { font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.015em; }
.onb-primary .d { font-size: 0.85rem; opacity: 0.9; }
.onb-primary .arr { font-size: 1.25rem; flex-shrink: 0; }
.onb-or { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.8125rem; margin: 1.25rem 0; }
.onb-or::before, .onb-or::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }
.onb-email { display: flex; gap: 0.5rem; }
.onb-email-input { flex: 1; min-width: 0; background: var(--bg-alt); border: 1.5px solid var(--line-soft); border-radius: var(--r-md); padding: 0.875rem 1rem; font-size: 1rem; color: var(--text); transition: border-color var(--dur); }
.onb-email-input:focus { outline: none; border-color: var(--accent); }
.onb-email-btn { flex-shrink: 0; cursor: pointer; background: var(--bg-alt); color: var(--text); border: 1.5px solid var(--line-soft); border-radius: var(--r-md); padding: 0 1.125rem; font-size: 0.9rem; font-weight: 600; transition: border-color var(--dur), background var(--dur); }
.onb-email-btn:hover:not(:disabled) { border-color: var(--accent); }
.onb-email-btn:disabled { opacity: 0.6; cursor: default; }
.onb-email-hint { color: var(--muted); font-size: 0.8rem; margin: 0.5rem 0 0; line-height: 1.4; }
.onb-email-hint.err { color: var(--danger, #e5484d); }
.onb-more { margin-top: 1.5rem; }
.onb-more > summary { cursor: pointer; color: var(--muted); font-size: 0.875rem; font-weight: 500; text-align: center; list-style: none; user-select: none; padding: 0.5rem; }
.onb-more > summary::-webkit-details-marker { display: none; }
.onb-more > summary::after { content: ' \25be'; }
.onb-more[open] > summary::after { content: ' \25b4'; }
.onb-more .onb-cards { margin-top: 0.75rem; }
.install-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 5rem;
  max-width: 440px;
  margin: 0 auto;
  background: var(--neutral-900);
  color: var(--cream-50);
  border-radius: var(--r-lg);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-lg);
  z-index: 25;
  transform: translateY(160%);
  opacity: 0;
  transition:
    transform var(--dur-md) var(--ease-spring),
    opacity var(--dur);
  pointer-events: none;
}
.install-banner.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.install-banner .ib-msg {
  flex: 1;
  font-size: 0.8125rem;
  line-height: 1.3;
}
.install-banner .ib-msg strong {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.125rem;
}
.install-banner .ib-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--cream-200);
  background: transparent;
}
.install-banner .ib-close:hover {
  background: rgba(255, 255, 255, 0.08);
}
.install-banner .ib-close svg {
  width: 14px;
  height: 14px;
}

.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 1rem);
  left: 1rem;
  right: 1rem;
  max-width: 380px;
  margin: 0 auto;
  background: var(--neutral-900);
  color: var(--cream-50);
  padding: 0.6875rem 1rem;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transform: translateY(-200%);
  transition: transform var(--dur-md) var(--ease-spring);
}
.toast.show {
  transform: translateY(0);
}
.toast.success {
  background: var(--green);
  color: white;
}
.toast.error {
  background: var(--red);
  color: white;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--orange-200);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-center {
  margin: 1.5rem auto;
  display: block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (min-width: 640px) {
  .hero h1 {
    font-size: 2.25rem;
  }
}

.chat-screen.active ~ .install-banner {
  display: none;
}

/* Voice input mic button */
.mic-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition:
    transform var(--dur) var(--ease),
    background var(--dur),
    color var(--dur);
  border: 1px solid var(--line-soft);
  cursor: pointer;
}
.mic-btn:hover {
  background: var(--bg-hi);
  border-color: var(--orange-200);
}
.mic-btn:active {
  transform: scale(0.92);
}
.mic-btn svg {
  width: 18px;
  height: 18px;
}
.mic-btn.recording {
  background: var(--red);
  color: white;
  border-color: var(--red);
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

#chatClear svg {
  width: 16px;
  height: 16px;
}

/* File attachment preview */
.attach-preview {
  display: flex;
  gap: 0.375rem;
  padding: 0 0 0.5rem;
  flex-wrap: wrap;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--r);
  background: var(--orange-100);
  color: var(--orange-700);
  font-size: 0.8125rem;
  font-weight: 500;
  max-width: 60%;
}
@media (prefers-color-scheme: dark) {
  .attach-chip {
    background: rgba(249, 115, 22, 0.18);
    color: var(--orange-300);
  }
}
.attach-chip .ae {
  font-size: 1rem;
  flex-shrink: 0;
}
.attach-chip .an {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-chip .ax {
  margin-left: 0.25rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  color: inherit;
}
.attach-chip .ax svg {
  width: 10px;
  height: 10px;
}
.bubble .img-attach {
  display: block;
  max-width: 240px;
  max-height: 240px;
  border-radius: 0.75rem;
  margin-top: 0.375rem;
  border: 1px solid var(--line-soft);
}
.bubble .file-attach {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.375rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.15);
  font-size: 0.8125rem;
  text-decoration: none;
  color: inherit;
}
.bubble.assistant .file-attach {
  background: var(--bg-hi);
  color: var(--ink);
}

/* Chat drawer */
.chat-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-md) var(--ease);
}
.chat-drawer-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
.chat-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 82vw);
  background: var(--bg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform var(--dur-md) var(--ease-spring);
  box-shadow: var(--shadow-lg);
  padding-top: env(safe-area-inset-top);
}
.chat-drawer.show {
  transform: translateX(0);
}
.chat-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--line-soft);
}
.chat-drawer-head h2 {
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0;
}
.chat-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.chat-drawer-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  padding: 2rem 1rem;
}
.chat-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--r);
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--bg-alt);
  transition:
    border-color var(--dur),
    background var(--dur);
}
.chat-row:hover {
  border-color: var(--orange-200);
}
.chat-row.active {
  border-color: var(--accent);
  background: var(--orange-50);
}
@media (prefers-color-scheme: dark) {
  .chat-row.active {
    background: rgba(249, 115, 22, 0.08);
  }
}
.chat-row-body {
  flex: 1;
  min-width: 0;
}
.chat-row-title {
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.chat-row-sub {
  color: var(--muted);
  font-size: 0.75rem;
  margin: 0.0625rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-row-del {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: none;
  place-items: center;
  color: var(--muted);
  background: transparent;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}
.chat-row:hover .chat-row-del {
  display: grid;
}
.chat-row-del:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.08);
}
.chat-row-del svg {
  width: 14px;
  height: 14px;
}

/* Chat drawer search */
.chat-drawer-search {
  padding: 0.5rem 1rem 0.625rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-drawer-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}
.chat-drawer-search input:focus {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.search-result {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-result:hover {
  background: var(--bg);
}
.search-result .role {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.search-result .snippet {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.125rem;
}
.search-result .snippet mark {
  background: rgba(249, 115, 22, 0.3);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

/* Chat list row hover/actions */
.chat-row {
  position: relative;
}
.chat-row-actions {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 0.25rem;
  background: var(--surface);
  padding: 0.25rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.chat-row:hover .chat-row-actions {
  display: flex;
}
.chat-row-actions button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.chat-row-actions button:hover {
  background: var(--border);
  color: var(--text);
}

/* Notifications bell + drawer */
.bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  border: 2px solid var(--surface);
}
.notif-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 90vw;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 70;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}
.notif-drawer.show {
  transform: translateX(0);
}
.notif-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.625rem;
  border-bottom: 1px solid var(--border);
}
.notif-drawer-head h2 {
  font-size: 1.05rem;
  margin: 0;
}
.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.notif-row {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}
.notif-row:hover {
  background: var(--bg);
}
.notif-row.unread {
  background: rgba(249, 115, 22, 0.04);
}
.notif-row.unread::before {
  content: "";
  position: absolute;
  left: 0.4rem;
  top: 1.1rem;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--brand);
}
.notif-row .ttl {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}
.notif-row .bdy {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.125rem;
  line-height: 1.4;
}
.notif-row .ts {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.notif-row .del {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  display: none;
  padding: 0.25rem;
}
.notif-row:hover .del {
  display: block;
}
.notif-row .del:hover {
  color: var(--text);
}
.notif-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.notif-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 65;
}
.notif-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Explicit theme override */
/* Manual theme toggle — must override the SAME full token set the OS
   `@media (prefers-color-scheme: dark)` blocks do, otherwise text/borders
   (which use --ink / --line) stay dark-on-dark and become invisible. */
:root[data-theme="dark"] {
  /* core surfaces */
  --bg: var(--neutral-950);
  --bg-alt: var(--neutral-900);
  --bg-hi: var(--neutral-800);
  /* text + lines (THIS is what the old toggle was missing) */
  --ink: var(--neutral-50);
  --ink-2: #e7e5e4;
  --muted: var(--neutral-400);
  --line: var(--neutral-800);
  --line-soft: var(--neutral-900);
  /* extended surfaces/elevation used elsewhere */
  --surface: var(--neutral-900);
  --surface-1: var(--neutral-900);
  --accent-soft: rgba(249, 115, 22, 0.16);
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.40), 0 1px 3px rgba(0, 0, 0, 0.30);
  --elev-2: 0 2px 6px rgba(0, 0, 0, 0.45), 0 8px 22px rgba(0, 0, 0, 0.40);
  --elev-3: 0 6px 14px rgba(0, 0, 0, 0.50), 0 18px 44px rgba(0, 0, 0, 0.55);
  --elev-4: 0 10px 24px rgba(0, 0, 0, 0.55), 0 30px 70px rgba(0, 0, 0, 0.62);
  --hairline: rgba(255, 255, 255, 0.07);
  --glass-bg: color-mix(in srgb, var(--bg) 70%, transparent);
  --glass-line: rgba(255, 255, 255, 0.08);
  /* alias tokens kept for any --text/--border consumers */
  --text: var(--neutral-50);
  --border: var(--neutral-800);
  /* deepen the brand-tinted shadows so cards don't glow on black */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}
:root[data-theme="light"] {
  /* core surfaces */
  --bg: var(--cream-50);
  --bg-alt: var(--cream-100);
  --bg-hi: var(--cream-200);
  /* text + lines back to the light palette */
  --ink: var(--neutral-900);
  --ink-2: var(--neutral-700);
  --muted: var(--neutral-500);
  --line: var(--neutral-200);
  --line-soft: var(--neutral-100);
  /* extended surfaces */
  --surface: var(--neutral-0);
  --surface-1: var(--neutral-0);
  --accent-soft: rgba(249, 115, 22, 0.10);
  /* alias tokens */
  --text: var(--neutral-900);
  --border: var(--neutral-200);
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  gap: 0.125rem;
  background: var(--bg-alt);
  padding: 0.125rem;
  border-radius: 0.625rem;
}
.theme-opt {
  background: transparent;
  border: none;
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
}
.theme-opt.active {
  background: var(--brand);
  color: white;
}
.theme-opt:not(.active):hover {
  color: var(--text);
}

.lang-picker {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}
.lang-picker:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* RTL layouts */
[dir="rtl"] .bottom-nav {
  flex-direction: row-reverse;
}
[dir="rtl"] .chat-drawer {
  right: auto;
  left: 0;
  border-right: 1px solid var(--border);
  border-left: none;
  transform: translateX(-100%);
}
[dir="rtl"] .chat-drawer.show {
  transform: translateX(0);
}
[dir="rtl"] .notif-drawer {
  left: 0;
  right: auto;
  border-right: 1px solid var(--border);
  border-left: none;
  transform: translateX(-100%);
}
[dir="rtl"] .notif-drawer.show {
  transform: translateX(0);
}
[dir="rtl"] .bell-badge {
  right: auto;
  left: 2px;
}

/* Stats panel */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
  padding: 0.75rem;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.875rem;
  text-align: center;
}
.stat-num {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--brand);
  margin: 0;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* API keys */
.api-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.api-key-row:last-child {
  border-bottom: none;
}
.api-key-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
  flex: 1;
}
.api-key-name {
  font-weight: 600;
  color: var(--text);
}
.api-key-meta {
  color: var(--muted);
  font-size: 0.75rem;
}
.api-key-prefix {
  font-family: "JetBrains Mono", monospace;
  color: var(--muted);
  font-size: 0.75rem;
}
.api-key-actions {
  display: flex;
  gap: 0.375rem;
}
.api-key-actions button {
  font-size: 0.75rem;
  padding: 0.25rem 0.625rem;
}
.secret-reveal {
  background: var(--brand);
  padding: 1rem;
  border-radius: 0.75rem;
  margin: 0.75rem 0;
  color: white;
}
.secret-reveal p {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}
.secret-reveal code {
  display: block;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.625rem;
  border-radius: 0.5rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  word-break: break-all;
  user-select: all;
  margin-bottom: 0.5rem;
}
.secret-reveal button {
  background: white;
  color: var(--brand);
  border: none;
  padding: 0.375rem 0.875rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Activity log modal */
.activity-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.activity-modal[hidden] {
  display: none;
}
.activity-card {
  background: var(--surface);
  border-radius: 1rem;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.activity-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.activity-head h2 {
  margin: 0;
  font-size: 1.1rem;
}
.activity-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.activity-row {
  padding: 0.625rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
}
.activity-row:last-child {
  border-bottom: none;
}
.activity-action {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--brand);
  background: rgba(249, 115, 22, 0.1);
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  text-transform: uppercase;
  white-space: nowrap;
}
.activity-target {
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
  word-break: break-word;
}
.activity-ts {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}
.activity-foot {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
}
.activity-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Coachmark/tour overlay */
.coachmark-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
}
.coachmark-spot {
  position: fixed;
  border: 3px solid var(--brand);
  border-radius: 999px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 101;
  transition: all 0.3s ease;
}
.coachmark-tip {
  position: fixed;
  background: var(--surface);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  max-width: 280px;
  z-index: 102;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.coachmark-tip h3 {
  margin: 0 0 0.375rem;
  font-size: 1rem;
  color: var(--text);
}
.coachmark-tip p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.coachmark-tip .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.coachmark-tip .step {
  font-size: 0.7rem;
  color: var(--muted);
}
.coachmark-tip button {
  background: var(--brand);
  color: white;
  border: none;
  padding: 0.375rem 0.875rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}
.coachmark-tip button.secondary {
  background: transparent;
  color: var(--muted);
}

/* Quota bars */
.quota-rows {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}
.quota-row {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.quota-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text);
}
.quota-meta span:last-child {
  color: var(--muted);
  font-size: 0.75rem;
}
.quota-bar {
  background: var(--bg-alt);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.quota-fill {
  background: var(--brand);
  height: 100%;
  transition: width 0.5s ease;
}
.quota-fill.warn {
  background: #f59e0b;
}
.quota-fill.danger {
  background: #dc2626;
}

/* Facts panel */
.fact-row {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.fact-row:last-child {
  border-bottom: none;
}
.fact-row .topic {
  display: inline-block;
  background: rgba(249, 115, 22, 0.12);
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.5rem;
}
.fact-row .text {
  color: var(--text);
  margin-top: 0.25rem;
}
.fact-row .actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.375rem;
}
.fact-row .actions button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.125rem 0.5rem;
  color: var(--muted);
}
.fact-row .actions button:hover {
  color: var(--text);
  border-color: var(--text);
}

/* Feedback thumbs */
.bubble.assistant {
  position: relative;
}
.bubble-actions {
  display: none;
  gap: 0.25rem;
  margin-top: 0.5rem;
}
.bubble.assistant:hover .bubble-actions,
.bubble.assistant.has-feedback .bubble-actions {
  display: flex;
}
.bubble-actions button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  transition: all 0.15s ease;
}
.bubble-actions button:hover {
  color: var(--text);
  border-color: var(--text);
}
.bubble-actions button.active {
  color: var(--brand);
  border-color: var(--brand);
  background: rgba(249, 115, 22, 0.1);
}

/* =====================================================================
 * SMOOTH POLISH — Sprint "everything springs" (Part A)
 * Pure transform/opacity (GPU) — never touches layout properties.
 * Vars `--ease-spring` + `--ease` + `--dur` are reused from :root above.
 * ===================================================================== */

/* --- Spring presses on interactive elements ------------------------- */
.btn,
.icon-btn,
.send-btn,
.mic-btn,
.nav-btn,
.btn-soft,
.btn-primary,
.btn-on-orange,
.btn-ghost-light,
.btn-danger,
.onb-card,
.theme-opt,
.setting button,
.chat-row,
.notif-row {
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.22s var(--ease-spring),
    opacity 0.22s var(--ease),
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    color var(--dur) var(--ease);
  will-change: transform;
}
.btn:active,
.icon-btn:active,
.send-btn:active,
.mic-btn:active,
.nav-btn:active,
.theme-opt:active,
.onb-card:active,
.chat-row:active,
.notif-row:active {
  transform: scale(0.96);
}
.send-btn:active {
  transform: scale(0.92);
}

/* press-state used by JS for non-button targets (settings rows etc.) */
.spring-press {
  transform: scale(0.97);
  transition: transform 0.18s var(--ease-spring);
}

/* --- Skeleton shimmer loader ---------------------------------------- */
@keyframes kamor-skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.skeleton {
  display: block;
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    var(--bg-alt, rgba(255, 255, 255, 0.04)) 0%,
    var(--line-soft, rgba(255, 255, 255, 0.08)) 50%,
    var(--bg-alt, rgba(255, 255, 255, 0.04)) 100%
  );
  background-size: 200% 100%;
  animation: kamor-skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 0.625rem;
  min-height: 1em;
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
.skeleton-line {
  height: 0.75rem;
  margin: 0.45rem 0;
  border-radius: 0.5rem;
}
.skeleton-line.w-60 {
  width: 60%;
}
.skeleton-line.w-80 {
  width: 80%;
}
.skeleton-line.w-40 {
  width: 40%;
}
.skeleton-row {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line-soft, var(--border, rgba(255, 255, 255, 0.06)));
}
.skeleton-card {
  height: 4.25rem;
  margin: 0.5rem 1rem;
}
.skeleton-stat {
  height: 2.5rem;
  margin: 0.5rem 0;
  border-radius: 0.75rem;
}
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* --- Chat bubble mount animation (used by Web Animations API too) --- */
@keyframes kamor-bubble-mount {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.bubble.mount-anim {
  animation: kamor-bubble-mount 0.32s var(--ease-spring) both;
}

/* --- Optimistic-send states ----------------------------------------- */
.bubble.sending {
  opacity: 0.72;
}
.bubble.sending::after {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.5rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.5;
  animation: kamor-send-pulse 0.9s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes kamor-send-pulse {
  0%,
  100% {
    transform: scale(0.7);
    opacity: 0.3;
  }
  50% {
    transform: scale(1);
    opacity: 0.8;
  }
}
.bubble.errored {
  position: relative;
  opacity: 1;
  cursor: pointer;
}
.bubble.errored::after {
  content: "↻";
  display: inline-block;
  margin-left: 0.5rem;
  font-weight: 700;
  color: #ff5a5f;
}
.bubble.errored::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ff5a5f;
  transform: translateY(-50%);
  box-shadow: 0 0 0 0 rgba(255, 90, 95, 0.6);
  animation: kamor-err-dot 1.4s ease-out infinite;
}
@keyframes kamor-err-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 90, 95, 0.6);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(255, 90, 95, 0);
  }
}

/* --- Swipe-to-dismiss on notification rows -------------------------- */
.notif-row {
  touch-action: pan-y;
  transform: translateX(var(--swipe-x, 0));
  transition:
    transform 0.28s var(--ease-spring),
    opacity 0.28s var(--ease);
}
.notif-row.swiping {
  transition: none;
}
.notif-row.dismissing {
  opacity: 0;
  transform: translateX(120%) !important;
}

/* --- Pull-to-refresh spinner on chat list drawer -------------------- */
.ptr-indicator {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, calc(-100% + var(--ptr-y, 0px)));
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--bg-alt, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--line-soft, var(--border, rgba(255, 255, 255, 0.1)));
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: var(--ptr-opacity, 0);
  transition:
    transform 0.18s var(--ease),
    opacity 0.18s var(--ease);
  z-index: 4;
}
.ptr-indicator .spin {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid var(--line-soft, rgba(255, 255, 255, 0.15));
  border-top-color: var(--brand, #f97316);
  transform: rotate(var(--ptr-rot, 0deg));
  transition: transform 0.05s linear;
}
.ptr-indicator.spinning .spin {
  animation: kamor-ptr-spin 0.8s linear infinite;
}
@keyframes kamor-ptr-spin {
  to {
    transform: rotate(360deg);
  }
}
.chat-drawer-body {
  position: relative;
}

/* Respect reduced motion globally for our spring scaling */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .icon-btn,
  .send-btn,
  .mic-btn,
  .nav-btn,
  .theme-opt,
  .onb-card,
  .chat-row,
  .notif-row {
    transition:
      background-color var(--dur) var(--ease),
      color var(--dur) var(--ease),
      border-color var(--dur) var(--ease);
  }
  .btn:active,
  .icon-btn:active,
  .send-btn:active,
  .mic-btn:active,
  .nav-btn:active,
  .theme-opt:active,
  .onb-card:active,
  .chat-row:active,
  .notif-row:active {
    transform: none;
  }
  .bubble.mount-anim {
    animation: none;
  }
}

/* ───────────────────────────── feature-wires ───────────────────────────── */
/* Compact toast-style install banner — used to overlap content. Now anchors
   to top of viewport and shrinks to a chip so the Dinner tile etc. stay
   tappable. */
.install-banner {
  bottom: auto;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  left: 50%;
  right: auto;
  transform: translate(-50%, -160%);
  max-width: 360px;
  padding: 0.5rem 0.875rem;
  border-radius: 999px;
  font-size: 0.8rem;
  gap: 0.5rem;
}
.install-banner.show {
  transform: translate(-50%, 0);
}
.install-banner .ib-msg {
  font-size: 0.78rem;
}
.install-banner .ib-msg strong {
  display: inline;
  font-size: 0.78rem;
  margin: 0 0.35rem 0 0;
}

/* tile-style buttons used by Media/Security/Smart-home/More */
button.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
  background: var(--surface-1, #fff);
  border: 1px solid var(--line, #eadcc8);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
  cursor: pointer;
  transition:
    transform var(--dur) var(--ease-spring),
    box-shadow var(--dur);
}
button.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}
button.card .e {
  font-size: 1.4rem;
  line-height: 1;
}
button.card .t {
  font-weight: 600;
  font-size: 0.95rem;
}
button.card .d {
  font-size: 0.78rem;
  color: var(--muted, #6b6053);
}

.media-form,
.sec-form {
  background: var(--surface-1, #fff);
  border: 1px solid var(--line, #eadcc8);
  border-radius: 12px;
  padding: 0.9rem;
  margin-top: 0.75rem;
}

/* Expert cards — show category + description */
.expert-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--surface-1, #fff);
  border: 1px solid var(--line, #eadcc8);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
  cursor: pointer;
  transition: transform var(--dur) var(--ease-spring);
}
.expert-card:hover {
  transform: translateY(-1px);
}
.expert-card .row-1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.expert-card .icon {
  font-size: 1.4rem;
}
.expert-card .name {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}
.expert-card .cat {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft, #fde9d3);
  color: var(--accent, #c8590f);
  text-transform: capitalize;
}
.expert-card .desc {
  font-size: 0.78rem;
  color: var(--muted, #6b6053);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.expert-chip {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid transparent;
  cursor: pointer;
}
.expert-chip.active {
  background: var(--accent, #f97316);
  color: #fff;
}

/* Expert badge in chat header */
.expert-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft, #fde9d3);
  color: var(--accent, #c8590f);
  font-size: 0.72rem;
  font-weight: 600;
  margin-left: 0.5rem;
}
.expert-pill button {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

/* More menu — pops up from the bottom nav */
.more-menu {
  position: fixed;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  width: min(360px, calc(100vw - 1.5rem));
  background: var(--surface-1, #fff);
  border: 1px solid var(--line, #eadcc8);
  border-radius: 16px;
  padding: 0.5rem;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.14);
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  opacity: 0;
  transition:
    transform var(--dur-md) var(--ease-spring),
    opacity var(--dur);
}
.more-menu[hidden] {
  display: none;
}
.more-menu.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.7rem 0.5rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.02);
  border: 0;
  cursor: pointer;
  font-size: 0.8rem;
}
.more-item .e {
  font-size: 1.4rem;
}
.more-item:hover {
  background: rgba(0, 0, 0, 0.05);
}
.more-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 55;
}
.more-menu-backdrop[hidden] {
  display: none;
}

/* Smart-home vendor tiles */
.vendor-tile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  background: var(--surface-1, #fff);
  border: 1px solid var(--line, #eadcc8);
  border-radius: 14px;
  cursor: pointer;
}
.vendor-tile .logo {
  font-size: 1.5rem;
  width: 32px;
  text-align: center;
}
.vendor-tile .body {
  flex: 1;
}
.vendor-tile .body .name {
  font-weight: 600;
  font-size: 0.95rem;
}
.vendor-tile .body .stat {
  font-size: 0.72rem;
  color: var(--muted, #6b6053);
}
.vendor-tile .badge {
  font-size: 0.7rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--muted, #6b6053);
}
.vendor-tile .badge.ok {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}
.vendor-tile .badge.err {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

/* Nav strip on small screens — let it scroll instead of wrapping awkwardly */
@media (max-width: 480px) {
  .bottom-nav {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }
  .bottom-nav::-webkit-scrollbar {
    display: none;
  }
  .bottom-nav .nav-btn {
    min-width: 70px;
    flex: 0 0 auto;
  }
}

/* Modal used by per-vendor connect forms */
.kamor-modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.kamor-modal {
  background: var(--surface-1, #fff);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  padding: 1.25rem;
  max-height: 90vh;
  overflow-y: auto;
}
.kamor-modal h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}
.kamor-modal .row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.75rem;
}
.kamor-modal label {
  font-size: 0.8rem;
  color: var(--muted, #6b6053);
}
.kamor-modal input,
.kamor-modal select,
.kamor-modal textarea {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line, #eadcc8);
  border-radius: 10px;
  font: inherit;
  width: 100%;
}
.kamor-modal .actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════
 * PREMIUM POLISH LAYER — "$1B feel" pass (additive, June 2026)
 * Pure enhancement on top of the existing token system. No IDs touched,
 * no JS hooks renamed. Wins by cascade order. Fully reversible (delete block).
 * Goals: depth · hierarchy · refined motion · polished states.
 * ═════════════════════════════════════════════════════════════════════ */

/* --- 1. Token reconciliation + premium elevation set ------------------ *
 * Several legacy classes reference --brand/--surface/--text/--border that
 * were ONLY defined under explicit [data-theme]. App boots in 'auto', so
 * those panels rendered with undefined vars (transparent / hard #fff).
 * Bind them to the design system for BOTH auto-light and auto-dark. */
:root {
  --brand: var(--accent);
  --brand-2: var(--accent-2);
  --surface: var(--neutral-0);
  --surface-1: var(--neutral-0);
  --text: var(--ink);
  --border: var(--line);
  --accent-soft: var(--orange-100);

  /* Premium elevation — softer, layered, color-tinted ambient + key light */
  --elev-1: 0 1px 2px rgba(28, 25, 23, 0.04), 0 1px 3px rgba(28, 25, 23, 0.05);
  --elev-2: 0 2px 4px rgba(28, 25, 23, 0.04), 0 6px 16px rgba(28, 25, 23, 0.07);
  --elev-3: 0 4px 8px rgba(28, 25, 23, 0.05), 0 14px 32px rgba(28, 25, 23, 0.10);
  --elev-4: 0 8px 16px rgba(28, 25, 23, 0.06), 0 24px 56px rgba(28, 25, 23, 0.14);
  --ring: 0 0 0 3px rgba(249, 115, 22, 0.30);
  --hairline: rgba(28, 25, 23, 0.06);
  --glass-bg: color-mix(in srgb, var(--bg) 72%, transparent);
  --glass-line: rgba(28, 25, 23, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: var(--neutral-900);
    --surface-1: var(--neutral-900);
    --accent-soft: rgba(249, 115, 22, 0.16);
    --elev-1: 0 1px 2px rgba(0, 0, 0, 0.40), 0 1px 3px rgba(0, 0, 0, 0.30);
    --elev-2: 0 2px 6px rgba(0, 0, 0, 0.45), 0 8px 22px rgba(0, 0, 0, 0.40);
    --elev-3: 0 6px 14px rgba(0, 0, 0, 0.50), 0 18px 44px rgba(0, 0, 0, 0.55);
    --elev-4: 0 10px 24px rgba(0, 0, 0, 0.55), 0 30px 70px rgba(0, 0, 0, 0.62);
    --hairline: rgba(255, 255, 255, 0.07);
    --glass-bg: color-mix(in srgb, var(--bg) 70%, transparent);
    --glass-line: rgba(255, 255, 255, 0.08);
  }
}

/* --- 2. Typography refinement — tighter display tracking, rhythm ------ */
body {
  font-feature-settings: "cv11", "ss01", "cv05", "calt";
  letter-spacing: -0.011em;
}
.screen-h1,
.hero h1,
.onb-h1 {
  text-wrap: balance;
}
.screen-h1 {
  font-size: clamp(1.6rem, 5.5vw, 1.75rem);
  letter-spacing: -0.03em;
  line-height: 1.12;
}
.screen-sub {
  font-size: 0.95rem;
  max-width: 42ch;
  letter-spacing: -0.006em;
}
.section-head h2 {
  letter-spacing: -0.02em;
}
.list-item .li-title,
.card .name,
.setting-label,
.skill-card .sn {
  letter-spacing: -0.012em;
}

/* --- 3. Glassmorphism refinement — topbar / nav / chat header --------- */
.topbar {
  background: var(--glass-bg);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-bottom: 1px solid var(--glass-line);
}
.bottom-nav {
  background: var(--glass-bg);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-top: 1px solid var(--glass-line);
  box-shadow: 0 -1px 0 var(--hairline);
}
.chat-header {
  background: var(--glass-bg);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-bottom: 1px solid var(--glass-line);
}

/* Brand mark — subtle inner highlight for a crafted, 3D feel */
.brand-mark {
  background:
    linear-gradient(135deg, var(--orange-400), var(--orange-600)),
    radial-gradient(120% 120% at 30% 20%, rgba(255, 255, 255, 0.45), transparent 55%);
  background-blend-mode: overlay, normal;
  box-shadow:
    var(--shadow-glow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 4px rgba(124, 45, 18, 0.30);
}

/* --- 4. Hero — richer depth, inner light, premium gradient ----------- */
.hero {
  background:
    radial-gradient(140% 120% at 85% -10%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(135deg, var(--orange-500) 0%, var(--orange-400) 48%, var(--orange-600) 100%);
  box-shadow:
    var(--shadow-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.10);
}
.hero h1 {
  font-size: clamp(1.875rem, 7vw, 2.125rem);
  letter-spacing: -0.035em;
  text-shadow: 0 1px 2px rgba(124, 45, 18, 0.18);
}
.hero p {
  max-width: 32ch;
}

/* --- 5. Cards & lists — refined elevation + spring hover ------------- */
.cards {
  gap: 0.75rem;
}
.card {
  border-color: var(--hairline);
  box-shadow: var(--elev-1);
  transition:
    transform 0.26s var(--ease-spring),
    border-color var(--dur) var(--ease),
    box-shadow 0.26s var(--ease);
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--orange-200);
  box-shadow: var(--elev-3);
}
.card:active {
  transform: translateY(-1px) scale(0.99);
}
.list-item {
  border-color: var(--hairline);
  box-shadow: var(--elev-1);
  transition:
    transform 0.22s var(--ease-spring),
    background var(--dur),
    border-color var(--dur),
    box-shadow 0.22s var(--ease);
}
.list-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-2);
}
.list-item .li-icon {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.20);
}

/* --- 6. Buttons — crisper press + glow on primary ------------------- */
.btn {
  letter-spacing: -0.01em;
}
.btn-primary {
  background: linear-gradient(180deg, var(--orange-500), var(--orange-600));
  box-shadow: var(--shadow-glow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn-primary:hover {
  box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn-on-orange {
  box-shadow: var(--elev-2);
}
.btn-on-orange:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-3);
}

/* --- 7. Bottom-nav — premium active indicator (pill + dot) ---------- */
.nav-btn {
  position: relative;
  isolation: isolate;
}
.nav-btn::before {
  content: "";
  position: absolute;
  inset: 0.125rem 0.25rem auto;
  height: calc(100% - 0.25rem);
  border-radius: 0.75rem;
  background: var(--accent-soft);
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity var(--dur) var(--ease),
    transform 0.3s var(--ease-spring);
  z-index: -1;
}
.nav-btn.active::before {
  opacity: 1;
  transform: scale(1);
}
.nav-btn.active {
  color: var(--accent);
}
.nav-btn.active svg {
  transform: translateY(-1px) scale(1.06);
}

/* --- 8. Inputs & focus — unified premium focus ring ----------------- */
.search-box input:focus,
.chat-input textarea:focus,
.lang-picker:focus,
.kamor-modal input:focus,
.kamor-modal select:focus,
.kamor-modal textarea:focus,
input.input:focus {
  border-color: var(--orange-300);
  box-shadow: var(--ring);
  outline: none;
}
:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 0.5rem;
}
.search-box input,
input.input {
  box-shadow: var(--elev-1);
  transition: border-color var(--dur), box-shadow var(--dur);
}

/* --- 9. Empty states — softer, more intentional -------------------- */
.empty {
  background:
    radial-gradient(120% 80% at 50% 0%, var(--bg-alt), transparent 70%),
    var(--bg-alt);
  border-color: var(--hairline);
  border-radius: var(--r-xl);
  padding: 3rem 1.5rem;
}
.empty-emoji {
  filter: saturate(1.05);
  animation: emptyFloat 4s var(--ease) infinite;
}
@keyframes emptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* --- 10. Skill / plan / expert cards — depth + spring -------------- */
.skill-card,
.expert-card,
.vendor-tile,
button.card {
  box-shadow: var(--elev-1);
  border-color: var(--hairline);
}
.skill-card:hover,
.expert-card:hover,
.vendor-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--elev-2);
}
.skill-card.enabled {
  box-shadow: var(--shadow-glow-soft);
}
.plan-card.active,
.onb-card.featured {
  box-shadow: var(--shadow-glow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* --- 11. Setting groups, stats, panels — unify on elevation -------- */
.setting-group,
.stat-card,
.activity-card,
.kamor-modal,
.more-menu {
  box-shadow: var(--elev-2);
  border-color: var(--hairline);
}
.stat-card {
  background: var(--bg-alt);
  transition: transform 0.22s var(--ease-spring), box-shadow var(--dur);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--elev-3);
}
.kamor-modal,
.activity-card {
  box-shadow: var(--elev-4);
}

/* --- 12. Chat bubbles — crafted depth ----------------------------- */
.bubble.assistant {
  box-shadow: var(--elev-1);
  border-color: var(--hairline);
}
.bubble.user {
  box-shadow: var(--shadow-glow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* --- 13. Screen entrance — refined spring stagger ----------------- */
.screen.active {
  animation: premiumScreenIn 0.42s var(--ease-spring) both;
}
@keyframes premiumScreenIn {
  from { opacity: 0; transform: translateY(12px) scale(0.995); }
  to   { opacity: 1; transform: none; }
}
.screen.active > * {
  animation: premiumRise 0.5s var(--ease-spring) both;
}
.screen.active > *:nth-child(1) { animation-delay: 0.02s; }
.screen.active > *:nth-child(2) { animation-delay: 0.06s; }
.screen.active > *:nth-child(3) { animation-delay: 0.10s; }
.screen.active > *:nth-child(4) { animation-delay: 0.14s; }
.screen.active > *:nth-child(5) { animation-delay: 0.18s; }
.screen.active > *:nth-child(n+6) { animation-delay: 0.20s; }
@keyframes premiumRise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* --- 14. Scrollbars — slim, on-brand (desktop) -------------------- */
@media (hover: hover) and (pointer: fine) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--orange-200) transparent;
  }
  *::-webkit-scrollbar { width: 9px; height: 9px; }
  *::-webkit-scrollbar-thumb {
    background: var(--orange-200);
    border-radius: 999px;
    border: 2px solid var(--bg);
  }
  *::-webkit-scrollbar-thumb:hover { background: var(--orange-300); }
  *::-webkit-scrollbar-track { background: transparent; }
}

/* --- 15. Desktop scale-up (1024px+) — make it feel like an app ----- */
@media (min-width: 1024px) {
  .main {
    max-width: 880px;
    padding: 2rem 2rem 3rem;
  }
  .screen-h1 { font-size: 2rem; }
  .hero {
    padding: 2.5rem 2.25rem;
    border-radius: 2rem;
  }
  .hero h1 { font-size: 2.5rem; }
  .hero p { font-size: 1rem; }
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.875rem;
  }
  .card { padding: 1.25rem; }
  .section-head { margin: 2.25rem 0 1rem; }
}
@media (min-width: 1440px) {
  .main { max-width: 1040px; }
  .skill-grid { grid-template-columns: repeat(5, 1fr); }
}

/* --- 16. Reduced-motion: honor the new entrance animations -------- */
@media (prefers-reduced-motion: reduce) {
  .screen.active,
  .screen.active > *,
  .empty-emoji {
    animation: none !important;
  }
  .card:hover,
  .list-item:hover,
  .skill-card:hover,
  .expert-card:hover,
  .vendor-tile:hover,
  .stat-card:hover,
  .btn-on-orange:hover {
    transform: none;
  }
}

/* ── Chat markdown: tables, lists, blockquotes (Fix C, v66) ───────────── */
.bubble.assistant .md-table {
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.875rem;
  overflow-x: auto;
  display: block;
  /* Let the table size to its content and SCROLL on narrow screens instead of
     crushing column 1 so "Category" wraps letter-by-letter (mobile bug). */
  width: max-content;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.bubble.assistant .md-table th,
.bubble.assistant .md-table td {
  border: 1px solid var(--line-soft);
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
  /* Keep cell words on sensible lines; headers never break mid-word. */
  min-width: 5.5rem;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}
.bubble.assistant .md-table th {
  white-space: nowrap;
}
.bubble.assistant .md-table th {
  background: var(--bg-alt);
  font-weight: 600;
}
.bubble.assistant .md-table tr:nth-child(even) td {
  background: rgba(127, 127, 127, 0.05);
}
.bubble.assistant p { margin: 0.4rem 0; }
.bubble.assistant p:first-child { margin-top: 0; }
.bubble.assistant p:last-child { margin-bottom: 0; }
.bubble.assistant h1,
.bubble.assistant h2,
.bubble.assistant h3,
.bubble.assistant h4,
.bubble.assistant h5,
.bubble.assistant h6 {
  margin: 0.6rem 0 0.3rem;
  line-height: 1.25;
  font-weight: 600;
}
.bubble.assistant h1 { font-size: 1.25rem; }
.bubble.assistant h2 { font-size: 1.15rem; }
.bubble.assistant h3 { font-size: 1.05rem; }
.bubble.assistant ul,
.bubble.assistant ol { margin: 0.4rem 0; padding-left: 1.4rem; }
.bubble.assistant li { margin: 0.15rem 0; }
.bubble.assistant blockquote {
  margin: 0.5rem 0;
  padding: 0.25rem 0.75rem;
  border-left: 3px solid var(--line-soft);
  color: var(--muted);
}
.bubble.assistant hr {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: 0.75rem 0;
}
.bubble.assistant pre.code {
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  font-size: 0.825rem;
  margin: 0.5rem 0;
  white-space: pre;
}

/* ============================================================
   Master-pass WS2 — chat readability + organization polish
   (additive; keeps the orange/cream brand + dark mode + spring)
   ============================================================ */

/* Inline code in assistant replies — was unstyled, now legible. */
.bubble.assistant code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg-hi);
  border: 1px solid var(--line-soft);
  border-radius: 0.35rem;
  padding: 0.05rem 0.3rem;
  white-space: break-spaces;
}
.bubble.assistant pre.code code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}
.bubble.assistant a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bubble.assistant strong { font-weight: 650; }

/* Rich assistant messages (tables / code / long lists) get a touch more
   width so content breathes without sacrificing the chat feel. */
.bubble.assistant { max-width: 90%; }
@media (min-width: 640px) {
  .bubble.assistant { max-width: 80%; }
}

/* First-run greeting bubble — make the seed message feel like a warm,
   guiding welcome rather than a lone gray pill. */
.chat-log > .bubble.assistant:first-child:only-child {
  background: linear-gradient(180deg, var(--orange-50), var(--bg-alt));
  border-color: var(--orange-200);
}
@media (prefers-color-scheme: dark) {
  .chat-log > .bubble.assistant:first-child:only-child {
    background: linear-gradient(180deg, rgba(249,115,22,0.06), var(--bg-alt));
  }
}

/* Drawer rhythm — clearer active row + comfortable touch targets. */
.chat-row { padding: 0.6875rem 0.75rem; }
.chat-row.active .chat-row-title { color: var(--accent); }

/* Section headers: consistent weight/spacing across all screens. */
.section-head h2 { letter-spacing: -0.01em; }

/* Make the chat input area feel tidy + grouped. */
.chat-input textarea::placeholder { color: var(--muted); }

/* Agent live tool-progress (Phase 4 UX) — friendly steps, never raw JSON. */
.agent-progress { margin: 4px 0 6px; font-size: .82rem; }
.agent-progress-live {
  color: var(--muted);
  display: inline-flex; align-items: center; gap: .4rem;
  animation: agentPulse 1.4s ease-in-out infinite;
}
.agent-progress-live:empty { display: none; }
@keyframes agentPulse { 0%,100% { opacity: .6; } 50% { opacity: 1; } }
.agent-steps { margin-top: 2px; }
.agent-steps > summary {
  cursor: pointer; color: var(--muted); font-size: .76rem;
  list-style: none; user-select: none;
}
.agent-steps > summary::-webkit-details-marker { display: none; }
.agent-steps > summary::before { content: '▸ '; }
.agent-steps[open] > summary::before { content: '▾ '; }
.agent-steps-list {
  margin: 4px 0 0; padding-left: 1.1rem; color: var(--muted);
  font-size: .78rem; line-height: 1.5;
}
.agent-steps-list li { margin: 1px 0; }

/* Inline tool-approval prompt (approval_required SSE event) */
.approval-prompt {
  margin: 6px 0; padding: 10px 12px; border-radius: 12px;
  background: var(--card, #16161e); border: 1px solid var(--accent, #7c5cff);
  font-size: .85rem;
}
.approval-label { margin-bottom: 8px; }
.approval-buttons { display: flex; gap: 8px; }
.approval-buttons button {
  padding: 6px 14px; border-radius: 8px; border: none; cursor: pointer;
  font-size: .82rem; font-weight: 600;
}
.btn-approve { background: #2bb673; color: #fff; }
.btn-deny { background: #444; color: #ddd; }
.approval-buttons button:disabled { opacity: .5; cursor: default; }

/* Continuum resume banner */
.continuum-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 4px 8px; padding: 8px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent, #7c5cff) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #7c5cff) 30%, transparent);
  font-size: .8rem; color: var(--muted, #aaa);
  transition: opacity 1.1s ease;
}
.continuum-banner.fade { opacity: 0; }
.continuum-banner button {
  background: none; border: 1px solid var(--accent, #7c5cff);
  color: var(--accent, #7c5cff); border-radius: 8px; padding: 4px 10px;
  font-size: .75rem; cursor: pointer; white-space: nowrap;
}
