/* ========================================================
   TrailTrack Stories — Global Styles
   ======================================================== */

/* ---- CSS Custom Properties ---- */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #273548;
  --surface-active: #2d3f54;
  --border: #334155;
  --border-light: #3e5068;

  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --green: #059669;
  --green-light: #10b981;
  --green-glow: rgba(16, 185, 129, 0.25);

  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.25);

  --orange: #f97316;
  --orange-glow: rgba(249, 115, 22, 0.25);

  --red: #dc2626;
  --red-glow: rgba(220, 38, 38, 0.2);

  --blue: #3b82f6;
  --blue-glow: rgba(59, 130, 246, 0.2);

  --purple: #8b5cf6;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow-green: 0 0 20px var(--green-glow);

  --nav-height: 60px;
  --sidebar-width: 260px;
  --chat-width: 200px;

  --transition-fast: 0.15s ease;
  --transition: 0.25s ease;
  --transition-slow: 0.4s ease;
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--green-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--green); }

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ---- App Layout ---- */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--chat-width);
  grid-template-rows: var(--nav-height) 1fr;
  grid-template-areas:
    "nav nav nav"
    "sidebar content chat";
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#main-nav {
  grid-area: nav;
  z-index: 100;
}

#sidebar {
  grid-area: sidebar;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

#content {
  grid-area: content;
  overflow-y: auto;
  overflow-x: hidden;
}

#chat-panel {
  grid-area: chat;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

/* ---- Online Users Panel (right sidebar) ---- */
.online-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.online-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.online-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.online-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.online-user-item:hover {
  background: var(--surface-hover);
}

.online-user-avatar {
  position: relative;
  flex-shrink: 0;
}

.online-user-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: var(--green-light, #10b981);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.online-user-info {
  min-width: 0;
}

.online-user-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-user-handle {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.online-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.online-menu-btn:hover {
  background: var(--surface-hover);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.btn:active::after { opacity: 0.1; }

.btn-primary {
  background: var(--green);
  color: white;
}
.btn-primary:hover {
  background: var(--green-light);
  box-shadow: var(--shadow-glow-green);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-danger {
  background: var(--red);
  color: white;
}
.btn-danger:hover {
  background: #ef4444;
  box-shadow: 0 0 16px var(--red-glow);
}

.btn-amber {
  background: var(--amber);
  color: #1a1a1a;
}
.btn-amber:hover {
  background: #fbbf24;
}

.btn-small { padding: 4px 10px; font-size: 0.8rem; }
.btn-medium { padding: 8px 16px; font-size: 0.9rem; }
.btn-large { padding: 12px 24px; font-size: 1rem; }
.btn-full { width: 100%; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
  transform: scale(1.1);
}

/* ---- Inputs ---- */
.form-group {
  margin-bottom: 16px;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  width: 100%;
  padding-right: 44px !important;
}

.password-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.password-toggle:hover {
  opacity: 1;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--border-light);
}

.card-elevated {
  box-shadow: var(--shadow-sm);
}

.card-elevated:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* ---- Avatar ---- */
.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--surface-hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.85rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-xl { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-xxl { width: 96px; height: 96px; font-size: 2rem; }

.avatar-wrap {
  position: relative;
  display: inline-block;
}

.online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: var(--green-light);
  border: 2px solid var(--surface);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

.online-dot-sm { width: 8px; height: 8px; }
.online-dot-lg { width: 14px; height: 14px; border-width: 3px; }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.badge-red {
  background: var(--red);
  color: white;
}

.badge-amber {
  background: var(--amber);
  color: #1a1a1a;
}

.badge-green {
  background: var(--green);
  color: white;
}

.badge-pulse {
  animation: badge-pulse 1.5s ease infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge-hunt { background: rgba(5, 150, 105, 0.2); color: var(--green-light); }
.status-badge-trophy { background: rgba(249, 115, 22, 0.2); color: var(--orange); }
.status-badge-live { background: rgba(220, 38, 38, 0.2); color: #f87171; }
.status-badge-post { background: rgba(59, 130, 246, 0.2); color: var(--blue); }
.status-badge-recap { background: rgba(139, 92, 246, 0.2); color: var(--purple); }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in var(--transition) ease;
}

.modal-large {
  max-width: 900px;
}

.modal-small {
  max-width: 380px;
}

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

.modal-header h2, .modal-header h3 {
  font-size: 1.1rem;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--text); }

@keyframes modal-in {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* ---- Auth Modal ---- */
.auth-modal {
  padding: 40px 32px;
  text-align: center;
}

.auth-brand {
  margin-bottom: 28px;
}

.auth-brand .brand-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
}

.auth-brand h1 {
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--green-light), var(--amber));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.auth-tab.active {
  background: var(--green);
  color: white;
}

.auth-form { text-align: left; }

.auth-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 10px;
  text-align: center;
  min-height: 20px;
}

/* ---- Toasts ---- */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  min-width: 280px;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.toast.toast-out {
  animation: toast-out 0.3s ease forwards;
}

.toast-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.9rem; }
.toast-message { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

.toast-success { border-left: 3px solid var(--green-light); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--blue); }
.toast-warning { border-left: 3px solid var(--amber); }

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ---- Dropdown ---- */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
  overflow: hidden;
}

.dropdown-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

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

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

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 18px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--green-light);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--green-light);
  border-radius: 2px 2px 0 0;
}

/* ---- Loading / Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 100%;
}

.skeleton-text-short { width: 60%; }
.skeleton-avatar { border-radius: 50%; }
.skeleton-photo { height: 200px; }

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

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--green-light);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* ---- Tooltip ---- */
/* ---- Tooltips ---- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  padding: 5px 12px;
  background: #111827;
  color: #f1f5f9;
  font-size: 0.75rem;
  white-space: nowrap;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border: 1px solid #334155;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* For items in the nav bar — tooltip goes BELOW */
#main-nav [data-tooltip]::after {
  top: calc(100% + 8px);
  bottom: auto;
}

/* Prevent overflow clipping */
#main-nav {
  overflow: visible !important;
}

#main-nav .nav-right {
  overflow: visible;
}

/* ---- Transitions ---- */
.fade-in {
  animation: fade-in var(--transition) ease;
}

.slide-up {
  animation: slide-up var(--transition) ease;
}

.scale-in {
  animation: scale-in var(--transition-fast) ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---- Lightbox ---- */
.lightbox {
  width: 95vw;
  height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  background: rgba(0,0,0,0.6);
  border: none;
  color: white;
  font-size: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}
.lightbox-close:hover { background: rgba(0,0,0,0.8); }

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(0,0,0,0.5);
  border: none;
  color: white;
  font-size: 2.5rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.lightbox-prev:hover, .lightbox-next:hover {
  background: rgba(0,0,0,0.8);
  transform: translateY(-50%) scale(1.1);
}
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }

.lightbox-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.lightbox-photo-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #000;
  overflow: hidden;
}

.lightbox-photo-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox-photo-wrap canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.lightbox-ai-panel {
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
}

/* ---- Utility ---- */
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green-light); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-center { text-align: center; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 16px; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--text);
}

.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  :root {
    --chat-width: 180px;
    --sidebar-width: 220px;
  }
}

/* ---- Mobile Backdrop ---- */
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--nav-height);
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  -webkit-tap-highlight-color: transparent;
}
.mobile-backdrop.active {
  display: block;
}

@media (max-width: 768px) {
  html {
    font-size: 13px;
  }

  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--nav-height) 1fr;
    grid-template-areas:
      "nav"
      "content";
  }

  #sidebar {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }

  #sidebar.open {
    display: block;
    animation: slide-in-left 0.2s ease;
  }

  #chat-panel {
    display: none;
    position: fixed;
    top: var(--nav-height);
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }

  #chat-panel.open {
    display: flex;
    animation: slide-in-right 0.2s ease;
  }

  .lightbox-ai-panel {
    display: none;
  }

  /* ---- Modals fullscreen on mobile ---- */
  .modal {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    animation: none;
  }

  .modal-large {
    max-width: 100%;
  }

  .modal-small {
    max-width: 100%;
  }

  /* Auth modal fullscreen */
  .auth-modal {
    padding: 24px 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /* ---- Touch targets — minimum 44px ---- */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  .btn-small {
    min-height: 36px;
    padding: 6px 12px;
  }

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

  .dropdown-item {
    padding: 12px 14px;
    min-height: 44px;
  }

  .tab {
    padding: 12px 14px;
    min-height: 44px;
  }

  /* ---- Toast positioning on mobile ---- */
  #toast-container {
    top: auto;
    bottom: 16px;
    right: 8px;
    left: 8px;
    max-width: 100%;
  }

  .toast {
    min-width: auto;
    width: 100%;
  }

  /* ---- Lightbox on mobile ---- */
  .lightbox {
    width: 100vw;
    height: 100vh;
  }

  .lightbox-prev,
  .lightbox-next {
    width: 44px;
    height: 44px;
    font-size: 2rem;
  }

  .lightbox-close {
    width: 44px;
    height: 44px;
  }

  /* ---- Prevent horizontal scrolling ---- */
  body, #app, #content {
    overflow-x: hidden;
  }

  /* ---- Form inputs — prevent zoom on iOS ---- */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px;
  }

  /* ---- Cards less hover effects on mobile ---- */
  .card-elevated:hover {
    transform: none;
  }

  .story-card:hover {
    transform: none;
  }
}

/* ---- Small phones (320px–480px) ---- */
@media (max-width: 480px) {
  html {
    font-size: 12.5px;
  }

  #sidebar.open {
    width: 100%;
  }

  #chat-panel.open {
    width: 100%;
    max-width: 100%;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 10px 16px;
  }

  .auth-modal {
    padding: 20px 16px;
  }

  .auth-brand h1 {
    font-size: 1.4rem;
  }

  .auth-brand .brand-icon {
    font-size: 2.5rem;
  }
}

@keyframes slide-in-left {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ---- Leaflet Overrides ---- */
.leaflet-container {
  background: var(--bg);
  font-family: var(--font);
}

.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip {
  background: var(--surface) !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  color: var(--text) !important;
  font-size: 0.85rem;
}

.map-pin-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  font-size: 14px;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.map-pin-icon span {
  transform: rotate(45deg);
}

.map-pin-trail_cam { background: var(--blue); }
.map-pin-harvest { background: var(--red); }
.map-pin-stand { background: var(--green); }
.map-pin-food_plot { background: var(--green-light); }
.map-pin-sighting { background: var(--amber); }
.map-pin-general { background: var(--text-secondary); }
