/* ===========================
   DESIGN SYSTEM
   =========================== */
:root {
  --bg-base:       #0c0c09;
  --bg-surface:    #131310;
  --bg-card:       #191914;
  --bg-input:      #1e1e17;
  --border:        #2c2c1e;
  --border-light:  #1e1e17;

  --text-primary:   #f0ead8;
  --text-secondary: #8a8274;
  --text-muted:     #48453a;

  --accent:        #D4A017;
  --accent-hover:  #E8B820;
  --accent-glow:   rgba(212,160,23,0.15);

  --risk-low:      #22c55e;
  --risk-medium:   #eab308;
  --risk-high:     #f97316;
  --risk-critical: #ef4444;

  --risk-low-bg:      rgba(34,197,94,0.12);
  --risk-medium-bg:   rgba(234,179,8,0.12);
  --risk-high-bg:     rgba(249,115,22,0.12);
  --risk-critical-bg: rgba(239,68,68,0.12);

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

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

  --transition: 0.18s ease;

  --nav-h: 64px;
  --mobile-nav-h: 60px;
  --mobile-tabs-h: 44px;
}

/* ===========================
   RESET & BASE
   =========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* Base colour + top radial glow + subtle grid — all in one background stack */
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse 900px 500px at 50% -60px, rgba(59,130,246,0.11) 0%, transparent 70%),
    repeating-linear-gradient(rgba(255,255,255,0.022) 0px, rgba(255,255,255,0.022) 1px, transparent 1px, transparent 48px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.022) 0px, rgba(255,255,255,0.022) 1px, transparent 1px, transparent 48px);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { display: block; max-width: 100%; }

/* ===========================
   SCROLLBAR
   =========================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===========================
   TYPOGRAPHY
   =========================== */
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; font-weight: 600; }
p  { color: var(--text-secondary); }

/* ===========================
   BUTTONS
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

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

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: var(--risk-critical);
  border: 1px solid rgba(239,68,68,0.25);
}
.btn-danger:hover {
  background: rgba(239,68,68,0.2);
}

.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-md); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ===========================
   FORMS
   =========================== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}
.form-label span { color: var(--risk-critical); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 11px 14px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

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

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

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-textarea { resize: vertical; min-height: 120px; }

.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.form-error { font-size: 0.8rem; color: var(--risk-critical); margin-top: 4px; display: none; }
.form-input.error { border-color: var(--risk-critical); }
.form-input.error + .form-error { display: block; }

.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* ===========================
   TAGS / CHIPS
   =========================== */
.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

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

.tag-chip.risk-tag.active {
  background: var(--risk-critical-bg);
  border-color: var(--risk-critical);
  color: var(--risk-critical);
}

/* ===========================
   CARDS
   =========================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-hover {
  cursor: pointer;
  transition: all var(--transition);
}
.card-hover:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===========================
   RISK BADGES
   =========================== */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.risk-badge.low      { background: var(--risk-low-bg);      color: var(--risk-low); }
.risk-badge.medium   { background: var(--risk-medium-bg);   color: var(--risk-medium); }
.risk-badge.high     { background: var(--risk-high-bg);     color: var(--risk-high); }
.risk-badge.critical { background: var(--risk-critical-bg); color: var(--risk-critical); }

.risk-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.risk-dot.low      { background: var(--risk-low); box-shadow: 0 0 6px var(--risk-low); }
.risk-dot.medium   { background: var(--risk-medium); box-shadow: 0 0 6px var(--risk-medium); }
.risk-dot.high     { background: var(--risk-high); box-shadow: 0 0 6px var(--risk-high); }
.risk-dot.critical { background: var(--risk-critical); box-shadow: 0 0 6px var(--risk-critical); }

/* ===========================
   TOP NAV
   =========================== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.topnav-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topnav-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.topnav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.topnav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  text-decoration: none;
}
.topnav-link:hover { background: var(--bg-input); color: var(--text-primary); }
.topnav-link.active { background: var(--accent-glow); color: var(--accent); }

.topnav-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}

/* ── AVATAR DROPDOWN ── */
.user-menu-wrap { position: relative; }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1100;
  min-width: 210px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
}
.user-dropdown.open { display: block; }
.dropdown-user-info {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.dropdown-user-name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
.dropdown-user-trade { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.dropdown-item:hover { background: var(--bg-input); color: var(--text-primary); }
.dropdown-item.danger { color: var(--risk-critical); }
.dropdown-item.danger:hover { background: var(--risk-critical-bg); color: var(--risk-critical); }
.dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ===========================
   MOBILE NAV
   =========================== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1000;
  height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* Force GPU layer — prevents iOS Safari fixed-element flicker on scroll */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.mobile-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--mobile-nav-h);
  width: 100%;
  padding: 0 16px;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
  transition: color var(--transition);
  border-radius: var(--radius-sm);
  /* reset button defaults */
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.mobile-nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }
.mobile-nav-item:hover, .mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item.active svg { stroke-width: 2.4; }

.mobile-nav-fab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-nav-fab-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(59,130,246,0.5);
  text-decoration: none;
  transition: all var(--transition);
}
.mobile-nav-fab-btn:hover { background: var(--accent-hover); transform: scale(1.08); }
.mobile-nav-fab-btn svg { width: 22px; height: 22px; stroke-width: 2.5; }

@media (max-width: 768px) {
  .topnav-links, .topnav-desktop-only { display: none; }
  .mobile-nav { display: flex; }
  body { padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 480px) {
  .container, .container-sm, .container-md { padding: 0 14px; }
  .page-header { padding: 18px 0 14px; }
  .page-header h1 { font-size: 1.4rem; }
}

/* ===========================
   PAGE LAYOUT
   =========================== */
.page { min-height: calc(100vh - var(--nav-h)); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 520px; margin: 0 auto; padding: 0 20px; }
.container-md { max-width: 760px; margin: 0 auto; padding: 0 20px; }

.page-header { padding: 28px 0 20px; }
.page-header h1 { margin-bottom: 4px; }

/* ===========================
   AUTH PAGES
   =========================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: var(--bg-base);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

@media (max-width: 480px) { .auth-card { padding: 28px 20px; } }

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.auth-brand-name { font-weight: 800; font-size: 1.3rem; letter-spacing: -0.02em; }
.auth-brand-sub { font-size: 0.78rem; color: var(--text-muted); }

.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 28px; }

.auth-form { display: flex; flex-direction: column; gap: 18px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span { color: var(--text-muted); font-size: 0.8rem; }

.auth-footer { text-align: center; margin-top: 20px; font-size: 0.875rem; color: var(--text-muted); }
.auth-footer a { color: var(--accent); font-weight: 500; }

/* ===========================
   DASHBOARD SPLIT
   =========================== */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - var(--nav-h));
  overflow: hidden;
}

.map-panel {
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%; height: 100%;
}

.feed-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.feed-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.feed-header h3 { font-size: 0.95rem; }

.feed-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===========================
   POST CARDS
   =========================== */
.post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: block;
  color: inherit;
}
.post-card:hover {
  border-color: var(--accent);
  background: var(--bg-card);
  transform: translateX(2px);
}
.post-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.post-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.post-card-meta span { display: flex; align-items: center; gap: 3px; }
.post-card-excerpt {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
  margin-bottom: 10px;
}
.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.post-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.post-tag.alert {
  background: var(--risk-critical-bg);
  color: var(--risk-critical);
  border-color: transparent;
}

/* ===========================
   MAP OVERLAYS
   =========================== */
.map-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-legend {
  position: absolute;
  bottom: 28px;
  left: 14px;
  z-index: 1000;
  background: rgba(22,27,34,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.map-legend h4 {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.legend-swatch {
  width: 14px; height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.map-tip-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1000;
  width: 240px;
  background: rgba(22,27,34,0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: none;
}
.map-tip-panel.visible { display: block; }
.map-tip-panel h4 {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.map-tip-panel p {
  font-size: 0.78rem;
  line-height: 1.5;
}
.map-tip-close {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.map-tip-close:hover { color: var(--text-primary); background: var(--bg-input); }

.neighbourhood-popup h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.neighbourhood-popup p {
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.neighbourhood-popup .risk-badge { margin-bottom: 8px; }

/* Leaflet overrides */
.leaflet-container { background: #0d1117 !important; }
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-md) !important;
  color: var(--text-primary) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-close-button { color: var(--text-muted) !important; font-size: 18px !important; }
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: var(--bg-surface) !important;
  color: var(--text-secondary) !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { background: var(--bg-input) !important; color: var(--text-primary) !important; }
.leaflet-control-attribution { background: rgba(22,27,34,0.7) !important; color: var(--text-muted) !important; }
.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* ===========================
   MOBILE DASHBOARD TABS
   =========================== */
.mobile-tabs {
  display: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.mobile-tabs-inner {
  display: flex;
  height: var(--mobile-tabs-h);
}
.mobile-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.mobile-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

@media (max-width: 768px) {
  .dashboard-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-h) - var(--mobile-tabs-h) - var(--mobile-nav-h));
    height: calc(100dvh - var(--nav-h) - var(--mobile-tabs-h) - var(--mobile-nav-h));
    overflow: hidden;
  }
  .mobile-tabs { display: block; }
  .map-panel {
    flex: 1;
    display: none;
  }
  .map-panel.active { display: block; }
  .feed-panel {
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--border);
    display: none;
    overflow: hidden;
  }
  .feed-panel.active { display: flex; }
  .map-tip-panel { width: 180px; }
  .map-search-wrap input { width: 160px; }
  .map-legend { bottom: 16px; left: 10px; padding: 10px 12px; }
  .map-legend h4 { margin-bottom: 6px; }
  .legend-item { margin-bottom: 4px; }
}

/* ===========================
   POST FORM PAGE
   =========================== */
.post-form-page {
  padding: 28px 0 40px;
}

.post-form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 28px;
}
@media (max-width: 600px) { .post-form-card { padding: 20px 16px; border-radius: var(--radius-lg); } }

.form-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border-light);
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.form-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

/* ===========================
   POST DETAIL
   =========================== */
.post-detail-page { padding: 28px 0 48px; }

.post-detail-header { margin-bottom: 24px; }
.post-detail-title { font-size: clamp(1.3rem, 4vw, 1.8rem); font-weight: 700; margin-bottom: 12px; line-height: 1.3; }
.post-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.post-detail-meta span { display: flex; align-items: center; gap: 5px; }

.post-detail-body {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

.post-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-value { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }

/* ===========================
   APPLY PAGE
   =========================== */
.apply-page { padding: 36px 0 60px; }

.apply-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
}
.apply-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-muted);
}
.apply-step.active { color: var(--accent); }
.apply-step.done { color: var(--risk-low); }
.step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}
.apply-step.active .step-num { border-color: var(--accent); color: var(--accent); }
.apply-step.done .step-num { border-color: var(--risk-low); background: var(--risk-low); color: #fff; }
.step-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 10px;
}

/* ===========================
   SEARCH BAR
   =========================== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 14px;
  transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar svg { color: var(--text-muted); flex-shrink: 0; width: 16px; height: 16px; }
.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  padding: 9px 0;
  flex: 1;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ===========================
   EMPTY STATE
   =========================== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 14px; opacity: 0.4; width: 40px; height: 40px; }
.empty-state p { font-size: 0.88rem; }

/* ===========================
   TOAST
   =========================== */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (max-width: 768px) { .toast-container { bottom: calc(var(--mobile-nav-h) + 12px); left: 20px; } }

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--risk-low); }
.toast.error   { border-left: 3px solid var(--risk-critical); }
.toast.info    { border-left: 3px solid var(--accent); }

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

/* ===========================
   UTILITIES
   =========================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.78rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ===========================
   SUPPORT WIDGET
   =========================== */
/* Support — desktop: floating pill */
#supportBtn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(212,160,23,0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
#supportBtn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(212,160,23,0.45);
}
#supportBtn svg { flex-shrink: 0; }

/* Modal backdrop */
#supportOverlay {
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#supportOverlay.open {
  opacity: 1;
  pointer-events: all;
}

/* Modal card */
#supportModal {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform 0.22s ease;
}
#supportOverlay.open #supportModal {
  transform: translateY(0);
}

.support-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.support-header-text h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 3px;
}
.support-header-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}
.support-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  line-height: 1;
  transition: color var(--transition);
}
.support-close:hover { color: var(--text-primary); }

.support-form { display: flex; flex-direction: column; gap: 14px; }
.support-form .form-group { display: flex; flex-direction: column; gap: 5px; }
.support-form .form-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.support-form .form-input,
.support-form .form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  font-size: 0.88rem;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition);
  width: 100%;
}
.support-form .form-input:focus,
.support-form .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.support-form .form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}
.support-success {
  text-align: center;
  padding: 16px 0 4px;
}
.support-success-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.3);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.support-success h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 6px; }
.support-success p  { font-size: 0.82rem; color: var(--text-muted); margin: 0; }

/* Support — mobile: slim vertical side tab */
@media (max-width: 768px) {
  #supportBtn {
    right: 0;
    bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 80px);
    flex-direction: column;
    gap: 0;
    border-radius: 0 6px 6px 0;
    padding: 18px 7px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    box-shadow: -3px 4px 18px rgba(212,160,23,0.3);
  }
  #supportBtn svg { display: none; }
  #supportBtn:hover {
    transform: rotate(180deg);
    right: 2px;
    box-shadow: -5px 4px 24px rgba(212,160,23,0.45);
  }
  .support-btn-label { display: block; }
}
@media (max-width: 480px) {
  #supportOverlay { padding: 12px; align-items: flex-end; }
  #supportModal { max-width: 100%; }
}
