:root {
  --ink: #0f172a;
  --ink-soft: #3b4758;
  --ink-muted: #6b7280;
  --fog: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --surface-strong: #e9eef2;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: rgba(15, 118, 110, 0.14);
  --leaf: #2f9a6a;
  --blue: #2563eb;
  --coral: #f26c4f;
  --sky: #dbeafe;
  --border: rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 6px 16px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 14px 32px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 28px 60px rgba(15, 23, 42, 0.18);
  --radius: 20px;
  --radius-sm: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: "Sora", sans-serif;
  color: var(--ink);
  background: var(--fog);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open {
  overflow: hidden;
}

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

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

p {
  margin: 0;
}

.bg-sheen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 18% 8%, rgba(15, 118, 110, 0.14), transparent 45%),
    radial-gradient(circle at 82% 12%, rgba(242, 108, 79, 0.12), transparent 45%),
    linear-gradient(140deg, #f8fafc 0%, #f2f5f2 50%, #eef3f7 100%);
  z-index: -1;
}

.bg-sheen::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.35;
  pointer-events: none;
}

h1,
h2,
h3 {
  font-family: "Instrument Serif", serif;
  letter-spacing: 0.2px;
  margin: 0 0 0.4rem;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.1;
}

h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  line-height: 1.2;
}

h3 {
  font-size: 1.2rem;
  line-height: 1.3;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.container {
  width: min(1160px, 92%);
  margin: 0 auto;
}

.narrow {
  width: min(560px, 92%);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(245, 247, 246, 0.9);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 16px;
  padding-right: max(0px, env(safe-area-inset-right));
  padding-left: max(0px, env(safe-area-inset-left));
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.nav-toggle:hover {
  background: var(--surface-muted);
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-toggle__bars,
.nav-toggle__bars::before,
.nav-toggle__bars::after {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle__bars::before,
.nav-toggle__bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle__bars::before { top: -7px; }
.nav-toggle__bars::after { top: 7px; }

.nav-toggle[aria-expanded="true"] .nav-toggle__bars {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after {
  transform: translateY(-7px) rotate(-45deg);
}

.brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.nav a {
  padding: 8px 14px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: all 0.2s ease;
}

.nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav a.is-active,
.nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.25);
}

.nav-ghost {
  border: 1px solid var(--border);
  background: rgba(15, 118, 110, 0.06);
  color: var(--accent-strong);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.site-main {
  padding: 40px 0 80px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-header > div {
  display: grid;
  gap: 6px;
}

.stats-export {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.export-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.export-form label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.export-form input[type="date"] {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.export-form input[type="date"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px 24px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(15, 118, 110, 0.08));
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.detail-header::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  top: -110px;
  right: -80px;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.22), transparent 70%);
  pointer-events: none;
}

.detail-header.page-header {
  border-bottom: none;
}

.detail-header__info {
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.detail-header__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.detail-header .actions {
  justify-self: end;
  position: relative;
  z-index: 1;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.tag-grade {
  gap: 8px;
}

.grade {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
}

.grade-emoji {
  font-size: 0.95rem;
}

.grade-gronn {
  color: var(--leaf);
}

.grade-bla {
  color: var(--blue);
}

.grade-rod {
  color: var(--coral);
}

.grade-svart {
  color: var(--ink);
}

.tag-grade.grade-gronn {
  border-color: rgba(47, 154, 106, 0.25);
  background: rgba(47, 154, 106, 0.12);
}

.tag-grade.grade-bla {
  border-color: rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.12);
}

.tag-grade.grade-rod {
  border-color: rgba(242, 108, 79, 0.25);
  background: rgba(242, 108, 79, 0.12);
}

.tag-grade.grade-svart {
  border-color: rgba(15, 23, 42, 0.2);
  background: rgba(15, 23, 42, 0.06);
}

.tag-text {
  text-transform: capitalize;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  color: var(--accent-strong);
  margin: 0;
  font-weight: 600;
}

.muted {
  color: var(--ink-muted);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.65;
  cursor: progress;
  transform: none;
}

.btn[aria-busy="true"]::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: btn-spin 0.7s linear infinite;
  margin-left: 4px;
}

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

.btn:hover {
  transform: translateY(-1px);
  background: var(--surface-muted);
  box-shadow: var(--shadow-sm);
  border-color: rgba(15, 118, 110, 0.2);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.24);
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.danger {
  background: var(--coral);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 26px rgba(242, 108, 79, 0.25);
}

.btn.danger:hover {
  background: #e85b3f;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}

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

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow-sm);
}

.filters input,
.filters select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  min-width: 200px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filters input:focus-visible,
.filters select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.trip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.trip-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.trip-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(15, 118, 110, 0.2);
}

.card-media {
  position: relative;
  height: 150px;
  background: var(--surface-muted);
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.trip-card:hover .card-media img {
  transform: scale(1.04);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  border: 1px solid transparent;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.tag {
  white-space: nowrap;
}

.card-media .badge {
  position: absolute;
  top: 12px;
  left: 12px;
  box-shadow: var(--shadow-sm);
}

.badge-private {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.25);
}

.badge-shared {
  background: rgba(47, 154, 106, 0.15);
  color: var(--leaf);
  border-color: rgba(47, 154, 106, 0.25);
}

.badge-public {
  background: rgba(242, 108, 79, 0.18);
  color: var(--coral);
  border-color: rgba(242, 108, 79, 0.3);
}

.card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.card-stats {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 28px;
  align-items: start;
}

.detail-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 24px;
  align-items: start;
}

.detail-media {
  display: grid;
  gap: 12px;
}

.detail-media .media-row {
  margin-bottom: 0;
}

.detail-media .media-row.has-gallery {
  grid-template-columns: minmax(0, 1fr);
}

.detail-data {
  display: grid;
  gap: 16px;
}

.info-card,
.self-report {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 8px;
}

.info-card h3 {
  margin: 0;
}

.info-card p,
.self-report p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.media-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.media-row.has-gallery {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: start;
}

.media-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hero-image {
  width: 100%;
  height: clamp(220px, 36vw, 360px);
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0;
}

.hero-image-button {
  border: none;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
}

.hero-image-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius);
}


.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin: 20px 0;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.meta-grid.compact {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  gap: 12px 24px;
}

.meta-grid.compact span:not(.label) {
  font-weight: 600;
  color: var(--ink);
}

.meta-grid .stat-text {
  text-transform: capitalize;
}

.side-panel .meta-grid.compact {
  gap: 10px 18px;
}

.label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.extra-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.extra-images img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}


.image-thumb {
  border: 1px solid var(--border);
  padding: 0;
  background: transparent;
  cursor: zoom-in;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.image-thumb img {
  width: 100%;
  height: 110px;
  border-radius: 0;
  display: block;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.media-gallery .image-thumb img {
  height: 120px;
}

.image-thumb:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(15, 118, 110, 0.25);
}

.image-thumb:hover img {
  transform: scale(1.04);
}

.image-thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.image-modal {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(15, 23, 42, 0.88);
  z-index: 2000;
  overflow: hidden;
  touch-action: none;
}

.image-modal.is-open {
  display: block;
}

.image-modal__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
}

.image-modal__stage.is-zoomed {
  cursor: grab;
}

.image-modal__stage.is-panning {
  cursor: grabbing;
}

.image-modal__img {
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: 0 0;
  transform: translate(0, 0) scale(1);
  will-change: transform;
  transition: transform 120ms ease-out;
}

.image-modal__img.is-interacting {
  transition: none;
}

.image-modal__close,
.image-modal__reset {
  position: absolute;
  top: 16px;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.image-modal__close { right: 16px; }
.image-modal__reset { right: 110px; }

.image-modal__close:hover,
.image-modal__reset:hover {
  background: rgba(15, 23, 42, 0.85);
}

.image-modal__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: #fff;
  font-size: 36px;
  line-height: 1;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  padding: 0;
}

.image-modal__nav:hover {
  background: rgba(15, 23, 42, 0.85);
}

.image-modal__nav--prev { left: 16px; }
.image-modal__nav--next { right: 16px; }

@media (max-width: 600px) {
  .image-modal__nav {
    width: 44px;
    height: 44px;
    font-size: 28px;
  }
  .image-modal__nav--prev { left: 8px; }
  .image-modal__nav--next { right: 8px; }
}

.image-modal__hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(15, 23, 42, 0.5);
  border-radius: 999px;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.image-modal__hint.is-hidden {
  opacity: 0;
}

.map-card {
  position: relative;
  height: 240px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  isolation: isolate;
}

.map-fs-wrap {
  position: relative;
}

.map-fullscreen-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1100;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  padding: 0;
}

.map-fullscreen-btn:hover {
  background: var(--accent-soft);
}

.map-fullscreen-btn:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.map-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.72);
  z-index: 2000;
}

.map-modal.is-open {
  display: flex;
}

.map-modal__dialog {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  width: min(1400px, 92vw);
  height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.map-modal__close {
  align-self: flex-end;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent-strong);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.map-modal__close:hover {
  background: var(--accent-soft);
}

.map-modal__body {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.map-modal__body > [data-map],
.map-modal__body > [data-map-picker] {
  width: 100%;
  height: 100%;
}

.map-card--inline {
  height: 200px;
  box-shadow: none;
}

.side-panel {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 16px;
}

.side-panel__header {
  display: grid;
  gap: 4px;
}

.side-stats {
  display: grid;
  gap: 12px;
}

.side-stat {
  display: grid;
  gap: 4px;
}

.side-stat strong {
  font-size: 1.05rem;
}

.side-actions {
  display: grid;
  gap: 10px;
}

.map-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--accent);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(15, 20, 25, 0.25);
}

.map-marker--start {
  background: var(--leaf);
}

.map-marker--finish {
  background: var(--coral);
}

.map-marker--selected {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink);
}

.map-fallback {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  color: var(--ink-muted);
  background: rgba(15, 118, 110, 0.08);
}

.chart-card {
  margin-top: 0;
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow: hidden;
}

#altitude-chart {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 200px;
}

.changelog-body {
  display: block;
  line-height: 1.6;
}

.changelog-body > :first-child {
  margin-top: 0;
}

.changelog-body h1 {
  display: none;
}

.changelog-body h2 {
  font-family: "Instrument Serif", serif;
  font-size: 1.3rem;
  margin: 28px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--accent-strong);
}

.changelog-body h3 {
  font-family: "Sora", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 16px 0 6px;
}

.changelog-body ul {
  margin: 0 0 12px;
  padding-left: 22px;
}

.changelog-body li {
  margin-bottom: 4px;
}

.changelog-body p {
  margin: 0 0 12px;
  color: var(--ink-soft);
}

.changelog-body a {
  color: var(--accent-strong);
  text-decoration: underline;
}

.changelog-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
}

.form {
  display: grid;
  gap: 14px;
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.form input,
.form select,
.form textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form input:focus-visible,
.form select:focus-visible,
.form textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.form input::placeholder,
.form textarea::placeholder {
  color: rgba(107, 114, 128, 0.8);
}

.form-grid {
  display: grid;
  gap: 28px;
  width: min(100%, 980px);
  margin: 0 auto;
}

.form-section {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 14px;
}

.form-section h2 {
  margin-bottom: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.image-preview {
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  padding: 12px;
  width: fit-content;
}

.image-preview img {
  width: 100%;
  max-width: 280px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.checkbox:hover {
  background: var(--surface-muted);
}

.checkbox input[type="radio"],
.checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}

.card.form h2 {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.card.form h2:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-weight: 600;
  border: 1px solid var(--border);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.flash__message {
  flex: 1;
  min-width: 0;
}

.flash__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 999px;
  opacity: 0.7;
}

.flash__close:hover {
  opacity: 1;
  background: rgba(15, 23, 42, 0.06);
}

.flash__close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.flash.success {
  background: rgba(47, 154, 106, 0.16);
  color: var(--leaf);
  border-color: rgba(47, 154, 106, 0.2);
}

.flash.error {
  background: rgba(242, 108, 79, 0.18);
  color: var(--coral);
  border-color: rgba(242, 108, 79, 0.25);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.6);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  padding: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  align-items: start;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.table th,
.table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  background: var(--surface-muted);
}

.table tbody tr:hover td {
  background: rgba(15, 118, 110, 0.04);
}

.laps {
  margin-top: 24px;
}

.laps-table th,
.laps-table td {
  font-size: 0.9rem;
  white-space: nowrap;
}

.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.site-footer {
  padding: 24px 0 40px;
  color: var(--ink-muted);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.footer-version {
  font-size: 0.85rem;
  margin-top: 4px;
}

.danger-zone {
  border: 1px solid rgba(242, 108, 79, 0.3);
  background: rgba(242, 108, 79, 0.08);
}

@media (min-width: 980px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .form-section:nth-child(4),
  .form-section:nth-child(5),
  .form-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-header .actions {
    justify-self: stretch;
    width: 100%;
    flex-wrap: wrap;
  }

  .detail-header .actions > .btn,
  .detail-header .actions form {
    flex: 1 1 calc(50% - 6px);
  }

  .detail-header .actions form .btn {
    width: 100%;
  }

  .media-row.has-gallery {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .nav-toggle {
    display: inline-flex;
  }

  .header-inner {
    flex-wrap: nowrap;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 12px;
    right: 12px;
    z-index: 20;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-md);
  }

  .nav.is-open {
    display: flex;
  }

  .nav a {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    justify-content: flex-start;
  }

  .filters {
    padding: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .filters input,
  .filters select,
  .filters .btn {
    min-width: 0;
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
  }

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

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

@media (max-width: 480px) {
  .media-gallery {
    grid-template-columns: minmax(0, 1fr);
  }

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

/* Table scroll affordance */
.table-wrap {
  position: relative;
  background:
    linear-gradient(to right, var(--surface) 0%, var(--surface) 4%, transparent 8%) 0 0,
    linear-gradient(to left, var(--surface) 0%, var(--surface) 4%, transparent 8%) 100% 0,
    radial-gradient(farthest-side at 0% 50%, rgba(15, 23, 42, 0.12), transparent) 0 0,
    radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, 0.12), transparent) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* Password field with reveal toggle */
.password-field {
  position: relative;
  display: block;
}

.password-field input {
  width: 100%;
  padding-right: 64px;
}

.password-field__toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 32px;
}

.password-field__toggle:hover {
  background: var(--accent-soft);
}

.password-field__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Character counter */
.char-counter {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-weight: 500;
  text-align: right;
}

.char-counter--warning {
  color: var(--coral);
}

/* Field-level errors */
.field-error {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--coral);
  font-weight: 600;
}

.form .field-error + input,
.form .field-error + select,
.form .field-error + textarea,
.form label.has-error input,
.form label.has-error select,
.form label.has-error textarea {
  border-color: var(--coral);
  box-shadow: 0 0 0 2px rgba(242, 108, 79, 0.18);
}

.field-help {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.required-mark {
  color: var(--coral);
  margin-left: 2px;
  font-weight: 700;
}

/* Extra images live preview */
.extra-images-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.extra-images-preview img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.extra-images-status {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* Footer safe area */
.site-footer {
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Sticky filter actions on mobile */
@media (max-width: 720px) {
  .table th,
  .table td {
    padding: 10px 6px;
    font-size: 0.85rem;
  }

  .checkbox {
    min-height: 44px;
  }

  .image-modal {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  min-width: 0;
  min-height: 0;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  user-select: none;
  line-height: 1;
  box-sizing: border-box;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-xs { width: 22px; height: 22px; min-width: 22px; font-size: 0.65rem; }
.avatar-sm { width: 32px; height: 32px; min-width: 32px; font-size: 0.85rem; }
.avatar-md { width: 48px; height: 48px; min-width: 48px; font-size: 1.2rem; }
.avatar-lg { width: 72px; height: 72px; min-width: 72px; font-size: 1.9rem; }

.avatar-hue-0 { background: #4a6cf7; }
.avatar-hue-1 { background: #e35d6a; }
.avatar-hue-2 { background: #2faa6f; }
.avatar-hue-3 { background: #b86bd9; }
.avatar-hue-4 { background: #d97f3b; }
.avatar-hue-5 { background: #2596be; }
.avatar-hue-6 { background: #d8a838; color: #2a2a2a; }
.avatar-hue-7 { background: #5e7387; }

.user-row {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.avatar-cropper {
  background: rgba(15, 23, 42, 0.88);
}
.avatar-cropper__dialog {
  width: min(540px, 92vw);
  max-height: 92vh;
  padding: 18px;
  display: grid;
  gap: 12px;
  box-sizing: border-box;
  overflow: hidden;
}
.avatar-cropper__dialog h3 {
  margin: 0;
}
.avatar-cropper__stage {
  background: rgba(15, 23, 42, 0.04);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: min(55vh, 420px);
  min-height: 0;
}
.avatar-cropper__stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}
.avatar-cropper__stage .cropper-container {
  max-width: 100%;
  max-height: 100%;
}
.avatar-cropper__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.avatar-cropper .cropper-view-box,
.avatar-cropper .cropper-face {
  border-radius: 50%;
}
.avatar-cropper .cropper-view-box {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: -2px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
}
