/* FanFlame shared styles — dark app theme, brand red #E53E3E. */
:root {
  --ff-primary: #E53E3E;          /* brand accent: icons, links, selected states */
  --ff-primary-strong: #C53030;   /* button/pill BACKGROUNDS — white text passes WCAG AA */
  --ff-secondary: #FC8181;        /* light red: danger/emphasis TEXT on dark surfaces */
  --ff-900: #121212;
  --ff-800: #1E1E1E;
  --ff-700: #2D2D2D;
  --ff-600: #383838;
  --ff-muted: #9CA3AF;            /* replaces #8a8a8a for secondary text (AA on cards) */
  --ff-success: #34D399;
  --ff-warn: #FBBF24;
  --ff-danger: #F87171;
  --ff-info: #60A5FA;
  --ff-sp-1: 4px; --ff-sp-2: 8px; --ff-sp-3: 12px; --ff-sp-4: 16px; --ff-sp-5: 24px; --ff-sp-6: 32px;
  --ff-r-sm: 10px; --ff-r-lg: 16px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--ff-900);
  color: #fff;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* Brand lockup matching FanFlame-Logo-With-Text.png: red flame + heavy white sans. */
.ff-logo {
  display: inline-flex; align-items: center; gap: 0.28em;
  font-family: 'Inter', sans-serif; font-weight: 800; letter-spacing: -0.02em; color: #fff;
}
.ff-logo img { height: 1.05em; width: auto; display: block; }
.ff-logo span { font-size: 0.82em; }

.ff-card {
  background: var(--ff-800);
  border: 1px solid var(--ff-700);
  border-radius: 16px;
}

.ff-input {
  width: 100%;
  background: var(--ff-700);
  border: 1px solid var(--ff-600);
  border-radius: 10px;
  color: #fff;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
}
.ff-input:focus { border-color: var(--ff-primary); }
.ff-input::placeholder { color: #9CA3AF; }
label.ff-label { display: block; font-size: 13px; color: #b5b5b5; margin: 14px 0 6px; }

.ff-btn {
  box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ff-primary-strong); color: #fff; border: none; border-radius: 10px;
  padding: 13px 18px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
  transition: filter .15s;
}
.ff-btn:hover { filter: brightness(1.08); }
.ff-btn:disabled { opacity: .6; cursor: not-allowed; }
.ff-btn-secondary { background: var(--ff-700); }
.ff-btn-ghost { background: transparent; border: 1px solid var(--ff-600); }

.ff-pill {
  display: inline-block; background: rgba(229,62,62,.24); color: var(--ff-secondary);
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
}
.ff-badge-green { background: rgba(16,185,129,.18); color: #10B981; }
.ff-badge-yellow { background: rgba(245,158,11,.18); color: #F59E0B; }
.ff-badge-red { background: rgba(229,62,62,.18); color: var(--ff-primary); }
.ff-badge-blue { background: rgba(59,130,246,.18); color: #3B82F6; }
.ff-badge-gray { background: rgba(156,163,175,.16); color: var(--ff-muted); }

.ff-container { max-width: 460px; margin: 0 auto; padding: 20px; }
.ff-topbar {
  position: sticky; top: 0; z-index: 20; background: var(--ff-800);
  border-bottom: 1px solid var(--ff-700); padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.ff-muted { color: var(--ff-muted); }
.ff-link { color: var(--ff-primary); text-decoration: none; cursor: pointer; }

.ff-social-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--ff-600);
  background: #fff; color: #1a1a1a; font-weight: 600; cursor: pointer; font-size: 15px;
}

.ff-spin { display: inline-block; animation: ff-rotate 0.8s linear infinite; }
@keyframes ff-rotate { to { transform: rotate(360deg); } }

.ff-divider { display: flex; align-items: center; gap: 12px; color: #8a8a8a; font-size: 13px; margin: 18px 0; }
.ff-divider::before, .ff-divider::after { content: ""; flex: 1; height: 1px; background: var(--ff-600); }

.ff-slot {
  border: 1px solid var(--ff-600); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
  cursor: pointer; display: flex; align-items: center; justify-content: space-between;
}
.ff-slot.selected { border-color: var(--ff-primary); background: rgba(229,62,62,.10); }
.ff-hidden { display: none !important; }

/* Generic selected state (duration chips, persona cards, etc.) */
.ff-selectable { cursor: pointer; }
.ff-selectable.selected { background: var(--ff-primary) !important; border-color: var(--ff-primary) !important; color: #fff !important; }
.ff-card.ff-selectable.selected { background: rgba(229,62,62,.12) !important; color: inherit !important; }

/* Generic modal overlay */
.ff-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.ff-modal { max-width: 400px; width: 100%; max-height: 85vh; overflow-y: auto; }
.ff-modal-wide { max-width: 560px; }

:focus-visible { outline: 2px solid var(--ff-primary); outline-offset: 2px; }

/* Bottom tab bar (nav shell) */
.ff-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: stretch;
  background: var(--ff-800); border-top: 1px solid var(--ff-700);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.ff-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ff-muted); text-decoration: none; font-size: 11px; padding: 6px 0;
}
.ff-tab i { font-size: 21px; }
.ff-tab.active { color: var(--ff-primary); }
/* Raised centre create button (reference tab bar) */
.ff-tab-add {
  width: 56px; height: 56px; border-radius: 50%; margin-top: -24px;
  background: var(--ff-primary); color: #fff; font-size: 30px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(229,62,62,.45);
}
.ff-tab-badge {
  position: absolute; top: 2px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
  background: var(--ff-primary); color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
/* Unread-count bubble inside list rows (messages inbox) */
.ff-unread-bubble {
  min-width: 22px; height: 22px; padding: 0 6px; box-sizing: border-box; flex-shrink: 0;
  background: var(--ff-primary); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
}

/* Round icon button — 40px min touch target */
.ff-iconbtn {
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--ff-700); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0; text-decoration: none;
}
.ff-iconbtn:hover { background: var(--ff-600); }

/* Fixed bottom action bar (reference create page) */
.ff-bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--ff-800); border-top: 1px solid var(--ff-700);
  padding: 14px 16px max(14px, env(safe-area-inset-bottom));
}
.ff-bottombar .ff-bottombar-inner { max-width: 460px; margin: 0 auto; display: flex; gap: 12px; }

/* Floating action button (reference schedule page) */
.ff-fab {
  position: fixed; right: 16px; bottom: 84px; z-index: 40;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--ff-primary); color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(229,62,62,.4);
}
.ff-fab:hover { filter: brightness(1.08); }

/* Calendar (reference schedule page) */
.ff-cal { border-radius: 12px; overflow: hidden; }
.ff-cal-head {
  display: grid; grid-template-columns: repeat(7, 1fr); text-align: center;
  padding: 8px 8px; border-bottom: 1px solid var(--ff-700);
  background: rgba(45,45,45,.5); font-size: 11px; font-weight: 500; color: #9ca3af;
}
.ff-cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 8px; }
.ff-cal-day {
  aspect-ratio: 1/1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; cursor: pointer; border-radius: 50%; font-size: 14px;
  border: 1px solid transparent;
}
.ff-cal-day.today { background: rgba(229,62,62,.15); font-weight: 600; color: var(--ff-primary); }
.ff-cal-day.sel { border-color: var(--ff-primary); }
.ff-cal-day.has::after {
  content: ''; position: absolute; bottom: 5px; width: 4px; height: 4px;
  background: var(--ff-primary); border-radius: 50%;
}

/* Removable chip (selected time slots on create page) */
.ff-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ff-700); border: 1px solid var(--ff-600); border-radius: 999px;
  padding: 6px 8px 6px 14px; font-size: 13px; margin: 0 8px 8px 0;
}
.ff-chip .ff-chip-x {
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--ff-600); color: #cfcfcf; display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
}
.ff-chip .ff-chip-x:hover { background: var(--ff-primary); color: #fff; }

/* Toggle switch (profile preferences) */
.ff-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.ff-switch input { opacity: 0; width: 0; height: 0; }
.ff-switch .track {
  position: absolute; inset: 0; background: var(--ff-600); border-radius: 999px; transition: background .15s; cursor: pointer;
}
.ff-switch .track::before {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .15s;
}
.ff-switch input:checked + .track { background: var(--ff-primary); }
.ff-switch input:checked + .track::before { transform: translateX(18px); }

/* Screen-reader-only (standard clip pattern) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Loading skeletons (dark shimmer) */
.ff-skel {
  position: relative; overflow: hidden;
  background: var(--ff-700); border-radius: var(--ff-r-sm);
  background-image: linear-gradient(90deg, var(--ff-700) 0%, var(--ff-600) 40%, var(--ff-700) 80%);
  background-size: 200% 100%;
  animation: ff-shimmer 1.4s ease-in-out infinite;
}
@keyframes ff-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.ff-skel-text { height: 14px; border-radius: 6px; margin: 6px 0; }
.ff-skel-title { height: 18px; width: 60%; border-radius: 6px; margin: 8px 0; }
.ff-skel-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.ff-skel-card { height: 72px; border-radius: var(--ff-r-lg); margin-bottom: 12px; }
.ff-skel-tile { height: 180px; border-radius: var(--ff-r-lg); }

/* Empty / error state block */
.ff-state { text-align: center; padding: 32px; }
.ff-state .ff-state-icon, .ff-state > i { font-size: 34px; color: var(--ff-muted); display: block; margin-bottom: 10px; }
.ff-state .ff-state-title { font-size: 15px; font-weight: 600; margin: 0 0 6px; color: #fff; }
.ff-state .ff-state-body { font-size: 13px; color: var(--ff-muted); margin: 0 0 4px; }
.ff-state .ff-retry { width: auto; margin-top: 14px; }

/* Toast stack */
#ffToasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 99999;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: 100%; max-width: 92vw;
}
.ff-toast {
  pointer-events: auto;
  background: var(--ff-800); color: #fff; border: 1px solid var(--ff-700);
  border-left: 4px solid var(--ff-info); border-radius: var(--ff-r-sm);
  padding: 12px 18px; font-size: 14px; max-width: 100%; box-sizing: border-box;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .2s;
}
.ff-toast.show { opacity: 1; }
.ff-toast-info { border-left-color: var(--ff-info); }
.ff-toast-success { border-left-color: var(--ff-success); }
.ff-toast-error { border-left-color: var(--ff-danger); }
.ff-toast-warn { border-left-color: var(--ff-warn); }

/* Responsive wide tier (pages opt in; default 460px unchanged) */
.ff-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 768px) {
  .ff-container.ff-wide { max-width: 720px; }
  body.ff-wide-page .ff-bottombar .ff-bottombar-inner { max-width: 720px; }
  .ff-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .ff-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1080px) {
  .ff-container.ff-wide { max-width: 900px; }
  body.ff-wide-page .ff-bottombar .ff-bottombar-inner { max-width: 900px; }
  .ff-grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Reduced motion: static spinners/skeletons, no transitions */
@media (prefers-reduced-motion: reduce) {
  .ff-spin, .ff-skel { animation: none; }
  *, *::before, *::after { transition: none !important; }
}
