:root {
  color-scheme: light dark;
  --background: #f4f5f7;
  --surface: #ffffff;
  --primary: #1b5e20;
  --primary-contrast: #ffffff;
  --accent: #ffa726;
  --text: #0f172a;
  --text-muted: #475569;
  --border: rgba(15, 23, 42, 0.1);
  --shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(27, 94, 32, 0.12), transparent 45%),
    radial-gradient(circle at bottom right, rgba(255, 167, 38, 0.12), transparent 40%),
    var(--background);
  color: var(--text);
}

.app-shell {
  margin: 0 auto;
  min-height: 100vh;
  max-width: 960px;
  width: min(100%, 960px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: clamp(1rem, 4vw, 1.5rem) clamp(1rem, 4vw, 2rem) 5.5rem;
}

.app-footer {
  margin-top: auto;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 1rem 0 2rem;
}

.app-footer time {
  color: var(--text);
  font-weight: 600;
}

.app-header {
  display: grid;
  gap: 1rem;
  align-items: flex-start;
  grid-template-columns: minmax(0, 1fr) auto;
}

.header-text {
  min-width: 0;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
}

.app-header p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

.profile-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
  width: auto;
  flex-wrap: wrap;
  justify-self: end;
  min-width: 0;
}

.profile-area .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.18);
}

.profile-area .user-meta {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 0.25rem;
  min-width: 0;
}

.profile-area .user-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.profile-area .user-actions button {
  padding: 0;
}

.back-link {
  font-size: 0.95rem;
}

.back-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.back-link a:hover,
.back-link a:focus-visible {
  text-decoration: underline;
}

.member-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.profile-area .user-meta span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

main#tab-content {
  flex: 1;
  display: grid;
}

section.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  display: grid;
  gap: 1.25rem;
}

section.card header h2 {
  margin: 0;
  font-size: 1.4rem;
}

section.card header p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

section.card h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1.1rem;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table.data-table thead {
  background: rgba(27, 94, 32, 0.08);
}

table.data-table th,
table.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.95rem;
  position: relative;
}

table.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

table.data-table th.sortable:hover {
  background: rgba(27, 94, 32, 0.15);
}

table.data-table th.resizable {
  position: relative;
}

.resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 1;
}

.resize-handle::after {
  content: '';
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 60%;
  background: rgba(15, 23, 42, 0.2);
  border-radius: 1px;
}

.resize-handle:hover::after {
  background: rgba(27, 94, 32, 0.5);
}

table.data-table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.03);
}

.allowlist-table-wrapper,
.waypoints-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 1024px) {
  .allowlist-table-wrapper,
  .waypoints-table-wrapper {
    overflow-x: visible;
  }
}

.allowlist-utilities {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.allowlist-utilities button {
  white-space: nowrap;
}

.allowlist-actions {
  display: flex;
  gap: 0.35rem;
}

.allowlist-actions .text {
  padding-inline: 0.75rem;
}

.actions-column {
  width: 150px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(27, 94, 32, 0.12);
  color: var(--primary);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
}

.role-badge.role-admin {
  background: rgba(27, 94, 32, 0.2);
}

.role-badge.role-guest {
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-muted);
}

.role-chip {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  margin-top: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(27, 94, 32, 0.12);
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-sections {
  display: grid;
  gap: 1.5rem;
}

details.admin-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: none;
  padding: 0;
  overflow: hidden;
}

details.admin-panel summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: clamp(1.25rem, 4vw, 2.25rem);
  position: relative;
}

details.admin-panel summary::-webkit-details-marker {
  display: none;
}

details.admin-panel summary::after {
  content: '';
  width: 0.75rem;
  height: 0.75rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  position: absolute;
  top: 50%;
  right: clamp(1.25rem, 4vw, 2.25rem);
  margin-top: -0.375rem;
  transition: transform 0.2s ease;
}

details.admin-panel[open] summary::after {
  transform: rotate(225deg);
}

details.admin-panel summary:focus-visible {
  outline: 3px solid rgba(27, 94, 32, 0.35);
  outline-offset: 4px;
  border-radius: var(--radius-md);
}

details.admin-panel h3 {
  margin: 0;
  font-size: 1.35rem;
}

.admin-panel-description {
  margin: 0 clamp(1.25rem, 4vw, 2.25rem);
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.admin-section-body {
  border-top: 1px solid var(--border);
  padding: 0 clamp(1.25rem, 4vw, 2.25rem) clamp(1.25rem, 4vw, 2.25rem);
  display: grid;
  gap: 1.5rem;
}

.rbac-panel summary {
  gap: 0.5rem;
}

.wp-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.wp-desc {
  color: #555;
  margin: 0.25rem 0 0.5rem;
}

.wp-actions {
  display: flex;
  gap: 0.5rem;
}

.wp-list .note {
  background: #f6f7f8;
  border: 1px solid #e6e6e6;
  padding: 0.75rem;
  border-radius: 0.5rem;
}

.rbac-grid {
  overflow: auto;
  margin-top: 0.75rem;
}

.rbac {
  width: 100%;
  border-collapse: collapse;
}

.rbac th,
.rbac td {
  border: 1px solid #e6e6e6;
  padding: 0.4rem 0.6rem;
  text-align: center;
  font-size: 0.9rem;
}

.rbac th:first-child,
.rbac td:first-child {
  text-align: left;
  white-space: nowrap;
}

.rbac input[type='checkbox'] {
  width: 1.1rem;
  height: 1.1rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.row.gap {
  gap: 0.75rem;
}

.row .grow {
  flex: 1 1 220px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.admin-allowlist {
  display: grid;
  gap: 1.5rem;
}

.library-admin {
  display: grid;
  gap: 1.5rem;
}

.library-admin .library-form,
.library-admin .library-upload,
.library-admin .library-list {
  display: grid;
  gap: 1rem;
}

.library-admin label span {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.library-admin input,
.library-admin select,
.library-admin textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
}

.library-admin textarea {
  resize: vertical;
}

.library-admin select {
  appearance: none;
  background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"%3E%3Cpath fill="%23475569" d="m4.47 6.47 3.53 3.53 3.53-3.53.94.94-4.47 4.47-4.47-4.47.94-.94Z"/%3E%3C/svg%3E')
    no-repeat right 0.85rem center;
  background-color: #fff;
  background-size: 0.85rem;
}

.library-grid {
  display: grid;
  gap: 1rem;
}

.library-grid.columns-3 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.library-grid.columns-2 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.library-upload {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: clamp(1rem, 3vw, 1.5rem);
  background: rgba(15, 23, 42, 0.02);
}

.library-upload h3 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.library-list h3 {
  margin: 0;
  font-size: 1.1rem;
}

.allowlist-form {
  display: grid;
  gap: 1rem;
}

.allowlist-form .form-grid {
  display: grid;
  gap: 1rem;
}

.allowlist-form label span {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.allowlist-form input,
.allowlist-form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
}

.allowlist-form select {
  appearance: none;
  background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"%3E%3Cpath fill="%23475569" d="m4.47 6.47 3.53 3.53 3.53-3.53.94.94-4.47 4.47-4.47-4.47.94-.94Z"/%3E%3C/svg%3E')
    no-repeat right 0.85rem center;
  background-color: #fff;
  background-size: 0.85rem;
}

.allowlist-form .form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.allowlist-form .note[data-tone='error'] {
  color: #b91c1c;
}

.allowlist-form .note[data-tone='success'] {
  color: #166534;
}

.allowlist-form .note[data-tone='info'] {
  color: var(--text-muted);
}

.allowlist-form .note.subtle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.muted {
  color: var(--text-muted);
  font-style: italic;
}

button.text.danger {
  color: #b91c1c;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(27, 94, 32, 0.12);
  color: var(--primary);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.grid-two {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 720px) {
  .grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .allowlist-form .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.highlight {
  background: rgba(255, 167, 38, 0.12);
  border-left: 4px solid var(--accent);
  padding: 1rem;
  border-radius: var(--radius-md);
}

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

.member-actions button {
  flex: 1 1 220px;
  min-width: 200px;
}

.metrics {
  display: grid;
  gap: 1rem;
}

.metric-card {
  background: rgba(27, 94, 32, 0.08);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.35rem;
}

.metric-card strong {
  font-size: 1.3rem;
}

.tab-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  background: rgba(244, 245, 247, 0.95);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 0.75rem clamp(0.75rem, 4vw, 1.25rem);
  margin-top: auto;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  -ms-overflow-style: none;
}

.diagnostic-panel {
  background: rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem 1.5rem;
  display: grid;
  gap: 0.75rem;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.diagnostic-panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.diagnostic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diagnostic-actions {
  display: flex;
  gap: 0.25rem;
}

.diagnostic-log {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.diagnostic-log li {
  background: rgba(255, 255, 255, 0.6);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(15, 23, 42, 0.08);
  list-style: none;
}

.diagnostic-log time {
  font-weight: 600;
  color: var(--text);
  margin-right: 0.5rem;
}

.diagnostic-log pre {
  margin: 0.25rem 0 0;
  padding: 0.35rem;
  background: rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}


.calendar-month {
  gap: 1.5rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.75rem;
}

.calendar-cell {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  min-height: 110px;
  background: rgba(15, 23, 42, 0.015);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.calendar-head {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  justify-content: center;
  align-items: center;
  min-height: auto;
  padding: 0;
}

.calendar-empty {
  background: transparent;
  border-style: dashed;
  min-height: 80px;
}

.calendar-date {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.calendar-cell.has-event {
  border-color: rgba(27, 94, 32, 0.35);
  background: rgba(27, 94, 32, 0.08);
  box-shadow: inset 0 0 0 1px rgba(27, 94, 32, 0.12);
}

.calendar-events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.calendar-event {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  border-left: 4px solid var(--primary);
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.calendar-event.continuation {
  border-left-style: dashed;
  background: rgba(27, 94, 32, 0.08);
}

.calendar-event strong {
  font-size: 0.85rem;
}

.calendar-event-range {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.calendar-event p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.4;
}

.calendar-event-flag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.calendar-event-summary {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  list-style: none;
}

.calendar-event-summary li {
  border-radius: var(--radius-md);
  border: 1px solid rgba(27, 94, 32, 0.18);
  padding: 0.85rem 1rem;
  background: rgba(27, 94, 32, 0.06);
  display: grid;
  gap: 0.35rem;
}

.calendar-event-summary li strong {
  font-size: 0.9rem;
}

.calendar-event-summary li span {
  font-weight: 600;
}

.calendar-event-summary li p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.schedule-month {
  display: grid;
  gap: 0.75rem;
}

.schedule-event-list {
  list-style: disc;
  margin: 0;
  padding-left: 1.25rem;
}

.schedule-event-list li + li {
  margin-top: 0.75rem;
}

.schedule-event-dates {
  font-weight: 600;
  color: var(--primary);
  display: block;
}

.schedule-event-details {
  display: grid;
  gap: 0.35rem;
}

.schedule-event-details p {
  margin: 0;
  color: var(--text-muted);
}

.schedule-event-details strong {
  font-size: 0.95rem;
}

.checklist {
  margin: 0;
  padding-left: 1.5rem;
  display: grid;
  gap: 0.5rem;
}

.checklist li {
  position: relative;
  padding-left: 1.25rem;
  line-height: 1.4;
}

.checklist li::before {
  content: '✔';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
}

.tab-bar {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.tab-bar.tab-bar--hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.tab-button {
  border: none;
  background: transparent;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.3;
  flex: 1 1 calc(50% - 0.5rem);
  min-width: 120px;
  gap: 0.4rem;
}

.tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.tab-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}

.tab-label-short {
  display: none;
}

.tab-button.restricted {
  color: var(--text-muted);
}

.tab-button.restricted::after {
  content: '🔒';
  font-size: 0.85rem;
  margin-left: 0.35rem;
}

.tab-button.active {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 10px 25px rgba(27, 94, 32, 0.35);
  transform: translateY(-2px);
}

@media (max-width: 639px) {
  html {
    font-size: 15px;
  }

  .app-shell {
    padding-bottom: 7.5rem;
  }

  .tab-bar {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%) !important;
    width: min(520px, calc(100% - 2rem));
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.45);
    border-radius: 999px;
    padding: 0.5rem;
    gap: 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
  }

  /* Keep tab bar visible on mobile to prevent accidental back button usage */
  .tab-bar.tab-bar--hidden {
    opacity: 1 !important;
    transform: translateX(-50%) !important;
    pointer-events: auto !important;
  }

  .tab-button {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.45rem 0.35rem;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.75);
  }

  .tab-button .tab-label-full {
    display: none;
  }

  .tab-button .tab-label-short {
    display: inline;
  }

  .tab-button .tab-icon svg {
    width: 1.2rem;
    height: 1.2rem;
  }

  .tab-button.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    box-shadow: none;
    transform: translateY(0);
  }
}

button.primary,
button.secondary,
button.text {
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  padding: 0.65rem 1.25rem;
}

button.primary {
  background: var(--primary);
  color: var(--primary-contrast);
}

button.secondary {
  background: rgba(27, 94, 32, 0.1);
  color: var(--primary);
}

button.text {
  background: transparent;
  color: var(--text-muted);
}

button.wide {
  width: 100%;
}

.auth-required [data-action="prompt-auth"] {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.35rem;
  border-radius: var(--radius-md);
}

.auth-dialog {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 1000;
}

.auth-card {
  background: var(--surface);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: min(100%, 420px);
  display: grid;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.auth-card form {
  display: grid;
  gap: 0.75rem;
}

.auth-card input {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
}

.profile-dialog {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 1100;
  overflow-y: auto;
}

.profile-card {
  background: var(--surface);
  padding: clamp(1.75rem, 4vw, 2.75rem);
  border-radius: var(--radius-lg);
  width: min(100%, 540px);
  display: grid;
  gap: 1.25rem;
  box-shadow: var(--shadow);
}

.profile-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.profile-card header button.text {
  color: var(--primary);
  padding: 0.35rem 0.75rem;
}

.profile-form {
  display: grid;
  gap: 0.9rem;
}

.profile-form .field-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.profile-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--text-muted);
}

.profile-form label.full {
  grid-column: 1 / -1;
}

.profile-form label span {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-form input,
.profile-form textarea {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-alt, #ffffff);
}

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

.profile-card .actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.divider {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.reference-list {
  display: grid;
  gap: 0.75rem;
}

.reference-item {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: grid;
  gap: 0.25rem;
}

.featured-reference {
  margin: 0.75rem 0;
}

.reference-item span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.reference-links {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  list-style: disc;
  list-style-position: outside;
}

.reference-links a {
  color: var(--primary);
  font-weight: 600;
}

.reference-links a:hover,
.reference-links a:focus-visible {
  text-decoration: underline;
}

.note {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chip-set {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(27, 94, 32, 0.14);
  color: var(--primary);
  font-size: 0.8rem;
}

.alert {
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid rgba(27, 94, 32, 0.25);
  background: rgba(27, 94, 32, 0.08);
}

.auth-feedback {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.alert strong {
  display: block;
  margin-bottom: 0.35rem;
}

@media (min-width: 640px) {
  .tab-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    border-radius: 999px;
    padding: 0.5rem;
    scrollbar-width: none;
  }

  .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .tab-button {
    flex: 0 0 auto;
    min-width: 0;
    padding: 0.6rem 1rem;
  }
}

@media (min-width: 720px) {
  .app-header {
    align-items: center;
    gap: 1.25rem;
  }

  .profile-area {
    flex-wrap: nowrap;
  }

  .profile-area .user-meta {
    text-align: right;
  }
}

@media (min-width: 1024px) {
  .app-shell {
    max-width: 1400px;
    padding-bottom: clamp(2rem, 5vw, 3rem);
  }

  .member-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    align-items: start;
    gap: clamp(1.5rem, 4vw, 2rem);
  }

  .member-layout #tab-content {
    grid-column: 1;
    grid-row: 2;
  }

  .member-layout .tab-bar {
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
    z-index: 100;
    transform: none;
    margin-top: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 0.85rem 1.25rem;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
  }

  .member-layout .tab-bar.tab-bar--hidden {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .member-layout .tab-button {
    flex: 0 0 auto;
    justify-content: center;
    text-align: center;
    gap: 0.45rem;
    padding: 0.65rem 1.1rem;
    border-radius: 999px;
    min-width: 0;
    font-size: 0.875rem;
    white-space: nowrap;
  }

  .member-layout .tab-button .tab-icon svg {
    width: 0.95rem;
    height: 0.95rem;
  }

  .member-layout .tab-button:hover,
  .member-layout .tab-button:focus-visible {
    background: rgba(27, 94, 32, 0.12);
    color: var(--primary);
  }

  .member-layout .tab-button.active {
    background: var(--primary);
    color: var(--primary-contrast);
    box-shadow: 0 4px 12px rgba(27, 94, 32, 0.3);
    transform: none;
  }
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -55%);
  background: var(--surface);
  color: var(--text);
  padding: clamp(1rem, 4vw, 1.5rem) clamp(1.1rem, 5vw, 2rem);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 900;
  max-width: min(90vw, 420px);
  width: min(90vw, 380px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%);
}
/* Icon-only button used for downloads */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin-left: .35rem;
  border: 1px solid var(--border, #dcdcdc);
  background: var(--card, #fff);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

.icon-btn:hover {
  background: var(--hover, #f5f7f8);
  border-color: var(--border-strong, #c8cdd2);
}

.icon-btn:active {
  transform: translateY(1px);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  color: #2c3e50; /* adjust to your theme */
}
/* Reference Library — responsive layouts & actions */
.ref-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 520px) {
  .ref-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 860px) {
  .ref-grid { grid-template-columns: repeat(3, 1fr); }
}
.ref-card {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  padding: 1rem 1rem 0.75rem;
  background: var(--surface, #fff);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.ref-card-head { margin-bottom: .5rem; }
.ref-card-title { margin: 0 0 .25rem 0; font-size: 1.05rem; }
.ref-card-desc { margin: 0 0 .5rem 0; color: var(--muted, #6b7280); font-size: .925rem; }

.ref-doc-list { list-style: none; margin: .25rem 0 0; padding: 0; display: grid; gap: .5rem; }
.ref-doc-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .5rem .6rem; border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px; background: var(--subtle, #fafafa);
}
.ref-doc-main {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1 1 auto;
  min-width: 0;
}
.ref-doc-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.chip-new {
  background: #ff5722;
  color: #ffffff;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.ref-actions {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #f8fafc;
  line-height: 1;
  cursor: pointer;
}

.action-btn:hover {
  background: #f5f6f7;
}

.action-btn .icon {
  width: 16px;
  height: 16px;
}

.ref-accordion { border: 1px solid var(--border, #e5e7eb); border-radius: 14px; overflow: hidden; }
.ref-acc-item + .ref-acc-item { border-top: 1px solid var(--border, #e5e7eb); }
.ref-acc-trigger {
  width: 100%; text-align: left; padding: .9rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface, #fff); border: 0; cursor: pointer; font-size: 1rem;
}
.ref-acc-panel { padding: .25rem 1rem 1rem; }
.ref-acc-trigger .chev { width: 18px; height: 18px; transition: transform .18s ease; }
.ref-acc-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }

.muted { color: var(--muted, #6b7280); }

/* Photos tab */
.photos-card {
  position: relative;
  overflow: hidden;
}

.photo-upload {
  display: grid;
  gap: 1rem;
}

.photo-dropzone {
  position: relative;
  border: 2px dashed rgba(15, 23, 42, 0.16);
  border-radius: var(--radius-md);
  padding: clamp(1.25rem, 4vw, 1.75rem);
  background: rgba(255, 255, 255, 0.6);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.photo-dropzone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-dropzone-body {
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  text-align: center;
  color: var(--text-muted);
}

.photo-dropzone-icon {
  width: 48px;
  height: 48px;
  fill: var(--primary);
  opacity: 0.85;
}

.photo-dropzone-hint {
  margin: 0;
  font-size: 0.85rem;
}

.photo-dropzone.is-dragover {
  border-color: rgba(27, 94, 32, 0.6);
  background: rgba(27, 94, 32, 0.08);
  transform: scale(1.01);
}

.photo-file-name {
  font-size: 0.9rem;
  color: var(--text);
}

.photo-caption {
  display: grid;
  gap: 0.4rem;
}

.photo-caption input {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(15, 23, 42, 0.16);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.photo-caption input:focus-visible {
  border-color: rgba(27, 94, 32, 0.65);
  outline: none;
  box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.2);
}

.photo-upload-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.photo-upload-actions .text {
  font-weight: 600;
}

.photo-upload-status {
  margin: 0;
  font-size: 0.9rem;
}

.photo-upload-status.is-error {
  color: #b91c1c;
}

.photo-upload-status.is-success {
  color: #166534;
}

.photo-preview {
  display: grid;
  gap: 1rem;
}

.photo-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.photo-preview-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.photo-thumb {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  min-height: 180px;
  background: rgba(15, 23, 42, 0.08);
}

.photo-thumb-link {
  display: block;
  height: 100%;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.photo-thumb-caption {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.75rem;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.75) 100%);
  color: #fff;
  font-size: 0.9rem;
  transition: opacity 0.3s ease;
}

.photo-thumb-meta {
  font-size: 0.8rem;
  opacity: 0.9;
}

.photo-thumb:hover img,
.photo-thumb-link:focus-visible img {
  transform: scale(1.05);
}

.photo-thumb:hover .photo-thumb-caption,
.photo-thumb-link:focus-visible + .photo-thumb-caption {
  opacity: 1;
}

@media (min-width: 720px) {
  .photo-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* Gallery page */
.gallery-body {
  background: radial-gradient(circle at top left, rgba(27, 94, 32, 0.08), transparent 45%),
    radial-gradient(circle at bottom right, rgba(255, 167, 38, 0.1), transparent 40%),
    var(--background);
}

.gallery-shell {
  max-width: 1180px;
}

.gallery-header {
  flex-direction: column;
  gap: 1.25rem;
}

.gallery-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
}

.gallery-main {
  display: grid;
  gap: 1.5rem;
}

.gallery-feed {
  display: grid;
  gap: 1rem;
}

.gallery-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.gallery-feed-actions .text {
  font-weight: 600;
}

.gallery-status[data-tone='error'] {
  color: #b91c1c;
}

.gallery-status[data-tone='muted'] {
  color: var(--text-muted);
}

.gallery-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 14px;
  grid-auto-flow: dense;
}

.gallery-grid[data-layout='grid'] {
  grid-auto-rows: auto;
}

.gallery-grid[data-state='empty']::before {
  content: '';
  display: none;
}

.gallery-tile {
  position: relative;
}

.gallery-grid[data-layout='mosaic'] .gallery-tile {
  grid-row: span 18;
}

.gallery-grid[data-layout='mosaic'] .gallery-tile[data-orientation='portrait'] {
  grid-row: span 24;
}

.gallery-grid[data-layout='mosaic'] .gallery-tile[data-orientation='landscape'] {
  grid-row: span 16;
}

.gallery-grid[data-layout='grid'] .gallery-tile {
  grid-row: auto;
}

.gallery-link {
  position: relative;
  display: block;
  height: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.05);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.gallery-caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1rem 1.1rem;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.85) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gallery-caption-title {
  margin: 0;
  font-size: 1rem;
}

.gallery-caption-meta {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.85;
}

.gallery-link:hover,
.gallery-link:focus-visible {
  outline: none;
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
}

.gallery-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.35), 0 18px 40px rgba(15, 23, 42, 0.22);
}

.gallery-link:focus-visible img,
.gallery-link:hover img {
  transform: scale(1.05);
}

.gallery-footer {
  margin-top: 2rem;
}

@media (min-width: 960px) {
  .gallery-header {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }
}

/* Ultra-wide desktop optimization */
@media (min-width: 1600px) {
  .app-shell {
    max-width: 1800px;
  }
}

/* Waypoints table specific styles */
.waypoints-table {
  font-size: 0.8rem;
  min-width: 100%;
  table-layout: auto;
}

.waypoints-table th,
.waypoints-table td {
  white-space: nowrap;
  padding: 0.4rem 0.6rem;
  vertical-align: top;
}

/* Name column - allow wrapping for better space utilization */
.waypoints-table td:nth-child(2),
.waypoints-table th:nth-child(2) {
  white-space: normal;
  word-wrap: break-word;
  max-width: 120px;
  min-width: 80px;
}

.waypoints-table td:nth-child(5) {
  /* Description column - allow wrapping */
  white-space: normal;
  max-width: 200px;
  word-wrap: break-word;
}

.waypoints-table th:first-child,
.waypoints-table td:first-child {
  /* Active column - narrow */
  width: 60px;
  text-align: center;
  padding: 0.4rem 0.3rem;
}

.waypoints-table .status-badge {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: bold;
}

.waypoints-table .status-badge.active {
  color: var(--primary);
}

.waypoints-table .status-badge.inactive {
  color: var(--text-muted);
}

.waypoint-actions {
  display: flex;
  gap: 0.35rem;
  white-space: nowrap;
}

.waypoint-actions .text {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

@media (min-width: 1024px) {
  .waypoints-table {
    font-size: 0.85rem;
  }

  .waypoints-table th,
  .waypoints-table td {
    padding: 0.5rem 0.75rem;
  }

  .waypoints-table th:first-child,
  .waypoints-table td:first-child {
    padding: 0.5rem 0.4rem;
  }

  .waypoints-table td:nth-child(2),
  .waypoints-table th:nth-child(2) {
    max-width: 150px;
  }

  .waypoints-table td:nth-child(5) {
    max-width: 250px;
  }
}
