/* ==========================================================================
   TextoFR — Messenger / WhatsApp-inspired PWA Styles
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --sidebar-width: 320px;
  --transition-fast: 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-slide: 260ms cubic-bezier(0.22, 1, 0.36, 1);
  --user-gradient: linear-gradient(135deg, #2563eb 0%, #059669 100%);
  --user-gradient-hover: linear-gradient(135deg, #1d4ed8 0%, #047857 100%);
  --accent-primary: #3b82f6;
  --accent-emerald: #10b981;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --warning-bg: rgba(245, 158, 11, 0.16);
  --warning-text: #fbbf24;
}

/* Dark Theme (Default) */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg-app: #0b0f17;
  --bg-sidebar: #111622;
  --bg-chat: #0d121c;
  --bg-chat-pattern: radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.06), transparent 45%),
                     radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.05), transparent 45%);
  --bg-surface: #182030;
  --bg-surface-hover: #202b3f;
  --bg-surface-active: rgba(59, 130, 246, 0.16);
  --bg-ai-bubble: #1c2436;
  --bg-input: #171f2e;
  --bg-modal: #141b29;
  --bg-footnote: rgba(255, 255, 255, 0.04);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-on-user: #ffffff;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
}

/* Light Theme */
html[data-theme="light"] {
  color-scheme: light;
  --bg-app: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-chat: #eef2f6;
  --bg-chat-pattern: radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.05), transparent 45%),
                     radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.05), transparent 45%);
  --bg-surface: #f8fafc;
  --bg-surface-hover: #eef2f7;
  --bg-surface-active: rgba(37, 99, 235, 0.1);
  --bg-ai-bubble: #ffffff;
  --bg-input: #ffffff;
  --bg-modal: #ffffff;
  --bg-footnote: #f8fafc;
  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-on-user: #ffffff;
  --warning-bg: rgba(245, 158, 11, 0.14);
  --warning-text: #b45309;
  --shadow-sm: 0 1px 4px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.18);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   App Shell & Responsive Layout (Mobile-first < 768px, Desktop >= 768px)
   ========================================================================== */

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  background: var(--bg-app);
}

.sidebar {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  transition: transform var(--transition-slide), opacity var(--transition-slide);
}

.chat-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  background-image: var(--bg-chat-pattern);
  transform: translateX(100%);
  transition: transform var(--transition-slide);
  min-width: 0;
}

.app-shell.mobile-chat-open .sidebar {
  transform: translateX(-18%);
  opacity: 0.7;
  pointer-events: none;
}

.app-shell.mobile-chat-open .chat-panel {
  transform: translateX(0);
}

@media (min-width: 768px) {
  .sidebar {
    position: relative;
    inset: auto;
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .chat-panel {
    position: relative;
    inset: auto;
    flex: 1 1 auto;
    transform: none !important;
  }

  .back-btn {
    display: none !important;
  }
}

/* ==========================================================================
   Sidebar Components
   ========================================================================== */

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--user-gradient);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.03em;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
  flex-shrink: 0;
}

.brand-logo.large {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  font-size: 22px;
  margin: 0 auto 14px;
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Theme Icon Toggle */
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: block; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
  font-size: 18px;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

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

.icon-btn:active {
  transform: scale(0.94);
}

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

.sidebar-controls {
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

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

.btn-new-chat {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--user-gradient);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.24);
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.btn-new-chat:hover {
  filter: brightness(1.06);
}

.btn-new-chat:active {
  transform: scale(0.985);
}

.plus-sign {
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}

.thread-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.thread-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.thread-item.active {
  background: var(--bg-surface-active);
}

.thread-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.thread-item.active .thread-avatar {
  background: var(--user-gradient);
  border-color: transparent;
  color: #fff;
}

.thread-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.thread-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.thread-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.thread-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.sidebar-footer {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sync-pill {
  font-size: 11.5px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sync-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  opacity: 0.75;
}

.sync-pill.syncing::before {
  background: var(--accent-primary);
  animation: pulseDot 1s infinite ease-in-out;
}

.sync-pill.error::before {
  background: var(--danger);
}

/* ==========================================================================
   API Key Warning Banner
   ========================================================================== */

.api-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--warning-bg);
  border-bottom: 1px solid rgba(245, 158, 11, 0.28);
  font-size: 13px;
  flex-shrink: 0;
}

.api-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.api-banner-text strong {
  color: var(--warning-text);
  font-size: 13px;
}

.api-banner-text span {
  color: var(--text-secondary);
  font-size: 12px;
}

.btn-banner {
  border: none;
  border-radius: var(--radius-pill);
  padding: 7px 13px;
  background: #f59e0b;
  color: #0b0f17;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ==========================================================================
   Active Chat Header & Container
   ========================================================================== */

.active-chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.back-btn {
  font-size: 20px;
  font-weight: 700;
  margin-left: -4px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--user-gradient);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chat-header-info {
  flex: 1 1 auto;
  min-width: 0;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent-emerald);
  flex-shrink: 0;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.chat-status.status-typing {
  color: var(--accent-primary);
}

.chat-status.status-typing .status-dot {
  animation: pulseDot 0.9s infinite ease-in-out;
}

.chat-persona {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* ==========================================================================
   Messages Feed & Messenger-Style Bubbles
   ========================================================================== */

.messages-container {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 18px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

@media (min-width: 768px) {
  .messages-container {
    padding: 20px 24px 20px;
  }
}

.chat-empty-hint {
  margin: auto;
  max-width: 420px;
  text-align: center;
  padding: 22px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.hint-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-active);
  color: var(--accent-primary);
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 10px;
}

.chat-empty-hint p {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-primary);
}

.chat-empty-hint .hint-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.messages-list {
  display: flex;
  flex-direction: column;
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: bubbleIn 180ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

@media (min-width: 768px) {
  .message-row {
    max-width: 68%;
  }
}

.message-row.user-row {
  align-self: flex-end;
  align-items: flex-end;
}

.message-row.ai-row {
  align-self: flex-start;
  align-items: flex-start;
}

/* Turn spacing vs grouped consecutive bubbles */
.message-row.turn-start {
  margin-top: 12px;
}

.message-row.turn-start:first-child {
  margin-top: 0;
}

.message-row.grouped {
  margin-top: 3px;
}

.bubble {
  padding: 9px 14px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.42;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  position: relative;
}

.user-bubble {
  background: var(--user-gradient);
  color: var(--text-on-user);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.22);
}

/* Sharp tail corners on consecutive user bubbles */
.user-row.group-first .user-bubble {
  border-bottom-right-radius: 5px;
}

.user-row.group-middle .user-bubble {
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
}

.user-row.group-last .user-bubble {
  border-top-right-radius: 5px;
}

.ai-bubble {
  background: var(--bg-ai-bubble);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.ai-bubble:hover {
  border-color: var(--border-strong);
}

.ai-bubble:active {
  transform: scale(0.99);
}

.ai-bubble:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Sharp tail corners on consecutive AI bubbles */
.ai-row.group-first .ai-bubble {
  border-bottom-left-radius: 5px;
}

.ai-row.group-middle .ai-bubble {
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}

.ai-row.group-last .ai-bubble {
  border-top-left-radius: 5px;
}

.message-time {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 0 4px;
  user-select: none;
}

/* Tap-to-Explain Footnote */
.bubble-footnote {
  margin-top: 5px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--bg-footnote);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-emerald);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  max-width: 100%;
  animation: bubbleIn 160ms ease-out;
}

.footnote-vi {
  color: var(--text-primary);
  font-weight: 500;
}

.footnote-slang {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.footnote-slang-item strong {
  color: var(--accent-emerald);
  font-weight: 600;
}

.footnote-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-style: italic;
}

/* Typing Indicator Bubble */
.typing-row {
  margin-top: 10px;
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  cursor: default;
}

.typing-bubble .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: bounceDot 1.2s infinite ease-in-out;
}

.typing-bubble .dot:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-bubble .dot:nth-child(3) {
  animation-delay: 0.32s;
}

/* ==========================================================================
   Bottom Input Bar
   ========================================================================== */

.composer {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  padding: 6px 6px 6px 16px;
  transition: border-color var(--transition-fast);
}

.composer-inner:focus-within {
  border-color: var(--accent-primary);
}

#message-input {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 15px;
  line-height: 1.4;
  max-height: 132px;
  padding: 6px 0;
  color: var(--text-primary);
}

#message-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--user-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--transition-fast), opacity var(--transition-fast), filter var(--transition-fast);
}

.send-btn svg {
  width: 17px;
  height: 17px;
  transform: translateX(-1px);
}

.send-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Empty No-Thread View (Desktop) */
.no-thread-view {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 24px;
}

.no-thread-card {
  max-width: 380px;
  text-align: center;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  padding: 32px 26px;
  box-shadow: var(--shadow-sm);
}

.no-thread-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.no-thread-card p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ==========================================================================
   Modals, Forms & Buttons
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 8, 15, 0.68);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 150ms ease-out;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 180ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal-card.modal-wide {
  max-width: 540px;
}

.modal-card.modal-compact {
  max-width: 380px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 520px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

.field-group input[type="text"],
.field-group input[type="password"],
.field-group input[type="url"],
.field-group textarea,
.field-group select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  border-color: var(--accent-primary);
}

.password-wrapper,
.sync-input-row {
  display: flex;
  gap: 8px;
}

.password-wrapper input,
.sync-input-row input {
  flex: 1 1 auto;
  min-width: 0;
}

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

.slider-badge {
  font-size: 12.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-active);
  color: var(--accent-primary);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 2px 0;
}

/* Presets Grid */
.presets-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.presets-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 480px) {
  .presets-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.preset-chip {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.preset-chip:hover {
  border-color: var(--accent-primary);
  background: var(--bg-surface-hover);
}

.preset-chip.selected {
  border-color: var(--accent-emerald);
  background: var(--bg-surface-active);
}

.preset-chip strong {
  font-size: 13px;
  color: var(--text-primary);
}

.preset-chip span {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-inline {
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.btn-primary {
  background: var(--user-gradient);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.07);
}

.btn-secondary,
.btn-inline {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover,
.btn-inline:hover {
  background: var(--bg-surface-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.08);
}

.confirm-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 82px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent-primary);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: var(--shadow-lg);
  animation: bubbleIn 180ms ease-out;
}

.toast.toast-error {
  border-left-color: var(--danger);
}

.toast.toast-success {
  border-left-color: var(--accent-emerald);
}

/* ==========================================================================
   Animations & Scrollbars
   ========================================================================== */

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

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bounceDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes pulseDot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.82);
  }
}

/* Subtle custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
