:root {
    --brick: #9E2B25;
    --brick-dark: #7C201C;
    --gold: #E1A11C;
    --gold-soft: #F2C14E;
    --blue: #335C7D;
    --blue-dark: #21425C;
    --ink: #1F262E;
    --muted: #6B7280;
    --paper: #FAF7F0;
    --card: #FFFFFF;
    --line: #E7E0D3;
    --shadow: 0 1px 2px rgba(31,38,46,.06), 0 8px 24px rgba(31,38,46,.06);
    --radius: 14px;
    --display: "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
    --body: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--body);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.55;
}

a { color: var(--blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3 { font-family: var(--display); line-height: 1.1; letter-spacing: .01em; }
h1 { font-size: 1.9rem; margin: 0 0 .3em; }
h2 { font-size: 1.35rem; margin: 0 0 .6em; }

.eyebrow {
    font-family: var(--display);
    text-transform: uppercase;
    letter-spacing: .14em;
    font-size: .72rem;
    font-weight: 700;
    color: var(--brick);
}

/* ---------- Top bar ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.topbar-inner {
    max-width: 1180px; margin: 0 auto; padding: .6rem 1.25rem;
    display: flex; align-items: center; gap: 1rem; flex-wrap: nowrap;
}
.brand { flex: 0 0 auto; }
.brand-logo { height: 44px; width: auto; display: block; }
.global-search { flex: 1 1 140px; display: flex; min-width: 0; }
.global-search input {
    flex: 1; min-width: 0; border: 1px solid var(--line); border-right: 0;
    border-radius: 999px 0 0 999px; padding: .5rem .9rem; font-size: .95rem; background: var(--paper);
}
.global-search input:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.global-search button {
    border: 0; background: var(--blue-dark); color: #fff; padding: 0 1rem;
    border-radius: 0 999px 999px 0; font-size: 1.1rem; cursor: pointer;
}
.main-nav { display: flex; gap: .9rem; align-items: center; font-weight: 600; flex: 0 0 auto; white-space: nowrap; }
.main-nav a { color: var(--ink); }
.main-nav a:hover { color: var(--brick); text-decoration: none; }
.nav-admin { color: var(--brick) !important; }

/* On narrow screens (phones / tablets) let the bar wrap and the search take its own row */
@media (max-width: 880px) {
    .topbar-inner { flex-wrap: wrap; }
    .global-search { order: 5; flex-basis: 100%; }
    .main-nav { gap: .8rem; flex-wrap: wrap; }
}

/* mountain-contour ridge: the page signature */
.ridge {
    height: 8px;
    background:
        repeating-linear-gradient(90deg, transparent 0 6px, rgba(255,255,255,.5) 6px 7px),
        linear-gradient(90deg, var(--blue) 0%, var(--gold) 55%, var(--brick) 100%);
}

/* ---------- User menu ---------- */
.user-menu { display: flex; align-items: center; gap: .6rem; flex: 0 0 auto; white-space: nowrap; }
.user-chip { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
.user-name { font-weight: 600; font-size: .92rem; }
@media (max-width: 520px) { .user-name { display: none; } }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-initials {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--blue); color: #fff; font-weight: 700; font-size: .8rem;
    font-family: var(--display);
}
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }
.btn-link:hover { color: var(--brick); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
    border: 1px solid transparent; border-radius: 999px; padding: .55rem 1.15rem;
    font: 600 .95rem var(--body); text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brick); color: #fff; }
.btn-primary:hover { background: var(--brick-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--blue); }
.btn-gold { background: var(--gold); color: #3a2c08; }

/* ---------- Layout / page ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.footer { border-top: 1px solid var(--line); color: var(--muted); text-align: center; padding: 1.5rem; font-size: .85rem; }

.page-head { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.filters select {
    flex: 1 1 0; min-width: 150px;
    border: 1px solid var(--line); border-radius: 999px; padding: .55rem 1rem; background: var(--card); font: inherit;
}
.filters input {
    border: 1px solid var(--line); border-radius: 999px; padding: .45rem .9rem; background: var(--card); font: inherit;
}
.filters .chip { flex: 0 0 auto; }
.chip-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem;
    font-size: .85rem; color: var(--ink); background: var(--card);
}
.chip.active { background: var(--blue-dark); color: #fff; border-color: var(--blue-dark); }

/* ---------- Trail grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.1rem; }
.trail-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
    transition: transform .12s ease, box-shadow .12s ease;
}
.trail-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(31,38,46,.12); }
.trail-card a { color: inherit; }
.thumb { aspect-ratio: 16/10; background: var(--blue-dark) center/cover no-repeat; position: relative; }
.thumb .ph {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--blue-dark), var(--blue)); color: rgba(255,255,255,.55);
    font-family: var(--display); letter-spacing: .1em; text-transform: uppercase; font-size: .8rem;
}
.trail-body { padding: .9rem 1rem 1.1rem; display: flex; flex-direction: column; gap: .35rem; }
.trail-title { font-family: var(--display); font-size: 1.12rem; font-weight: 700; }
.trail-meta { color: var(--muted); font-size: .85rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.trail-meta .dot::before { content: "·"; margin-right: .5rem; }

.badge {
    display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em;
    padding: .18rem .6rem; border-radius: 999px; text-transform: uppercase;
}
.b-easy { background: #E6F4EA; color: #1E7A3C; }
.b-medium { background: #FBF1D9; color: #9A6B07; }
.b-hard { background: #F7E2E0; color: var(--brick-dark); }
.b-kids { background: #E7EEF5; color: var(--blue-dark); }
.b-default { background: #EEE; color: #555; }
.b-upcoming { background: var(--gold); color: #3a2c08; }

/* ---------- Detail page ---------- */
.detail-hero { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 1.5rem; }
.detail-hero img { width: 100%; max-height: 420px; object-fit: cover; }
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start; }
.facts { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.facts dl { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; font-weight: 600; }
.prose { white-space: pre-wrap; }
.section-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; }

/* ---------- Media gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: .75rem; }
.media-tile { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #000; }
.media-tile img, .media-tile video { width: 100%; height: 160px; object-fit: cover; display: block; }
.media-cap { font-size: .8rem; color: var(--muted); padding: .35rem .5rem; background: var(--card); }

/* ---------- Statistics ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 1rem; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; box-shadow: var(--shadow);
}
.stat .num { font-family: var(--display); font-size: 2rem; font-weight: 700; color: var(--blue-dark); }
.stat .lbl { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .sub { font-size: .85rem; color: var(--ink); margin-top: .2rem; }

.bar-row { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: .6rem; margin: .35rem 0; }
.bar-track { background: var(--paper); border: 1px solid var(--line); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--gold)); }

/* ---------- Forms ---------- */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.75rem; max-width: 760px; box-shadow: var(--shadow); }
.form-row { margin-bottom: 1rem; }
.form-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .92rem; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], input[type=url], textarea, select {
    width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; font: inherit; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
textarea { min-height: 120px; resize: vertical; }
.field-hint { color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.text-danger, .validation-summary-errors { color: var(--brick-dark); font-size: .88rem; }
.alert { border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; }
.alert-success { background: #E6F4EA; color: #1E7A3C; }
.alert-info { background: #E7EEF5; color: var(--blue-dark); }

/* ---------- Members ---------- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 1rem; }
.member-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; display: flex; gap: .9rem; align-items: center; }
.avatar-lg { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.role-tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.role-admin { color: var(--brick); }
.role-member { color: var(--blue-dark); }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }

@media (max-width: 760px) {
    .detail-grid { grid-template-columns: 1fr; }
    .form-row.two { grid-template-columns: 1fr; }
    .main-nav { order: 3; width: 100%; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---- Login page ---- */
.login-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: stretch;
    max-width: 880px;
    margin: 2rem auto;
}
.login-form-col { min-width: 0; }
.login-form-col h1 { margin: 0 0 1rem; }
.login-form-col form {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow);
}
.login-form-col .btn-primary { width: 100%; justify-content: center; margin-top: .25rem; }

.login-brand-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
}
.login-logo { max-width: 240px; width: 100%; height: auto; }
.since-2015 {
    font-family: var(--display);
    font-weight: 700;
    color: var(--brick);
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: 1.05rem;
}

@media (max-width: 700px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-brand-col { order: -1; }
}
