/* ═══ Safari / Mobile Viewport Safety ═══ */
/* Uses a JS-set --app-height (most reliable for standalone/PWA on iOS),
   falls back to 100dvh then 100vh. */
:root {
  --app-height: 100vh;
}
.h-dvh-safe {
  height: 100vh;
  height: 100dvh;
  height: var(--app-height);
}

/* Main content offset — matches header height (which includes safe-area-inset-top via max()) */
#main-content {
  padding-top: calc(56px + max(env(safe-area-inset-top, 0px), 12px)) !important;
}

/* Safe area padding for devices with notch/home indicator (iPhone X+).
   Uses !important so it adds on top of Tailwind utility pb-* values. */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .pb-safe {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom)) !important;
  }
}

/* Sleek Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 10px; }
.dark ::-webkit-scrollbar-thumb { background: #444746; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }
.dark ::-webkit-scrollbar-thumb:hover { background: #c4c7c5; }

textarea::-webkit-scrollbar { width: 0px; }
textarea:focus::-webkit-scrollbar { width: 6px; }

.dropdown-enter { opacity: 0; transform: scale(0.98) translateY(-5px); }
.dropdown-enter-active { opacity: 1; transform: scale(1) translateY(0); transition: opacity 150ms ease-out, transform 150ms ease-out; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Welcome → Chat smooth transition */
#welcome-screen {
  transition: opacity 0.4s ease, transform 0.4s ease;
}
#welcome-screen.fade-out {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(1rem); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-toast { animation: slideUpFade 0.3s ease-out forwards; }

/* Custom Toggle Switch */
input:checked ~ .toggle-bg { background-color: #3b82f6; }
.dark input:checked ~ .toggle-bg { background-color: #a8c7fa; }
input:checked ~ .toggle-dot { transform: translateX(100%); }

/* Model info tooltip — shown on hover of the ⓘ icon next to model names */
.model-tooltip-wrap { display: inline-flex; align-items: center; }
.model-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.5;
  color: #e3e3e3;
  background: #1e1f20;
  border: 1px solid #333;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 100;
  pointer-events: none;
  animation: tooltipFadeIn 0.15s ease-out;
}
.model-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e1f20;
}
.model-tooltip-wrap:hover .model-tooltip { display: block; }

/* Light mode tooltip */
:root:not(.dark) .model-tooltip {
  color: #374151;
  background: #fff;
  border-color: #e5e7eb;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
:root:not(.dark) .model-tooltip::after { border-top-color: #fff; }

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Loading skeleton — typewriter text */
.loader-hello {
    position: relative;
    display: inline;
    transition: opacity 0.4s ease;
}

.loader-hello::before {
    content: "";
    position: absolute;
    right: -4px;
    top: 8%;
    height: 80%;
    border-right: 3px solid #9b72cb;
    animation: blink-cursor 0.7s step-end infinite;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Hide default details marker */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

:root {
  --mindpal-user-bubble-bg: #f0f4f9;
  --mindpal-user-bubble-text: #1f1f1f;
}

:root[data-accent="orange"] {
  --mindpal-user-bubble-bg: #fff1e8;
  --mindpal-user-bubble-text: #7c2d12;
}

:root[data-accent="green"] {
  --mindpal-user-bubble-bg: #eaf8ef;
  --mindpal-user-bubble-text: #14532d;
}

.dark {
  --mindpal-user-bubble-bg: #1e1f20;
  --mindpal-user-bubble-text: #e3e3e3;
}

.dark[data-accent="orange"] {
  --mindpal-user-bubble-bg: #3a2418;
  --mindpal-user-bubble-text: #fed7aa;
}

.dark[data-accent="green"] {
  --mindpal-user-bubble-bg: #163023;
  --mindpal-user-bubble-text: #bbf7d0;
}

[data-contrast="high"] {
  --mindpal-user-bubble-bg: #111827;
  --mindpal-user-bubble-text: #ffffff;
}

.chat-user-bubble {
  background: var(--mindpal-user-bubble-bg) !important;
  color: var(--mindpal-user-bubble-text) !important;
}

/* Shimmer text for AI loading state */
.shimmer-text {
    background: linear-gradient(90deg, #4285f4 0%, #9b72cb 50%, #4285f4 100%);
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: shimmer 2s linear infinite;
}
.dark .shimmer-text {
    background: linear-gradient(90deg, #a8c7fa 0%, #d3bcfa 50%, #a8c7fa 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
}
@keyframes shimmer { to { background-position: 200% center; } }

/* Voice Recording Pulse */
@keyframes pulse-ring {
    0% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.recording-pulse {
    animation: pulse-ring 2s infinite;
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444 !important;
}

/* MindPal design tokens extracted from the prototype Tailwind config. */
.bg-gemini-bg { background-color: #ffffff; }
.bg-gemini-surface { background-color: #f0f4f9; }
.text-gemini-text { color: #1f1f1f; }
.text-gemini-muted { color: #444746; }
.border-gemini-border { border-color: #e0e0e0; }
.hover\:bg-gemini-surface:hover { background-color: #f0f4f9; }

.dark .dark\:bg-gemini-darkBg { background-color: #131314; }
.dark .dark\:bg-gemini-darkSurface { background-color: #1e1f20; }
.dark .dark\:text-gemini-darkText { color: #e3e3e3; }
.dark .dark\:text-gemini-darkMuted { color: #c4c7c5; }
.dark .dark\:border-gemini-darkBorder { border-color: #444746; }
.dark .dark\:hover\:bg-gemini-darkSurface:hover { background-color: #1e1f20; }

/* MindPal custom utility fallbacks.
   These preserve the prototype colors if Tailwind CDN config is delayed. */

.bg-gemini-bg { background-color: #ffffff; }
.bg-gemini-surface { background-color: #f0f4f9; }
.text-gemini-text { color: #1f1f1f; }
/* Shimmer text for AI loading state */
.shimmer-text {
    background: linear-gradient(90deg, #4285f4 0%, #9b72cb 50%, #4285f4 100%);
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: shimmer 2s linear infinite;
}
.dark .shimmer-text {
    background: linear-gradient(90deg, #a8c7fa 0%, #d3bcfa 50%, #a8c7fa 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
}
@keyframes shimmer { to { background-position: 200% center; } }

/* Voice Recording Pulse */
@keyframes pulse-ring {
    0% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.recording-pulse {
    animation: pulse-ring 2s infinite;
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444 !important;
}

/* MindPal design tokens extracted from the prototype Tailwind config. */
.bg-gemini-bg { background-color: #ffffff; }
.bg-gemini-surface { background-color: #f0f4f9; }
.text-gemini-text { color: #1f1f1f; }
.text-gemini-muted { color: #444746; }
.border-gemini-border { border-color: #e0e0e0; }
.hover\:bg-gemini-surface:hover { background-color: #f0f4f9; }

.dark .dark\:bg-gemini-darkBg { background-color: #131314; }
.dark .dark\:bg-gemini-darkSurface { background-color: #1e1f20; }
.dark .dark\:text-gemini-darkText { color: #e3e3e3; }
.dark .dark\:text-gemini-darkMuted { color: #c4c7c5; }
.dark .dark\:border-gemini-darkBorder { border-color: #444746; }
.dark .dark\:hover\:bg-gemini-darkSurface:hover { background-color: #1e1f20; }

/* MindPal custom utility fallbacks.
   These preserve the prototype colors if Tailwind CDN config is delayed. */

.bg-gemini-bg { background-color: #ffffff; }
.bg-gemini-surface { background-color: #f0f4f9; }
.text-gemini-text { color: #1f1f1f; }
.text-gemini-muted { color: #444746; }
.border-gemini-border { border-color: #e0e0e0; }

.dark .dark\:bg-gemini-darkBg { background-color: #131314; }
.dark .dark\:bg-gemini-darkSurface { background-color: #1e1f20; }
.dark .dark\:text-gemini-darkText { color: #e3e3e3; }
.dark .dark\:text-gemini-darkMuted { color: #c4c7c5; }
.dark .dark\:border-gemini-darkBorder { border-color: #444746; }

.hover\:bg-gemini-surface:hover { background-color: #f0f4f9; }
.dark .dark\:hover\:bg-gemini-darkSurface:hover { background-color: #1e1f20; }

/* Message content box padding for proper spacing on all screen sizes */
.content-box {
  padding-right: 8px;
}

@media (max-width: 640px) {
  .content-box {
    padding-right: 4px;
  }
}

/* ── Code blocks & inline code ── */
.code-block-wrap {
  position: relative;
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #1e1f20;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.code-lang-label {
  display: inline-block;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  width: 100%;
}

.code-block {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e5e7eb;
  white-space: pre;
  tab-size: 2;
}

.code-block code {
  font-family: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
}

.inline-code {
  padding: 2px 6px;
  border-radius: 6px;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.06);
  color: #1f2937;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.dark .inline-code {
  background: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.1);
}

/* Settings modal */
#profile-content {
  width: min(860px, calc(100vw - 24px));
  height: min(760px, calc(100vh - 32px));
  height: min(760px, calc(100dvh - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  background: #fbfcfe;
}

.settings-panel-scroll {
  min-height: 0;
  background: #fbfcfe;
}

.settings-sidebar {
  min-height: 0;
  background: #f4f5f7;
  border-right: 1px solid rgba(31, 41, 55, 0.08);
}

.settings-tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 12px;
  color: #425466;
  text-align: left;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.settings-tab-btn:hover,
.settings-tab-btn.active {
  background: #e7e9ed;
  color: #111827;
  box-shadow: none;
}

.settings-tab-btn:hover {
  transform: translateX(1px);
}

.dark .settings-tab-btn {
  color: #cbd5e1;
}

.dark .settings-tab-btn:hover,
.dark .settings-tab-btn.active {
  background: #2f2f2f;
  color: #ffffff;
  box-shadow: none;
}

.settings-panel {
  display: none;
}

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

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

.settings-title {
  font-size: 20px;
  line-height: 30px;
  font-weight: 650;
  color: #102033;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.dark .settings-title {
  color: #ffffff;
  border-bottom-color: #303030;
}

.settings-section {
  display: flex;
  flex-direction: column;
  padding-top: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 15px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.dark .settings-row {
  border-bottom-color: #303030;
}
.settings-row:last-child {
  border-bottom: none;
}
.settings-row-block {
  border-bottom: none;
}

.settings-row-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.settings-row-title {
  font-size: 14px;
  line-height: 20px;
  font-weight: 620;
  color: #172033;
}

.dark .settings-row-title {
  color: #ffffff;
}

.settings-row-copy {
  max-width: 420px;
  font-size: 12px;
  line-height: 17px;
  color: #6b7280;
}

.dark .settings-row-copy {
  color: #b8b8b8;
}

.settings-row-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 14px;
  color: #111827;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.settings-row-action:hover,
.settings-row-action:focus-visible {
  background: #f3f4f6;
  outline: none;
}

.dark .settings-row-action {
  color: #ffffff;
}

.dark .settings-row-action:hover,
.dark .settings-row-action:focus-visible {
  background: #303030;
}

.settings-select {
  max-width: 230px;
  background: transparent;
  color: #111827;
  border: 0;
  outline: 0;
  font-size: 14px;
  text-align: right;
}

.settings-select-wrap,
.settings-choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  flex: none;
}

.settings-choice-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: 260px;
  background: #ffffff;
  color: #172033;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  outline: 0;
  padding: 7px 10px 7px 12px;
  font-size: 14px;
  font-weight: 580;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.settings-choice-label {
  min-width: 0;
}

.settings-choice-wide {
  min-width: 190px;
}

.settings-choice-trigger:hover,
.settings-choice-trigger:focus-visible,
.settings-choice.open .settings-choice-trigger {
  border-color: rgba(15, 23, 42, 0.24);
  background: #f8fafc;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.settings-choice-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  display: none;
  min-width: 190px;
  padding: 6px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
}

.settings-choice.open .settings-choice-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-choice-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  color: #26364a;
  background: transparent;
  font-size: 14px;
  font-weight: 560;
  text-align: left;
  cursor: pointer;
}

.settings-choice-option:hover,
.settings-choice-option:focus-visible,
.settings-choice-option.active {
  background: #f1f3f5;
  color: #111827;
  outline: none;
}

.dark #profile-content {
  background: #181b1f;
}

.dark .settings-panel-scroll {
  background: #181b1f;
}

.dark .settings-sidebar {
  background: #1f1f1f;
  border-right-color: rgba(255, 255, 255, 0.08);
}

.dark .settings-choice-trigger {
  color: #f8fafc;
  background: #22272e;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.dark .settings-choice-trigger:hover,
.dark .settings-choice-trigger:focus-visible,
.dark .settings-choice.open .settings-choice-trigger {
  border-color: rgba(255, 255, 255, 0.24);
  background: #2a2f36;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.dark .settings-choice-menu {
  background: #20252b;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.dark .settings-choice-option {
  color: #e5edf7;
}

.dark .settings-choice-option:hover,
.dark .settings-choice-option:focus-visible,
.dark .settings-choice-option.active {
  background: #303030;
  color: #ffffff;
}

.settings-textarea {
  width: 100%;
  resize: vertical;
  min-height: 132px;
  line-height: 1.45;
}

.dark .settings-select {
  color: #ffffff;
  background: #1f1f1f;
}

.settings-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #6b7280;
  transition: background-color 150ms ease, color 150ms ease;
}

.settings-icon-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.dark .settings-icon-btn {
  color: #c4c7c5;
}

.dark .settings-icon-btn:hover {
  background: #333333;
  color: #ffffff;
}

.settings-account-surface {
  padding: 18px 0;
  border-bottom: 1px solid #eeeeee;
}

.dark .settings-account-surface {
  border-bottom-color: #303030;
}

.settings-memory-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  font-size: 13px;
  color: #4b5563;
}

.dark .settings-memory-grid {
  color: #c4c7c5;
}

.settings-accent-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #3b82f6;
}

.settings-accent-dot[data-accent="orange"] {
  background: #f97316;
}

.settings-accent-dot[data-accent="green"] {
  background: #22c55e;
}

.settings-accent-dot[data-accent="mindpal-blue"] {
  background: #3b82f6;
}

.settings-row-block {
  align-items: stretch;
  flex-direction: column;
  gap: 12px;
}

.settings-pill-btn,
.settings-danger-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.settings-pill-btn:hover {
  background: #f3f4f6;
}

.settings-danger-pill {
  color: #ef4444;
  border-color: #ef4444;
}

.dark .settings-pill-btn {
  border-color: #444444;
  color: #ffffff;
}

.dark .settings-pill-btn:hover {
  background: #2f2f2f;
}

.settings-danger-pill:hover {
  background: rgba(239, 68, 68, 0.1);
}

.settings-textbox {
  width: 100%;
  min-height: 96px;
  padding: 14px;
  border-radius: 10px;
  background: #f3f4f6;
  color: #111827;
  font-size: 13px;
  line-height: 1.5;
}

.dark .settings-textbox {
  background: #050505;
  color: #ffffff;
}

.settings-subtitle {
  margin-top: 24px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eeeeee;
  font-size: 18px;
  font-weight: 500;
  color: #111827;
}

.dark .settings-subtitle {
  color: #ffffff;
  border-bottom-color: #303030;
}

.settings-intro {
  max-width: 520px;
  padding: 16px 0 24px;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.6;
}

.dark .settings-intro {
  color: #d1d5db;
}

.settings-shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  border-radius: 16px;
}

.settings-shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 0;
  background: #f3f4f6;
  color: #111827;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.dark .settings-shortcut-row {
  background: #303030;
  color: #ffffff;
}

.settings-shortcut-row:hover,
.settings-shortcut-row:focus-visible {
  background: #e5e7eb;
  outline: none;
}

.dark .settings-shortcut-row:hover,
.dark .settings-shortcut-row:focus-visible {
  background: #3a3a3a;
}

.settings-shortcut-row kbd {
  flex: none;
  color: #4b5563;
  font-size: 14px;
}

.dark .settings-shortcut-row kbd {
  color: #f3f4f6;
}

.settings-memory-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 0 0;
}

.settings-memory-summary-card,
.settings-memory-empty,
.settings-memory-manage-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
}

.dark .settings-memory-summary-card,
.dark .settings-memory-empty,
.dark .settings-memory-manage-card {
  border-color: #383838;
}

.settings-memory-manage {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-memory-manage.hidden {
  display: none;
}

@media (max-width: 640px) {
  #profile-content {
    width: 100vw;
    height: 94dvh;
    border-radius: 24px 24px 0 0;
    flex-direction: column;
    margin-bottom: 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  #profile-modal:not(.opacity-0) #profile-content {
    transform: translateY(0);
  }

  .settings-row {
    align-items: flex-start;
    gap: 14px;
  }

  .settings-row-action,
  .settings-select {
    font-size: 13px;
  }

  /* Bottom sheet behavior for unified dropdown on mobile */
  #unified-dropdown {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 24px 24px 0 0;
    margin-bottom: 0;
    padding: 16px 8px calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -10px 25px rgba(0,0,0,0.1);
  }

  #unified-dropdown:not(.hidden) {
    display: flex;
    flex-direction: column;
    transform: translateY(0);
  }
}

/* Touch feedback for interactive elements */
button:active,
.mood-btn:active,
.settings-tab-btn:active,
.settings-row-action:active,
.model-option:active,
.mode-option:active {
  transform: scale(0.97);
  opacity: 0.8;
  transition: transform 0.1s ease;
}

/* Ensure momentum scrolling on iOS */
.settings-panel-scroll,
#chat-history,
#voice-transcript-panel {
  -webkit-overflow-scrolling: touch;
}

/* "Coming soon" disabled pill */
.settings-coming-soon {
  opacity: 0.55;
  pointer-events: none;
  cursor: default;
  border-style: dashed;
  font-weight: 500;
}

/* "Always on" status badge */
.settings-always-on-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #16a34a;
  background: rgba(22, 163, 74, 0.08);
}

.dark .settings-always-on-badge {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
}

/* Custom dialog danger variant */
#custom-dialog-confirm.dialog-danger {
  background: #ef4444;
  color: #ffffff;
}

#custom-dialog-confirm.dialog-danger:hover {
  background: #dc2626;
}

.dark #custom-dialog-confirm.dialog-danger {
  background: #ef4444;
  color: #ffffff;
}

.dark #custom-dialog-confirm.dialog-danger:hover {
  background: #dc2626;
}

/* Character counter for custom instructions */
.settings-char-counter {
  display: block;
  text-align: right;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  transition: color 150ms ease;
}

.settings-char-counter.near-limit {
  color: #f59e0b;
}

.settings-char-counter.at-limit {
  color: #ef4444;
  font-weight: 600;
}

.dark .settings-char-counter {
  color: #6b7280;
}

.dark .settings-char-counter.near-limit {
  color: #f59e0b;
}

.dark .settings-char-counter.at-limit {
  color: #ef4444;
}

/* Remove duplicate color utilities — keeping single source of truth above */

/* ── Voice overlay message bubbles ── */
.voice-msg {
  max-width: 85%;
  padding: 12px 18px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.55;
  transition: opacity 0.2s ease;
  word-break: break-word;
}

.voice-msg:empty {
  display: none;
}

/* Voice overlay is theme-aware */
.voice-msg-ai {
  align-self: flex-start;
  background: transparent;
  color: #1f1f1f;
  font-weight: 400;
}

.dark .voice-msg-ai {
  color: rgba(255, 255, 255, 0.85);
}

.voice-msg-user {
  align-self: flex-end;
  background: rgba(0, 0, 0, 0.04);
  color: #1f1f1f;
  border-radius: 24px;
}

.dark .voice-msg-user {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

/* Dialog animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* Unified selector dropdown animation */
#unified-dropdown {
  animation: scaleIn 0.15s ease;
  transform-origin: bottom right;
}

/* Toggle switch (Pro confirmation) */
#pro-confirm-toggle:checked ~ div:first-of-type {
  background-color: #ef4444;
}
#pro-confirm-toggle:checked ~ div:last-of-type {
  transform: translateX(1.25rem);
}

/* Focus styles for a11y */
#unified-dropdown [role="menuitem"]:focus {
  outline: none;
  background-color: rgba(0, 0, 0, 0.05);
}
.dark #unified-dropdown [role="menuitem"]:focus {
  background-color: rgba(255, 255, 255, 0.08);
}

/* ═══════════════ Quota Banner ═══════════════ */
.quota-banner {
  padding: 0 16px;
  margin-bottom: 4px;
  transition: opacity 0.2s ease, max-height 0.2s ease;
  max-height: 60px;
  opacity: 1;
}
.quota-banner.hidden {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 16px;
  margin: 0;
  pointer-events: none;
}
.quota-banner-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}
.dark .quota-banner-inner {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

/* ═══════════════ Usage Progress Bar ═══════════════ */
.usage-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
}
.dark .usage-bar-track {
  background: rgba(255, 255, 255, 0.06);
}
.usage-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width 0.5s ease;
  min-width: 0;
}
.usage-bar-fill.warn {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}
.usage-bar-fill.full {
  background: #ef4444;
}
