﻿/* ==========================================================================
   style.css — Dravyx UI Components
   Mobile-first. Uses ONLY design tokens from tokens.css.
   ZERO hardcoded colors, spacing, font-sizes, radius, z-index, or keyframes.
   ========================================================================== */


/* ==========================================================================
   1. Reset & Base
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* Scrollbars */
::-webkit-scrollbar { width: var(--space-1-5); height: var(--space-1-5); }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Selection */
::selection {
  background: var(--accent-glow);
  color: var(--text);
}


/* ==========================================================================
   2. App Layout — mobile-first (flex column)
   ========================================================================== */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  /* JS overrides this via --app-height from visualViewport.height so the
     flex container shrinks when the software keyboard opens — pins the
     composer flush to the top of the keyboard (Claude-app behavior). */
  height: var(--app-height, 100dvh);
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
}


/* ==========================================================================
   3. Sidebar — mobile: fixed off-canvas drawer
   ========================================================================== */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  /* Always leave a ~44px sliver of the main content visible when the drawer
     is open so users have a visual tap target to close it. The old 85vw
     cap was dead on any device wider than ~305px. */
  max-width: calc(100vw - 44px);
  padding-top: env(safe-area-inset-top, 0px);
  z-index: var(--z-sidebar);
  transform: translateX(-100%);
  transition: transform var(--duration-slow) var(--ease-ios);
  box-shadow: none;
  background: var(--bg-sidebar);
  border-right: var(--space-px) solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Don't let scrolling the channel list bounce-scroll the whole app. */
  overscroll-behavior: contain;
}

.sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-xl);
}

.sidebar-header {
  height: var(--topbar-height-mobile);
  padding: 0 var(--space-4);
  border-bottom: var(--space-px) solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  box-sizing: border-box;
}

.sidebar-header .logo {
  width: var(--space-8);
  height: var(--space-8);
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 700;
  font-size: var(--text-base);
  letter-spacing: var(--tracking-tight);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header h1 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  letter-spacing: var(--tracking-tight);
}

/* Sidebar search */
.sidebar-search {
  padding: var(--space-2) var(--space-3);
  position: relative;
}

.search-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-input);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  outline: none;
  transition: border-color var(--duration-normal) var(--ease-default);
}

.search-input:focus {
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-results {
  position: absolute;
  top: 100%;
  left: var(--space-3);
  right: var(--space-3);
  background: var(--bg-elevated);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-lg);
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: var(--z-overlay);
  box-shadow: var(--glass-highlight), var(--shadow-lg);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .search-results {
    background: var(--bg-glass-strong);
    -webkit-backdrop-filter: var(--blur-md);
    backdrop-filter: var(--blur-md);
  }
}

.search-result-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-bottom: var(--space-px) solid var(--border-light);
  transition: background var(--duration-fast) var(--ease-default);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-surface-hover);
}

.search-result-title {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-0-5);
}

.search-result-snippet {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}

.search-result-snippet mark {
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

.search-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.channel-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  padding: var(--space-3) var(--space-3) var(--space-1);
  margin-top: var(--space-1);
}

.channel-section-label:first-child {
  margin-top: 0;
}

.channel-item {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
  margin-bottom: var(--space-0-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-secondary);
  min-height: var(--space-10);
}

.channel-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.channel-item.active {
  background: var(--accent-subtle);
  color: var(--text);
  font-weight: 500;
}

.channel-item .channel-icon {
  font-size: var(--text-lg);
  width: var(--space-5);
  text-align: center;
  flex-shrink: 0;
}

.channel-item .channel-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
}

.channel-item .channel-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.channel-item .channel-delete {
  display: none;
  /* 44px min touch target per WCAG 2.5.5. Uses padding on a small icon so
     visual footprint stays tight while the hit area passes AA. */
  width: 44px;
  min-width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-lg);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  transition: all var(--duration-normal) var(--ease-default);
}

.channel-item:hover .channel-delete {
  display: flex;
  align-items: center;
  justify-content: center;
}

.channel-item:hover .channel-time {
  display: none;
}

.channel-item .channel-delete:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.sidebar-footer {
  padding: var(--space-3);
  padding-bottom: calc(env(safe-area-inset-bottom, var(--space-3)) + var(--space-1));
  border-top: var(--space-px) solid var(--border-light);
}

/* Sidebar overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-medium);
  z-index: var(--z-sidebar-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-ios);
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}


/* ==========================================================================
   4. Topbar — flat bg, icon buttons (40px touch targets)
   ========================================================================== */

.topbar {
  height: var(--topbar-height-mobile);
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: var(--z-sticky);
  /* Liquid-glass treatment: solid fallback first, then glass override where
     backdrop-filter is supported. The hairline border is replaced with a
     specular highlight that reads as "light hitting the top edge of glass". */
  background: var(--bg-glass-solid);
  border-bottom: var(--space-px) solid var(--border);
  box-shadow: var(--glass-highlight);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar {
    background: var(--bg-glass);
    -webkit-backdrop-filter: var(--blur-md);
    backdrop-filter: var(--blur-md);
    border-bottom-color: transparent;
  }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
}

.topbar-icon-btn {
  /* 44px touch target (was 40px — fat-fingered adjacent buttons on mobile). */
  width: 44px;
  height: 44px;
  /* Reset all browser-default button padding/line-height so the inner SVG
     centers exactly. Without this, <button> elements pick up a small UA
     padding that shifts the flex-centered icon by 1-2px versus the <a>
     elements that share the same class — visible as off-center icons. */
  padding: 0;
  margin: 0;
  line-height: 1;
  font: inherit;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-normal) var(--ease-default);
  text-decoration: none;
}

/* SVG inside an icon button should never inherit baseline/sizing weirdness. */
.topbar-icon-btn > svg {
  display: block;
  flex-shrink: 0;
}

.topbar-icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.topbar-icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.topbar-title {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  max-width: 140px;
}


/* ==========================================================================
   5. Main Content — flex column container
   ========================================================================== */

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}


/* ==========================================================================
   6. Chat Area — flex column, scrollable
   ========================================================================== */

.chat-area {
  flex: 1 1 auto;
  min-height: 0;  /* iOS: lets the flex child shrink when keyboard opens */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-0-5);
}


/* ==========================================================================
   7. Messages
   ========================================================================== */

.message {
  max-width: var(--message-max-width);
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  animation: fadeIn var(--duration-slow) var(--ease-default);
  transition: background var(--duration-normal) var(--ease-default);
  position: relative;
}

.message:hover {
  background: transparent;
}

.message-avatar {
  width: var(--space-8);
  height: var(--space-8);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  margin-top: var(--space-0-5);
  overflow: hidden;
}

.message.user .message-avatar {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: var(--space-px) solid var(--border);
}

.message.assistant .message-avatar {
  background: var(--accent);
  color: var(--text);
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-role {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-0-5);
  color: var(--text);
  letter-spacing: var(--tracking-normal);
}

.message.user .message-role {
  color: var(--text-secondary);
}

.message-text {
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  word-wrap: break-word;
  word-break: break-word;
  color: var(--text);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Smooth expand when streaming content loads (code blocks, tables, etc.) */
.message-text > * {
  animation: fadeIn var(--duration-slow) var(--ease-default);
}

.message-text pre,
.message-text table,
.message-text .tl-tool,
.message-text .code-header {
  animation: scaleIn var(--duration-slow) var(--ease-default);
  transform-origin: top left;
}

.message.user .message-text {
  color: var(--text-secondary);
}

.message-text p {
  margin-bottom: var(--space-2);
}

.message-text p:last-child {
  margin-bottom: 0;
}

.message-text pre {
  background: var(--bg-input);
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin: var(--space-3) 0;
  border: var(--space-px) solid var(--border);
}

.message-text code {
  background: var(--accent-subtle);
  color: var(--accent);
  padding: var(--space-0-5) var(--space-1-5);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
}

.message-text pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-weight: 400;
}

/* Grouped messages (Slack-style) */
.message.grouped {
  padding-top: var(--space-0-5);
  padding-bottom: var(--space-0-5);
}

.message.grouped .message-avatar {
  visibility: hidden;
}

.message.grouped .message-role {
  display: none;
}

/* .msg-copy-btn is defined in chat.css (single source of truth). */


/* ==========================================================================
   8. Input Area — mobile: border-top, safe-area bottom padding
   ========================================================================== */

.input-area {
  position: relative;
  padding: var(--space-1-5) var(--space-2) calc(env(safe-area-inset-bottom, var(--space-2)) + var(--space-1));
  flex-shrink: 0;
  background: var(--bg);
  border-top: var(--space-px) solid var(--border);
}

/* Composer: 2-row layout matching Claude Code's VS Code extension.
   Row 1 = textarea + voice mic. Row 2 = attach + slash + spacer + send.
   The container owns the rounded border and shadow; rows are transparent. */
.input-container {
  max-width: var(--input-max-width);
  margin: 0 auto;
  background: var(--bg-elevated);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-2) var(--space-2) var(--space-1);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default);
}

.input-container:focus-within {
  border-color: var(--border-hover);
  box-shadow: 0 0 0 var(--space-0-5) var(--accent-subtle), var(--shadow-sm);
}

.input-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.input-row-top {
  align-items: flex-end;
}

.input-spacer { flex: 1 1 auto; }

.input-container textarea {
  flex: 1;
  border: none;
  outline: none;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-md);  /* 15px reads cleaner in a 2-row composer */
  line-height: var(--leading-normal);
  resize: none;
  min-height: 28px;
  max-height: 200px;
  background: transparent;
  color: var(--text);
}

.input-container textarea::placeholder {
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/* All composer buttons share base layout. Variants below add color. */
.input-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default),
              transform var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  line-height: 1;
}

.input-btn > svg { display: block; flex-shrink: 0; }

.input-btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}
.input-btn-ghost:focus-visible {
  outline: none;
  background: var(--bg-surface-hover);
  color: var(--text);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Send button: square-rounded, accent-filled, with stop-icon swap when
   .is-streaming is set (so the same button doubles as a stop control). */
.input-btn-send {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  box-shadow: var(--glass-highlight, none);
}
.input-btn-send:hover {
  background: var(--accent-hover);
}
.input-btn-send:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.input-btn-send:disabled {
  background: var(--bg-surface-hover);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}
.input-btn-send .send-icon-stop { display: none; }
.input-btn-send.is-streaming .send-icon-arrow { display: none; }
.input-btn-send.is-streaming .send-icon-stop { display: block; }
.input-btn-send.is-streaming {
  background: var(--bg-surface);
  color: var(--text);
}
.input-btn-send.is-streaming:hover {
  background: var(--bg-surface-hover);
}

/* Legacy `.input-btn.send` selector (kept as alias in case any code path
   still toggles it). New code should prefer .input-btn-send. */
.input-btn.send {
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
}
.input-btn.send:hover {
  background: var(--accent-hover);
}

.input-btn.send:active {
  transform: scale(0.97);
}

.input-btn.send:disabled {
  background: var(--bg-surface-hover);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.input-btn.send.stop-mode {
  background: var(--danger);
}

.input-btn.send.stop-mode:hover {
  background: var(--danger-hover);
}

.input-btn.send.stop-mode svg {
  display: none;
}

.input-btn.send.stop-mode::after {
  content: "\25A0";
  font-size: var(--text-base);
}

.input-btn.voice-active {
  background: var(--danger);
  color: var(--text);
  animation: pulse var(--duration-spring) infinite;
}

.input-btn.voice-transcribing {
  background: var(--accent);
  color: var(--text-inverse);
  animation: breathe var(--duration-spring) infinite;
}

.input-btn.drag-cancel {
  background: var(--bg-surface);
  color: var(--text-muted);
  animation: none;
  opacity: 0.5;
}

/* Voice cancel hint (slide to cancel) */
.voice-cancel-hint {
  position: absolute;
  right: clamp(60px, 20vw, 100px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  font-size: var(--text-sm);
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity var(--duration-normal) var(--ease-default),
              color var(--duration-normal) var(--ease-default);
  pointer-events: none;
  white-space: nowrap;
}

.voice-cancel-hint.active {
  color: var(--danger);
  opacity: 1;
}

.voice-cancel-arrow {
  animation: slideArrow 1s ease-in-out infinite;
  font-size: var(--text-lg);
}

/* Voice recording timer */
.voice-rec-timer {
  position: absolute;
  left: var(--space-12);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--danger);
  pointer-events: none;
}

.voice-rec-timer::before {
  content: '';
  width: var(--space-2);
  height: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--danger);
  animation: recDot 1s ease-in-out infinite;
}

/* Chat attachments preview */
.chat-attachments-preview {
  max-width: var(--input-max-width);
  margin: 0 auto var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}


/* ==========================================================================
   9. Welcome Screen
   ========================================================================== */

.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  gap: var(--space-3);
}

.welcome .logo-large {
  width: var(--space-12);
  height: var(--space-12);
  background: var(--accent);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-1);
  letter-spacing: var(--tracking-tight);
  overflow: hidden;
}
.welcome .logo-large.emoji { font-size: 32px; }

.welcome h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: var(--tracking-tight);
}

.welcome p {
  color: var(--text-secondary);
  max-width: 380px;
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
}

.welcome-suggestions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  max-width: 520px;
}

.welcome-suggestion {
  padding: var(--space-3) var(--space-5);
  background: var(--bg-elevated);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
  white-space: nowrap;
  min-height: var(--space-10);
  display: flex;
  align-items: center;
}

.welcome-suggestion:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--bg-surface-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.welcome-suggestion:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.welcome-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.welcome-hint code {
  background: var(--accent-subtle);
  color: var(--accent);
  padding: var(--space-0-5) var(--space-1);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}


/* ==========================================================================
   10. Login Screen
   ========================================================================== */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  /* 100vh on iOS Safari with the URL bar visible overflows the card — use
     dvh so the viewport matches what the user can actually see. */
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}

.login-card {
  background: var(--bg-sidebar);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8) var(--space-6);
  width: 100%;
  max-width: 380px;
  text-align: center;
  animation: scaleIn var(--duration-slow) var(--ease-default);
}

.login-card .logo-large {
  width: var(--space-12);
  height: var(--space-12);
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0 auto var(--space-4);
  letter-spacing: var(--tracking-tight);
  overflow: hidden;
}

.login-card h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-1-5);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: var(--space-6);
  font-size: var(--text-base);
}

.login-card .error {
  background: var(--danger-subtle);
  color: var(--danger);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  display: none;
  border: var(--space-px) solid var(--danger-subtle);
}


/* ==========================================================================
   11. Setup Wizard
   ========================================================================== */

.setup-wizard {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}

.setup-card {
  background: var(--bg-sidebar);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  animation: scaleIn var(--duration-slow) var(--ease-default);
}

.setup-card-header {
  background: var(--accent-gradient);
  padding: var(--space-6) var(--space-8) var(--space-6);
  text-align: center;
  color: var(--text);
}

.setup-card-header .logo-large {
  width: var(--space-12);
  height: var(--space-12);
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0 auto var(--space-3);
  letter-spacing: var(--tracking-tight);
  overflow: hidden;
}

.setup-card-header h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0 0 var(--space-1);
  letter-spacing: var(--tracking-tight);
  color: #ffffff;  /* Pure white on orange header — crisper than --text (#ececec) */
}

.setup-card-header p {
  font-size: var(--text-base);
  color: rgba(255, 255, 255, 0.9);
  opacity: 1;
  margin: 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.setup-card-body {
  padding: var(--space-6) var(--space-8);
}

.setup-card h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0;
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

.setup-card p {
  font-size: var(--text-base);
  color: var(--text-secondary);
}

.setup-card .form-group {
  text-align: left;
}

/* ---- Click-to-copy chip used in the setup wizard ---- */
.setup-copy-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1-5) var(--space-3);
  margin-top: var(--space-1);
  background: var(--bg-input);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default);
}
.setup-copy-chip:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
}
.setup-copy-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.setup-copy-chip .setup-copy-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}
.setup-copy-chip .setup-copy-label {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
}
.setup-copy-chip.copied {
  background: var(--success-subtle);
  border-color: var(--success);
}
.setup-copy-chip.copied .setup-copy-icon,
.setup-copy-chip.copied .setup-copy-label {
  color: var(--success);
}


/* ==========================================================================
   12. Buttons
   ========================================================================== */

.btn {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: var(--space-px) solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  font-family: var(--font-body);
  letter-spacing: var(--tracking-normal);
  min-height: var(--space-10);
}

.btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: scale(0.97);
}

/* Keyboard-only focus ring — previously buttons had no visible focus at all. */
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.btn[aria-busy="true"] {
  opacity: 0.75;
  cursor: progress;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  border-color: transparent;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-gradient);
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(255, 107, 43, 0.35);
  opacity: 0.9;
}

.btn-danger {
  background: var(--danger);
  color: var(--text);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  min-height: var(--space-8);
}

.btn-ghost {
  border: none;
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.btn-block {
  width: 100%;
  justify-content: center;
}


/* ==========================================================================
   13. Forms
   ========================================================================== */

.form-group {
  margin-bottom: 0;
  padding: var(--space-3) 0;
  border-bottom: var(--space-px) solid var(--border-light);
}

.form-group:last-child {
  border-bottom: none;
}

.form-group label {
  display: block;
  font-size: var(--text-base);
  font-weight: 500;
  margin-bottom: var(--space-1-5);
  color: var(--text);
}

/* Inline checkbox row — overrides .form-group label's block layout so the
   checkbox sits next to its text instead of stacking + stretching full-width.
   Higher specificity via double class is deliberate. */
.form-group label.checkbox-label,
label.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 0;
  cursor: pointer;
  user-select: none;
}
/* Reset the full-width form-input styling when the input is a checkbox — the
   generic `.form-group input` rule paints padding/border/background across
   the whole width, which turns the checkbox into a stretched bar. */
.form-group input[type="checkbox"],
.checkbox-label input[type="checkbox"] {
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}
.checkbox-label span {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: var(--space-3);
  border: var(--space-px) solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg-input);
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              background-color var(--duration-fast) var(--ease-default);
}

.form-group input:hover:not(:focus),
.form-group select:hover:not(:focus),
.form-group textarea:hover:not(:focus) {
  border-color: var(--border-hover);
}

.form-group select {
  appearance: none;
  -webkit-appearance: none;
  /* Lighter chevron color matches the new --text-muted (#9a9a92). */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239a9a92' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  background-color: var(--bg-input);
  cursor: pointer;
}

.form-group select:hover:not(:focus) {
  background-color: var(--bg-surface);
}

.form-group select option {
  background: var(--bg-elevated);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 var(--space-0-5) var(--accent-subtle);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group .secret-input {
  -webkit-text-security: disc;
}

.textarea-mono {
  font-family: var(--font-mono) !important;
  font-size: var(--text-sm) !important;
}

.form-group .hint,
.settings-section > .hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1-5);
  padding: var(--space-1) var(--space-1) var(--space-2);
  line-height: var(--leading-normal);
}

.hint a {
  color: var(--accent);
  text-decoration: none;
}

.hint a:hover {
  text-decoration: underline;
}

.hint code {
  background: var(--accent-subtle);
  color: var(--accent);
  padding: var(--space-0-5) var(--space-1);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}


/* ==========================================================================
   14. Settings Page
   ========================================================================== */

/* Mobile: horizontal scrolling pill tabs on top */
.settings-page {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn var(--duration-slow) var(--ease-default);
}

.settings-page.open {
  display: flex;
}

.settings-tabs {
  width: 100%;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-bottom: var(--space-px) solid var(--border);
  padding: var(--space-2);
  display: flex;
  flex-direction: row;
  gap: var(--space-1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
  text-align: left;
  white-space: nowrap;
  min-height: var(--space-10);
}

.settings-tab:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.settings-tab.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

.settings-tab svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.settings-tab.active svg {
  opacity: 1;
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-4);
  min-width: 0;
  max-width: 700px;
  background: var(--bg);
}

/* Voice settings state classes */
#voiceEngineStatus { color: var(--text-muted); }
#voiceEngineStatus.active { color: var(--primary); }
.inactive { opacity: 0.6; }

.settings-content h2 {
  font-size: var(--text-3xl);
  font-weight: 700;
  margin-bottom: var(--space-5);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

.settings-tab-panel {
  display: none;
  width: 100%;
}

.settings-tab-panel.active {
  display: block;
}

.settings-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
}

/* Settings sections as cards */
.settings-section {
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-4);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: var(--tracking-normal);
  margin-bottom: var(--space-3);
}


/* ==========================================================================
   15. Delete Modal
   ========================================================================== */

.delete-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-heavy);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.delete-modal {
  background: var(--bg-elevated);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
  animation: scaleIn var(--duration-slow) var(--ease-default);
}

.delete-modal-header {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-3);
}

.delete-modal-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: var(--space-2) 0;
  line-height: var(--leading-normal);
}

.delete-modal-text strong {
  color: var(--text);
}

.delete-modal-input {
  width: 100%;
  padding: var(--space-3);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-body);
  margin: var(--space-3) 0 var(--space-4);
  outline: none;
  transition: border-color var(--duration-normal) var(--ease-default);
}

.delete-modal-input:focus {
  border-color: var(--danger);
}

.delete-modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* QR modal — flex-column centering for the QR canvas + URL.
   The qrcode library renders an SVG that's a block element, so
   text-align:center on the parent doesn't center it. We use flex on a
   dedicated holder + cap the SVG width so it can never push outside. */
.qr-modal {
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.qr-modal-header {
  width: 100%;
  text-align: center;
  margin-bottom: 0;
}

.qr-canvas-holder {
  width: 240px;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-canvas {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-canvas svg {
  width: 100%;
  height: auto;
  display: block;
}

.qr-modal-url {
  width: 100%;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  word-break: break-all;
  text-align: center;
  margin: 0;
}

.qr-modal .delete-modal-actions {
  width: 100%;
  justify-content: center;
}

.delete-modal-cancel {
  background: var(--bg-surface);
  border: var(--space-px) solid var(--border);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  transition: all var(--duration-normal) var(--ease-default);
  min-height: var(--space-10);
}

.delete-modal-cancel:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.delete-modal-confirm {
  background: var(--danger);
  border: none;
  color: var(--text);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-body);
  transition: all var(--duration-normal) var(--ease-default);
  min-height: var(--space-10);
}

.delete-modal-confirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.delete-modal-confirm:not(:disabled):hover {
  background: var(--danger-hover);
  box-shadow: var(--shadow-md);
}


/* ==========================================================================
   16. Toasts
   ========================================================================== */

.toast-container {
  position: fixed;
  top: var(--space-12);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  animation: slideIn var(--duration-slow) var(--ease-default);
  max-width: 340px;
  pointer-events: auto;
  line-height: var(--leading-normal);
  color: var(--text);
}

.toast.error  { border-left: var(--space-0-5) solid var(--danger);  background: var(--danger-subtle); }
.toast.success { border-left: var(--space-0-5) solid var(--success); background: var(--success-subtle); }
.toast.info    { border-left: var(--space-0-5) solid var(--info);    background: var(--info-subtle); }
.toast.removing {
  opacity: 0;
  transform: translateX(20px);
  transition: all var(--duration-fast) var(--ease-default);
}


/* ==========================================================================
   17. Save Status
   ========================================================================== */

.save-status {
  display: inline-block;
  font-size: var(--text-xs);
  margin-left: var(--space-1);
  color: var(--text-muted);
  transition: opacity var(--duration-normal) var(--ease-default);
}

.save-status.saving {
  color: var(--warning);
}

.save-status.saved {
  color: var(--success);
}


/* ==========================================================================
   18. Typing Indicator — 3 dots with staggered pulse
   ========================================================================== */

.typing-indicator {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1) 0;
}

.typing-indicator span {
  width: var(--space-1-5);
  height: var(--space-1-5);
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: streamPulse 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }


/* ==========================================================================
   19. Memory Items
   ========================================================================== */

.memories-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: var(--space-3);
}

.memory-project-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.memory-project-pill {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: var(--space-px) solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
}

.memory-project-pill:hover {
  background: var(--bg-surface-hover);
}

.memory-project-pill.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

.memory-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  background: transparent;
  border-radius: 0;
  margin-bottom: 0;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  transition: background var(--duration-normal) var(--ease-default);
  border: none;
  border-bottom: var(--space-px) solid var(--border-light);
}

.memory-item:hover {
  background: var(--bg-surface-hover);
}

.memory-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-normal);
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  flex-shrink: 0;
  margin-top: var(--space-px);
}

.memory-content {
  flex: 1;
  color: var(--text-secondary);
}

.memory-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-0-5);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-default);
  flex-shrink: 0;
}

.memory-item:hover .memory-delete {
  opacity: 1;
}

.memory-delete:hover {
  color: var(--danger);
  background: var(--danger-subtle);
}

.memory-test {
  background: none;
  border: var(--space-px) solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px var(--space-1);
  border-radius: var(--radius-sm);
  font-size: 11px;
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-default);
  flex-shrink: 0;
}

.memory-item:hover .memory-test {
  opacity: 1;
}

.memory-test:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.memory-test:disabled {
  opacity: 0.5;
  cursor: default;
}

.memory-folder + .memory-folder {
  border-top: var(--space-px) solid var(--border-light);
}

.memory-folder-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  cursor: pointer;
  user-select: none;
}

.memory-folder-header:hover {
  background: var(--bg-surface-hover);
}

.memory-folder-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--duration-normal) var(--ease-default);
}

.memory-folder-header.expanded .memory-folder-icon {
  transform: rotate(90deg);
}

.memory-folder-name {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-normal);
  color: var(--accent);
}

.memory-folder-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-surface-hover);
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-full);
}

.memory-folder-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-0-5);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-default);
  flex-shrink: 0;
}

.memory-folder-header:hover .memory-folder-delete {
  opacity: 1;
}

.memory-folder-delete:hover {
  color: var(--danger);
  background: var(--danger-subtle);
}

.memory-folder-items .memory-item {
  padding-left: var(--space-4);
}

.memory-folder-items .memory-item:last-child {
  border-bottom: none;
}


.approvals-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
  align-items: start;
}

.approvals-column {
  background: var(--bg-surface);
  border: var(--space-px) solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  min-height: 120px;
  max-height: 480px;
  display: flex;
  flex-direction: column;
}

.approvals-column-header {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-normal);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

.approvals-column-count {
  background: var(--bg-surface-hover);
  border-radius: var(--radius-full);
  padding: 0 var(--space-2);
}

.approvals-column-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

.approval-card {
  background: var(--bg-base);
  border: var(--space-px) solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.approval-card-title {
  font-weight: 600;
  color: var(--text-primary);
}

.approval-card-desc {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}

.approval-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.approvals-empty {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-style: italic;
}

.task-board-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-px);
}

.task-board-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: var(--space-px) solid var(--border-light);
  font-size: var(--text-sm);
}

.task-board-emoji {
  flex-shrink: 0;
}

.task-board-name {
  font-weight: 600;
  width: 120px;
  flex-shrink: 0;
}

.task-board-status {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.task-board-status-idle { background: var(--bg-surface-hover); color: var(--text-muted); }
.task-board-status-active { background: var(--success-subtle, var(--accent-subtle)); color: var(--success, var(--accent)); }
.task-board-status-working { background: var(--accent-subtle); color: var(--accent); }
.task-board-status-error { background: var(--danger-subtle); color: var(--danger); }

.connector-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.connector-status {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.connector-status.connected { background: var(--success-subtle); color: var(--success); }
.connector-status.disconnected { background: var(--bg-surface-hover); color: var(--text-muted); }

.connector-write-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  cursor: pointer;
}

.task-board-task {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-board-time {
  color: var(--text-muted);
  font-size: var(--text-xs);
  flex-shrink: 0;
}

/* ==========================================================================
   20. Skills
   ========================================================================== */

.skills-section-label {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  padding: var(--space-3) var(--space-1) var(--space-1-5);
}

.skills-section-label:first-child {
  padding-top: 0;
}

/* Skill cards — iOS grouped list style */
.skill-card {
  border: none;
  border-bottom: var(--space-px) solid var(--border-light);
  border-radius: 0;
  padding: var(--space-3) var(--space-4);
  margin-bottom: 0;
  transition: background var(--duration-normal) var(--ease-default);
  background: var(--bg-elevated);
}

.skills-section-label + .skill-card {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.skill-card:last-child,
.skill-card + .skills-section-label {
  border-bottom: none;
}

.skill-card:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.skills-section-label + .skill-card:last-child {
  border-radius: var(--radius-lg);
}

.skill-card:hover {
  background: var(--bg-surface-hover);
}

/* Skill dialog */
.skill-dialog {
  border: var(--space-px) solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-3);
  background: var(--bg);
}


/* ==========================================================================
   21. Clone Upload
   ========================================================================== */

.clone-upload {
  border: var(--space-0-5) dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
}

.clone-upload:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.clone-upload.dragover {
  border-color: var(--accent);
  background: var(--accent-subtle);
  transform: scale(1.01);
}


/* ==========================================================================
   22. Session Bar
   ========================================================================== */

.session-bar {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: var(--space-px) solid var(--border-light);
  background: var(--bg);
  flex-shrink: 0;
}

.session-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.session-bar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.session-model {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.session-status {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.context-bar {
  width: var(--space-12);
  height: var(--space-1);
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.context-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) var(--ease-default);
}

.context-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.badge-btn {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: var(--space-px) solid var(--border);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
  font-family: var(--font-body);
}

.badge-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}


/* ==========================================================================
   23. Avatar Image — reusable
   ========================================================================== */

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Voice active label (used in voice panel) */
.voice-active-label {
  position: absolute;
  top: var(--space-3);
  left: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
  opacity: 0.8;
}


/* ==========================================================================
   24. PIN Pad — iOS Lock Screen Style (mobile only)
   ========================================================================== */

.pin-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 340px;
  padding: var(--space-6) var(--space-4);
  gap: var(--space-4);
}

.pin-logo {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.pin-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: var(--tracking-tight);
}

.pin-error {
  font-size: var(--text-sm);
  color: var(--danger);
  min-height: 20px;
  text-align: center;
}

.pin-dots {
  display: flex;
  gap: var(--space-4);
  margin: var(--space-2) 0 var(--space-6);
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  border: 2px solid var(--text-secondary);
  background: transparent;
  transition: all var(--duration-normal) var(--ease-spring);
}

.pin-dot.filled {
  background: var(--text);
  border-color: var(--text);
  transform: scale(1.15);
}

.pin-dot.error {
  border-color: var(--danger);
  background: var(--danger);
  animation: pinShake 0.5s var(--ease-default);
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 80px);
  gap: var(--space-4);
  justify-content: center;
}

.pin-key {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-hover);
  background: var(--glass-subtle);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all var(--duration-fast) var(--ease-default);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pin-key:hover {
  background: var(--glass-soft);
}

.pin-key:active {
  background: var(--glass-medium);
  transform: scale(0.95);
}

.pin-key-empty {
  border: none;
  background: none;
  cursor: default;
}

.pin-key-empty:active {
  background: none;
  transform: none;
}

.pin-key-delete {
  border: none;
  background: none;
  color: var(--text-secondary);
}

.pin-key-delete:active {
  background: var(--glass-subtle);
  color: var(--text);
}

.pin-digit {
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.5px;
}

.pin-letters {
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Mobile-first: hide desktop elements, show mobile elements */
/* Mobile/desktop visibility utilities.
   Each element keeps its own natural display — these rules only HIDE,
   never force a display value. So a .desktop-only .topbar-icon-btn on
   desktop stays inline-flex (its own class), instead of being clobbered
   to block (which kills SVG flex centering inside the button). */
@media (max-width: 767px) {
  .desktop-only { display: none !important; }

  /* iOS auto-zooms any focused input with computed font-size < 16px, and
     ignores user-scalable=no since iOS 10. Bump every focusable control to
     16px on phone-sized viewports to stop the zoom-in-on-tap behavior.
     Desktop keeps the designed 13–15px sizes. */
  input,
  textarea,
  select,
  [contenteditable="true"] {
    font-size: 16px !important;
  }
}
@media (min-width: 768px) {
  .mobile-only { display: none !important; }
}

/* ==========================================================================
   25. Responsive — desktop overrides
   Breakpoint at 768px: iPad (all sizes) and larger get the static-sidebar
   layout. iPad Mini portrait (744px) and phones stay on the mobile drawer.
   Mobile rules use `max-width: 768px` (inclusive), so at exactly 768 the
   later desktop rules override via cascade order — intentional.
   ========================================================================== */

@media (min-width: 768px) {

  /* App layout → grid with sidebar */
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "sidebar content";
    height: 100vh;
    height: 100dvh;
    /* Keep safe area for iPad PWA — status bar still overlaps */
    padding-top: env(safe-area-inset-top, 0px);
  }

  /* Sidebar → static grid area */
  .sidebar {
    position: static;
    grid-area: sidebar;
    transform: none;
    max-width: none;
    padding-top: 0;
    z-index: auto;
    box-shadow: none;
  }

  .sidebar.open {
    box-shadow: none;
  }

  .sidebar-header {
    height: var(--topbar-height);
  }

  .sidebar-overlay {
    display: none;
  }

  /* (.mobile-only / .desktop-only display rules are media-scoped above and
     deliberately never set a display value on .desktop-only on desktop —
     so the element keeps whatever display its own class declares.
     See the comment at the top of the file's visibility utilities.) */

  /* Main content → grid area */
  .main {
    grid-area: content;
  }

  /* Topbar */
  .topbar {
    height: var(--topbar-height);
    padding: 0 var(--space-5);
  }

  .topbar-title {
    max-width: none;
  }

  /* Chat area — desktop padding */
  .chat-area {
    padding: var(--space-6) var(--space-6) var(--space-2);
  }

  /* Messages — larger avatars on desktop */
  .message {
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
  }

  .message-avatar {
    width: 36px;
    height: 36px;
  }

  .message-role {
    font-size: var(--text-sm);
  }

  .message-text {
    font-size: var(--text-md);
    line-height: var(--leading-relaxed);
  }

  /* Input area — desktop: gradient bg, no border-top */
  .input-area {
    padding: var(--space-3) var(--space-6) calc(env(safe-area-inset-bottom, var(--space-5)) + var(--space-2));
    background: linear-gradient(to top, var(--bg) 60%, transparent);
    border-top: none;
  }

  .input-container textarea {
    font-size: var(--text-md);
    padding: var(--space-3);
  }

  /* Welcome — row layout for suggestions */
  .welcome h2 {
    font-size: var(--text-2xl);
  }

  .welcome-suggestions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Settings — desktop: vertical sidebar tabs */
  .settings-page {
    flex-direction: row;
  }

  .settings-tabs {
    width: var(--settings-sidebar-width);
    flex-direction: column;
    overflow-x: visible;
    border-bottom: none;
    border-right: var(--space-px) solid var(--border);
    padding: var(--space-4) var(--space-2);
    gap: var(--space-0-5);
  }

  .settings-tab {
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
  }

  .settings-content {
    padding: var(--space-6) var(--space-8) var(--space-10);
  }

  /* Login card */
  .login-card {
    padding: var(--space-10) var(--space-8);
  }
}

/* ==========================================================================
   26. iPad / tablet tweaks (768px – 1024px)
   Narrower sidebar and tighter padding so iPad portrait (768-834px)
   doesn't feel cramped when both sidebar and chat share the viewport.
   ========================================================================== */

@media (min-width: 768px) and (max-width: 1024px) {

  :root {
    --sidebar-width: 220px;
    /* Give the settings tab column a touch more room on iPad so the labels
       don't truncate — desktop uses 180px but iPad has less horizontal real
       estate once the main sidebar and content padding are subtracted. */
    --settings-sidebar-width: 200px;
  }

  .chat-area {
    padding: var(--space-4) var(--space-4) var(--space-2);
  }

  .input-area {
    padding: var(--space-3) var(--space-4) calc(env(safe-area-inset-bottom, var(--space-5)) + var(--space-2));
  }

  .settings-content {
    padding: var(--space-4) var(--space-6) var(--space-8);
  }

  /* Voice panel sized between mobile and full desktop so the orb doesn't
     dominate iPad portrait. */
  .voice-orb {
    width: 112px;
    height: 112px;
  }
}

/* ==========================================================================
   Settings Active State
   ========================================================================== */
.settings-active { color: var(--accent) !important; }

/* Token usage chart */
.usage-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.usage-stat {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}

.usage-stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

.usage-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-top: var(--space-0-5);
}

.usage-chart-container {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.usage-chart-container canvas {
  width: 100%;
  height: 200px;
}

.usage-models {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-2);
}

.usage-model-card {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-0-5);
}

.usage-model-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text);
  text-transform: capitalize;
}

.usage-model-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.usage-agents-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin: var(--space-4) 0 var(--space-2);
  color: var(--text-secondary);
}

.usage-agents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.usage-agents-table th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-normal);
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--space-px) solid var(--border-light);
}

.usage-agents-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--space-px) solid var(--border-light);
  color: var(--text-secondary);
}

.usage-agents-table td:first-child {
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

/* Audit log */
.audit-log-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 500px;
  overflow-y: auto;
}

.audit-entry {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  align-items: center;
}

.audit-entry-time {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.audit-entry-action {
  color: var(--text);
  font-weight: 600;
}

.audit-entry-action.auth { color: var(--warning); }
.audit-entry-action.tool { color: var(--info); }
.audit-entry-action.setting { color: var(--accent); }

.audit-entry-detail {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

@media (max-width: 768px) {
  .audit-entry {
    grid-template-columns: 1fr;
    gap: var(--space-0-5);
  }
  .audit-entry-detail {
    text-align: left;
    max-width: none;
  }
}


/* ==========================================================================
   Audit-remediation additions: offline banner, keyboard overlay, skeletons,
   empty states, context gauge, code copy feedback, sidebar scroll fade.
   ========================================================================== */

/* ---- Keyboard shortcut overlay (triggered by `?` key) ---- */
.kbd-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--overlay-dense);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn var(--duration-normal) var(--ease-default);
}
.kbd-overlay-panel {
  background: var(--bg-elevated);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-6);
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: scaleIn var(--duration-normal) var(--ease-spring);
}
.kbd-overlay-panel h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-4);
  color: var(--text);
}
.kbd-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  margin-bottom: var(--space-4);
}
.kbd-group-title {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-top: var(--space-2);
}
.kbd-label {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
.kbd-keys {
  display: inline-flex;
  gap: var(--space-1);
}
.kbd-key {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--bg-input);
  border: var(--space-px) solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  color: var(--text);
  min-width: 24px;
  text-align: center;
}

/* ---- Skeleton loader ---- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface) 0%,
    var(--bg-surface-hover) 50%,
    var(--bg-surface) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line { height: 12px; margin-bottom: var(--space-2); }
.skeleton-line.short { width: 45%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long { width: 92%; }
.skeleton-block { height: 64px; margin-bottom: var(--space-2); border-radius: var(--radius-md); }

/* ---- Empty state ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  font-size: var(--text-xl);
}
.empty-state-title {
  color: var(--text);
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.empty-state-text {
  font-size: var(--text-sm);
  max-width: 320px;
  line-height: var(--leading-relaxed);
}

/* ---- Code block copy feedback (success flash) ---- */
.copy-success {
  background: var(--success-subtle) !important;
  color: var(--success) !important;
  border-color: var(--success) !important;
  transition: all var(--duration-normal) var(--ease-default);
}

/* ---- Sidebar bottom scroll fade hint ---- */
.channel-list {
  position: relative;
}
.channel-list-scroll-fade {
  position: sticky;
  bottom: 0;
  height: 24px;
  margin-top: -24px;
  background: linear-gradient(to bottom, transparent, var(--bg-sidebar));
  pointer-events: none;
}

/* ---- Voice orb listening glow (was plain) ---- */
.voice-orb.listening {
  filter: drop-shadow(0 0 12px var(--accent-glow));
}

/* ---- Context bar — warn color at >80% ---- */
.context-bar-fill.warn { background: var(--warning); }
.context-bar-fill.danger { background: var(--danger); }

/* ---- save-status error variant (was only saving/saved) ---- */
.save-status.error {
  color: var(--danger);
}

/* ---- Lightbox tokenized (was hardcoded white) ---- */
.lightbox-frame,
.lightbox-sheet {
  background: var(--bg-elevated);
  color: var(--text);
}


/* ==========================================================================
   Audit round 2: Mobile + iPad polish (2026-04-21)
   ========================================================================== */

/* ---- Prevent accidental pull-to-refresh / rubber-banding on iOS ---- */
.chat-area,
.console-panel,
.sidebar,
.settings-content,
.voice-conversation {
  overscroll-behavior: contain;
}
html, body {
  /* Page itself shouldn't bounce — individual scroll regions handle it. */
  overscroll-behavior-y: none;
}

/* Keyboard positioning is handled by --app-height (see .app rule above):
   the flex container shrinks, pushing .input-area up naturally. Only keep
   a small scroll-padding so the newest message isn't tucked under the
   composer when the keyboard is open. */
html.keyboard-open .chat-area {
  scroll-padding-bottom: var(--space-4);
}

/* ---- Short landscape viewports (phones rotated) ---- */
@media (max-height: 600px) and (orientation: landscape) {
  /* PIN pad: shrink the grid so it fits without scrolling. */
  .pin-grid {
    grid-template-columns: repeat(3, 56px);
    gap: var(--space-2);
  }
  .pin-key {
    width: 56px;
    height: 56px;
  }
  .pin-digit {
    font-size: 22px;
  }
  .pin-letters {
    display: none;
  }
  .pin-dots {
    margin-bottom: var(--space-2);
  }
  .pin-title {
    font-size: var(--text-lg);
    margin-bottom: var(--space-2);
  }

  /* Welcome: kill the big hero so suggestions + composer fit. */
  .welcome .logo-large {
    width: 40px;
    height: 40px;
    margin-bottom: var(--space-2);
  }
  .welcome h2 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-1);
  }
  .welcome p {
    font-size: var(--text-sm);
    margin-bottom: var(--space-3);
  }
  .welcome-hint {
    display: none;
  }

  /* Chat padding collapses so the tail of the conversation is visible. */
  .chat-area {
    padding: var(--space-2) var(--space-3);
  }
}

/* ---- Tiny phones (≤360px) ---- */
@media (max-width: 360px) {
  :root {
    --sidebar-width: 240px;
  }
  .topbar {
    padding: 0 var(--space-2);
  }
  .topbar-right {
    gap: var(--space-1);
  }
}


/* ==========================================================================
   iOS 26 "Liquid Glass" treatments (mobile + iPad)
   Desktop keeps the warm-charcoal solid look; small screens get the glass
   sidebar drawer, floating composer, and specular highlights that iOS 26
   apps use. Everything wrapped in @supports so the solid fallback is safe.
   ========================================================================== */

.glass-highlight {
  box-shadow: var(--glass-highlight), var(--shadow-md);
}

/* Voice orb: subtle specular rim so the "listening/speaking" pulse reads
   as light on glass rather than a flat color blob. */
.voice-orb {
  box-shadow: var(--glass-highlight-strong);
}

/* Primary button: same light-on-edge treatment — separates it from ghost. */
.btn-primary {
  box-shadow: var(--glass-highlight), var(--shadow-sm);
}
.btn-primary:hover {
  box-shadow: var(--glass-highlight-strong), var(--shadow-md);
}

/* Mobile & iPad-portrait glass drawer + floating composer.
   Scope to max-width: 1024px so iPad lands in the glass treatment too. */
@media (max-width: 1024px) {

  /* Sidebar drawer (mobile only — desktop static sidebar stays solid). */
  @media (max-width: 767px) {
    .sidebar {
      background: var(--bg-glass-solid);
      border-right-color: transparent;
      box-shadow: var(--glass-highlight);
    }
    @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
      .sidebar {
        background: var(--bg-glass-sidebar);
        -webkit-backdrop-filter: var(--blur-lg);
        backdrop-filter: var(--blur-lg);
      }
      .sidebar.open {
        /* Drop the hard shadow + specular highlight when open so the glass
           edge catches the light against the darkened main content. */
        box-shadow: var(--glass-highlight-strong), var(--shadow-xl);
      }
    }

    /* Floating composer: the single biggest iOS-native polish lever. */
    .input-area {
      background: transparent;
      border-top: none;
      padding: 0 var(--space-2) calc(env(safe-area-inset-bottom, var(--space-2)) + var(--space-2));
    }
    .input-container {
      border-radius: var(--radius-2xl);
      background: var(--bg-glass-solid);
      border-color: transparent;
      box-shadow: var(--glass-highlight), 0 8px 24px rgba(0, 0, 0, 0.35);
    }
    @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
      .input-container {
        background: var(--bg-glass-surface);
        -webkit-backdrop-filter: var(--blur-md);
        backdrop-filter: var(--blur-md);
      }
    }
    .input-container:focus-within {
      box-shadow: var(--glass-highlight-strong),
                  0 0 0 2px var(--accent-subtle),
                  0 8px 24px rgba(0, 0, 0, 0.4);
    }
    /* Reserve bottom space in the chat so the last message isn't tucked
       behind the floating composer. */
    .chat-area {
      padding-bottom: var(--space-3);
    }

    /* Session bar on mobile — matches the glass composer aesthetic */
    .session-bar {
      border-bottom: none;
      box-shadow: var(--glass-highlight);
    }
  }

  /* Modals, lightbox, voice panel get softer rounded corners on small
     screens — not full glass (text on these needs max contrast) but
     concentric with the floating composer. */
  .delete-modal,
  .kbd-overlay-panel {
    border-radius: var(--radius-2xl);
    box-shadow: var(--glass-highlight), var(--shadow-xl);
  }

  .voice-panel {
    border-radius: 0;  /* full-screen, but content inside gets soft radii */
  }

  .lightbox-img,
  .lightbox-frame,
  .lightbox-sheet {
    border-radius: var(--radius-2xl);
  }
}

/* Even on desktop, the command palette + modals benefit from the concentric
   radius bump the tokens already gave them. Specular highlight on modals
   adds depth without changing the base aesthetic. */
.delete-modal-overlay .delete-modal,
.kbd-overlay-panel {
  box-shadow: var(--glass-highlight), var(--shadow-xl);
}

.command-palette {
  box-shadow: var(--glass-highlight), var(--shadow-lg);
}


/* ==========================================================================
   Custom <select> replacement (custom-select.js auto-enhances every <select>)
   Native dropdowns can't be styled past their trigger — the popup is OS
   chrome. These styles replace the trigger and a body-attached panel that
   matches the command palette aesthetic.
   ========================================================================== */

/* Hide the native <select> visually but keep it focusable for forms / a11y. */
.cs-native-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border-width: 0 !important;
  pointer-events: none !important;
}

.cs-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.cs-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3);
  border: var(--space-px) solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-body);
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--duration-fast) var(--ease-default),
              background var(--duration-fast) var(--ease-default);
}

.cs-trigger:hover:not([disabled]) {
  background: var(--bg-surface);
  border-color: var(--border-hover);
}

.cs-trigger:focus-visible,
.cs-trigger.is-open {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 var(--space-0-5) var(--accent-subtle);
}

.cs-trigger[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.cs-trigger-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-trigger-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-default);
}

.cs-trigger.is-open .cs-trigger-chevron {
  transform: rotate(180deg);
}

/* Popup panel — body-attached so overflow:hidden ancestors don't clip it.
   Uses the same glass + section grammar as the command palette. */
.cs-panel {
  position: fixed;
  z-index: var(--z-modal);
  background: var(--bg-elevated);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-highlight, none), var(--shadow-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-1) 0;
  animation: paletteIn var(--duration-fast) var(--ease-default);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .cs-panel {
    background: var(--bg-glass-strong);
    -webkit-backdrop-filter: var(--blur-md);
    backdrop-filter: var(--blur-md);
  }
}

.cs-group-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3) var(--space-1);
}
.cs-group-title:not(:first-child) {
  border-top: var(--space-px) solid var(--border-light);
  margin-top: var(--space-1);
  padding-top: var(--space-3);
}

.cs-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background var(--duration-fast) var(--ease-default);
}

.cs-item.is-active,
.cs-item:hover:not(.is-disabled) {
  background: var(--bg-surface-hover);
}

.cs-item.is-selected {
  color: var(--accent);
  font-weight: 500;
}

.cs-item.is-disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.cs-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-item-check {
  flex-shrink: 0;
  color: var(--accent);
}

/* Mobile: items get a touch more padding so they're tappable. */
@media (max-width: 768px) {
  .cs-item { padding: var(--space-3); font-size: var(--text-base); }
  .cs-panel { max-height: 60vh !important; }
}


/* ==========================================================================
   Mobile composer — collapse 2-row Claude Code layout to single row.
   Phones expect the iOS Messages pattern: [+] [textarea] [mic] [send]
   in one compact row. The desktop 2-row split (textarea/voice on top,
   attach/slash/spacer/send underneath) wastes vertical space on a phone
   where the keyboard already eats half the screen.

   We use display:contents on .input-row to dissolve the row wrappers so
   all 6 children flow into .input-container directly, then reorder via
   `order:` and hide the bits that don't belong on mobile.
   ========================================================================== */
@media (max-width: 767px) {
  .input-container {
    flex-direction: row;
    align-items: flex-end;
    gap: var(--space-1);
    padding: var(--space-1-5);
  }
  .input-row {
    display: contents;
  }

  /* Keep the textarea between the leading + and trailing mic/send.
     Without explicit order, the .input-row-bottom children would render
     after the textarea (DOM order). */
  #attachBtn      { order: 1; }
  #messageInput   { order: 2; }
  #voiceInputBtn  { order: 3; }
  #sendBtn        { order: 4; }

  /* Slash / + spacer don't belong in the single-row mobile layout.
     Slash menu is still reachable: type "/" in the textarea. */
  #slashBtn,
  .input-spacer {
    display: none;
  }

  /* Compact textarea so the row stays one-line tall when empty. */
  .input-container textarea {
    padding: var(--space-2) var(--space-2);
    font-size: var(--text-md);
    min-height: 32px;
  }

  /* Shrink the trailing buttons so the textarea has more room. */
  .input-btn {
    width: 36px;
    height: 36px;
  }
  .input-btn-send {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);  /* round send button on mobile feels iOS-native */
  }
}


/* ==========================================================================
   Effort slider panel — segmented control for thinking effort.
   Appears on long-press / keyboard-activation of the .effort-toggle or
   on `/effort` with no arg. Body-attached overlay so it never gets
   clipped by session-bar overflow.
   ========================================================================== */
.effort-slider-panel {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--overlay-medium);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-default);
}
.effort-slider-panel.is-open {
  display: flex;
  opacity: 1;
}
@media (min-width: 768px) {
  .effort-slider-panel {
    align-items: center;
  }
}

.effort-slider-card {
  background: var(--bg-elevated);
  border: var(--space-px) solid var(--border);
  border-radius: var(--radius-2xl);
  padding: var(--space-4);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--glass-highlight), var(--shadow-xl);
  transform: translateY(100%);
  transition: transform var(--duration-normal) var(--ease-ios);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .effort-slider-card {
    background: var(--bg-glass-strong);
    -webkit-backdrop-filter: var(--blur-md);
    backdrop-filter: var(--blur-md);
  }
}
.effort-slider-panel.is-open .effort-slider-card {
  transform: translateY(0);
}
@media (min-width: 768px) {
  .effort-slider-card { transform: scale(0.96); }
  .effort-slider-panel.is-open .effort-slider-card { transform: scale(1); }
}

.effort-slider-title {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-3);
  text-align: center;
}

.effort-slider-track {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-1);
  background: var(--bg-surface);
  padding: var(--space-1);
  border-radius: var(--radius-xl);
}

.effort-seg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-0-5);
  padding: var(--space-2) var(--space-1);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  min-height: 56px;
  transition: background var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default);
}

.effort-seg:hover,
.effort-seg:focus-visible {
  outline: none;
  color: var(--text);
  background: var(--bg-surface-hover);
}

.effort-seg.is-active {
  background: var(--accent);
  color: var(--text-inverse);
  box-shadow: var(--glass-highlight);
}

.effort-seg-icon {
  font-size: var(--text-xl);
  line-height: 1;
}

.effort-seg-label {
  font-weight: 500;
  white-space: nowrap;
}

.effort-slider-hint {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.3em;
}

/* Very narrow phones: drop labels, keep icons only. */
@media (max-width: 400px) {
  .effort-seg-label { display: none; }
  .effort-seg { min-height: 44px; }
}


/* ==========================================================================
   Theme preview grid (Settings > Appearance, below the <select>).
   Optional visual preview tiles — mostly aspirational here; if you want
   live thumbnails wire them in later.
   ========================================================================== */
.theme-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}
