/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f7fa;
  --surface:   #ffffff;
  --surface2:  #f8f9fc;
  --border:    #e1e6ef;
  --text:      #1e2a3a;
  --text-dim:  #6b7a92;
  --primary:   #4a7dc9;
  --primary-light: #e8f0fa;
  --primary-hover: #3a68b0;
  --danger:    #d94848;
  --danger-bg: #fff2f2;
  --warning:   #e89a3c;
  --warning-bg:#fff8ed;
  --success:   #39b87e;
  --success-bg:#f0faf5;
  --info:      #4a9dc9;
  --info-bg:   #e8f5fa;
  --neutral:   #7e8ab8;
  --neutral-bg:#f2f4ff;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(30,42,58,0.08);
  --shadow:    0 2px 8px rgba(30,42,58,0.1);
  --shadow-lg: 0 8px 24px rgba(30,42,58,0.12);
}

/* ── Dark mode override ───────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0f1117;
  --surface:     #1a1d27;
  --surface2:    #222530;
  --border:      #2e3240;
  --text:        #e4e7ef;
  --text-dim:    #8a90a5;
  --primary:     #5e94e0;
  --primary-light: #1e2a3a;
  --primary-hover: #7caef0;
  --danger:      #e85c5c;
  --danger-bg:   #2a1515;
  --warning:     #f0a84c;
  --warning-bg:  #2a2215;
  --success:     #4cc991;
  --success-bg:  #152a1f;
  --info:        #5eaee0;
  --info-bg:     #152030;
  --neutral:     #8e98d0;
  --neutral-bg:  #1a1d30;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.3);
  --shadow:      0 2px 8px rgba(0,0,0,0.35);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.45);
}
[data-theme="dark"] img {
  opacity: 0.92;
}

/* Smooth theme transitions on key elements */
.topbar, .panel, .tile, .tile-inner, .tile-icon, .highlight-card, .news-card, .fin-card,
.chat-msg, .chat-input-bar, .unsub-row, .modal-content,
.email-modal-content, .btn, .btn-sm {
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-text-size-adjust: 100%;
}

/* Prevent iOS auto-zoom on input focus (requires font-size >= 16px) */
input, select, textarea {
  font-size: 16px;
  touch-action: manipulation;
}

/* Prevent double-tap zoom on interactive elements */
a, button, label, .btn, .btn-sm {
  touch-action: manipulation;
}

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

/* ── App content scroll container ─────────────────────────── */
/* All page content scrolls inside this wrapper; body never scrolls */
.app-content {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none;
  transition: opacity 0.12s ease;
}
.app-content.spa-loading {
  opacity: 0.4;
  pointer-events: none;
}
/* When content child needs to fill the entire wrapper (e.g. chat) */
.app-content:has(.chat-fullpage) {
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}
.app-content--no-topbar {
  top: 0;
}
@supports (padding-top: env(safe-area-inset-top)) {
  .app-content--no-topbar {
    top: env(safe-area-inset-top);
  }
}
@media (max-width: 768px) {
  .app-content {
    top: 48px;
    bottom: calc(44px + env(safe-area-inset-bottom, 0px));
  }
  @supports (padding-top: env(safe-area-inset-top)) {
    .app-content {
      top: calc(48px + env(safe-area-inset-top));
    }
    .app-content--no-topbar {
      top: env(safe-area-inset-top);
    }
  }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 20px;
}
.back-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
  font-weight: 500;
}
.back-link:hover { color: var(--primary); }
.logo {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.refresh-info {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ── Theme toggle button ──────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}
.theme-toggle:active svg {
  transform: rotate(30deg);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.87rem;
  font-weight: 500;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.btn:hover {
  background: var(--surface2);
  box-shadow: var(--shadow);
}
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-ghost:hover { color: var(--text); }
.btn-ghost svg { display: block; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-success {
  background: transparent;
  border-color: var(--success);
  color: var(--success);
  font-size: 0.75rem;
  padding: 4px 12px;
  font-weight: 600;
  box-shadow: none;
}
.btn-success:hover {
  background: var(--success-bg);
  box-shadow: var(--shadow-sm);
}

/* ── Container ─────────────────────────────────────────────── */
.container {
  max-width: 1340px;
  margin: 0 auto;
  padding: 28px;
}

/* ── Landing page ──────────────────────────────────────────── */
.landing { max-width: 1040px; }

/* Welcome hero section */
.welcome-hero {
  position: relative;
  padding: 32px 32px 28px;
  margin-bottom: 28px;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary) 0%, #5a8fd8 40%, var(--info) 100%);
  box-shadow: 0 4px 20px rgba(74,125,201,0.25);
}
[data-theme="dark"] .welcome-hero {
  background: linear-gradient(135deg, #2a4a7a 0%, #2d5590 40%, #2a5a80 100%);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.welcome-hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,0.12) 0%, transparent 50%),
    radial-gradient(circle at 15% 80%, rgba(255,255,255,0.06) 0%, transparent 40%);
  pointer-events: none;
}
.welcome-hero-content {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
}
.welcome-hero-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.welcome-hero-text {
  flex: 1;
  min-width: 0;
}
.welcome-hero-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.welcome-hero-sub {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.8);
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.text-dim, .panel-sub {
  color: var(--text-dim);
  font-size: 0.88rem;
}
.panel-sub {
  margin-top: 6px;
  line-height: 1.4;
}

/* ── View toggle buttons ──────────────────────────────────── */
.view-toggle {
  display: inline-flex;
  gap: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-top: 16px;
}
.view-toggle-topbar {
  margin-top: 0;
  margin-right: 4px;
}
.vt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
}
.vt-btn:hover {
  color: var(--text);
  background: var(--surface);
}
.vt-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  transition: gap 0.3s ease;
}
@media (max-width: 700px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Compact grid mode ───────────────────────────────────── */
.tile-grid--compact {
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.tile-grid--compact .tile {
  border-radius: 14px;
}
.tile-grid--compact .tile::before {
  display: none;
}
.tile-grid--compact .tile-inner {
  padding: 20px 16px 18px;
  align-items: center;
  text-align: center;
}
.tile-grid--compact .tile-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  margin-bottom: 12px;
}
.tile-grid--compact .tile-icon svg {
  width: 24px;
  height: 24px;
}
.tile-grid--compact .tile-title {
  font-size: 0.88rem;
  margin-bottom: 0;
}
.tile-grid--compact .tile-desc {
  display: none;
}
.tile-grid--compact .tile-footer {
  display: none;
}
.tile-grid--compact .tile:hover {
  transform: translateY(-3px) scale(1.02);
}
@media (max-width: 700px) {
  .tile-grid--compact {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .tile-grid--compact .tile-inner {
    padding: 18px 14px 16px;
  }
  .tile-grid--compact .tile-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    margin-bottom: 10px;
  }
  .tile-grid--compact .tile-icon svg {
    width: 22px;
    height: 22px;
  }
  .tile-grid--compact .tile-title {
    font-size: 0.82rem;
  }
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.25s ease, border-color 0.25s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  border-radius: 16px 0 0 16px;
  opacity: 0.7;
  transition: width 0.25s ease, opacity 0.25s;
}
.tile:hover::before {
  width: 6px;
  opacity: 1;
}
.tile-inner {
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.tile:hover {
  transform: translateY(-5px);
  border-color: transparent;
  box-shadow: 0 12px 32px rgba(74,125,201,0.15), 0 2px 8px rgba(0,0,0,0.08);
}
[data-theme="dark"] .tile:hover {
  box-shadow: 0 12px 32px rgba(94,148,224,0.12), 0 2px 8px rgba(0,0,0,0.3);
}
.tile:active {
  transform: translateY(-2px) scale(0.98);
}
.tile-placeholder {
  opacity: 0.4;
  cursor: default;
}
.tile-placeholder:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.tile-icon {
  margin-bottom: 18px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--primary-light);
  color: var(--primary);
  transition: transform 0.25s ease, box-shadow 0.25s;
}
.tile:hover .tile-icon {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(74,125,201,0.2);
}
.tile-icon svg {
  width: 26px;
  height: 26px;
}
/* Per-tile accent colors */
.tile-email::before { background: var(--info); }
.tile-email .tile-icon { background: var(--info-bg); color: var(--info); }
.tile-email:hover .tile-icon { box-shadow: 0 4px 14px rgba(74,157,201,0.25); }
.tile-email .tile-stat { color: var(--info); }

.tile-bills::before { background: var(--warning); }
.tile-bills .tile-icon { background: var(--warning-bg); color: var(--warning); }
.tile-bills:hover .tile-icon { box-shadow: 0 4px 14px rgba(232,154,60,0.25); }
.tile-bills .tile-stat { color: var(--warning); }

.tile-finance::before { background: var(--success); }
.tile-finance .tile-icon { background: var(--success-bg); color: var(--success); }
.tile-finance:hover .tile-icon { box-shadow: 0 4px 14px rgba(57,184,126,0.25); }
.tile-finance .tile-stat { color: var(--success); }

.tile-news::before { background: var(--neutral); }
.tile-news .tile-icon { background: var(--neutral-bg); color: var(--neutral); }
.tile-news:hover .tile-icon { box-shadow: 0 4px 14px rgba(126,138,184,0.25); }
.tile-news .tile-stat { color: var(--neutral); }

.tile-chat::before { background: #9b6dd7; }
.tile-chat .tile-icon { background: #f3edfc; color: #9b6dd7; }
.tile-chat:hover .tile-icon { box-shadow: 0 4px 14px rgba(155,109,215,0.25); }
.tile-chat .tile-stat { color: #9b6dd7; }
[data-theme="dark"] .tile-chat .tile-icon { background: #2a1f3a; color: #b893e6; }
[data-theme="dark"] .tile-chat .tile-stat { color: #b893e6; }

.tile-settings::before { background: var(--text-dim); }
.tile-settings .tile-icon { background: var(--surface2); color: var(--text-dim); }
.tile-settings:hover .tile-icon { box-shadow: 0 4px 14px rgba(107,122,146,0.2); }

.tile-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.tile-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
  flex: 1;
}
.tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tile-stat {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
}
.tile-arrow {
  color: var(--text-dim);
  transition: transform 0.2s ease, color 0.2s;
}
.tile:hover .tile-arrow {
  transform: translateX(3px);
  color: var(--primary);
}
.tile-badge {
  margin-top: 18px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

/* ── Summary cards ─────────────────────────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
}
.card-value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.1;
}
.card-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 6px;
}
.card-danger  .card-value { color: var(--danger); }
.card-warning .card-value { color: var(--warning); }
.card-primary .card-value { color: var(--primary); }
.card-info    .card-value { color: var(--info); }
.card-neutral .card-value { color: var(--neutral); }

/* ── Two column layout ─────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
  align-items: start;
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Compact panels for side-by-side layout */
.compact-panel {
  max-height: 520px;
  display: flex;
  flex-direction: column;
}
.compact-panel .chat-messages {
  max-height: 320px;
}

/* Email page chat panel -- taller */
.email-chat-panel {
  display: flex;
  flex-direction: column;
  max-height: 620px;
}
.email-chat-panel .chat-messages {
  max-height: 450px;
  flex: 1;
}

.unsub-scroll {
  overflow-y: auto;
  max-height: 380px;
  flex: 1;
}
.unsub-scroll::-webkit-scrollbar { width: 6px; }
.unsub-scroll::-webkit-scrollbar-track { background: var(--surface2); }
.unsub-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.unsub-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Collapsible panels ─────────────────────────────────── */
.collapsible-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.collapsible-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.collapsible-header:hover {
  background: var(--surface2);
}
.collapse-chevron {
  transition: transform 0.3s ease;
  flex-shrink: 0;
  color: var(--text-dim);
}
.collapsible-panel.collapsed .collapse-chevron {
  transform: rotate(-90deg);
}
.collapsible-body {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  opacity: 1;
}
.collapsible-panel.collapsed .collapsible-body {
  max-height: 0;
  opacity: 0;
}
.collapse-badge {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-left: 6px;
}

/* Other emails row styling - must sit above delete bg like unsub-row */
.other-email-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  box-sizing: border-box;
  touch-action: pan-y;
  user-select: none;
  will-change: transform;
}
.other-email-row:hover {
  background: var(--surface2);
}
.unsub-swipe-container .other-email-row {
  border-bottom: none;
}
.other-email-info {
  flex: 1;
  min-width: 0;
}
.other-email-subject {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.other-email-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.other-email-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--neutral-bg);
  color: var(--neutral);
  white-space: nowrap;
}

/* ── Panels ────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.panel-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.panel-header-left {
  min-width: 0;
  flex: 1;
}
.panel-header-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}
.refresh-days-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  min-width: 160px;
  overflow: hidden;
}
.refresh-days-header {
  padding: 8px 16px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.refresh-days-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.refresh-days-item {
  display: block;
  width: 100%;
  padding: 9px 16px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.refresh-days-item:hover {
  background: var(--surface2);
}
.refresh-days-item.active {
  font-weight: 700;
  color: var(--primary);
}
.full-width { max-width: none; }

/* ── Section labels inside panels ──────────────────────────── */
.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
}
.section-label.danger  { color: var(--danger); }
.section-label.warning { color: var(--warning); }
.section-label.success { color: var(--success); }

/* ── Horizontal scroll highlights (email cards) ─────────────── */
.highlight-scroll {
  display: flex;
  overflow-x: auto;
  gap: 18px;
  padding: 24px 24px 24px 32px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  user-select: none;
  will-change: scroll-position;
}
.highlight-scroll:active {
  cursor: grabbing;
  scroll-behavior: auto; /* Disable smooth during drag for immediate response */
}
.highlight-scroll.active {
  scroll-behavior: auto;
}
.highlight-scroll::-webkit-scrollbar { height: 8px; }
.highlight-scroll::-webkit-scrollbar-track { background: var(--surface2); }
.highlight-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.highlight-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Add spacing after last card */
.highlight-scroll::after {
  content: '';
  flex: 0 0 16px;
}

.highlight-card {
  flex: 0 0 62%;
  min-width: 280px;
  max-width: 420px;
  min-height: 140px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s, opacity 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}
.highlight-card-swipe {
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.highlight-card-swipe.swiping {
  transition: none;
}
.highlight-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: var(--primary);
}
.highlight-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  z-index: 2;
}
.highlight-card:hover .highlight-dismiss {
  opacity: 1;
}
.highlight-dismiss:hover {
  background: var(--danger, #d94848);
  color: #fff;
}
@media (pointer: coarse) {
  .highlight-dismiss {
    opacity: 1;
    width: 28px;
    height: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
  }
}
.highlight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}
.highlight-subject {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.3;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.highlight-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.highlight-badge.urgent    { background: var(--danger-bg);  color: var(--danger); }
.highlight-badge.important { background: var(--info-bg);    color: var(--info); }
.highlight-badge.bills     { background: var(--warning-bg); color: var(--warning); }
.highlight-badge.financial { background: var(--neutral-bg); color: var(--neutral); }

.highlight-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.highlight-reason-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}
.highlight-summary {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Bill rows ─────────────────────────────────────────────── */
.bill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.bill-row:last-child { border-bottom: none; }
.bill-row:hover { background: var(--surface2); }
.bill-row.overdue { border-left: 4px solid var(--danger); background: var(--danger-bg); }
.bill-row.upcoming { border-left: 4px solid var(--warning); }
.bill-row.paid { border-left: 4px solid var(--success); opacity: 0.6; }

.bill-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bill-payee {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.bill-due {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.bill-pay-link {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  margin-right: 8px;
  transition: background 0.15s;
}
.bill-pay-link:hover { background: var(--primary-hover); }
.bill-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.bill-amount {
  font-weight: 700;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
.bill-amount.danger { color: var(--danger); }
.bill-amount.warning { color: var(--warning); }
.btn-pay {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
}
.btn-pay:hover {
  background: var(--primary-hover);
}
.btn-link-add {
  background: transparent;
  border: 1px dashed var(--text-dim);
  color: var(--text-dim);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.btn-link-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.bill-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 6px;
}
.bill-badge.overdue { background: var(--danger-bg); color: var(--danger); }
.bill-badge.paid    { background: var(--success-bg); color: var(--success); }
.bill-chevron {
  font-size: 1.4rem;
  color: var(--text-dim);
  line-height: 1;
}

/* ── Bill detail modal ─────────────────────────────────────── */
.bill-modal-body { padding: 0 !important; }
.bill-modal-info {
  text-align: center;
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}
.bill-modal-amount {
  font-size: 2.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.bill-modal-payee {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
}
.bill-modal-due {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 6px;
}
.bill-modal-due.overdue {
  color: var(--danger);
  font-weight: 600;
}
.bill-modal-paid-badge {
  display: inline-block;
  margin-top: 10px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 6px;
}
.bill-modal-notes {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 10px;
  font-style: italic;
}
.bill-modal-section {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.bill-statement-meta {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bill-statement-summary {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
}
.bill-statement-details {
  margin-top: 12px;
}
.bill-statement-details summary {
  font-size: 0.8rem;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}
.bill-statement-body {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface2);
  padding: 12px;
  border-radius: var(--radius);
  line-height: 1.5;
}
.bill-modal-pay-link {
  margin-top: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.bill-modal-pay-link a {
  color: var(--primary);
  word-break: break-all;
  font-size: 0.82rem;
}
.bill-modal-actions {
  padding: 20px 24px 24px;
  display: flex;
  gap: 12px;
}
.bill-modal-btn {
  flex: 1;
  text-align: center;
  justify-content: center;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 700;
}
.btn-success-fill {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
}
.btn-success-fill:hover {
  opacity: 0.9;
}

/* ── Email items (legacy list view) ────────────────────────── */
.email-item {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.email-item:last-child { border-bottom: none; }
.email-item:hover { background: var(--surface2); }

.email-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.email-subject {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
  color: var(--text);
}
.email-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.email-badge.urgent    { background: var(--danger-bg);  color: var(--danger); }
.email-badge.important { background: var(--info-bg);    color: var(--info); }
.email-badge.bills     { background: var(--warning-bg); color: var(--warning); }
.email-badge.financial { background: var(--neutral-bg); color: var(--neutral); }

.email-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.email-summary {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.highlight-tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-dim);
  margin-left: 8px;
}

/* ── Chat ──────────────────────────────────────────────────── */
.chat-panel {
  max-width: 900px;
}
.chat-messages {
  padding: 24px;
  max-height: 450px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface2);
}
.chat-msg {
  padding: 14px 18px;
  border-radius: var(--radius);
  max-width: 85%;
  font-size: 0.9rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}
.chat-msg.user {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}
.chat-msg.assistant {
  background: var(--surface);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border);
}
.chat-msg.loading {
  color: var(--text-dim);
  font-style: italic;
  background: var(--surface2);
  border: none;
  box-shadow: none;
}
.chat-msg p {
  word-break: break-word;
  overflow-wrap: break-word;
  margin: 0;
}

/* Blinking cursor for streaming responses */
.chat-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: chatBlink 0.7s infinite;
}
@keyframes chatBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input-area input {
  flex: 1;
  min-width: 0;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input-area input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ── Unsubscribe / inbox cleanup ───────────────────────────── */
.unsub-info {
  padding: 12px 24px;
  font-size: 0.85rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

/* Swipe container */
.unsub-swipe-container {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.unsub-swipe-container:last-child { border-bottom: none; }

/* Delete action revealed behind the row */
.unsub-delete-bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 24px;
  background: var(--danger);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  gap: 8px;
  pointer-events: none;
  z-index: 1;
}
.unsub-delete-bg svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
}

/* The foreground row that slides */
.unsub-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  transition: background 0.15s;
  gap: 14px;
  touch-action: pan-y;
  user-select: none;
  will-change: transform;
}
.unsub-row:hover { background: var(--surface2); }

/* Slide-out animation */
.unsub-swipe-container.removing .unsub-row,
.unsub-swipe-container.removing .other-email-row {
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.unsub-swipe-container.removing {
  max-height: 70px;
  animation: collapseRow 0.3s 0.2s ease forwards;
}
@keyframes collapseRow {
  from { max-height: 70px; opacity: 1; }
  to { max-height: 0; opacity: 0; padding: 0; border-bottom-width: 0; }
}

/* Delete button that appears when swiped */
.unsub-delete-btn {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  background: var(--danger);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.unsub-delete-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.unsub-delete-btn svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
}

.unsub-left {
  flex: 1;
  min-width: 0;
}
.unsub-sender {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.unsub-detail {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-top: 3px;
}
.unsub-count {
  flex-shrink: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.unsub-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn-block {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  box-shadow: none;
}
.btn-block:hover {
  background: var(--danger-bg);
  box-shadow: var(--shadow-sm);
}
.btn-unsub {
  background: transparent;
  border: 1px solid var(--warning);
  color: var(--warning);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  font-weight: 600;
  display: inline-block;
  box-shadow: none;
}
.btn-unsub:hover {
  background: var(--warning-bg);
  box-shadow: var(--shadow-sm);
}
.blocked-tag {
  font-size: 0.72rem;
  color: var(--success);
  padding: 4px 10px;
  border: 1px solid var(--success);
  border-radius: 6px;
  background: var(--success-bg);
  font-weight: 600;
}

/* ── Empty state ───────────────────────────────────────────── */
.empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ── Loading spinner ───────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Email detail modal ────────────────────────────────────── */
.email-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(30, 42, 58, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.email-modal.active {
  display: flex;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.email-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(20px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

.email-modal-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface2);
}
.email-modal-title {
  flex: 1;
  min-width: 0;
}
.email-modal-title h3 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
  color: var(--text);
}
.email-modal-meta {
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.email-modal-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
  font-weight: 300;
}
.email-modal-close:hover {
  color: var(--text);
}

.email-modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.email-modal-body p {
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 12px;
}
.email-modal-body p:last-child {
  margin-bottom: 0;
}

.email-modal-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.email-modal-tag {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.email-modal-tag.urgent    { background: var(--danger-bg);  color: var(--danger); }
.email-modal-tag.important { background: var(--info-bg);    color: var(--info); }
.email-modal-tag.bills     { background: var(--warning-bg); color: var(--warning); }
.email-modal-tag.financial { background: var(--neutral-bg); color: var(--neutral); }

/* ── Modal section labels & full message ───────────────────── */
.modal-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-dim);
  margin: 20px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.modal-section-label:first-child {
  margin-top: 0;
}

.full-message-toggle {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.full-message-content {
  animation: fadeIn 0.25s ease;
  margin-top: 16px;
}

.full-message-frame-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  margin-top: 8px;
}
.full-message-frame {
  width: 100%;
  min-height: 200px;
  height: 400px;
  border: none;
  display: block;
}
[data-theme="dark"] .full-message-frame {
  filter: invert(0.88) hue-rotate(180deg);
}
[data-theme="dark"] .full-message-frame-wrap {
  background: #1a1a2e;
}

.plain-text-fallback {
  margin-top: 12px;
}
.plain-text-fallback summary {
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 0;
  font-weight: 600;
}
.plain-text-fallback summary:hover {
  color: var(--primary);
}
.plain-text-body {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 500px;
  overflow-y: auto;
  margin-top: 8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ═══════════════════════════════════════════════════════════
   FINANCE PAGE
   ═══════════════════════════════════════════════════════════ */

.finance-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.fin-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fin-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.fin-card-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 4px;
}
.fin-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.card-income { border-left-color: var(--success); }
.card-expenses { border-left-color: var(--danger); }
.card-savings { border-left-color: var(--primary); }
.card-bills { border-left-color: var(--warning); }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

.chart-container {
  position: relative;
  height: 280px;
  padding: 16px;
}

/* Account rows */
.account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.account-row:last-child { border-bottom: none; }
.account-row:hover { background: var(--surface2); }
.account-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.account-balance {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}
.balance-negative { color: var(--danger); }

/* Budget rows */
.budget-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.budget-row:last-child { border-bottom: none; }
.budget-info {
  flex: 0 0 140px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.budget-name {
  font-weight: 600;
  font-size: 0.85rem;
}
.budget-bar {
  flex: 1;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}
.budget-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.budget-pct {
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 40px;
  text-align: right;
}

/* Transaction list */
.txn-list {
  max-height: 500px;
  overflow-y: auto;
}
.txn-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.txn-row:last-child { border-bottom: none; }
.txn-row:hover { background: var(--surface2); }
.txn-date {
  flex: 0 0 60px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.txn-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.txn-merchant {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.txn-cat {
  font-size: 0.75rem;
}
.txn-amount {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}
.amount-expense { color: var(--danger); }
.amount-income { color: var(--success); }

/* Insights */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding: 16px;
}
.insight-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
}
.insight-card.insight-info { background: var(--info-bg); color: var(--info); }
.insight-card.insight-warning { background: var(--warning-bg); color: var(--warning); }
.insight-card.insight-success { background: var(--success-bg); color: var(--success); }
.insight-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Bills on finance page */
.bills-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-dim);
  padding: 12px 16px 4px;
}
.bill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.bill-row:last-child { border-bottom: none; }
.bill-row.overdue { background: var(--danger-bg); }
.bill-payee { font-weight: 600; flex: 1; }
.bill-date { font-size: 0.82rem; color: var(--text-dim); }
.bill-amount { font-weight: 700; }

/* Input sm */
.input-sm {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 160px;
}
.input-sm:focus { border-color: var(--primary); }

/* Form styles */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.list-scroll {
  max-height: 340px;
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════
   NEWS PAGE
   ═══════════════════════════════════════════════════════════ */

.news-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.news-tab {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.news-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.news-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 20px;
}

.news-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.news-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.news-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.news-card-body {
  padding: 16px 20px 20px;
}
.news-card-cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 6px;
  display: inline-block;
}
.news-card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 8px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-card-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.news-source { font-weight: 600; }

/* Card top row: category + bias badge side by side */
.news-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.news-card-top .news-card-cat {
  margin-bottom: 0;
}

/* Card bullet preview */
.news-card-bullet {
  display: block;
  line-height: 1.5;
}

/* ── Bias badges ─────────────────────────────────────── */
.bias-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 99px;
  line-height: 1.4;
  white-space: nowrap;
}
.bias-left {
  background: #dbeafe;
  color: #1e40af;
}
.bias-lean-left {
  background: #e0f2fe;
  color: #0369a1;
}
.bias-center {
  background: #dcfce7;
  color: #166534;
}
.bias-lean-right {
  background: #fef3c7;
  color: #92400e;
}
.bias-right {
  background: #fee2e2;
  color: #991b1b;
}
/* Dark mode overrides */
[data-theme="dark"] .bias-left {
  background: #1e3a5f;
  color: #93c5fd;
}
[data-theme="dark"] .bias-lean-left {
  background: #164e63;
  color: #7dd3fc;
}
[data-theme="dark"] .bias-center {
  background: #14532d;
  color: #86efac;
}
[data-theme="dark"] .bias-lean-right {
  background: #78350f;
  color: #fcd34d;
}
[data-theme="dark"] .bias-right {
  background: #7f1d1d;
  color: #fca5a5;
}

/* ── Structured summary (modal) ──────────────────────── */
.news-summary-bullets {
  margin: 0 0 14px 0;
  padding-left: 20px;
  list-style: disc;
}
.news-summary-bullets li {
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 6px;
  color: var(--text);
}
.news-why-matters {
  background: var(--surface2);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 8px;
}
.news-why-matters strong {
  color: var(--primary);
}

/* Article detail modal */
.article-hero {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}
.article-meta {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.article-desc {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 20px;
}


/* ═══════════════════════════════════════════════════════════
   CHAT FULLPAGE
   ═══════════════════════════════════════════════════════════ */

.chat-fullpage {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
}

.chat-fullpage .chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-fullpage .chat-msg {
  padding: 14px 20px;
  border-radius: var(--radius);
  max-width: 85%;
  font-size: 0.92rem;
  line-height: 1.6;
  animation: fadeSlideUp 0.25s ease;
}
.chat-fullpage .chat-msg.user {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-fullpage .chat-msg.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-input-bar {
  display: flex;
  flex-shrink: 0;
  gap: 10px;
  padding: 16px 0 24px;
  border-top: 1px solid var(--border);
}
.chat-input-bar input {
  flex: 1;
  min-width: 0;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.chat-input-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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


/* ═══════════════════════════════════════════════════════════
   GLOBAL ANIMATIONS & POLISH
   ═══════════════════════════════════════════════════════════ */

/* Stagger-fade: children animate in sequentially */
.stagger-fade > * {
  opacity: 0;
  animation: fadeSlideUp 0.35s ease forwards;
}
.stagger-fade > *:nth-child(1) { animation-delay: 0s; }
.stagger-fade > *:nth-child(2) { animation-delay: 0.06s; }
.stagger-fade > *:nth-child(3) { animation-delay: 0.12s; }
.stagger-fade > *:nth-child(4) { animation-delay: 0.18s; }
.stagger-fade > *:nth-child(5) { animation-delay: 0.24s; }
.stagger-fade > *:nth-child(6) { animation-delay: 0.30s; }
.stagger-fade > *:nth-child(7) { animation-delay: 0.36s; }
.stagger-fade > *:nth-child(8) { animation-delay: 0.42s; }
.stagger-fade > *:nth-child(n+9) { animation-delay: 0.48s; }
@media (prefers-reduced-motion: reduce) {
  .stagger-fade > * { opacity: 1; animation: none; }
}

/* Skeleton loading shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 6px;
}
.skeleton-line:last-child { width: 60%; }
.skeleton-card {
  height: 140px;
  border-radius: var(--radius);
}
.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
}
.toast.toast-exit {
  animation: toastOut 0.25s ease forwards;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-info    { border-left: 4px solid var(--primary); }
.toast-warning { border-left: 4px solid var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(60px); }
}

/* Page load animation */
.container {
  animation: pageIn 0.4s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Smooth button press */
.btn:active {
  transform: scale(0.97);
}

/* Panel hover glow */
.panel {
  transition: box-shadow 0.2s ease;
}
.panel:hover {
  box-shadow: var(--shadow);
}

/* Tile hover lift */
.tile:not(.tile-placeholder):hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}
.tile {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Disabled buttons */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}


/* ── Scrollbar styling ─────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }


/* ═══════════════════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION BAR
   ═══════════════════════════════════════════════════════════ */

.bottom-nav {
  display: none; /* hidden on desktop */
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding: 6px 0 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    justify-content: space-around;
    align-items: stretch;
  }
  .bottom-nav::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    z-index: -1;
  }
  .bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    border-radius: 0;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 48px;
    flex: 1;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }
  .bnav-item svg {
    flex-shrink: 0;
  }
  .bnav-item:active {
    opacity: 0.5;
    transition: none;
  }
  .bnav-item.active {
    color: var(--primary);
  }
  .bnav-more-btn {
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .bnav-more-btn:active {
    opacity: 0.5;
    transition: none;
  }

  /* ── More popup (slide-up sheet) ──────────────── */
  .bnav-more-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 998;
  }
  .bnav-more-popup.open {
    display: block;
  }
  .bnav-more-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    animation: fadeIn 0.15s ease;
  }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  .bnav-more-sheet {
    position: absolute;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    padding: 12px 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    animation: sheetUp 0.2s ease;
  }
  @keyframes sheetUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  .bnav-more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.78rem;
    font-weight: 600;
    min-width: 72px;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .bnav-more-item:hover, .bnav-more-item:active {
    background: var(--primary-light);
    color: var(--primary);
  }
  .bnav-more-item.active {
    color: var(--primary);
    background: var(--primary-light);
  }

}


/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════ */

/* ── Tablet (max 768px) ─────────────────────────────────── */
@media (max-width: 768px) {
  .container, .panel, .panel-header, .collapsible-header,
  .unsub-row, .other-email-row, .chat-input-area,
  .two-col, .collapsible-stack, .email-chat-panel {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* Flex children must be able to shrink */
  .panel-header > *, .collapsible-header > *,
  .unsub-row > *, .unsub-left, .unsub-actions,
  .other-email-info, .chat-input-area > * {
    min-width: 0;
  }

  /* Topbar */
  .topbar {
    padding: 12px 16px;
    max-width: 100vw;
    overflow: hidden;
  }
  .topbar-left {
    gap: 8px;
    min-width: 0;
    overflow: hidden;
  }
  .logo {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .back-link {
    font-size: 0.82rem;
    flex-shrink: 0;
  }
  .topbar-right {
    gap: 6px;
    flex-shrink: 0;
  }
  .refresh-info {
    display: none;
  }

  /* Container */
  .container {
    padding: 16px;
    max-width: 100vw;
    overflow-x: hidden;
    margin-top: 15px;
  }
#navTileGrid{
  margin-top: 15px;
}
  /* Panel */
  .panel {
    margin-bottom: 16px;
    max-width: 100%;
  }
  .panel-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .panel-header h2 {
    font-size: 0.95rem;
  }
  .panel-sub {
    font-size: 0.78rem;
  }

  /* Unsub actions: smaller on mobile */
  .unsub-actions {
    gap: 4px;
  }
  .btn-block, .btn-unsub {
    font-size: 0.68rem;
    padding: 3px 8px;
  }
  .unsub-row {
    padding: 10px 12px;
    gap: 8px;
  }

  /* Finance cards */
  .finance-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .fin-card {
    padding: 14px 16px;
  }
  .fin-card-value {
    font-size: 1.2rem;
  }

  /* Charts */
  .chart-container {
    height: 220px;
    padding: 10px;
  }

  /* News grid */
  .news-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .news-card-img {
    height: 160px;
  }

  /* News tabs: horizontal scroll */
  .news-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 4px;
  }
  .news-tabs::-webkit-scrollbar { display: none; }
  .news-tab {
    flex-shrink: 0;
    padding: 6px 16px;
    font-size: 0.8rem;
  }

  /* Transactions */
  .txn-row {
    padding: 10px 12px;
    gap: 10px;
  }
  .txn-date {
    flex: 0 0 48px;
    font-size: 0.72rem;
  }
  .txn-merchant {
    font-size: 0.82rem;
  }
  .txn-amount {
    font-size: 0.85rem;
  }

  /* Budget rows */
  .budget-info {
    flex: 0 0 100px;
  }

  /* Account rows */
  .account-row {
    padding: 10px 12px;
  }

  /* Input search */
  .input-sm {
    width: 120px;
  }

  /* Insights */
  .insights-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  /* Highlight cards */
  /* Highlights: vertical scroll on mobile */
  .highlight-scroll {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 420px;
    padding: 12px 14px;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    cursor: default;
  }
  .highlight-scroll::after {
    display: none;
  }
  .highlight-card {
    flex: 0 0 auto;
    min-width: 0;
    width: 100%;
    min-height: auto;
  }
  .highlight-card:hover {
    transform: none;
  }

  /* Collapsible panels: start collapsed on mobile */
  .collapsible-panel {
    margin-bottom: 10px;
  }
  .collapsible-panel.mobile-collapsed .collapsible-body,
  .collapsible-panel.collapsed .collapsible-body {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
  }
  .collapsible-panel.mobile-collapsed .collapse-chevron,
  .collapsible-panel.collapsed .collapse-chevron {
    transform: rotate(-90deg);
  }
  .collapsible-body {
    max-height: 320px;
  }
  .collapsible-header {
    padding: 10px 14px;
  }
  .collapsible-header h2 {
    font-size: 0.88rem;
  }
  .collapsible-header .panel-sub {
    display: none;
  }

  /* Unsub/other email scrolls - show more rows when expanded */
  .unsub-scroll {
    max-height: 280px;
  }
  .unsub-row {
    padding: 8px 12px;
  }
  .unsub-sender {
    font-size: 0.82rem;
  }
  .unsub-detail {
    font-size: 0.7rem;
  }
  .other-email-row {
    padding: 8px 12px;
    gap: 8px;
  }
  .other-email-subject {
    font-size: 0.82rem;
  }
  .other-email-meta {
    font-size: 0.7rem;
  }

  /* Email page chat -- usable on mobile */
  .email-chat-panel {
    max-height: none;
  }
  .email-chat-panel .chat-messages {
    max-height: 280px;
    padding: 10px 12px;
    gap: 10px;
  }
  .email-chat-panel .chat-msg {
    padding: 10px 14px;
    font-size: 0.88rem;
    max-width: 90%;
  }
  .email-chat-panel .panel-header {
    padding: 12px 14px;
  }
  .email-chat-panel .panel-header h2 {
    font-size: 0.92rem;
  }
  .email-chat-panel .panel-header .panel-sub {
    display: none;
  }
  .chat-input-area {
    padding: 10px 12px;
    gap: 8px;
  }
  .chat-input-area input {
    padding: 12px 14px;
    font-size: 16px;
  }
  .chat-input-area .btn-primary {
    padding: 12px 18px;
    font-size: 0.92rem;
  }

  /* Chat fullpage: flex layout keeps input bar at bottom */
  .chat-fullpage {
    padding: 15px 10px;
  }
  .chat-fullpage .chat-messages {
    flex: 1;
    min-height: 0;
    padding: 12px 0 8px;
  }
  .chat-input-bar {
    flex-shrink: 0;
    background: var(--surface);
    padding: 10px 4px 12px;
    border-top: 1px solid var(--border);
  }
  .chat-input-bar input {
    padding: 12px 14px;
    font-size: 16px;
  }
  .chat-input-bar .btn {
    padding: 12px 18px;
    font-size: 0.95rem;
  }

  /* Bills chat -- usable on mobile */
  .chat-panel .chat-messages {
    max-height: 280px;
  }

  /* Buttons: prevent squishing on mobile */
  .btn-sm {
    padding: 7px 14px;
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .btn {
    padding: 10px 18px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .topbar-right {
    flex-wrap: nowrap;
    overflow: visible;
  }
  .topbar-right .btn-sm {
    min-width: auto;
  }
.tasks-container{
  margin-top: 15px;
}
  /* Email modal: full screen */
  .email-modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 75vh;
    border-radius: 0;
    margin: 0;
  }
  .email-modal-header {
    border-radius: 0;
  }
}


/* ── Phone (max 500px) ──────────────────────────────────── */
@media (max-width: 500px) {
  /* Landing tiles: single column for card view */
  .tile-grid:not(.tile-grid--compact) {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .tile-grid:not(.tile-grid--compact) .tile-inner {
    padding: 20px 18px 18px;
  }
  .tile-grid:not(.tile-grid--compact) .tile-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    margin-bottom: 14px;
  }
  .tile-grid:not(.tile-grid--compact) .tile-icon svg {
    width: 22px;
    height: 22px;
  }
  .tile-grid:not(.tile-grid--compact) .tile-title {
    font-size: 0.98rem;
  }
  .tile-grid:not(.tile-grid--compact) .tile-desc {
    font-size: 0.78rem;
  }
  .tile-grid:not(.tile-grid--compact) .tile-footer {
    margin-top: 12px;
    padding-top: 10px;
  }

  /* Grid compact: 2 columns on phone */
  .tile-grid--compact {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  /* Topbar: tighter */
  .topbar {
    padding: 10px 12px;
  }
  .logo {
    font-size: 1rem;
  }
  .btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  /* Container */
  .container {
    padding: 12px;
  }

  /* Welcome hero - mobile */
  .welcome-hero {
    padding: 22px 20px 20px;
    margin-bottom: 20px;
  }
  .welcome-hero-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }
  .welcome-hero-icon svg {
    width: 22px;
    height: 22px;
  }
  .welcome-hero-title {
    font-size: 1.2rem;
  }
  .welcome-hero-sub {
    font-size: 0.82rem;
  }

  /* Two-col: already collapses at 900px, just tighten */
  .two-col {
    gap: 10px;
  }

  /* Collapsible panels -- extra tight on phone */
  .collapsible-header {
    padding: 8px 12px;
  }
  .collapsible-header h2 {
    font-size: 0.84rem;
  }
  .collapsible-panel {
    margin-bottom: 8px;
  }
  .email-chat-panel .panel-header {
    padding: 10px 12px;
  }
  .email-chat-panel .panel-header h2 {
    font-size: 0.88rem;
  }
  .chat-input-area {
    padding: 8px 10px;
  }
  .chat-input-area input {
    padding: 11px 12px;
    font-size: 16px;
  }
  .chat-input-area .btn-primary {
    padding: 11px 16px;
    font-size: 0.88rem;
  }

  /* Compact panel */
  .compact-panel {
    max-height: 250px;
  }

  /* Finance: stack all cards */
  .finance-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .fin-card {
    padding: 12px 14px;
  }
  .fin-card-label {
    font-size: 0.7rem;
  }
  .fin-card-value {
    font-size: 1.05rem;
  }

  /* Bills */
  .bill-row {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  /* Chat input bar */
  .chat-input-bar {
    padding: 8px 2px 10px;
    gap: 6px;
  }
  .chat-input-bar input {
    padding: 12px 12px;
    font-size: 16px;
  }
  .chat-input-bar .btn {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  /* Chat messages */
  .chat-fullpage .chat-msg {
    max-width: 92%;
    padding: 12px 14px;
    font-size: 0.9rem;
  }

  /* Highlight scroll -- already vertical from 768px, just tighten */
  .highlight-scroll {
    padding: 10px 12px;
    max-height: 360px;
  }
  .highlight-card {
    padding: 14px 16px;
  }

  /* Unsubscribe / other email lists -- show more rows on phone */
  .unsub-scroll {
    max-height: 220px;
  }
  .collapsible-body {
    max-height: 220px;
  }
  .email-chat-panel .chat-messages {
    max-height: 240px;
  }
  .chat-panel .chat-messages {
    max-height: 240px;
  }
}


/* ── Safe area insets for notched phones / Capacitor ─────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .topbar {
    padding-top: calc(12px + env(safe-area-inset-top));
  }
}


/* ═══════════════════════════════════════════════════════════
   SETTINGS PAGE
   ═══════════════════════════════════════════════════════════ */

.usage-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 20px;
}
.usage-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}
.usage-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.usage-card-cost {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}
.usage-card-detail {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.usage-breakdown {
  border-top: 1px solid var(--border);
}
.usage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
.usage-row:last-child { border-bottom: none; }
.usage-svc {
  font-weight: 600;
  font-size: 0.88rem;
  min-width: 100px;
  text-transform: capitalize;
}
.usage-detail {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.usage-cost {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.9rem;
}

.service-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.service-row:last-child { border-bottom: none; }
.service-icon { font-size: 1.3rem; }
.service-info { flex: 1; }
.service-name { font-weight: 600; font-size: 0.9rem; }
.service-detail { font-size: 0.78rem; color: var(--text-dim); margin-top: 1px; }
.service-status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
}
.service-status.success {
  background: var(--success-bg);
  color: var(--success);
}
.service-status.dim {
  background: var(--surface2);
  color: var(--text-dim);
}

.job-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.job-row:last-child { border-bottom: none; }
.job-name { font-weight: 600; font-size: 0.88rem; }
.job-next { font-size: 0.8rem; color: var(--text-dim); }

.stats-grid {
  display: flex;
  gap: 24px;
  padding: 20px;
}
.stat-item { text-align: center; flex: 1; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.82rem; color: var(--text-dim); margin-top: 4px; }

.activity-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.activity-row:last-child { border-bottom: none; }
.activity-agent {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}
.activity-action { font-weight: 500; }
.activity-msg {
  grid-column: 1 / -1;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.activity-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

@media (max-width: 768px) {
  .usage-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
  }
  .usage-card { padding: 12px; }
  .usage-card-cost { font-size: 1.1rem; }
  .stats-grid { gap: 12px; padding: 16px; }
  .stat-value { font-size: 1.3rem; }
  .activity-row { padding: 10px 14px; }
}
@media (max-width: 500px) {
  .usage-cards {
    grid-template-columns: 1fr 1fr;
  }
  .service-row { padding: 12px 14px; }
  .job-row { padding: 10px 14px; flex-direction: column; align-items: flex-start; gap: 4px; }
}


/* ── File Manager ────────────────────────────────────────── */

/* Big upload button -- mobile first */
.fm-upload-bar {
  padding: 16px;
}
.fm-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.fm-upload-btn:hover { background: var(--primary-hover); }
.fm-upload-btn:active { transform: scale(0.98); }

/* Drop zone (secondary, for desktop drag) */
.fm-drop-zone {
  margin: 0 16px 8px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: border-color 0.2s, background 0.2s;
}
.fm-drop-zone svg { color: var(--text-dim); flex-shrink: 0; }
.fm-drop-zone.fm-drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* Upload progress */
.fm-upload-progress-wrap {
  padding: 0 16px 12px;
}
.fm-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.fm-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.2s;
  width: 0;
}
.fm-progress-text { font-size: 0.8rem; }

/* Breadcrumb */
.fm-breadcrumb {
  padding: 10px 16px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.fm-crumb-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.fm-crumb-link:hover { text-decoration: underline; }
.fm-crumb-sep { color: var(--text-dim); font-size: 0.75rem; }

/* File list panel */
.fm-panel { padding: 0; overflow: hidden; }

/* File row -- mobile-friendly card layout */
.fm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  cursor: default;
}
.fm-row:last-child { border-bottom: none; }
.fm-row:hover { background: var(--surface2); }
.fm-row[onclick] { cursor: pointer; }

.fm-row-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}
.fm-row-info {
  flex: 1;
  min-width: 0;
}
.fm-row-name {
  font-weight: 500;
  font-size: 0.95rem;
  word-break: break-word;
  line-height: 1.3;
}
.fm-row-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.fm-row-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Action buttons -- big enough to tap */
.fm-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.fm-action-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.fm-action-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Settings page file manager link */
.fm-link-panel {
  transition: background 0.15s;
}
.fm-link-panel:hover {
  background: var(--surface2);
}

/* Hide drop zone on mobile (button is primary) */
@media (max-width: 600px) {
  .fm-drop-zone { display: none; }
  .fm-upload-bar { padding: 12px; }
  .fm-row { padding: 12px; gap: 10px; }
  .fm-action-btn { width: 36px; height: 36px; }
}

/* On desktop, widen the upload button area */
@media (min-width: 601px) {
  .fm-upload-btn {
    max-width: 320px;
  }
}

/* ═══════════════════════════════════════════════════════════
   GYM TRACKER -- Mobile-first
   ═══════════════════════════════════════════════════════════ */

/* Container */
.gym-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 12px;
  padding-bottom: 80px;
}

/* Sections */
.gym-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.gym-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.gym-section-header h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}
.gym-pad {
  padding: 14px 14px;
}
.gym-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
}
.gym-sub {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 6px;
}

/* Horizontal scroll filter pills */
.gym-filter-scroll {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.gym-filter-scroll::-webkit-scrollbar { display: none; }
.gym-filter-scroll-inner {
  border-bottom: none;
  padding-bottom: 4px;
}

.gym-pill {
  flex-shrink: 0;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  min-height: 38px;
  display: flex;
  align-items: center;
}
.gym-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.gym-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Exercise select */
.gym-select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7a92' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
  min-height: 48px;
}
.gym-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
[data-theme="dark"] .gym-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238a90a5' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
}

/* Weight full row + sets/reps half row */
.gym-input-full {
  margin-bottom: 10px;
}
.gym-input-full .gym-stepper {
  max-width: 100%;
}
.gym-input-full .gym-step-input {
  font-size: 1.4rem;
}
.gym-input-full .gym-step-btn {
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
}
.gym-input-row {
  display: flex;
  gap: 8px;
}
.gym-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gym-input-group label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}
.gym-stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.gym-step-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 52px;
  border: none;
  background: var(--surface2);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.gym-step-btn:active {
  background: var(--primary);
  color: #fff;
}
.gym-step-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 12px 2px;
  outline: none;
  -moz-appearance: textfield;
}
.gym-step-input::-webkit-outer-spin-button,
.gym-step-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Big log button */
.gym-log-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-top: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  min-height: 54px;
}
.gym-log-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.gym-log-btn:not(:disabled):active {
  transform: scale(0.97);
}
.gym-log-btn--success { background: var(--success) !important; }
.gym-log-btn--error { background: var(--danger) !important; }

/* Plate calculator display */
.gym-plate-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.gym-plate-label {
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.gym-plate-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 16px;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
}
.gym-plate-total {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* Clear all button */
.gym-clear-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 38px;
}
.gym-clear-btn:active {
  background: var(--danger);
  color: #fff;
}

/* Today's workout log rows */
.gym-log-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.gym-log-row:last-child { border-bottom: none; }
.gym-log-emoji {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}
.gym-log-info {
  flex: 1;
  min-width: 0;
}
.gym-log-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}
.gym-log-detail {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.gym-log-plates {
  color: var(--primary);
  font-weight: 600;
  margin-left: 4px;
}
.gym-del-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, color 0.1s;
}
.gym-del-btn:active {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ── Collapsible sections ──────────────────────────────── */
.gym-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
  min-height: 50px;
}
.gym-section-toggle h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}
.gym-chevron {
  color: var(--text-dim);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.gym-collapsible.open .gym-chevron {
  transform: rotate(180deg);
}
.gym-collapse-body {
  animation: gymSlideDown 0.25s ease;
}
@keyframes gymSlideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 2000px; }
}

/* ── My Weights section ────────────────────────────────── */
.gym-weight-group-label {
  padding: 10px 16px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.gym-weight-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.gym-weight-row:last-child { border-bottom: none; }
.gym-weight-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.92rem;
  min-width: 0;
}
.gym-weight-val {
  font-size: 0.92rem;
  color: var(--text);
  white-space: nowrap;
}
.gym-weight-val strong {
  font-size: 1rem;
  color: var(--primary);
}
.gym-weight-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  text-transform: uppercase;
  flex-shrink: 0;
}
.gym-weight-row--tap {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.gym-weight-row--tap:active {
  background: var(--surface2);
}
.gym-weight-arrow {
  flex-shrink: 0;
  color: var(--text-dim);
  margin-left: 4px;
}

/* ── History section ──────────────────────────────────── */
.gym-history-date {
  padding: 10px 16px 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.gym-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.gym-history-row:last-child { border-bottom: none; }
.gym-history-emoji {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}
.gym-history-name {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gym-history-stat {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.82rem;
  white-space: nowrap;
}

/* Gym tile on home */
.tile-gym::before { background: #e85c5c; }
.tile-gym .tile-icon { background: #fff2f2; color: #e85c5c; }
.tile-gym:hover .tile-icon { box-shadow: 0 4px 14px rgba(232,92,92,0.25); }
.tile-gym .tile-stat { color: #e85c5c; }
[data-theme="dark"] .tile-gym .tile-icon { background: #2a1515; color: #f08080; }
[data-theme="dark"] .tile-gym .tile-stat { color: #f08080; }

/* ── Gym mobile tweaks ────────────────────────────────── */
@media (max-width: 600px) {
  .gym-input-full .gym-step-btn {
    width: 52px;
    height: 52px;
    font-size: 1.4rem;
  }
  .gym-input-full .gym-step-input {
    font-size: 1.3rem;
  }
}
@media (max-width: 500px) {
  .gym-container {
    padding: 8px;
    padding-bottom: 80px;
  }
  .gym-section {
    margin-bottom: 8px;
    border-radius: 10px;
  }
  .gym-filter-scroll {
    padding: 10px 12px;
    gap: 6px;
  }
  .gym-pill {
    padding: 7px 14px;
    font-size: 0.78rem;
    min-height: 34px;
  }
  .gym-pad {
    padding: 12px;
  }
  .gym-select {
    padding: 12px 14px;
    font-size: 0.95rem;
    min-height: 46px;
  }
  .gym-step-btn {
    width: 44px;
    height: 48px;
    font-size: 1.2rem;
  }
  .gym-step-input {
    font-size: 1.05rem;
    padding: 10px 2px;
  }
  .gym-log-btn {
    padding: 14px;
    font-size: 1rem;
    min-height: 50px;
  }
  .gym-log-row {
    padding: 12px;
    gap: 10px;
  }
  .gym-section-header {
    padding: 12px;
  }
  .gym-section-toggle {
    padding: 12px;
    min-height: 46px;
  }
  .gym-weight-row {
    padding: 10px 12px;
  }
  .gym-history-row {
    padding: 8px 12px;
  }
}


/* ── Feedback category buttons ───────────────────────────── */
.fb-cat-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.fb-cat-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.fb-cat-btn[data-cat="bug"].active {
  background: #ef4444;
  border-color: #ef4444;
}
.fb-cat-btn[data-cat="feature"].active {
  background: #3b82f6;
  border-color: #3b82f6;
}

/* ── Touch-friendly: ensure minimum tap target sizes ─────── */
@media (pointer: coarse) {
  .btn, .news-tab, .bnav-item {
    min-height: 44px;
  }
  .btn-sm {
    min-height: 36px;
  }
  .theme-toggle {
    min-width: 36px;
    min-height: 36px;
  }
}
