/* ========================================================
   OFFLINE FRIEND CHAT - MEYAKHEL & SHANDANA WORLD
   Comprehensive Mobile-First PWA Styling
   ======================================================== */

:root {
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --header-height: 64px;
  --footer-height: 70px;
  --radius-bubble: 20px;
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- THEMES --- */
body.theme-midnight {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-card: rgba(26, 35, 58, 0.75);
  --bg-input: #1b253b;
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --user-bubble-bg: linear-gradient(135deg, #4f46e5, #7c3aed);
  --friend-bubble-bg: #1c263c;
}

body.theme-rose {
  --bg-primary: #190f14;
  --bg-secondary: #291822;
  --bg-card: rgba(53, 30, 44, 0.75);
  --bg-input: #381f2f;
  --border-color: rgba(244, 63, 94, 0.15);
  --text-primary: #fff1f2;
  --text-secondary: #fda4af;
  --text-muted: #9f1239;
  --accent-primary: #f43f5e;
  --accent-glow: rgba(244, 63, 94, 0.35);
  --accent-gradient: linear-gradient(135deg, #f43f5e, #fb7185);
  --user-bubble-bg: linear-gradient(135deg, #e11d48, #be123c);
  --friend-bubble-bg: #341a2a;
}

body.theme-cyber {
  --bg-primary: #050508;
  --bg-secondary: #0d0f1f;
  --bg-card: rgba(18, 22, 48, 0.75);
  --bg-input: #161b36;
  --border-color: rgba(6, 182, 212, 0.2);
  --text-primary: #ecfeff;
  --text-secondary: #67e8f9;
  --text-muted: #0e7490;
  --accent-primary: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.45);
  --accent-gradient: linear-gradient(135deg, #06b6d4, #3b82f6);
  --user-bubble-bg: linear-gradient(135deg, #0284c7, #2563eb);
  --friend-bubble-bg: #131930;
}

body.theme-emerald {
  --bg-primary: #06140e;
  --bg-secondary: #0c2419;
  --bg-card: rgba(18, 48, 34, 0.75);
  --bg-input: #153827;
  --border-color: rgba(16, 185, 129, 0.15);
  --text-primary: #ecfdf5;
  --text-secondary: #6ee7b7;
  --text-muted: #047857;
  --accent-primary: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.35);
  --accent-gradient: linear-gradient(135deg, #10b981, #059669);
  --user-bubble-bg: linear-gradient(135deg, #059669, #047857);
  --friend-bubble-bg: #112d20;
}

/* --- BASE RESETS & APP CONTAINER --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  font-family: var(--font-family);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

#app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  position: relative;
  background: var(--bg-secondary);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

/* --- HEADER --- */
#main-header {
  height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 14px;
  padding-right: 14px;
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.avatar-wrapper {
  position: relative;
}

.avatar-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 2px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  background: #10b981;
}

.status-dot.offline-active {
  box-shadow: 0 0 8px #10b981;
}

.header-info {
  display: flex;
  flex-direction: column;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-title-row h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

.badge-role {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--accent-glow);
  color: var(--accent-primary);
  text-transform: uppercase;
}

.header-status-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.icon-btn.active {
  color: var(--accent-primary);
  background: var(--accent-glow);
}

.icon-btn .icon {
  width: 20px;
  height: 20px;
}

.install-btn {
  width: auto;
  border-radius: 20px;
  padding: 0 10px;
  gap: 4px;
  background: var(--accent-glow);
  color: var(--text-primary);
  border: 1px solid var(--accent-primary);
}

.install-badge {
  font-size: 12px;
  font-weight: 600;
}

/* --- CHANNEL TABS (AI Friend vs Direct with Partner) --- */
.channel-tabs {
  display: flex;
  background: rgba(10, 15, 28, 0.95);
  padding: 6px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  z-index: 45;
}

.channel-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.channel-tab-btn.active {
  background: var(--accent-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.pending-badge {
  background: #f59e0b;
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.sync-now-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 8px;
  cursor: pointer;
  margin-left: auto;
  margin-right: 8px;
  transition: transform 0.15s;
}

.sync-now-btn:active {
  transform: scale(0.95);
}

.pair-box {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 16px;
  padding: 14px;
}

.msg-status-tag {
  font-size: 9.5px;
  opacity: 0.8;
  margin-left: 4px;
}

.msg-status-tag.pending {
  color: #fbbf24;
}

.msg-status-tag.delivered {
  color: #34d399;
}

.airdrop-chip-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10px;
  color: inherit;
  cursor: pointer;
  margin-left: 6px;
}

/* --- OFFLINE BANNER --- */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.12);
  border-bottom: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 12px;
  color: #34d399;
}

.banner-icon {
  margin-right: 6px;
}

.banner-close {
  background: transparent;
  border: none;
  color: #34d399;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

/* --- CHAT MESSAGES SCROLL AREA --- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* Welcome Card */
.welcome-card {
  text-align: center;
  padding: 24px 18px;
  margin: 10px auto 16px auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  max-width: 92%;
  backdrop-filter: blur(10px);
}

.welcome-icon {
  font-size: 38px;
  margin-bottom: 10px;
}

.welcome-card h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-card p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

.quick-action-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  padding: 7px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 12.5px;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

/* Message Rows */
.msg-row {
  display: flex;
  width: 100%;
  animation: msg-appear 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes msg-appear {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-row.user {
  justify-content: flex-end;
}

.msg-row.friend {
  justify-content: flex-start;
  gap: 8px;
}

.msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-bubble);
  position: relative;
  word-break: break-word;
  user-select: text;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

.msg-row.user .msg-bubble {
  background: var(--user-bubble-bg);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg-row.friend .msg-bubble {
  background: var(--friend-bubble-bg);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-color);
}

.msg-text {
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10.5px;
  margin-top: 5px;
  opacity: 0.7;
}

.speak-msg-btn {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  opacity: 0.6;
  padding: 0 3px;
  font-size: 12px;
  transition: opacity 0.15s;
}

.speak-msg-btn:hover {
  opacity: 1;
}

/* Sticker in Chat */
.msg-sticker {
  width: 130px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.msg-sticker:hover {
  transform: scale(1.08);
}

.msg-sticker svg, .msg-sticker img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
}

.sticker-bubble {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

/* Photos & Videos in Chat (WhatsApp Style) */
.media-bubble {
  padding: 4px !important;
  overflow: hidden;
}

.msg-image-wrapper {
  max-width: 260px;
  max-height: 320px;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
}

.msg-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 14px;
  transition: transform 0.2s ease;
}

.msg-image-wrapper:hover img {
  transform: scale(1.02);
}

.msg-video-wrapper {
  max-width: 270px;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  background: #000000;
}

.msg-video-wrapper video {
  width: 100%;
  max-height: 320px;
  display: block;
  border-radius: 14px;
  outline: none;
}

/* Lightbox Modal */
.lightbox-wrapper {
  position: relative;
  max-width: 92vw;
  max-height: 88vh;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-close-btn {
  position: absolute;
  top: -46px;
  right: 0px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 26px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.lightbox-close-btn:active {
  transform: scale(0.9);
}

.lightbox-media-container img, .lightbox-media-container video {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
  object-fit: contain;
}

/* Voice Note in Chat */
.audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  padding: 4px 0;
}

.play-audio-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.audio-track {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.audio-waveform-bars {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 22px;
}

.audio-bar {
  width: 3px;
  height: 60%;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 2px;
  transition: height 0.15s;
}

.audio-player.playing .audio-bar {
  animation: sound-bounce 0.8s infinite ease-in-out alternate;
}

.audio-player.playing .audio-bar:nth-child(2) { animation-delay: 0.1s; }
.audio-player.playing .audio-bar:nth-child(3) { animation-delay: 0.25s; }
.audio-player.playing .audio-bar:nth-child(4) { animation-delay: 0.15s; }
.audio-player.playing .audio-bar:nth-child(5) { animation-delay: 0.3s; }

@keyframes sound-bounce {
  0% { height: 25%; }
  100% { height: 100%; }
}

.audio-duration {
  font-size: 11px;
  opacity: 0.8;
}

/* --- TYPING INDICATOR --- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--friend-bubble-bg);
  padding: 8px 12px;
  border-radius: 16px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: typing-jump 1.2s infinite ease-in-out;
}

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

@keyframes typing-jump {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

/* --- RECORDING BAR --- */
.recording-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(220, 38, 38, 0.15);
  border-top: 1px solid rgba(220, 38, 38, 0.3);
  backdrop-filter: blur(10px);
}

.recording-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}

.wave-bar {
  width: 3px;
  height: 20px;
  background: #ef4444;
  border-radius: 2px;
  animation: sound-bounce 0.6s infinite ease-in-out alternate;
}

.recording-timer {
  font-weight: 700;
  font-size: 14px;
  color: #ef4444;
}

.recording-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

.record-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.record-action-btn.cancel {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.record-action-btn.send {
  background: #ef4444;
  color: #ffffff;
}

.record-action-btn svg {
  width: 18px;
  height: 18px;
}

/* --- FOOTER INPUT BAR --- */
#chat-footer {
  min-height: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: 12px;
  padding-right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(19, 27, 46, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  z-index: 40;
}

.input-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.input-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.input-btn .icon {
  width: 22px;
  height: 22px;
}

.send-btn {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.send-btn:hover {
  transform: scale(1.05);
}

.sms-btn {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  font-size: 11px;
  font-weight: 700;
  width: auto;
  border-radius: 18px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.sms-btn:hover {
  background: rgba(16, 185, 129, 0.28);
  transform: scale(1.04);
}

.input-wrapper {
  flex: 1;
  background: var(--bg-input);
  border-radius: 22px;
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
}

#message-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.35;
  resize: none;
  outline: none;
  max-height: 100px;
  user-select: text;
}

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

/* --- STICKER & DOODLE DRAWER --- */
.sticker-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 380px;
  background: var(--bg-secondary);
  border-top-left-radius: 26px;
  border-top-right-radius: 26px;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: transform var(--transition-smooth);
}

.sticker-drawer.hidden {
  transform: translateY(105%);
}

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

.drawer-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.drawer-tab {
  padding: 6px 12px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}

.drawer-tab.active {
  background: var(--accent-gradient);
  color: #ffffff;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.sticker-item {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  cursor: pointer;
  padding: 8px;
  transition: transform 0.15s, background 0.15s;
}

.sticker-item:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.08);
}

.sticker-item svg {
  width: 100%;
  height: 100%;
}

/* Doodle Canvas Container */
.doodle-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  gap: 10px;
}

.doodle-canvas-wrapper {
  background: #1e293b;
  border-radius: 16px;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  overflow: hidden;
  touch-action: none;
}

#doodle-canvas {
  display: block;
  cursor: crosshair;
}

.doodle-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 320px;
}

.doodle-colors {
  display: flex;
  gap: 8px;
}

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}

.color-dot.active {
  border-color: #ffffff;
  transform: scale(1.15);
}

.doodle-actions {
  display: flex;
  gap: 8px;
}

/* --- MODALS --- */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

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

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 26px;
  color: var(--text-secondary);
  cursor: pointer;
}

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

.modal-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.capsule-card, .install-guide-card {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.capsule-card h3, .install-guide-card h3 {
  font-size: 14.5px;
  color: var(--text-primary);
}

.capsule-card p, .install-guide-card p {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.install-steps {
  padding-left: 20px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Buttons */
.btn-primary {
  padding: 10px 18px;
  border-radius: 16px;
  border: none;
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-secondary {
  padding: 10px 18px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}

.btn-subtle {
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
}

.btn-danger {
  padding: 10px 18px;
  border-radius: 16px;
  border: none;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.full-width {
  width: 100%;
}

/* Settings Form Controls */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.setting-row {
  display: flex;
  gap: 12px;
}

.form-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 12px;
  color: var(--text-secondary);
}

.form-field input, .teach-box input {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
}

.persona-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.persona-chip {
  padding: 9px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.persona-chip.active {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  font-weight: 600;
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.theme-btn {
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 11.5px;
  cursor: pointer;
}

.theme-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.slider-row input[type="range"] {
  width: 65%;
}

.teach-box {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--border-color);
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

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