:root {
  --ink: #1c1915;
  --muted: #6d655c;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e3d9c8;
  --pine: #1b3329;
  --pine-2: #2d5644;
  --shadow: 0 18px 50px rgba(40, 28, 16, 0.12);
  color-scheme: light;
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

button, input, select {
  font: inherit;
  color: inherit;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app-shell {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.mast { padding: 20px 16px 8px; }

.brand {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pine-2);
}

.mast h1 {
  margin: 6px 0 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.7rem, 8vw, 2.1rem);
  font-weight: 560;
  line-height: 1.1;
}

.lede {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.search-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(243, 239, 230, 0.96);
}

.query { flex: 1 1 10rem; min-width: 0; }

.query input,
.filter-block select,
#open-filters,
.apply,
.text-btn,
.chip,
.tabbar button,
.mark,
.view-more,
.load-more,
.profile-form input {
  min-height: 48px;
}

.query input,
.profile-form input,
.filter-block select {
  width: 100%;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-size: 1rem;
}

#open-filters,
.apply,
.load-more,
.view-more {
  border: 0;
  border-radius: 14px;
  background: var(--pine);
  color: #f6f3ec;
  font-weight: 600;
  padding: 0 16px;
  text-decoration: none;
}

#open-filters { flex: 1 1 6.5rem; }

.count {
  margin: 4px 16px 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.trek-card {
  display: block;
  margin: 0 16px 12px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.trek-card h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 560;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.peak, .blurb, .status-line {
  margin: 8px 0 0;
  line-height: 1.4;
}

.peak, .status-line { color: var(--muted); }

.facts {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
}

.facts div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
}

.facts dt {
  color: var(--muted);
  font-size: 0.92rem;
}

.facts dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.facts .missing { color: var(--muted); font-weight: 500; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.view-more, .load-more, .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 8rem;
}

.mark {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-weight: 600;
  padding: 0 12px;
}

.mark[aria-pressed="true"] {
  background: var(--pine);
  border-color: var(--pine);
  color: #f6f3ec;
}

.load-more {
  display: flex;
  width: calc(100% - 32px);
  margin: 4px 16px 16px;
}

.empty {
  margin: 12px 16px 24px;
  padding: 20px 16px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.empty h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.5rem;
}

.empty p { margin: 8px 0 0; line-height: 1.45; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 32rem;
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #fffdf8;
  border-top: 1px solid var(--line);
}

.tabbar button {
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-weight: 600;
  padding: 0 4px;
}

.tabbar button[aria-current="page"] {
  background: var(--pine);
  color: #f6f3ec;
}

.history-switch { margin: 0 16px 12px; }

.profile-form {
  display: grid;
  gap: 12px;
  padding: 8px 16px 16px;
}

.profile-form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.form-error { margin: 0; color: #8d2d2d; }

.sheet[hidden], section[hidden], .empty[hidden], .note[hidden], .form-error[hidden] { display: none; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(28, 25, 21, 0.46);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  overflow: auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
}

.sheet-head, .sheet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-head h2 {
  margin: 8px 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.6rem;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--pine-2);
  font-weight: 600;
  padding: 0 8px;
}

.filter-block {
  padding: 8px 0 12px;
  border-top: 1px solid var(--line);
}

.filter-block h3 {
  margin: 8px 0;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.filter-block label {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  font-weight: 600;
}

.hint, .note {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.4;
}

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

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  padding: 0 14px;
  font-weight: 600;
}

.chip[aria-pressed="true"] {
  background: var(--pine);
  border-color: var(--pine);
  color: #f6f3ec;
}

.sheet-actions {
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: var(--paper);
}

.apply { flex: 1; }

@media (min-width: 540px) {
  .sheet-panel { left: auto; width: min(32rem, 100%); }
}
