/*
  Ilkeston Cycle Club — base styles.
  Brand tokens pulled from ilkeston.cc: orange #FB8B35, near-black nav,
  white, body copy grey #333. No build step — plain CSS, mobile-first.
*/

:root {
  --color-primary: #FB8B35;
  --color-primary-dark: #E07A28;
  --color-ink: #14151A;
  --color-white: #FFFFFF;
  --color-body: #333333;
  --color-muted: #6B7280;
  --color-border: #E5E7EB;
  --color-bg: #FFFFFF;
  --color-bg-subtle: #F7F7F5;
  --color-danger: #D14343;
  --color-success: #2E8B57;

  --font-heading: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 21, 26, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 21, 26, 0.10);

  --header-height: 60px;
  --max-width: 640px; /* mobile-first content width; primary usage is on phones */
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  color: var(--color-body);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-ink);
  line-height: 1.25;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--color-primary-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* Layout shell */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  background: var(--color-ink);
  color: var(--color-white);
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-white);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
}

.app-header__brand .badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--color-white);
  font-size: 0.9rem;
}

.app-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 16px 112px; /* bottom padding clears the taller mobile tab bar */
  min-height: calc(100vh - var(--header-height));
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
}

.icon-btn--on-dark {
  color: rgba(255, 255, 255, 0.9);
}

.icon-btn:active {
  background: rgba(0, 0, 0, 0.06);
}

.icon-btn--on-dark:active {
  background: rgba(255, 255, 255, 0.12);
}

/* Bottom tab bar — generously sized touch targets (full item height
   ~64px, not just the icon) since this is used one-handed on a bike. */

.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(20, 21, 26, 0.06);
}

.app-tabbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 8px 4px 6px;
  color: var(--color-muted);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-body);
  flex: 1;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.app-tabbar__item svg {
  transition: transform 0.1s ease;
}

.app-tabbar__item:active svg {
  transform: scale(0.9);
}

.app-tabbar__item.is-active {
  color: var(--color-primary-dark);
  position: relative;
}

.app-tabbar__item.is-active::before {
  content: '';
  position: absolute;
  top: 4px;
  width: 32px;
  height: 3px;
  border-radius: 999px;
  background: var(--color-primary);
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-white);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-outline {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-ink);
}

.btn-block {
  width: 100%;
}

/* Cards */

.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

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

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-primary-dark);
}

/* Forms */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 6px;
  color: var(--color-ink);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  color: var(--color-ink);
}

.field input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.field-error {
  color: var(--color-danger);
  font-size: 0.82rem;
  margin-top: 6px;
}

.field-hint {
  color: var(--color-muted);
  font-size: 0.82rem;
  margin-top: 6px;
}

/* Alerts */

.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-success {
  background: #EAF6EE;
  color: var(--color-success);
  border: 1px solid #CDEBD6;
}

.alert-error {
  background: #FBEAEA;
  color: var(--color-danger);
  border: 1px solid #F3CFCF;
}

/* Auth screens */

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--color-bg-subtle);
}

.auth-shell__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-ink);
}

.auth-shell__brand .badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--color-white);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.auth-card .text-muted {
  margin-bottom: 20px;
  display: block;
}

.auth-links {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
}

/* Badges / chips */

.badge-role {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-bg-subtle);
  color: var(--color-ink);
  border: 1px solid var(--color-border);
}

.badge-role.is-admin {
  background: #FFF1E6;
  color: var(--color-primary-dark);
  border-color: #FFDCB8;
}

/* Member row (roles management) */

.member-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}

.member-row:last-child {
  border-bottom: none;
}

.member-row__name {
  font-weight: 600;
  color: var(--color-ink);
}

.member-row__roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.role-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
}

.role-toggle input {
  accent-color: var(--color-primary);
}

/* Forms: select / textarea to match .field input */

.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  color: var(--color-ink);
  font-family: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 90px;
}

.textarea-lg {
  min-height: 180px;
}

.prose-body {
  white-space: pre-line;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Page header with an action button (e.g. ride list -> New ride) */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-header h1 {
  margin-bottom: 0;
}

/* Ride cards */

.ride-card {
  display: block;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  color: inherit;
}

.ride-card:hover {
  text-decoration: none;
  border-color: var(--color-primary);
}

.ride-card__when {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.ride-card__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-ink);
  margin-bottom: 6px;
}

.ride-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--color-bg-subtle);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

.pill--draft {
  background: #FFF1E6;
  color: var(--color-primary-dark);
  border-color: #FFDCB8;
}

.pill--cancelled {
  background: #FBEAEA;
  color: var(--color-danger);
  border-color: #F3CFCF;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
}

.section-heading h2 {
  font-size: 1rem;
  margin-bottom: 0;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-muted);
}

/* Floating action button — the primary way to start a new ride */

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 45;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.fab:active {
  background: var(--color-primary-dark);
}

/* Map */

.map-picker,
.map-display {
  width: 100%;
  height: 260px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  margin-bottom: 8px;
  background: var(--color-bg-subtle);
  /* Leaflet's own controls/panes use z-index up to 1000. Without this,
     that leaks past our position:fixed bottom nav (z-index 40) and
     paints over it wherever the map happens to scroll near the bottom
     of the screen. isolation:isolate boxes Leaflet's stacking inside
     this element so it can never escape upward past page-level UI. */
  position: relative;
  isolation: isolate;
}

/* Ride detail */

.ride-header {
  margin-bottom: 4px;
}

.ride-header__type {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-muted);
}

.stat-row {
  display: flex;
  gap: 18px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat__value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-ink);
}

.stat__label {
  font-size: 0.72rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Get-there action sheet */

.action-sheet {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-sheet__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-ink);
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--color-white);
}

.action-sheet__item:hover {
  text-decoration: none;
  border-color: var(--color-primary);
}

.action-sheet__item svg {
  color: var(--color-primary-dark);
  flex-shrink: 0;
}

/* RSVP controls */

.rsvp-bar {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

/* Forms used purely to wrap a single button inside a flex row shouldn't
   introduce their own box — let the button itself be the flex item. */
.rsvp-bar form,
.inline-actions form {
  display: contents;
}

.rsvp-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  color: var(--color-ink);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.rsvp-btn.is-selected {
  border-color: var(--color-primary);
  background: #FFF1E6;
  color: var(--color-primary-dark);
}

.rsvp-btn--clear {
  color: var(--color-muted);
}

.attendee-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attendee-list__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.attendee-list__row:last-child {
  border-bottom: none;
}

/* Meet-point picker: saved-spot select, search box + results, locate btn */

.meet-picker-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.meet-picker-tools .field {
  margin-bottom: 0;
}

.meet-search-wrap {
  position: relative;
}

.map-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
}

.map-search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-white);
  font-size: 0.86rem;
  color: var(--color-ink);
  cursor: pointer;
}

.map-search-result:last-child {
  border-bottom: none;
}

.map-search-result:hover,
.map-search-result:active {
  background: var(--color-bg-subtle);
}

.locate-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  color: var(--color-ink);
  font-size: 0.82rem;
  font-weight: 600;
}

/* File / image upload fields */

.upload-field {
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--color-bg-subtle);
}

.upload-field__preview:empty {
  display: none;
}

.upload-field__preview-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 12px;
  display: block;
}

.upload-field__row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  color: var(--color-ink);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
}

.upload-btn:active {
  background: var(--color-bg-subtle);
}

.upload-field__filename {
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Legacy alias kept for any inline preview rendered without the
   file-upload component (e.g. existing-value previews). */
.upload-preview {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

/* Header image banners (ride/news detail) */

.header-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.inline-image {
  width: 100%;
  border-radius: var(--radius);
  margin: 12px 0;
}

/* Featured */

.featured-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.featured-card {
  flex: 0 0 auto;
  width: 240px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  background: var(--color-ink);
  color: var(--color-white);
  height: 140px;
  box-shadow: var(--shadow-sm);
}

.featured-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}

.featured-card__body {
  position: relative;
  z-index: 1;
  padding: 12px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.featured-card__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.25;
}

.featured-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

/* News cards (mirrors .ride-card) */

.news-card {
  display: block;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  color: inherit;
}

.news-card:hover {
  text-decoration: none;
  border-color: var(--color-primary);
}

.news-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.news-card__body {
  padding: 14px 16px;
}

.news-card__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 4px;
}

/* Comments */

.comment {
  display: flex;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}

.comment:last-child {
  border-bottom: none;
}

.comment__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-bg-subtle);
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-weight: 700;
  font-size: 0.8rem;
}

.comment__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comment__body {
  flex: 1;
}

.comment__author {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--color-ink);
}

.comment__meta {
  font-size: 0.76rem;
  color: var(--color-muted);
  margin-bottom: 4px;
}

.comment__photo {
  max-width: 240px;
  border-radius: var(--radius);
  margin-top: 8px;
  display: block;
}

.comment-form {
  margin-bottom: 20px;
}

.comment-form textarea {
  min-height: 70px;
}

/* Avatar (profile) */

.avatar-circle {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--color-bg-subtle);
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.6rem;
  margin-bottom: 12px;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Admin dashboard */

.admin-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  color: inherit;
}

.admin-link:hover {
  text-decoration: none;
  border-color: var(--color-primary);
}

.admin-link__icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--color-bg-subtle);
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-link__body {
  flex: 1;
}

.admin-link__title {
  font-weight: 700;
  color: var(--color-ink);
}

.admin-link__desc {
  font-size: 0.82rem;
  color: var(--color-muted);
}

.admin-link__chevron {
  color: var(--color-muted);
  flex-shrink: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-muted);
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Small layout/text utilities — used instead of ad-hoc inline styles
   so spacing and secondary text read the same on every page. */

.inline-actions {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.icon-inline {
  vertical-align: -3px;
}

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

.link-row {
  margin-bottom: 20px;
  font-weight: 600;
}

/* Strava route picker */

.strava-picker__chosen {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg-subtle);
}

/* display:flex above would otherwise beat the hidden attribute. */
.strava-picker__chosen[hidden] {
  display: none;
}

.strava-picker__chosen strong {
  display: block;
}

.strava-picker__list {
  margin-top: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  max-height: 280px;
  overflow-y: auto;
}

.strava-route {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-white);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-body);
  cursor: pointer;
}

.strava-route:last-child {
  border-bottom: 0;
}

.strava-route:active {
  background: var(--color-bg-subtle);
}

.strava-route__name {
  display: block;
  font-weight: 600;
}

.strava-route__meta {
  display: block;
}

.btn-link {
  border: 0;
  background: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-danger);
  cursor: pointer;
}

/* Rich text: editor and rendered output */

.rich-editor {
  min-height: 140px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  background: var(--color-white);
}

/* Trix lays the toolbar out on one non-wrapping row that scrolls sideways.
   At the width this app actually gets, that means a scrollbar under the
   buttons on every form, so let the groups wrap onto a second line. */
/* "body" is here to out-specify Trix's own rule, which uses exactly this
   selector and is loaded after app.css. */
body trix-toolbar .trix-button-row {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
  overflow-x: visible;
}

trix-toolbar .trix-button-group {
  border-color: var(--color-border);
  margin-bottom: 0;
}

/* Only there to push undo/redo to the far right of a single row, which
   leaves a stray divider once the row wraps. */
body trix-toolbar .trix-button-group-spacer {
  display: none;
}

trix-toolbar .trix-button {
  border-color: var(--color-border);
}

/* Trix offers these, but the app has no file-upload path through the editor
   and no colour/heading levels beyond one, so they are hidden rather than
   left to fail. */
trix-toolbar .trix-button--icon-attach,
trix-toolbar .trix-button-group--file-tools {
  display: none;
}

.prose-body > *:first-child { margin-top: 0; }
.prose-body > *:last-child { margin-bottom: 0; }

.prose-body h1, .prose-body h2, .prose-body h3 {
  font-family: var(--font-heading);
  margin: 18px 0 8px;
}

.prose-body h1 { font-size: 1.3rem; }
.prose-body h2 { font-size: 1.15rem; }
.prose-body h3 { font-size: 1rem; }

.prose-body ul, .prose-body ol { padding-left: 22px; margin: 10px 0; }
.prose-body li { margin-bottom: 4px; }

.prose-body blockquote {
  margin: 12px 0;
  padding-left: 12px;
  border-left: 3px solid var(--color-primary);
  color: var(--color-muted);
}

.prose-body a { color: var(--color-primary); }

.prose-body pre {
  background: var(--color-bg-subtle);
  padding: 10px 12px;
  border-radius: var(--radius);
  overflow-x: auto;
}

.prose-body--tight { font-size: 0.95rem; }

/* Image upload with crop */

.image-upload {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--color-bg-subtle);
}

.image-upload__current {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.image-upload .field-hint {
  margin-bottom: 0;
}

.image-cropper {
  margin-top: 12px;
}

/* The stage takes the aspect ratio of the picture being cropped (set from
   JS), so the whole photo is visible while choosing the part to keep. */
.image-cropper__stage {
  width: 100%;
  max-height: 60vh;
  background: var(--color-ink);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.image-cropper .form-actions {
  margin-top: 10px;
}

/* Square icon shown beside an item in the feed */

.feed-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
}

.ride-card__head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* Compact navigation chips under the meet point map */

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

.nav-chip {
  flex: 1 1 0;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  color: var(--color-ink);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-body);
  text-decoration: none;
  cursor: pointer;
}

.nav-chip svg {
  color: var(--color-primary);
}

.nav-chip:hover {
  text-decoration: none;
  border-color: var(--color-primary);
}

.nav-chip:active {
  background: var(--color-bg-subtle);
}

/* Strava route embed */

.strava-embed {
  margin-bottom: 8px;
}

.strava-embed iframe {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* Attachments */

.attachment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.attachment-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.92rem;
}

.attachment-list__item:last-child {
  border-bottom: 0;
}

.attachment-list__item svg {
  color: var(--color-muted);
  flex-shrink: 0;
}

.attachment-list__item a {
  overflow-wrap: anywhere;
}

.attachment-list--tight {
  margin-top: 8px;
  font-size: 0.85rem;
}

/* A square preview at full width dwarfs the form on a phone. */
.image-upload__current--square {
  max-width: 200px;
}

/* Collapsible maps */

.map-panel {
  margin-bottom: 12px;
}

.map-panel__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  list-style: none;
}

.map-panel__summary::-webkit-details-marker {
  display: none;
}

.map-panel__summary svg {
  color: var(--color-primary);
}

.map-panel__summary::after {
  content: '';
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--color-muted);
  border-bottom: 2px solid var(--color-muted);
  transform: rotate(45deg) translateY(-2px);
}

.map-panel[open] .map-panel__summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.map-panel[open] .map-panel__summary::after {
  transform: rotate(-135deg) translateY(-2px);
}

.map-panel[open] .map-panel__summary span::after {
  content: ' — drag to move, pinch or scroll to zoom';
  font-weight: 400;
  color: var(--color-muted);
  font-size: 0.82rem;
}

.map-panel .map-display {
  margin-bottom: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: 0;
}

/* Elevation profile */

.elevation {
  margin: 0 0 12px;
}

.elevation__plot {
  position: relative;
  cursor: crosshair;
}

.elevation__cursor,
.elevation__dot {
  visibility: hidden;
}

.elevation__cursor.is-shown,
.elevation__dot.is-shown {
  visibility: visible;
}

.elevation__cursor {
  stroke: var(--color-ink);
  stroke-width: 1;
  opacity: 0.35;
  vector-effect: non-scaling-stroke;
}

.elevation__dot {
  fill: var(--color-primary);
  stroke: var(--color-white);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.elevation__tooltip {
  position: absolute;
  top: 6px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 9px;
  border-radius: var(--radius);
  background: var(--color-ink);
  color: var(--color-white);
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
}

.elevation__tooltip strong {
  font-weight: 700;
}

.elevation__tooltip span {
  opacity: 0.85;
}

.elevation__svg {
  width: 100%;
  height: 110px;
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg-subtle);
}

.elevation__area {
  fill: rgba(251, 139, 53, 0.16);
}

.elevation__line {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.elevation__scale {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 6px;
}

/* Compact editor used for comments */

.rich-editor--compact {
  min-height: 90px;
  font-size: 0.95rem;
}

.rich-editor__toolbar--compact .trix-button-row {
  gap: 6px;
}

.rich-editor__toolbar--compact .trix-button {
  height: 1.8em;
}

.comment-form {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 20px;
}

.comment-form .field:last-of-type {
  margin-bottom: 12px;
}

.comment-form .image-upload {
  background: var(--color-white);
}

.btn-link[hidden] {
  display: none;
}

/* Section tabs (settings) */

.tab-row {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.tab-row__item {
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-row__item:hover {
  text-decoration: none;
  color: var(--color-ink);
}

.tab-row__item.is-active {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary);
}

.app-header__logo {
  height: 40px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
}

/* One logo for room, a compact one where there isn't any. */
.app-header__logo--compact {
  display: none;
}

@media (max-width: 480px) {
  .app-header__logo--wide {
    display: none;
  }

  .app-header__logo--compact {
    display: block;
    max-width: 160px;
  }
}

/* A logo keeps its own shape, so the preview must not stretch it. The
   checked backdrop shows where it is see-through. */
.image-upload__current--fit {
  width: auto;
  max-width: 100%;
  max-height: 120px;
  padding: 8px;
  border-radius: var(--radius);
  background-color: var(--color-ink);
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* Storage usage */

.usage-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
  margin: 8px 0 6px;
}

.usage-bar__fill {
  height: 100%;
  background: var(--color-primary);
}

/* Community */

.forum-category {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: inherit;
}

.forum-category:last-child {
  border-bottom: 0;
}

.forum-category:hover {
  text-decoration: none;
}

.forum-category__name {
  font-family: var(--font-heading);
  font-weight: 700;
}

.forum-category--child {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-left: 12px;
  color: var(--color-muted);
  font-size: 0.92rem;
}

.topic-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: inherit;
}

.topic-row:last-child {
  border-bottom: 0;
}

.topic-row:hover {
  text-decoration: none;
}

.topic-row--card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--color-white);
}

.topic-row__title {
  font-weight: 600;
  color: var(--color-ink);
}

.forum-post {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--color-white);
}

.forum-post__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.forum-post__author {
  font-weight: 600;
  color: var(--color-ink);
}

.forum-post__actions {
  display: flex;
  gap: 14px;
  margin-top: 10px;
}

.forum-post__history {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.profile-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 8px;
}

.card--accent {
  border-color: var(--color-primary);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

/* Ride page: each part in its own panel so the page reads in blocks
   rather than as one long column of text. */

.panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-white);
  padding: 16px;
  margin-bottom: 16px;
}

.panel--tint {
  background: var(--color-bg-subtle);
}

.panel--route {
  background: linear-gradient(180deg, #FFF7F0 0%, var(--color-white) 55%);
  border-color: #F6DCC4;
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

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

.panel__head svg {
  color: var(--color-primary);
}

.panel > *:last-child {
  margin-bottom: 0;
}

.panel .map-display,
.panel .elevation__svg {
  border-color: var(--color-border);
}

.ride-hero {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.ride-hero .header-image {
  border-radius: 0;
  margin: 0;
  width: 100%;
}

.ride-hero__body {
  padding: 16px;
}

.ride-hero__body h1 {
  margin-bottom: 6px;
}

.avatar-small {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.attendee-list__row {
  text-decoration: none;
  color: inherit;
}

.attendee-list__row:hover {
  text-decoration: none;
  color: var(--color-primary-dark);
}
