/* === Brand: CSS Variables === */
:root {
  --font-body: 'DM Sans', sans-serif;
  --font-display: 'DM Serif Display', serif;

  --grey-50:  #FAFAF9;
  --grey-100: #F5F5F4;
  --grey-200: #E7E5E4;
  --grey-300: #D6D3D1;
  --grey-400: #A8A29E;
  --grey-500: #78716C;
  --grey-600: #57534E;
  --grey-800: #292524;
  --grey-900: #1C1917;
  --grey-950: #0F0F0F;

  --pink: #FF2867;

  --bg: var(--grey-50);
  --surface: #FFFFFF;
  --text: var(--grey-900);
  --text-muted: var(--grey-600);
  --border: var(--grey-200);
  --accent: var(--pink);
  --accent-hover: #E6164F;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  --sidebar-width: 220px;
  --sidebar-collapsed-width: 60px;
}

:root.dark {
  --bg: var(--grey-950);
  --surface: var(--grey-900);
  --text: var(--grey-50);
  --text-muted: var(--grey-400);
  --border: var(--grey-800);
  --accent-hover: #FF5088;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
}

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

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { line-height: 1.2; font-weight: 600; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: 2.5rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

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

/* === Layout === */
#app { display: flex; min-height: 100vh; }

.app-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-xl);
  max-width: 960px;
}

@media (max-width: 768px) {
  .app-content { padding: var(--space-md); margin-left: var(--sidebar-collapsed-width); }
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transition: width var(--transition-normal);
  overflow: hidden;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  gap: var(--space-sm);
  min-height: 60px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  text-decoration: none;
}
.sidebar-logo:hover { color: var(--text); }
.sidebar-logo svg { width: 28px; height: 28px; flex-shrink: 0; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.sidebar-toggle:hover { color: var(--text); background: var(--grey-100); }
:root.dark .sidebar-toggle:hover { background: var(--grey-800); }
.sidebar-toggle svg { width: 18px; height: 18px; transition: transform var(--transition-normal); }
.sidebar.collapsed .sidebar-toggle svg,
.sidebar:not(.expanded) .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-sm);
  gap: 2px;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-size: 0.9375rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.sidebar-link:hover { color: var(--text); background: var(--grey-100); }
:root.dark .sidebar-link:hover { background: var(--grey-800); }
.sidebar-link.active { color: var(--accent); }
.sidebar-link svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-action { font-family: var(--font-body); }

.sidebar-footer {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--border);
}
.sidebar.collapsed .sidebar-footer { align-items: center; }

.sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-fast);
}

/* Collapsed */
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar-label { opacity: 0; width: 0; pointer-events: none; }
.sidebar.collapsed .sidebar-link {
  width: 40px; height: 40px;
  padding: 0; justify-content: center; align-items: center; gap: 0;
}
.sidebar.collapsed .sidebar-header { justify-content: center; padding: var(--space-sm); }
.sidebar.collapsed .sidebar-logo {
  position: absolute; inset: 0;
  justify-content: center; align-items: center;
  opacity: 0.06; pointer-events: none;
}
.sidebar.collapsed .sidebar-collapse-btn { margin: 0 auto; }

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 200;
  }
  .sidebar:not(.expanded) { width: var(--sidebar-collapsed-width); }
  .sidebar:not(.expanded) .sidebar-label { opacity: 0; width: 0; pointer-events: none; }
  .sidebar:not(.expanded) .sidebar-link {
    width: 40px; height: 40px;
    padding: 0; justify-content: center; gap: 0;
  }
  .sidebar:not(.expanded) .sidebar-header { justify-content: center; padding: var(--space-sm); }
  .sidebar:not(.expanded) .sidebar-logo {
    position: absolute; inset: 0;
    justify-content: center; align-items: center;
    opacity: 0.06; pointer-events: none;
  }
  .sidebar:not(.expanded) .sidebar-collapse-btn { margin: 0 auto; }
  .sidebar.expanded {
    width: var(--sidebar-width);
    box-shadow: var(--shadow-lg);
  }
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 199;
}

/* === Buttons === */
button, .btn {
  font-family: var(--font-body);
  font-weight: 500;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.9375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

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

.btn-full { width: 100%; }

.btn-sm { padding: var(--space-xs) var(--space-sm); font-size: 0.8125rem; }

.btn-icon { gap: var(--space-xs); }
.btn-icon svg { width: 18px; height: 18px; }

.btn-icon-only {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: var(--space-xs);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon-only:hover { color: var(--accent); }
.btn-icon-only svg { width: 18px; height: 18px; }

/* === Forms === */
input, textarea, select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition-fast);
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

.form-container { max-width: 600px; }
.form-stack { display: flex; flex-direction: column; gap: var(--space-md); }
.form-group { display: flex; flex-direction: column; gap: var(--space-xs); }
.form-group label { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: var(--space-md); justify-content: flex-end; }
.form-error { color: var(--accent); font-size: 0.875rem; }

/* Custom checkbox */
input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Custom radio */
input[type="radio"] {
  appearance: none;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
input[type="radio"]:checked {
  border-color: var(--accent);
}
input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: var(--radius-full);
  background: var(--accent);
}

.photo-preview { margin-top: var(--space-sm); }
.photo-preview img { max-width: 100%; max-height: 200px; border-radius: var(--radius-md); object-fit: cover; }

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

/* === View Content === */
.view-content { width: 100%; }
.view-header { margin-bottom: var(--space-xl); }
.view-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-md); flex-wrap: wrap; }

.loading-state, .empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--text-muted);
}
.empty-state .btn { margin-top: var(--space-lg); }

.section-title { margin-bottom: var(--space-md); font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.75rem; }
.section-title.muted { color: var(--text-muted); }

/* === Catch Grid === */
.catch-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.catch-card { padding: 0; overflow: hidden; }
.catch-photo img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.catch-info { padding: var(--space-md); }
.catch-species { font-weight: 600; font-size: 1.125rem; }
.catch-meta { display: flex; gap: var(--space-md); font-size: 0.875rem; color: var(--text-muted); margin-top: var(--space-xs); }
.catch-details { display: flex; gap: var(--space-md); font-size: 0.8125rem; color: var(--text-muted); margin-top: var(--space-xs); }
.catch-date { font-size: 0.75rem; color: var(--text-muted); margin-top: var(--space-xs); }
.catch-notes { font-size: 0.875rem; color: var(--text-muted); margin-top: var(--space-sm); font-style: italic; }

.filter-toggle { display: flex; align-items: center; gap: var(--space-sm); font-size: 0.875rem; color: var(--text-muted); cursor: pointer; }
.filter-toggle input { width: auto; }

/* === Waters Grid === */
.waters-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.water-card { padding: 0; overflow: hidden; text-decoration: none; color: var(--text); display: block; }
.water-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--text); }
.water-image img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.water-info { padding: var(--space-md); }
.water-info h3 { font-size: 1.125rem; }
.water-species { font-size: 0.875rem; color: var(--text-muted); margin-top: var(--space-xs); }

/* Water Detail */
.water-detail { max-width: 800px; }
.water-detail-image img { width: 100%; max-height: 400px; object-fit: cover; border-radius: var(--radius-lg); margin-bottom: var(--space-lg); }
.water-detail h2 { margin-bottom: var(--space-md); }
.water-description { margin-bottom: var(--space-xl); line-height: 1.7; }
.water-detail-sections { display: flex; flex-direction: column; gap: var(--space-md); }
.detail-section h3 { margin-bottom: var(--space-sm); }
.back-link { display: inline-block; margin-bottom: var(--space-lg); color: var(--text-muted); font-size: 0.875rem; }
.back-link:hover { color: var(--accent); }

/* === Events === */
.events-section { margin-bottom: var(--space-2xl); }
.events-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.event-card { display: flex; align-items: flex-start; gap: var(--space-md); }
.event-card.past { opacity: 0.6; }
.event-date-badge {
  display: flex; flex-direction: column; align-items: center;
  min-width: 48px; padding: var(--space-xs) var(--space-sm);
  background: var(--grey-100); border-radius: var(--radius-md);
}
:root.dark .event-date-badge { background: var(--grey-800); }
.event-day { font-size: 1.25rem; font-weight: 700; line-height: 1; }
.event-month { font-size: 0.6875rem; text-transform: uppercase; color: var(--text-muted); }
.event-info { flex: 1; min-width: 0; }
.event-title { font-weight: 600; }
.event-meta { display: flex; gap: var(--space-sm); flex-wrap: wrap; font-size: 0.8125rem; color: var(--text-muted); margin-top: var(--space-xs); }
.event-description { font-size: 0.875rem; color: var(--text-muted); margin-top: var(--space-sm); }

/* === News === */
.news-list { display: flex; flex-direction: column; gap: var(--space-md); }
.news-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-md); }
.news-header h3 { font-size: 1.125rem; }
.news-meta { display: flex; gap: var(--space-md); font-size: 0.8125rem; color: var(--text-muted); margin-top: var(--space-xs); }
.news-content { margin-top: var(--space-md); line-height: 1.7; white-space: pre-wrap; }

/* === Guest Cards === */
.guestcard-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.guestcard-item { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-md); }
.guestcard-name { font-weight: 600; }
.guestcard-meta { display: flex; gap: var(--space-md); font-size: 0.8125rem; color: var(--text-muted); margin-top: var(--space-xs); flex-wrap: wrap; }
.guestcard-notes { font-size: 0.875rem; color: var(--text-muted); margin-top: var(--space-sm); }
.guestcard-issuer { font-size: 0.75rem; color: var(--text-muted); margin-top: var(--space-sm); }

/* === Members === */
.members-count { font-size: 0.875rem; color: var(--text-muted); margin-bottom: var(--space-md); }
.members-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.member-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; }
.member-name { font-weight: 600; }
.member-email { font-size: 0.8125rem; color: var(--text-muted); }
.member-role { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.role-select { width: auto; padding: var(--space-xs) var(--space-sm); font-size: 0.8125rem; }

/* === Badge === */
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  background: var(--grey-100);
  color: var(--grey-600);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  letter-spacing: 0.025em;
}
:root.dark .badge { background: var(--grey-800); color: var(--grey-400); }

/* === Auth === */
.auth-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-xl);
}
.auth-card {
  width: 100%;
  max-width: 380px;
}
.auth-logo { display: flex; justify-content: center; margin-bottom: var(--space-lg); }
.auth-logo svg { width: 48px; height: 48px; color: var(--accent); }
.auth-card h1 { text-align: center; margin-bottom: var(--space-xs); }
.auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: var(--space-xl); }
.auth-link { text-align: center; margin-top: var(--space-lg); font-size: 0.875rem; color: var(--text-muted); }

/* === Overlay === */
.overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-lg);
}
.overlay-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 400px; width: 100%;
}
.overlay-card h3 { margin-bottom: var(--space-md); }

/* === PWA Display Mode === */
@media (display-mode: standalone) {
  .hide-in-pwa { display: none !important; }
}
@media not (display-mode: standalone) {
  .hide-in-browser { display: none !important; }
}

/* === Motion === */
/* === Landing Page === */
.landing {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
}
.landing-hero {
  text-align: center;
  padding: var(--space-3xl) 0 var(--space-2xl);
}
.landing-logo svg {
  width: 64px;
  height: 64px;
  color: var(--text);
  margin-bottom: var(--space-md);
}
.landing-subtitle {
  color: var(--text-muted);
  font-size: 1.125rem;
  margin-top: var(--space-sm);
}
.landing-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  margin-top: var(--space-xl);
}
.landing-section {
  margin-top: var(--space-2xl);
}
.landing-section h2 {
  margin-bottom: var(--space-md);
}

/* === Motion === */
.fade-in {
  opacity: 0; transform: translateY(12px);
  animation: fadeIn 0.4s ease forwards;
}
@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }
