/*
 * ClawPad PWA — Component Styles
 * Chat bubbles, project cards, bottom nav, input bar, modals, badges.
 * Step 6: Glassmorphism, gradients, premium polish.
 */

/* ── Bottom Navigation ─────────────────────────────── */

.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 56px;
  background: var(--glass-bg-heavy);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  flex-shrink: 0;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
}
.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: transform 0.2s ease;
}
.nav-item.active {
  color: var(--brand);
}
/* Gold dot under active tab */
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 6px var(--brand);
}
.nav-item:active {
  opacity: 0.7;
}
.nav-item:active svg {
  transform: scale(0.9);
}

/* Nav icon wrap (for badge positioning) */
.nav-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
}

/* ── Project Card ──────────────────────────────────── */

.project-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.project-card:active {
  background: var(--hover-bg);
}
.project-card.pinned {
  background: linear-gradient(90deg, rgba(242, 201, 76, 0.06) 0%, transparent 60%);
  border-left: 3px solid var(--brand);
}
.project-pin {
  display: inline-flex;
  align-items: center;
  color: var(--brand);
  margin-right: 4px;
  vertical-align: middle;
}

.project-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface) 0%, var(--hover-bg) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--brand);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.project-info {
  flex: 1;
  min-width: 0;
}
.project-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-preview {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.project-meta {
  flex-shrink: 0;
  text-align: right;
}
.project-time {
  font-size: 12px;
  color: var(--ink-muted);
}
.project-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
  color: var(--ink-on-brand);
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

/* ── Chat Bubbles ──────────────────────────────────── */

.message-row {
  display: flex;
  padding: 2px 16px;
  animation: fadeIn 0.15s ease-out;
}
.message-row.user {
  justify-content: flex-end;
}
.message-row.assistant {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}
.message-row.user .message-bubble {
  background: var(--gradient-user-bubble, var(--bubble-user));
  color: var(--bubble-user-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.message-row.assistant .message-bubble {
  background: var(--bubble-ai);
  color: var(--bubble-ai-text);
  border-bottom-left-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.message-bubble .msg-time {
  display: block;
  font-size: 11px;
  color: var(--timestamp);
  margin-top: 4px;
  text-align: right;
  opacity: 0.8;
}

/* Markdown inside bubbles */
.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble strong { font-weight: 600; }
.message-bubble em { font-style: italic; }
.message-bubble del { opacity: 0.6; }
.message-bubble h2 { font-size: 16px; font-weight: 600; margin: 12px 0 6px; }
.message-bubble h3 { font-size: 15px; font-weight: 600; margin: 10px 0 4px; }
.message-bubble h4 { font-size: 14px; font-weight: 600; margin: 8px 0 4px; }
.message-bubble hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.message-bubble a { color: var(--brand); text-decoration: underline; }
.message-bubble blockquote {
  border-left: 3px solid var(--brand);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--ink-soft);
  font-style: italic;
}

/* Inline code */
.message-bubble .inline-code,
.message-bubble code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
}

/* Code blocks */
.code-block {
  position: relative;
  margin: 8px -4px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: none;
  border: none;
}
.code-block code {
  background: none;
  padding: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
}
.code-lang {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.code-copy-btn {
  position: absolute;
  top: 4px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}
.code-copy-btn:hover,
.code-copy-btn:active {
  background: rgba(255,255,255,0.12);
  color: var(--ink);
}
.code-copy-btn.copied {
  color: var(--ok);
}
.code-copy-btn svg {
  width: 12px;
  height: 12px;
}

/* Syntax highlighting */
.hl-kw  { color: #c678dd; }  /* keywords — purple */
.hl-str { color: #98c379; }  /* strings — green */
.hl-cmt { color: #5c6370; font-style: italic; }  /* comments — gray */
.hl-num { color: #d19a66; }  /* numbers — orange */
.hl-key { color: #61afef; }  /* keys/props — blue */

/* Tables */
.md-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0;
}
.message-bubble table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
.message-bubble th, .message-bubble td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.message-bubble th {
  background: rgba(255,255,255,0.04);
  font-weight: 600;
}

.message-bubble pre {
  margin: 8px 0;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  overflow-x: auto;
}
.message-bubble ul, .message-bubble ol {
  padding-left: 20px;
  margin: 6px 0;
}
.message-bubble li { margin-bottom: 2px; }

/* Typing indicator bubble */
.typing-bubble {
  background: var(--bubble-ai) !important;
  padding: 6px 14px !important;
}

/* Streaming indicator */
.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--brand);
  margin-left: 2px;
  animation: blink 1s infinite;
  vertical-align: text-bottom;
  border-radius: 1px;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Thinking indicator — dimmed area shown during AI analysis phase */
.thinking-bubble {
  background: var(--bubble-ai) !important;
  opacity: 0.7;
  padding: 16px 18px !important;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.thinking-label {
  font-size: 13px;
  color: var(--ink-muted);
  font-style: italic;
}
.thinking-dots {
  display: inline-flex;
  gap: 4px;
}
.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: thinkPulse 1.5s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.3s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.6s; }
@keyframes thinkPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

/* ── Chat Input Bar ────────────────────────────────── */

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
  background: var(--glass-bg-heavy);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 8px 14px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-xl);
  color: var(--input-text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  outline: none;
  overflow-y: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chat-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.12);
}
.chat-input::placeholder {
  color: var(--input-placeholder);
}

.mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}
.mic-btn:hover {
  background: var(--hover-bg);
  color: var(--ink);
}
.mic-btn:active {
  transform: scale(0.9);
}
.mic-btn svg {
  width: 18px;
  height: 18px;
}
.mic-btn.recording {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.16);
}
.mic-btn.transcribing {
  color: var(--ink);
  background: var(--hover-bg);
}
.mic-btn.disabled {
  opacity: 0.45;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-brand, var(--btn-primary));
  color: var(--btn-primary-text);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
}
.send-btn:active {
  transform: scale(0.9);
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}
.send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ── Header Bar ────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--glass-bg-heavy);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  min-height: 52px;
}
.header-back {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--brand);
  -webkit-tap-highlight-color: transparent;
}
.header-back svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.header-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.header-subtitle {
  font-size: 12px;
  color: var(--ink-soft);
}

/* ── Message Bottom Row (badges + timestamp) ───────── */

.msg-bottom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.msg-bottom-row .msg-time {
  margin-top: 0;
  margin-left: auto;
}

/* ── Share Badges (Local | XX% / Cloud | XX%) ──────── */

.share-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}
.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.model-badge b {
  font-weight: 700;
  font-size: 11px;
}
.badge-sep {
  opacity: 0.4;
  font-size: 11px;
  margin: 0 1px;
}
.model-badge.local {
  background: rgba(60, 207, 122, 0.15);
  color: var(--ok);
}
.model-badge.cloud {
  background: rgba(242, 201, 76, 0.12);
  color: var(--brand);
}

/* ── FAB (Floating Action Button) ──────────────────── */

.fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0));
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gradient-brand, var(--btn-primary));
  color: var(--btn-primary-text);
  border: none;
  box-shadow: var(--shadow-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.fab:active {
  transform: scale(0.9);
  box-shadow: var(--shadow-md);
}
.fab svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* ── Search Bar ────────────────────────────────────── */

.search-bar {
  padding: 8px 16px;
  background: transparent;
}
.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--input-text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.1);
}
.search-input::placeholder {
  color: var(--input-placeholder);
}
.search-wrap {
  position: relative;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink-muted);
  fill: currentColor;
}

/* ── Job Card ──────────────────────────────────────── */

.job-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin: 8px 16px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.job-card:active {
  background: var(--hover-bg);
  transform: scale(0.98);
}
.job-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}
.job-brief {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.job-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.job-status.active { background: rgba(242,201,76,0.12); color: var(--brand); }
.job-status.completed { background: rgba(60,207,122,0.12); color: var(--ok); }
.job-status.failed { background: rgba(228,92,92,0.12); color: var(--danger); }
.job-status.paused { background: rgba(232,168,64,0.12); color: var(--warn); }

/* ── Settings Items ────────────────────────────────── */

.settings-group {
  padding: 16px;
}
.settings-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.settings-item:last-child { border-bottom: none; }
.settings-label {
  font-size: 15px;
  color: var(--ink);
}
.settings-value {
  font-size: 14px;
  color: var(--ink-soft);
}

/* Select dropdown */
.cp-select {
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--input-text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}
.cp-select:focus { border-color: var(--input-focus); }

/* ── Modal / Dialog ────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s ease-out;
}
.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px 16px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}
.modal-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--input-text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s ease;
}
.modal-input:focus { border-color: var(--input-focus); }
.modal-input::placeholder { color: var(--input-placeholder); }

.modal-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.modal-btn:active {
  transform: scale(0.98);
}
.modal-btn.primary {
  background: var(--gradient-brand, var(--btn-primary));
  color: var(--btn-primary-text);
}
.modal-btn.secondary {
  background: var(--btn-secondary);
  color: var(--btn-secondary-text);
  margin-top: 8px;
}

/* ── Empty State ───────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px;
  text-align: center;
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state-title {
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 8px;
}
.empty-state-text {
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 280px;
  line-height: 1.5;
}

/* ── Connection Status Dot ─────────────────────────── */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.connected {
  background: var(--ok);
  box-shadow: 0 0 6px rgba(60, 207, 122, 0.4);
}
.status-dot.connecting { background: var(--warn); animation: pulse 1.5s infinite; }
.status-dot.disconnected { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Toast ─────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%) translateY(0);
  padding: 10px 20px;
  background: var(--glass-bg-heavy);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  z-index: 500;
  animation: toastSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}
.toast.success { border-color: rgba(60, 207, 122, 0.25); }
.toast.error { border-color: rgba(228, 92, 92, 0.25); }

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

/* ── Skeleton Loaders ─────────────────────────────── */

.skeleton-list {
  padding: 0;
}
.skeleton-card-wrap {
  animation: fadeIn 0.3s ease both;
}
.skeleton-project-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.skeleton-project-card .skel-text {
  flex: 1;
  min-width: 0;
}
.skeleton-time {
  width: 40px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}
.skeleton-job-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin: 8px 16px;
  animation: fadeIn 0.3s ease both;
}
.skeleton-job-card .skel-job-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.skeleton-badge {
  width: 56px;
  height: 20px;
  border-radius: var(--radius-md);
}
.skeleton-msg {
  padding: 4px 16px;
  animation: fadeIn 0.3s ease both;
}
.skeleton-msg-user {
  display: flex;
  justify-content: flex-end;
}
.skeleton-msg-ai {
  display: flex;
  justify-content: flex-start;
}
.skeleton-bubble {
  border-radius: 16px;
  height: 48px;
  width: 70%;
}
.skeleton-bubble.short {
  width: 50%;
  height: 36px;
}
.skeleton-search-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeIn 0.3s ease both;
}

/* ── Utility ──────────────────────────────────────── */

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* ── Bottom Sheet ─────────────────────────────────── */

.bs-overlay {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.bs-sheet {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  box-shadow: var(--shadow-lg);
}

/* ── Action Menu ──────────────────────────────────── */

.action-menu {
  background: var(--glass-bg-heavy);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
}

/* ── Scroll FAB (chat scroll to bottom) ──────────── */

.scroll-fab {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
}

/* ── File Attachment UI ──────────────────────────── */

.attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.attach-btn:active {
  color: var(--brand);
}
.attach-btn svg {
  width: 20px;
  height: 20px;
}

.attach-preview-strip {
  display: flex;
  gap: 8px;
  padding: 8px 12px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.attach-preview-strip::-webkit-scrollbar {
  display: none;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  max-width: 200px;
}
.attach-chip-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.attach-chip-ext {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: var(--hover-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--brand);
  flex-shrink: 0;
}
.attach-chip-name {
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-chip-size {
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.attach-chip-remove {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: none;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.attach-chip-remove:active {
  background: rgba(228, 92, 92, 0.2);
  color: var(--danger);
}

/* ── Connection Quality Indicator ────────────────── */

.conn-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}
.conn-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.conn-bar {
  width: 3px;
  border-radius: 1px;
  background: var(--line);
  transition: background 0.3s ease, height 0.3s ease;
}
.conn-bar:nth-child(1) { height: 5px; }
.conn-bar:nth-child(2) { height: 9px; }
.conn-bar:nth-child(3) { height: 14px; }

.conn-bar.active.conn-excellent { background: var(--ok); }
.conn-bar.active.conn-good { background: var(--ok); }
.conn-bar.active.conn-fair { background: var(--warn); }
.conn-bar.active.conn-poor { background: var(--danger); }
.conn-bar.active.conn-unknown { background: var(--ink-muted); }

.conn-label {
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.conn-offline-text {
  color: var(--danger);
}

/* ── App Lock Screen ─────────────────────────────── */

.lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg, #0B1020);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}
.lock-content {
  text-align: center;
  padding: 32px;
  max-width: 320px;
}
.lock-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.lock-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}
.lock-subtitle {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 24px;
}
.lock-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}
.lock-btn.primary {
  background: var(--gradient-brand, var(--btn-primary));
  color: var(--btn-primary-text);
  box-shadow: var(--shadow-glow);
}
.lock-btn:active {
  transform: scale(0.97);
}
.lock-pin-inputs {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}
.lock-pin-digit {
  width: 48px;
  height: 56px;
  background: var(--input-bg);
  border: 2px solid var(--input-border);
  border-radius: var(--radius-lg);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}
.lock-pin-digit:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.15);
}
.lock-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

/* ── Download Notification (post-connect prompt) ──── */

.download-notif {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(242, 201, 76, 0.1) 0%, rgba(100, 136, 255, 0.08) 100%);
  border: 1px solid rgba(242, 201, 76, 0.2);
  border-radius: 14px;
  animation: fadeIn 0.3s ease-out;
}
.download-notif-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.download-notif-body {
  flex: 1;
  min-width: 0;
}
.download-notif-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}
.download-notif-text {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.3;
}
.download-notif-action {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: var(--brand);
  color: var(--bg-deepest, #0B1020);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.download-notif-action:active {
  opacity: 0.7;
}
.download-notif-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.download-notif-close:active {
  background: rgba(255,255,255,0.06);
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}

/* ── Get the App (Settings page) ──────────────────── */

.get-app-card {
  background: var(--surface-raised, var(--surface));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 16px;
}
.get-app-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 14px;
}
.get-app-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--btn-primary);
  color: var(--btn-primary-text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  text-decoration: none;
  text-align: center;
}
.get-app-btn:active {
  opacity: 0.8;
}
.get-app-btn svg {
  flex-shrink: 0;
}
.get-app-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  background: rgba(100, 136, 255, 0.06);
  border-radius: 10px;
  border: 1px solid rgba(100, 136, 255, 0.15);
}
.get-app-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.get-app-step b {
  color: var(--brand);
  font-weight: 600;
}
.get-app-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--bg-deepest);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
