/* Ironclad - App Styles
   Dark theme default, light theme via [data-theme="light"]
   Target: 45+ male with reading glasses
*/

/* Typography - Distinctive fonts */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@400;500;600;700&display=swap');

/* ============================================
   CSS Variables - Dark Theme (Default)
   Color palette matched to joinironclad.com
   ============================================ */
:root {
  /* Surfaces - rich dark tones */
  --bg: #0d0f12;
  --panel: #14171e;
  --text: #e8eaed;
  --muted: #9ca3af;
  --border: rgba(255,255,255,.08);

  /* Accents */
  --accent: #c9d1d9;
  --accent2: #2d6a4f;           /* Darker forest green for hover */

  /* Brand accent trio - from website feature pills */
  --accent-green: #4a7c59;      /* Sage green dot */
  --accent-gold: #c9a227;       /* Warm gold dot */
  --accent-coral: #c4654a;      /* Terracotta dot */

  /* Status colors - refined, masculine palette */
  --good: #2d6a4f;              /* Forest green - matching website */
  --warn: #c9a227;              /* Warm gold/amber */
  --bad: #c4654a;               /* Terracotta coral */
  --rest: #6b7280;

  /* Status backgrounds */
  --good-bg: rgba(45,106,79,.25);
  --warn-bg: rgba(201,162,39,.20);
  --bad-bg: rgba(196,101,74,.20);
  --rest-bg: rgba(107,114,128,.15);

  /* Typography - Larger for readability */
  --font-sm: 14px;
  --font-base: 17px;
  --font-lg: 20px;
  --font-xl: 26px;
  --font-2xl: 32px;
  --font-streak: 80px;

  /* Touch targets */
  --touch-min: 48px;

  /* Spacing */
  --radius: 16px;
  --radius-sm: 12px;
}

/* ============================================
   Light Theme - Warm & Masculine
   ============================================ */
[data-theme="light"] {
  --bg: #f5f3f0;           /* Warm cream instead of cold gray */
  --panel: #fefefe;
  --text: #1a1a1a;
  --muted: #64605a;        /* Warm gray */
  --border: rgba(26,26,26,.10);
  --accent: #374151;       /* Slate */
  --accent2: #1e5038;      /* Even darker forest green for hover on light */

  /* Brand accent trio - slightly deeper for light bg */
  --accent-green: #3d6b4a;
  --accent-gold: #a67f1a;
  --accent-coral: #a84a32;

  /* Status colors - same refined palette, slightly darker for light bg */
  --good: #1e5038;         /* Darker forest green for light theme */
  --warn: #a67f1a;         /* Deeper gold */
  --bad: #a84a32;          /* Deeper terracotta */

  /* Status backgrounds */
  --good-bg: rgba(30,80,56,.12);
  --warn-bg: rgba(166,127,26,.12);
  --bad-bg: rgba(168,74,50,.12);
  --rest-bg: rgba(100,96,90,.08);
}

/* ============================================
   Pill Badges - Website Feature Style
   ============================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 100px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

[data-theme="light"] .pill {
  background: rgba(0,0,0,.04);
  border-color: rgba(0,0,0,.08);
}

.pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
}

.pill.pill-gold::before {
  background: var(--accent-gold);
}

.pill.pill-coral::before {
  background: var(--accent-coral);
}

.pill.pill-green::before {
  background: var(--accent-green);
}

/* ============================================
   Theme Switcher
   ============================================ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Show sun icon in dark mode, moon in light mode */
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }

[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ============================================
   Base Styles
   ============================================ */
html {
  font-size: var(--font-base);
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-top: 56px; /* Space for top header */
  padding-bottom: 60px; /* Space for bottom nav */
  /* Hide scrollbar but allow scrolling */
  -ms-overflow-style: none;
  scrollbar-width: none;
  overflow-x: hidden;
}

/* Subtle noise texture for depth */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
  z-index: -1;
}

body::-webkit-scrollbar {
  display: none;
}

main {
  display: block;
  width: 100%;
}

body.forum-mode {
  padding-bottom: 0; /* No bottom nav in forum mode */
}

/* Mobile adjustments - optimized for iPhone 16 Pro and similar */
@media (max-width: 767px) {
  .page-container {
    padding: 0.75rem;
  }

  .page-header {
    margin-bottom: 0.75rem;
  }

  /* Slightly smaller streak on mobile */
  .font-streak {
    font-size: 48px;
  }

  /* Tighter card spacing */
  .card-iron {
    padding: 1rem;
  }

  /* Reduce margins between cards */
  .mb-3 {
    margin-bottom: 0.75rem !important;
  }

  /* Tighter row gaps */
  .g-3 {
    --bs-gutter-y: 0.75rem;
    --bs-gutter-x: 0.75rem;
  }

  /* Compact day strip */
  .day-strip {
    gap: 6px;
  }

  .day-cell {
    font-size: 0.875rem;
  }

  /* Smaller page title */
  .page-title {
    font-size: 1.25rem;
  }

  /* Compact nav on mobile */
  .nav-item {
    padding: 0.2rem 0.5rem;
    font-size: 0.875rem;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }
}

/* ============================================
   Typography
   ============================================ */
a {
  text-decoration: none;
}

.text-muted {
  color: var(--muted) !important;
}

.font-lg { font-size: var(--font-lg); }
.font-xl { font-size: var(--font-xl); }
.font-2xl { font-size: var(--font-2xl); }
.font-streak {
  font-family: 'Bebas Neue', sans-serif;
  font-size: var(--font-streak);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--good);
  text-shadow: 0 0 40px rgba(74, 222, 128, 0.3);
}

[data-theme="light"] .font-streak {
  text-shadow: none;
}

.brand {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 400;
  font-size: 1.25rem;
}

/* ============================================
   Cards & Panels - Glassmorphism
   ============================================ */
.card-iron {
  background: rgba(20, 23, 30, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.3),
              inset 0 1px 0 rgba(255,255,255,.05);
}

[data-theme="light"] .card-iron {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 4px 24px rgba(0,0,0,.08),
              inset 0 1px 0 rgba(255,255,255,.8);
}

.card-iron-inner {
  background: rgba(255,255,255,.03);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

[data-theme="light"] .card-iron-inner {
  background: rgba(0,0,0,.03);
}

/* ============================================
   Status Colors
   ============================================ */
.status-good { color: var(--good); }
.status-warn { color: var(--warn); }
.status-bad { color: var(--bad); }
.status-rest { color: var(--rest); }

.status-bg-good { background: var(--good-bg); }
.status-bg-warn { background: var(--warn-bg); }
.status-bg-bad { background: var(--bad-bg); }
.status-bg-rest { background: var(--rest-bg); }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.good { background: var(--good); }
.status-dot.warn { background: var(--warn); }
.status-dot.bad { background: var(--bad); }
.status-dot.rest { background: var(--rest); }

/* ============================================
   7-Day Strip
   ============================================ */
.day-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.day-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--border);
}

.day-cell.green {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
}
.day-cell.amber {
  background: var(--warn-bg);
  border-color: var(--warn);
  color: var(--warn);
}
.day-cell.red {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}
.day-cell.gray {
  background: var(--rest-bg);
  color: var(--muted);
}

/* ============================================
   Streak Bars (segmented progress)
   ============================================ */
.streak-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.streak-label {
  font-size: 0.95rem;
  color: var(--muted);
  width: 85px;
  flex-shrink: 0;
  white-space: nowrap;
}

.streak-bar {
  flex: 1;
  height: 16px;
  display: flex;
  gap: 2px;
}

.streak-segment {
  flex: 1;
  background: var(--rest-bg);
  border-radius: 2px;
}

.streak-segment.filled {
  background: var(--good);
}

.streak-count {
  font-size: 0.95rem;
  font-weight: 600;
  width: 28px;
  flex-shrink: 0;
  text-align: right;
  color: var(--muted);
}

/* ============================================
   Streak Badge
   ============================================ */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  font-weight: 600;
}

[data-theme="light"] .streak-badge {
  background: rgba(0,0,0,.02);
}

/* ============================================
   Buttons
   ============================================ */
/* Glassmorphic Buttons */
.btn-iron {
  min-height: var(--touch-min);
  padding: 0.875rem 1.25rem;
  font-size: var(--font-base);
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(20, 23, 30, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  transition: all 0.15s ease;
}

.btn-iron:hover {
  background: rgba(30, 35, 45, 0.85);
  border-color: rgba(255,255,255,.2);
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}

[data-theme="light"] .btn-iron {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}

[data-theme="light"] .btn-iron:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0,0,0,.12);
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}

.btn-iron-primary {
  background: rgba(47, 107, 79, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white;
  border: 1px solid rgba(74, 124, 89, 0.5);
  box-shadow: 0 4px 16px rgba(47, 107, 79, 0.3);
}

.btn-iron-primary:hover {
  background: rgba(47, 107, 79, 0.95);
  border-color: rgba(74, 124, 89, 0.7);
  box-shadow: 0 6px 20px rgba(47, 107, 79, 0.4);
  color: white;
}

/* ============================================
   Form Controls
   ============================================ */
.form-control-iron {
  min-height: var(--touch-min);
  padding: 0.875rem 1rem;
  font-size: var(--font-base);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  box-sizing: border-box;
}

textarea.form-control-iron {
  resize: vertical;
}

.form-control-iron:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(95,117,98,.15);
  outline: none;
}

/* Large toggle switch */
.toggle-iron {
  width: 60px;
  height: 34px;
  background: var(--rest-bg);
  border-radius: 17px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-iron::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 26px;
  background: white;
  border-radius: 50%;
  top: 4px;
  left: 4px;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}

.toggle-iron.active {
  background: var(--good);
}

.toggle-iron.active::after {
  transform: translateX(26px);
}

.toggle-iron.danger.active {
  background: var(--bad);
}

/* ============================================
   Bottom Navigation
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 0.25rem 0;
  padding-bottom: max(0.25rem, env(safe-area-inset-bottom));
  z-index: 1000;
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  max-width: 500px;
  margin: 0 auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.25rem 0.75rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
}

.nav-item.highlight {
  color: var(--good);
}

/* Hide nav labels on very small screens */
@media (max-width: 374px) {
  .nav-item span {
    display: none;
  }
  .nav-item svg {
    margin-bottom: 0;
  }
}

/* ============================================
   Top Header
   ============================================ */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 1001;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 1rem;
}

.header-inner .brand {
  font-size: 1.1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mode-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s ease;
}

.mode-toggle-btn:hover {
  background: var(--panel);
  border-color: var(--accent);
}

.hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.hamburger-btn:hover {
  background: var(--bg);
}

/* ============================================
   Hamburger Menu Overlay
   ============================================ */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.menu-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Glassmorphic Menu Panel */
.menu-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 85vw;
  height: 100%;
  background: rgba(20, 23, 30, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255,255,255,.1);
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.menu-overlay.open .menu-panel {
  transform: translateX(0);
}

[data-theme="light"] .menu-panel {
  background: rgba(255, 255, 255, 0.85);
  border-left: 1px solid rgba(0,0,0,.08);
  box-shadow: -8px 0 32px rgba(0,0,0,.12);
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.menu-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.menu-close:hover {
  color: var(--text);
  background: var(--bg);
}

.menu-nav {
  flex: 1;
  padding: 0.5rem;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.menu-item:hover {
  background: var(--bg);
}

.menu-item svg {
  color: var(--muted);
}

.menu-item-danger {
  color: var(--bad);
}

.menu-item-danger svg {
  color: var(--bad);
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0;
}

/* Prevent body scroll when menu is open */
body.menu-open {
  overflow: hidden;
}

/* ============================================
   Page Container
   ============================================ */
.page-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
  box-sizing: border-box;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

/* ============================================
   Utilities
   ============================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

.touch-target {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
}

/* Hide in screenshot mode */
.screenshot-mode .bottom-nav,
.screenshot-mode .btn-iron {
  display: none !important;
}

/* ============================================
   Responsive - Desktop
   ============================================ */
@media (min-width: 1024px) {
  body {
    padding-bottom: 0;
    padding-left: 200px;
  }

  .bottom-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: auto;
    width: 200px;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
  }

  .bottom-nav-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0 0.75rem;
  }

  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
  }

  .nav-item svg {
    margin-bottom: 0;
  }

  .nav-item:hover {
    background: rgba(255,255,255,.03);
  }

  [data-theme="light"] .nav-item:hover {
    background: rgba(0,0,0,.03);
  }

  .page-container {
    padding: 2rem;
  }
}

/* Forum mode - no sidebar on desktop */
@media (min-width: 1024px) {
  body.forum-mode {
    padding-left: 0;
  }

  body.forum-mode .bottom-nav {
    display: none;
  }

  body.forum-mode .page-container {
    max-width: 1000px;
  }
}

/* ============================================
   View Transitions
   ============================================ */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: fade-out 0.12s ease-out;
}

::view-transition-new(root) {
  animation: fade-in 0.12s ease-in;
}

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

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

/* ============================================
   HTMX Loading Indicator
   ============================================ */
#page-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
}

#page-loader .loader-bar {
  height: 100%;
  width: 0;
  background: var(--good);
  transition: width 0.1s ease;
}

#page-loader.htmx-request .loader-bar {
  width: 90%;
  transition: width 0.8s ease-out;
}

/* ============================================
   Optimistic UI - Button States
   ============================================ */
.btn-iron.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn-iron.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Form control focus transitions */
.form-control-iron,
.btn-iron {
  transition: all 0.15s ease;
}

/* Card entrance animation */
@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-iron {
  animation: card-enter 0.2s ease-out;
}

/* ============================================
   Forum Styles
   ============================================ */

/* Forum typography - smaller than main app */
.forum-post-card,
.forum-comment {
  font-size: 0.9rem;
}

/* Back link */
.forum-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0;
}

.forum-back-link:hover {
  color: var(--text);
}

/* Glassmorphic Forum Submit Button */
.forum-new-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  background: rgba(47, 107, 79, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(74, 124, 89, 0.5);
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(47, 107, 79, 0.3);
  transition: all 0.15s ease;
}

.forum-new-btn:hover {
  background: rgba(47, 107, 79, 0.95);
  border-color: rgba(74, 124, 89, 0.7);
  box-shadow: 0 6px 20px rgba(47, 107, 79, 0.4);
  color: white;
}

/* Glassmorphic Forum Cancel Button */
.forum-cancel-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(20, 23, 30, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  transition: all 0.15s ease;
}

.forum-cancel-btn:hover {
  color: var(--text);
  background: rgba(30, 35, 45, 0.85);
  border-color: rgba(255,255,255,.2);
}

[data-theme="light"] .forum-cancel-btn {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}

[data-theme="light"] .forum-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0,0,0,.12);
}

/* Reply button */
.reply-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0;
  cursor: pointer;
}

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

/* Post rows in topic list */
.forum-post-row {
  display: block;
  padding: 0.875rem 1rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}

.forum-post-row:last-child {
  border-bottom: none;
}

.forum-post-row:hover {
  background: rgba(255,255,255,.03);
}

[data-theme="light"] .forum-post-row:hover {
  background: rgba(0,0,0,.02);
}

/* Reuse topics list container for posts */
.forum-posts-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* New post page - full height */
.new-post-page {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 120px);
}

.new-post-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.new-post-textarea {
  flex: 1;
  min-height: 200px;
  resize: none;
}

/* Topics list - compact format */
.forum-topics-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.forum-topic-row {
  display: block;
  padding: 0.875rem 1rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}

.forum-topic-row:last-child {
  border-bottom: none;
}

.forum-topic-row:hover {
  background: rgba(255,255,255,.03);
}

[data-theme="light"] .forum-topic-row:hover {
  background: rgba(0,0,0,.02);
}

/* Topic title - single line with ellipsis */
.forum-topic-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.forum-topic-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Tiny avatar for topic list */
.author-avatar-xs {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent2);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Post card in list */
.forum-post-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.1s ease;
}

.forum-post-card:hover {
  transform: translateX(4px);
}

.min-width-0 {
  min-width: 0; /* Allow text truncation in flexbox */
}

/* Author avatar */
.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.author-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* Author info line */
.author-info {
  font-size: 0.9rem;
}

/* Pinned badge */
.badge-pinned {
  font-size: 0.95rem;
  padding: 0.2rem 0.5rem;
  background: var(--good-bg);
  color: var(--good);
  border-radius: 4px;
  font-weight: 600;
}

/* Like buttons */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.like-btn:hover {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}

.like-btn.liked {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}

.like-btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.like-btn-sm:hover {
  color: var(--bad);
}

.like-btn-sm.liked {
  color: var(--bad);
}

/* Post body */
.post-body a,
.comment-body a {
  color: var(--accent2);
  text-decoration: underline;
}

/* Mentions */
.mention {
  color: var(--accent2);
  font-weight: 500;
}

/* Forum comment */
.forum-comment {
  padding-top: 0;
}

/* ============================================
   Slide Transitions - Drill-down only
   ============================================ */
main.htmx-swapping {
  opacity: 0;
  transition: opacity 0.1s ease-out;
}

main.slide-right {
  animation: slideInRight 0.2s ease-out;
}

main.slide-left {
  animation: slideInLeft 0.2s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(30%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
  from { transform: translateX(-30%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   Thread View - Long Angle Style
   ============================================ */
.forum-thread {
  padding-bottom: 1rem;
}

/* Breadcrumb */
.thread-breadcrumb {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.thread-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.thread-breadcrumb a:hover {
  color: var(--text);
}

/* Thread card - contains entire thread */
.thread-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

/* Post header: avatar + name/date */
.thread-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.thread-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.thread-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.thread-content {
  flex: 1;
  min-width: 0;
}

.thread-author {
  font-weight: 600;
  font-size: 0.9rem;
}

.thread-date {
  color: var(--muted);
  font-size: 0.9rem;
}

.thread-date a {
  color: var(--muted);
  text-decoration: none;
}

.thread-date a:hover {
  color: var(--text);
}

/* Author badge */
.thread-author-badge {
  font-size: 0.9rem;
  padding: 0.125rem 0.375rem;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  font-weight: 600;
}

/* Post title */
.thread-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0.75rem 0 0.5rem 0;
  line-height: 1.3;
}

/* Post/comment body */
.thread-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

.thread-body p {
  margin: 0 0 0.75rem 0;
}

.thread-body p:last-child {
  margin-bottom: 0;
}

/* Action row */
.thread-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

.thread-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.15s ease;
}

.thread-action-btn:hover {
  color: var(--text);
}

.thread-action-btn.liked {
  color: var(--bad);
}

/* Replies section */
.thread-replies-header {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* Reply item container */
.thread-reply {
  margin-bottom: 0.75rem;
}

.thread-reply:last-child {
  margin-bottom: 0;
}

/* Gray box for reply content (header + body) */
.reply-box {
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
}

/* Reply header: avatar + name + badges inline */
.reply-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.reply-header .thread-avatar {
  width: 32px;
  height: 32px;
  font-size: 0.875rem;
}

/* Reply body - full width */
.thread-reply .thread-body {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* Reply footer: date + actions (outside the gray box) */
.reply-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  padding: 0.25rem 0.75rem 0;
  color: var(--muted);
}

.reply-footer .thread-action-btn {
  color: var(--muted);
}

.reply-footer .thread-action-btn:hover {
  color: var(--text);
}

.reply-date {
  color: var(--muted);
}

/* Comment thread container */
.comment-thread {
  margin-bottom: 0.5rem;
}

.comment-thread:last-child {
  margin-bottom: 0;
}

/* Nested replies with connector lines */
.nested-replies {
  position: relative;
  margin-left: 16px;
  padding-left: 20px;
  margin-top: 0.5rem;
}

/* Each nested reply has an L-shaped connector */
.thread-reply.nested {
  position: relative;
  margin-bottom: 0.5rem;
}

.thread-reply.nested::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 0;
  width: 20px;
  height: 20px;
  border-left: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
  border-bottom-left-radius: 10px;
}

/* Vertical line connecting multiple nested replies */
.thread-reply.nested::after {
  content: '';
  position: absolute;
  left: -20px;
  top: 20px;
  bottom: -0.5rem;
  width: 2px;
  background: var(--border);
}

/* Last nested reply doesn't need the continuing vertical line */
.thread-reply.nested:last-child::after {
  display: none;
}

.thread-reply.nested:last-child {
  margin-bottom: 0;
}

/* Reply form */
.thread-reply-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.thread-reply-card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  padding-bottom: 3rem;
}

.thread-reply-input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.9rem;
  color: var(--text);
  resize: none;
  font-family: inherit;
  box-sizing: border-box;
}

.thread-reply-input:focus {
  outline: none;
}

.thread-reply-input::placeholder {
  color: var(--muted);
}

.thread-post-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.thread-post-btn:hover {
  background: var(--text);
}

/* Three-dot more button */
.thread-more-btn {
  margin-left: auto;
}

/* No replies state */
.thread-no-replies {
  font-size: 0.95rem;
  color: var(--muted);
}
