/* ------------------------------------------------------------------ */
/* Primitives (base, cards, wells, badges, inputs)                    */
/* ------------------------------------------------------------------ */

/* Base */

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

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

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--color-surface);
  color: var(--color-on-surface);
  font-family: var(--font-sans);
  font-size: 0.875rem; /* body-md */
  line-height: 1.25rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p,
figure {
  margin: 0;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

dl,
dd,
dt {
  margin: 0;
}

[hidden] {
  display: none !important;
}

input[type="submit"] {
  cursor: pointer;
  border: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Standard structural card */
.card {
  background: var(--color-surface-card);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.card--danger {
  border-left: 4px solid var(--color-accent-route);
}

/* Card cover link — stretches an invisible link over the whole card so every
   non-interactive pixel navigates to the card's detail page (BUGS item: make
   full card clickable). The card must be position:relative; interactive
   controls inside (buttons, forms, docks, menus, popovers) must be lifted
   above it with position:relative; z-index:2 to stay clickable. The link
   itself is empty, aria-hidden and untabbable — the visible title link keeps
   carrying the accessible name. */
.card-link-cover {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Recessed well for nested content and telemetry */
.well {
  background: var(--color-surface-canvas);
  border-radius: var(--radius-lg);
}

/* Micro badges / status pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: 0.125rem var(--space-xs);
  border-radius: var(--radius);
  background: var(--color-surface-canvas);
  font-size: 0.6875rem;
  line-height: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Pill variant of the micro badge (hero eyebrow) */
.badge--pill {
  padding: var(--space-2xs) var(--space-sm);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  background: var(--color-surface-card);
  box-shadow: var(--shadow-sm);
  font-size: 0.75rem;
  line-height: 1.125rem;
  margin-bottom: var(--space-xl);
}

.status-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: var(--radius-full);
  background: var(--color-track-split);
}

.status-dot--accent {
  background: var(--color-accent-route);
}

.divider {
  border: 0;
  border-top: 1px solid var(--color-surface-container);
  margin: var(--space-md) 0;
}

/* Text inputs: recessed canvas surface, borderless, ring focus */
.input {
  width: 100%;
  height: 2.5rem;
  padding-inline: var(--space-sm);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
  color: var(--color-text-primary);
  transition: box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--color-text-tertiary);
}

.input:focus,
.input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.field-label {
  display: block;
  font-size: 0.8125rem;
  line-height: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: var(--space-xs);
}
/* ------------------------------------------------------------------ */
/* Type scale (DESIGN.md §Typography)                                   */
/* ------------------------------------------------------------------ */

.t-display-lg {
  font-size: 2.5rem;
  line-height: 3rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.t-headline-lg {
  font-size: 1.875rem;
  line-height: 2.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.t-headline-md {
  font-size: 1.375rem;
  line-height: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.t-headline-sm {
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.t-title-lg {
  font-size: 1.25rem;
  line-height: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.t-title-md {
  font-size: 1rem;
  line-height: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.t-body-lg {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.005em;
}
.t-body-md {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 400;
}
.t-body-sm {
  font-size: 0.8125rem;
  line-height: 1.125rem;
  font-weight: 400;
}
.t-label-md {
  font-size: 0.8125rem;
  line-height: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.t-label-sm {
  font-size: 0.6875rem;
  line-height: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.t-code-sm {
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.t-uppercase {
  text-transform: uppercase;
}
/* ------------------------------------------------------------------ */
/* Layout shell (header/main/footer)      */
/* ------------------------------------------------------------------ */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter-mobile);
}

@media (min-width: 1024px) {
  .container {
    padding-inline: var(--gutter-desktop);
  }
}

/* Fixed frosted top bar */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-subtle);
}

.app-header__inner {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  min-width: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.brand-logo {
  height: 2.25rem;
  width: 2.25rem;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Primary nav — underlined tabs on the header baseline */
.app-nav {
  display: none;
  align-items: center;
  gap: var(--space-lg);
}

@media (min-width: 768px) {
  .app-nav {
    display: flex;
  }
}

.app-nav__link {
  display: flex;
  align-items: center;
  height: var(--nav-height);
  border-bottom: 2px solid transparent;
  font-size: 0.8125rem;
  line-height: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.app-nav__link:hover {
  color: var(--color-text-primary);
}

.app-nav__link--active {
  border-bottom-color: var(--color-primary);
}

/* Bottom navigation — thumb-reach replacement for the header nav */
.app-nav-mobile {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: grid;
  grid-auto-flow: column;
  padding: var(--space-2xs) var(--space-sm)
    calc(var(--space-2xs) + env(safe-area-inset-bottom));
  background: var(--color-surface-card);
  border-top: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-sm);
}

.app-nav-mobile__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-md);
  transition: color 0.15s ease;
}

.app-nav-mobile__link:hover {
  color: var(--color-text-primary);
}

.app-nav-mobile__link.is-active {
  color: var(--color-primary);
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Account chip — avatar pip + disclosure chevron (dropdown trigger) */
.account-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.account-chip__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  /* Transparent fill — the initials variant paints its own pip (see
     .account-avatar__initials); a photo never sits on a dark background */
  overflow: hidden;
}

.account-chip__chevron {
  transition: color 0.15s ease;
}

.account-chip:hover .account-chip__chevron {
  color: var(--color-text-primary);
}

/* Account dropdown menu (stitch_explorer_v0.2 shell update) */
.account-wrap {
  position: relative;
}

.account-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  width: 14rem;
  margin-top: var(--space-xs);
  padding: var(--space-xs);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.account-menu[hidden] {
  display: none;
}

.account-menu__header {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border-subtle);
}

.account-menu__user {
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.account-menu__items {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding-top: var(--space-xs);
}

.account-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-lg);
  font-weight: 400;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.account-menu__item:hover {
  background: var(--color-surface-canvas);
}

.account-menu__item--danger {
  font-weight: 500;
}

.account-menu__item--danger .account-menu__icon {
  color: var(--color-accent-route);
}

/* Round tonal icon buttons (theme toggle, sign out, card actions) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-canvas);
  color: var(--color-text-secondary);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.icon-btn:hover {
  background: var(--color-surface-container);
  color: var(--color-text-primary);
}

/* Main content sits below the fixed bar */
.app-main {
  flex: 1 0 auto;
  padding-top: var(--nav-height);
}

.app-main__inner {
  padding-block: var(--space-lg);
}

/* Footer */
.app-footer {
  background: var(--color-surface-card);
  border-top: 1px solid var(--color-border-subtle);
}

.app-footer__inner {
  min-height: var(--nav-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding-block: var(--space-sm);
}

@media (min-width: 640px) {
  .app-footer__inner {
    flex-direction: row;
  }
}

.app-footer__copy {
  font-size: 0.6875rem;
  line-height: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.app-footer__nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.app-footer__link {
  font-size: 0.6875rem;
  line-height: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.15s ease;
}

.app-footer__link:hover {
  color: var(--color-text-primary);
}
/* ------------------------------------------------------------------ */
/* Buttons (DESIGN.md §Components — Buttons)                            */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  height: 2.5rem;
  padding-inline: var(--space-md);
  border-radius: var(--radius-lg);
  font-size: 0.8125rem;
  line-height: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

/* Primary: solid carbon black, white label */
.btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

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

/* Secondary: raised card surface, darkens on hover */
.btn--secondary {
  background: var(--color-surface-card);
}

.btn--secondary:hover {
  background: var(--color-surface-canvas);
}

/* Ghost: transparent, quiet label */
.btn--ghost {
  background: transparent;
  box-shadow: none;
}

.btn--ghost:hover {
  background: var(--color-surface-canvas);
  color: var(--color-text-primary);
}

/* Destructive: card surface with route-accent label, soft fill on hover */
.btn--danger {
  background: var(--color-surface-card);
}

.btn--danger:hover {
  background: var(--color-accent-route-soft);
}

/* Small variant (h-8 toolbar chips) */
.btn--sm {
  height: 2rem;
  padding-inline: var(--space-sm);
  font-size: 0.6875rem;
  line-height: 0.875rem;
}

/* Disabled: quiet, non-interactive (account-page placeholders, modals) */
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Large hero CTA (ref: px-7 py-3.5 rounded-xl text-sm) */
.btn--lg {
  height: 3.25rem;
  padding-inline: 1.75rem;
  border-radius: var(--radius-xl);
  font-size: 0.875rem;
  line-height: 1.125rem;
}

/* Full-width variant (auth submit buttons) */
.btn--block {
  width: 100%;
}
/* Material Symbols (icon font loaded in the layout head) */
.material-symbols-outlined {
  font-size: 1.25rem;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
}

.ms-14 {
  font-size: 0.875rem;
}
.ms-16 {
  font-size: 1rem;
}
.ms-18 {
  font-size: 1.125rem;
}
.calendar-popover--route-card {
  position: absolute;
  top: -21rem;
  right: -10.5rem;
  z-index: 40;
  width: 18.5rem;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-md);
}

.calendar-popover {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  z-index: 40;
  width: 18.5rem;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-md);
}

.calendar-popover__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}

.calendar-popover__month {
  font-weight: 600;
}

.calendar-popover__nav {
  display: inline-flex;
  gap: var(--space-2xs);
}

.calendar-popover__nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.calendar-popover__nav-btn:hover {
  background: var(--color-surface-container);
  color: var(--color-text-primary);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
  margin-bottom: var(--space-2xs);
}

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

.calendar-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-inline: auto;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  transition: background-color 0.15s ease;
}

.calendar-day:hover {
  background: var(--color-surface-container);
}

.calendar-day--today {
  box-shadow: inset 0 0 0 1px var(--color-border-strong);
}

.calendar-day.calendar-day--selected {
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 600;
}

.calendar-day.calendar-day--selected:hover {
  background: var(--color-primary-container);
}

.calendar-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border-subtle);
}

.calendar-time__select {
  background: var(--color-surface-canvas);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.375rem 0.5rem;
  cursor: pointer;
}

.calendar-popover__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-sm);
}

.calendar-popover__link {
  background: none;
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.calendar-popover__link:hover {
  background: var(--color-surface-container);
}

.calendar-popover__done {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: var(--radius-lg);
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.calendar-popover__done:hover {
  background: var(--color-primary-container);
}

.calendar-remove-form {
  display: none;
}
/* ------------------------------------------------------------------ */
/* Card kebab menu (reuses dropdown_controller)                       */
/* ------------------------------------------------------------------ */

.card-menu {
  position: relative;
  display: inline-flex;
}

.card-menu__panel {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  z-index: 40;
  min-width: 12rem;
  padding: 0.25rem;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.card-menu__panel .button_to {
  display: flex;
}

.menu-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.menu-item:hover {
  background: var(--color-surface-canvas);
}

.menu-item.menu-item--danger {
  color: var(--color-on-error-container);
}

.menu-item.menu-item--danger:hover {
  background: var(--color-accent-route-soft);
}
/* ------------------------------------------------------------------ */
/* Modals (upload + edit dialogs)                                      */
/* ------------------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: rgba(15, 18, 25, 0.4);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    visibility 0s linear 0.2s;
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.2s ease;
}

body.has-open-modal {
  overflow: hidden;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
}

.modal__card {
  position: relative;
  width: 100%;
  max-width: 36rem;
  max-height: calc(100vh - 2 * var(--space-lg));
  overflow-y: auto;
  padding: var(--space-xl);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s ease;
}

.modal.is-open .modal__card {
  transform: translateY(0) scale(1);
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.modal__form .field {
  margin-bottom: var(--space-md);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}

@media (max-width: 480px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.input--textarea {
  height: auto;
  min-height: 5.5rem;
  padding-block: var(--space-xs);
  resize: vertical;
  line-height: 1.375rem;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

/* ------------------------------------------------------------------ */
/* Upload dropzone                                                     */
/* ------------------------------------------------------------------ */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xl) var(--space-lg);
  border-radius: var(--radius-xl);
  background: var(--color-surface-canvas);
  text-align: center;
  cursor: pointer;
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  box-shadow: var(--focus-ring);
}

.dropzone__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-card);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-xs);
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.dropzone:hover .dropzone__icon,
.dropzone.is-dragover .dropzone__icon {
  background: var(--color-text-primary);
  color: var(--color-surface-card);
}

/* Keep the input focusable but invisible */
.dropzone__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dropzone__files {
  margin-top: var(--space-sm);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ */
/* Upload modal — route prefix (v0.13, stitch_explorer_v0.13)          */
/* ------------------------------------------------------------------ */

.upload-prefix__label-row {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin: var(--space-md) 0 var(--space-xs);
}

/* The row owns the spacing; the label's default bottom margin would
   off-center the help icon vertically. */
.upload-prefix__label {
  margin-bottom: 0;
}

.upload-prefix__help {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--color-text-tertiary);
  cursor: help;
  transition: color 0.15s ease;
}

.upload-prefix__help .material-symbols-outlined {
  font-size: 1rem;
  line-height: 1;
}

.upload-prefix__help:hover,
.upload-prefix__help:focus-visible {
  color: var(--color-text-secondary);
}

/* CSS-only tooltip: hover or keyboard focus reveals the design ref's
   helper copy above the icon. */
.upload-prefix__tooltip {
  position: absolute;
  bottom: calc(100% + 0.375rem);
  left: 150%;
  transform: translate(-50%, 2px);
  z-index: 30;
  width: max-content;
  max-width: 17rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  background: var(--color-text-primary);
  color: var(--color-surface-card);
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 400;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.upload-prefix__help:hover .upload-prefix__tooltip,
.upload-prefix__help:focus-visible .upload-prefix__tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
/* ------------------------------------------------------------------ */
/* Verify-email modal (v0.12, design-refs/stitch_explorer_v0.12)        */
/* Soft: rendered in the app layout over any page, dismissable (24h    */
/* snooze cookie). Hard: locked on the standalone gate page.           */
/* ------------------------------------------------------------------ */

.modal__card--verify {
  max-width: 26rem;
  text-align: center;
}

.verify-modal__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
}

.verify-modal__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin: 0 auto var(--space-md);
  border-radius: var(--radius-full);
  background: var(--color-surface-canvas);
  color: var(--color-text-primary);
}

.verify-modal__icon .material-symbols-outlined {
  font-size: 1.375rem;
}

.verify-modal__intro {
  margin-top: var(--space-xs);
}

.verify-modal__address {
  overflow-wrap: anywhere;
  margin-bottom: var(--space-md);
}

.verify-modal__flash {
  margin-bottom: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-lg);
  text-align: left;
}

.verify-modal__flash--alert {
  background: var(--color-accent-route-soft);
  color: var(--color-on-error-container);
}

.verify-modal__flash--notice {
  background: var(--color-surface-canvas);
}

.verify-modal__digits {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.verify-modal__digit {
  width: 2.75rem;
  height: 3.25rem;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
  font-size: 1.125rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.verify-modal__digit:focus {
  border-color: var(--color-border-strong);
  box-shadow: var(--focus-ring);
}

.verify-modal__submit {
  width: 100%;
  margin-bottom: var(--space-md);
}

.verify-modal__resend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  margin-bottom: var(--space-md);
}

.verify-modal__resend-form {
  display: inline-flex;
}

.verify-modal__resend-btn {
  color: var(--color-text-primary);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.verify-modal__resend-btn[disabled],
.verify-modal__resend-btn:disabled {
  color: var(--color-text-tertiary);
  text-decoration: none;
  cursor: not-allowed;
}

.verify-modal__links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.verify-modal__link {
  color: var(--color-text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.verify-modal__link:hover {
  color: var(--color-text-primary);
}

.verify-modal__email-form {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.verify-modal__email-input {
  flex: 1;
  text-align: left;
}

.verify-modal__info {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  padding: var(--space-sm);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
  text-align: left;
}

.verify-modal__info .material-symbols-outlined {
  flex: none;
  font-size: 1.125rem;
  color: var(--color-text-tertiary);
}

/* Bare host page behind the hard gate (verification_gate layout) */
.gate {
  min-height: 100dvh;
}

.gate-body {
  background: var(--color-surface-container);
}

/* Sign out stays reachable below the locked gate card */
.gate__signout {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 61; /* above the .modal overlay (60) */
}

.gate__signout-form {
  display: inline-flex;
}

.gate__signout-btn {
  color: var(--color-text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gate__signout-btn:hover {
  color: var(--color-text-primary);
}
/* ------------------------------------------------------------------ */
/* Empty states                                                       */
/* ------------------------------------------------------------------ */

.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding-block: var(--space-3xl);
  text-align: center;
}

.library-empty[hidden] {
  display: none !important;
}

.library-empty__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-canvas);
  margin-bottom: var(--space-2xs);
}

.library-empty p {
  max-width: 26rem;
}
/* ------------------------------------------------------------------ */
/* Flash messages (status pills)                                        */
/* ------------------------------------------------------------------ */

.flash {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.flash--notice {
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
}

.flash--notice::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--color-track-split);
  flex-shrink: 0;
}

.flash--alert {
  background: var(--color-accent-route-soft);
  color: var(--color-on-error-container);
}
/* Completion celebration (design-refs/stitch_explorer_v0.11): marking a
 * calendar entry completed bounces the fresh card, pops the check and fires a
 * confetti burst. Keyframes/classes are driven by the completion-confetti
 * Stimulus controller; the canvas it paints into lives above every overlay. */

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 70; /* above the upload modal (60) — the burst overlays everything */
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes celebration-card-bounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.04); }
  65% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

@keyframes celebration-check-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.celebration-bounce {
  animation: celebration-card-bounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.celebration-check-pop {
  animation: celebration-check-pop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
/* Content color helpers */
.c-primary {
  color: var(--color-text-primary);
}
.c-secondary {
  color: var(--color-text-secondary);
}
.c-tertiary {
  color: var(--color-text-tertiary);
}
.c-accent {
  color: var(--color-accent-route);
}
.c-success {
  color: var(--color-track-split);
}
.c-elevation {
  color: var(--color-track-elevation);
}
/* ------------------------------------------------------------------ */
/* Account settings page (Phase 12; Phase 9 shipped the share card)     */
/* Ref: design-refs/stitch_explorer_v0.9/stitch_explorer/my_account     */
/* ------------------------------------------------------------------ */

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

.account__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

/* Section cards (moved from layout.css with the Phase 9 page) */
.account__card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  /* Anchor targets for the sidebar nav; keep clears of the fixed header */
  scroll-margin-top: calc(var(--nav-height) + var(--space-md));
}

.account__section-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border-subtle);
}

.account__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.account__head h1 {
  margin: 0;
}

.account__head p {
  margin: 0;
}

/* Desktop split: sticky mini profile + section nav. Below 1024px the
   sidebar is hidden entirely — a single scroll with section headers reads
   better on mobile (user's chosen adaptation). */
.account__sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .account {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--space-xl);
  }

  .account__sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    flex: 0 0 16rem;
    position: sticky;
    top: calc(var(--nav-height) + var(--space-lg));
  }

  .account__content {
    flex: 1 1 auto;
    gap: var(--space-xl);
  }
}

/* Sidebar mini profile card */
.account__user-card {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.account__user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.account__user-meta p {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Sidebar section nav */
.account__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-xs);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.account__nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.625rem var(--space-sm);
  border-radius: var(--radius-lg);
  font-size: 0.8125rem;
  line-height: 1rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.account__nav-link:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-canvas);
}

/* Avatar (Phase 12) — round wrapper + helper-provided content. Shared by the
   header chip, the calendar pips and the account page. The wrapper stays
   TRANSPARENT: a photo must never sit on the dark pip colour (sub-pixel
   seams or transparent image corners would read as a black ring). Only the
   initials variant paints the fill. */
.account-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.account-avatar--md {
  width: 3rem;
  height: 3rem;
}

.account-avatar--lg {
  width: 6rem;
  height: 6rem;
}

.account-avatar__initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 600;
}

.account-avatar--md .account-avatar__initials {
  font-size: 0.8125rem;
  line-height: 1rem;
}

.account-avatar--lg .account-avatar__initials {
  font-size: 1.5rem;
  line-height: 2rem;
  letter-spacing: -0.01em;
}

/* No variants (image_processing is out of the Gemfile): the wrapper crops
   instead. The image itself gets NO border-radius — it must fill the square
   so the wrapper's dark background can never bleed through as a ring; the
   wrapper's radius + overflow: hidden does the rounding. */
.account-avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.account-chip__avatar .account-avatar__initials {
  font-size: 0.75rem;
  line-height: 1rem;
}

/* Avatar well inside the profile card */
.account__avatar-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface-canvas);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
}

@media (min-width: 640px) {
  .account__avatar-block {
    flex-direction: row;
    align-items: center;
    justify-content: start;
    gap: var(--space-xl);
  }
}

.account__avatar-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.account__avatar-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* The mini-forms (avatar change / remove) sit inline in the button row */
.account__avatar-form {
  display: inline-flex;
  margin: 0;
}

/* Visually hidden file input: the styled label is the button */
.account__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.account__avatar-hint {
  margin: 0;
}

/* Profile / password forms */
.account__form {
  display: flex;
  flex-direction: column;
}

.account__form .form-errors {
  margin-bottom: var(--space-md);
}

.account__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

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

/* Password row spans three columns on wide screens (ref: md:grid-cols-3) */
@media (min-width: 768px) {
  .account__grid--password {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.account__field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* field-label ships a bottom margin; the flex gap above replaces it */
.account__field .field-label {
  margin-bottom: 0;
}

.account__field-hint {
  margin: 0;
}

.account__form-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-md);
}

/* Inline prefix (@username) and suffix (Verified) decorations */
.account__input-wrap {
  position: relative;
  display: flex;
}

.account__input-stamp {
  position: absolute;
  top: 50%;
  left: var(--space-sm);
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.account__input--stamped {
  padding-left: 2rem;
}

.account__input--badged {
  padding-right: 5.5rem;
}

.account__verified {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-size: 0.6875rem;
  line-height: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-track-split);
  white-space: nowrap;
}

/* Share toggle — iOS-style switch around the (visually hidden) checkbox
   (moved from layout.css with the Phase 9 page) */
.account__toggle-form {
  margin: 0;
}

.account__switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.account__switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.account__switch-track {
  position: relative;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  background: var(--color-surface-container-high);
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.account__switch-thumb {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-card);
  box-shadow: var(--shadow-sm);
  transform: translateY(-50%);
  transition: left 0.15s ease;
}

.account__switch-input:checked + .account__switch-track {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.account__switch-input:checked + .account__switch-track .account__switch-thumb {
  left: calc(100% - 1.1875rem);
  background: #fff;
}

.account__switch-input:focus-visible + .account__switch-track {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.account__share {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border-subtle);
}

.account__share-row {
  display: flex;
  gap: var(--space-2xs);
}

.account__share-row .input {
  flex: 1;
  min-width: 0;
  color: var(--color-text-secondary);
}

/* Connected accounts (Phase 12): real Drive state, honest placeholders */
.account__connected {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.account__connected-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-surface-canvas);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
}

@media (min-width: 768px) {
  .account__connected-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.account__connected-main {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.account__connected-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-lg);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-sm);
}

.account__connected-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.account__connected-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2xs);
}

.account__connected-title h3 {
  margin: 0;
}

.account__connected-meta p {
  margin: 0;
}

.account__connected-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

@media (max-width: 767px) {
  .account__connected-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Status pills: live (green) vs muted placeholder states */
.account__pill {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  line-height: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.account__pill--live {
  background: rgba(16, 185, 129, 0.12);
  color: var(--color-track-split);
}

.account__pill--muted {
  background: var(--color-surface-container);
  color: var(--color-text-secondary);
}

/* Danger zone (ref: card--danger primitive — left route-accent border) */
.account__card--danger {
  border-left: 4px solid var(--color-accent-route);
}

.account__danger-title {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.account__danger-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface-canvas);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
}

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

.account__danger-row h3 {
  margin: 0 0 0.25rem;
}

.account__danger-row p {
  margin: 0;
}

/* Delete confirmation dialog */
.account__modal {
  max-width: 28rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.account__modal-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
}

.account__modal-head p {
  margin: 0.25rem 0 0;
}

.account__modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-full);
  background: var(--color-accent-route-soft);
  color: var(--color-accent-route);
}

.account__modal-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  background: var(--color-surface-canvas);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  color: var(--color-accent-route);
}

.account__modal-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: 0;
}

.account__modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}
/* ------------------------------------------------------------------ */
/* Auth pages (devise/sessions + devise/registrations — sign_in /     */
/* sign_up)                                                           */
/* ------------------------------------------------------------------ */

/* Centered column for the auth card; 500px = sign-up ref width */
.auth {
  width: 100%;
  max-width: 31.25rem;
  margin-inline: auto;
  padding-block: var(--space-xl);
}

.auth-card {
  background: var(--color-surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-card__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
}

.auth-card__logo {
  width: 5rem;
  height: 5rem;
  margin-bottom: var(--space-md);
}

.auth-card__title {
  margin: 0 0 var(--space-sm);
  font-size: 1.375rem; /* 22px per auth refs */
  line-height: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
}

.auth-card__lede {
  margin: 0 0 var(--space-lg);
  font-size: 0.875rem;
  line-height: 1.25rem;
  text-align: center;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-field__aside {
  font-size: 0.8125rem;
  line-height: 1rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.auth-field__aside:hover {
  color: var(--color-text-primary);
}

.auth-field__hint {
  margin: var(--space-2xs) 0 0;
  font-size: 0.75rem;
  line-height: 1rem;
}

/* First/Last name pair */
.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

@media (max-width: 420px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }
}

/* Card footer strip with the cross-link between sign-in and sign-up */
.auth-card__footer {
  padding: var(--space-sm) var(--space-xl);
  background: var(--color-surface-container-low);
  border-top: 1px solid var(--color-border-subtle);
  text-align: center;
}

.auth-card__footer-text {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.25rem;
}

.auth-card__footer-link {
  margin-left: var(--space-2xs);
  font-weight: 600;
  transition: color 0.15s ease;
}

.auth-card__footer-link:hover {
  color: var(--color-primary-container);
}

/* Inline validation summary above the form fields */
.form-errors {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-lg);
  background: var(--color-accent-route-soft);
  color: var(--color-on-error-container);
}

.form-errors__title {
  margin: 0 0 var(--space-2xs);
  font-size: 0.8125rem;
  line-height: 1.125rem;
  font-weight: 600;
}

.form-errors__list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.8125rem;
  line-height: 1.125rem;
}
/* ------------------------------------------------------------------ */
/* Phase 7 — Weekly training calendar (.wc-*)                         */
/* Sidebar route pool + 7 Monday-start day columns over a telemetry   */
/* bar. Reuses the token system above;                                */
/* ------------------------------------------------------------------ */

.mob-wc,
.app-nav-mobile,
.mob-sheet {
  display: none;
}

.wc {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Breadcrumb + friend-view badge */
.wc__breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.wc__breadcrumb-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  transition: color 0.15s ease;
}

.wc__breadcrumb-link:hover {
  color: var(--color-text-primary);
}

.wc__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: 0.125rem var(--space-xs);
  border-radius: var(--radius-full);
  background: var(--color-surface-container-low);
}

/* Header row: heading left, profile chip right */
.wc__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border-subtle);
}

.wc__profile {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.wc__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  /* Transparent fill — the initials variant paints its own pip (see
     .account-avatar__initials); a photo never sits on a dark background */
  overflow: hidden;
}

.wc__profile-id p {
  margin: 0;
}

/* Toolbar */
.wc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.wc-toolbar__nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.wc-toolbar__nav-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-lg);
  transition:
    color 0.15s ease,
    background 0.15s ease;
}

.wc-toolbar__nav-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-container-low);
}

.wc-toolbar__divider {
  width: 1px;
  height: 1.25rem;
  background: var(--color-border-subtle);
}

.wc-toolbar__range {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-2xs) var(--space-md);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.wc-toolbar__today {
  margin-left: var(--space-2xs);
  padding: 0.125rem var(--space-xs);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
}

/* Layout: sidebar + day grid */
.wc__layout {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  gap: var(--space-lg);
  align-items: start;
}

.wc__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

.wc__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space-xs);
}

/* Sidebar route pool */
.wc-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + var(--space-lg));
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.wc-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.wc-sidebar__title {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.wc-sidebar__glyph {
  font-size: 1.25rem;
}

.wc-sidebar__search {
  position: relative;
}

.wc-sidebar__search-icon {
  position: absolute;
  top: 50%;
  left: var(--space-xs);
  transform: translateY(-50%);
  pointer-events: none;
}

.wc-sidebar__search .input {
  height: 2.25rem;
  padding-left: 2.25rem;
}

.wc-sidebar__pool {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: 34rem;
  overflow-y: auto;
  padding: 2px; /* keep the drag-over outline inside the scroll box */
  /* Hide scrollbar */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/old Edge */
}

.wc-sidebar__pool::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

.wc-sidebar__pool--drag-over {
  border-radius: var(--radius-lg);
  outline: 2px dashed var(--color-track-split);
  outline-offset: -2px;
}

.wc-sidebar__empty,
.wc-sidebar__no-match {
  margin: 0;
  padding: var(--space-md);
  text-align: center;
  background: var(--color-surface-canvas);
  border: 1px dashed var(--color-border-subtle);
  border-radius: var(--radius-lg);
}

.wc-sidebar__hint {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2xs);
  margin: 0;
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-surface-container-low);
  border-radius: var(--radius-lg);
}

.wc-sidebar__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: var(--space-xs);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  transition: background 0.15s ease;
}

.wc-sidebar__cta:hover {
  background: var(--color-surface-container-low);
}

/* Sidebar route cards (drag pool / friend week list) */
.wc-route-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-sm);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  cursor: grab;
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease;
  margin-bottom: var(--space-xs);
  box-shadow: var(--shadow-sm);
}

.wc-route-card:last-child {
  margin-bottom: 0;
}

.wc-route-card:hover {
  box-shadow: var(--shadow-md);
}

/* The sidebar filter hides cards with [hidden]; keep it winning. */
.wc-route-card[hidden] {
  display: none;
}

.wc-route-card.is-dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.wc-route-card--friend {
  cursor: default;
}

.wc-route-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2xs);
}

.wc-route-card__title {
  margin: 0;
  min-width: 0;
}

.wc-route-card__link:hover {
  text-decoration: underline;
}

.wc-route-card__tier {
  align-self: flex-start;
}

.wc-gpx-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  flex-shrink: 0;
  padding: 0.125rem var(--space-xs);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: color 0.15s ease;
}

.wc-gpx-btn:hover {
  color: var(--color-text-primary);
}

.wc-route-card__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  overflow: hidden;
  background: var(--color-surface-canvas);
  border-radius: var(--radius-md);
}

.wc-route-card__route-map {
  display: block;
  width: 100%;
  height: 3.5rem;
  object-fit: cover;
}

.wc-route-card__thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
}

.wc-route-card__metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: 0.25rem;
  gap: var(--space-2xs);
}

.wc-route-card__metric {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
}

/* Day columns */
.wc-day {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-height: 21rem;
  padding: var(--space-sm);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.wc-day--today {
  border: 2px dashed var(--color-accent-route);
  box-shadow: var(--shadow-lg);
}

.wc-day--drag-over {
  border-color: var(--color-track-split);
  outline: 1px solid var(--color-track-split);
}

.wc-day__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2xs);
  border-bottom: 1px solid var(--color-border-subtle);
}

.wc-day__dow {
  display: flex;
  flex-direction: column;
  align-items: baseline;
  padding-bottom: var(--space-xs);
}

.wc-day__dow .t-label-lg {
  font-weight: 600;
}

.wc-day__km {
  padding: 0.125rem var(--space-2xs);
  border-radius: var(--radius-full);
  background: var(--color-surface-canvas);
  white-space: nowrap;
}

.wc-day__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-xs);
}

.wc-day__empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-height: 6.5rem;
  padding: var(--space-sm);
  border: 2px dashed var(--color-border-subtle);
  border-radius: var(--radius-lg);
  text-align: center;
}

/* Scheduled entries */
.wc-entry {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
}

.wc-entry--completed {
  background: var(--color-surface-container-low);
  opacity: 0.8;
}

.wc-entry--completed .wc-entry__link {
  text-decoration: line-through;
}

/* Lift the hovered card above its neighbours so the floating action dock can
   overhang into the column padding without being clipped or covered */
.wc-entry:hover,
.wc-entry:focus-within,
.wc-entry:has(.wc-popover:not([hidden])) {
  z-index: 4;
}

/* Row 1 — my view: completed checkbox, truncated title, hover X (unschedule);
   friend view: title + join popover / joined badge. */
.wc-entry__top {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

/* Interactive rows lifted above the card cover link (see primitives.css):
   the completed checkbox, the title link and the time editor stay clickable */
.wc-entry__top,
.wc-entry__editor,
button.wc-entry__slot {
  position: relative;
  z-index: 2;
}

.wc-entry__check-form {
  display: inline-flex;
  flex-shrink: 0;
}

.wc-entry__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-canvas);
  color: var(--color-on-primary);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.wc-entry__check .material-symbols-outlined {
  opacity: 0;
}

.wc-entry__check:hover {
  border-color: var(--color-track-split);
}

.wc-entry--completed .wc-entry__check {
  background: var(--color-track-split);
  border-color: var(--color-track-split);
}

.wc-entry--completed .wc-entry__check .material-symbols-outlined {
  opacity: 1;
}

.wc-entry__title {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.wc-entry__link {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wc-entry__link:hover {
  text-decoration: underline;
}

/* Action dock — floats over the card's bottom edge, outside the content
   flow; revealed on card hover, keyboard focus or an open popover */
.wc-entry__dock {
  position: absolute;
  bottom: -20%;
  left: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 50%);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.15s ease,
    visibility 0.15s ease;
}

.wc-entry:hover .wc-entry__dock,
.wc-entry:focus-within .wc-entry__dock,
.wc-entry:has(.wc-popover:not([hidden])) .wc-entry__dock {
  opacity: 1;
  visibility: visible;
}

/* Touch devices have no hover — keep the dock reachable */
@media (hover: none) {
  .wc-entry__dock {
    opacity: 1;
    visibility: visible;
  }
}

/* Unschedule X */
.wc-entry__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.wc-entry__remove:hover {
  background: var(--color-accent-route-soft);
  color: var(--color-on-error-container);
}

/* Row 2 — stats: the value carries the color, the unit stays muted */
.wc-entry__metrics {
  display: flex;
  /* flex-wrap: wrap; */
  gap: var(--space-2xs) var(--space-xs);
  justify-content: space-between;
}

.wc-entry__metric {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  white-space: nowrap;
}

.wc-entry__unit {
  font-weight: 400;
}

/* Row 3 — start time; a button (my view) that opens the inline editor */
.wc-entry__slot {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  align-self: flex-start;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}

button.wc-entry__slot {
  cursor: pointer;
}

button.wc-entry__slot:hover {
  color: var(--color-text-primary);
}

.wc-entry__joined-note {
  margin: 0;
}

.wc-entry__editor {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.wc-entry__editor .input {
  height: 2rem;
  flex: 1;
  min-width: 0;
}

/* Join popover (friend view) */
.wc-join {
  position: relative;
  flex-shrink: 0;
}

.wc-join__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-xs);
  border-radius: var(--radius-full);
  transition: background 0.15s ease;
}

.wc-join__btn:hover {
  background: var(--color-surface-container-low);
}

/* Joined state: inert status button — no pointer affordance, no hover flash */
.wc-join__btn:disabled {
  cursor: default;
}

.wc-join__btn:disabled:hover {
  background: transparent;
}

.wc-join__btn--public:hover {
  background: var(--color-surface-container-low);
}

.wc-popover {
  position: absolute;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  width: 17rem;
  padding: var(--space-sm);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.wc-popover[hidden] {
  display: none;
}

.wc-popover p {
  margin: 0;
}

.wc-popover__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.wc-popover__head {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.wc-popover__title {
  margin: 0;
}

.wc-popover__stats {
  display: flex;
  align-items: center;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-surface-container-low);
  border-radius: var(--radius-md);
}

.wc-popover__stat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  flex: 1;
}

.wc-popover__stat + .wc-popover__stat {
  border-left: 1px solid var(--color-border-subtle);
}

.wc-popover__riders {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin: 0;
}

.wc-popover__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-on-primary);
}

/* Docked at the card bottom — the popover opens upward instead */
.wc-entry__dock .wc-popover {
  top: auto;
  bottom: calc(100% + 0.5rem);
  right: -160%;
}

.wc-popover__close {
  margin-left: auto;
}

.wc-popover__cta {
  width: 100%;
  justify-content: center;
  margin-top: var(--space-2xs);
}

/* Telemetry bar */
.wc-telemetry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md) var(--space-xl);
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.wc-telemetry__glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-canvas);
}

.wc-telemetry__stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.wc-telemetry__sep {
  width: 1px;
  height: 2rem;
  background: var(--color-border-subtle);
}

/* Phase 9 — "Share calendar" on my public calendar's telemetry bar */
.wc-share-btn {
  display: inline-flex;
  margin-left: auto;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface-canvas);
  transition: background 0.15s ease;
}

.wc-share-btn:hover {
  background: var(--color-surface-container-low);
}

/* Transport forms are filled and submitted by Stimulus; never visible. */
.wc-transport-form {
  display: none;
}

/* Responsive: stack the sidebar above the grid; days fold to 2 / 1 cols. */
@media (max-width: 1100px) {
  .wc__layout {
    grid-template-columns: 1fr;
  }

  .wc-sidebar {
    position: static;
  }

  .wc-sidebar__pool {
    max-height: none;
  }

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

@media (max-width: 640px) {
  .wc__grid {
    grid-template-columns: 1fr;
  }

  .wc-day {
    min-height: auto;
  }

  .wc-popover {
    width: min(17rem, 80vw);
  }
}
/* Friends page (Phase 11) — pending requests, rich week cards and the
   Find friends popup. Shares the library hero / empty-state primitives. */
.friends {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.friends__hero-actions {
  margin-bottom: var(--space-lg);
}

.friends__riding-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-bottom: 0;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Toolbar: search + riding filter (client-side via friends-filter)    */
/* ------------------------------------------------------------------ */

.friends__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: calc(-1 * var(--space-md));
  padding: var(--space-sm);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.friends__search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 18rem;
}

.friends__search-icon {
  position: absolute;
  top: 50%;
  left: 0.625rem;
  transform: translateY(-45%);
  pointer-events: none;
}

.friends__search-input {
  width: 100%;
  height: 2.5rem;
  padding-inline: 2.25rem var(--space-sm);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
  color: var(--color-text-primary);
}

.friends__search-input::placeholder {
  color: var(--color-text-tertiary);
}

.friends__search-input:focus,
.friends__search-input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.friends__filter {
  height: 2.5rem;
  margin-left: auto;
  padding-inline: var(--space-sm);
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
}

.friends__filter-select {
  height: 100%;
  background: transparent;
  color: inherit;
  border: 0;
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Pending requests                                                    */
/* ------------------------------------------------------------------ */

.friends__requests {
  padding: var(--space-lg);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.friends__requests-head {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.friends__requests-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  padding: 0 0.375rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-canvas);
}

.friends__requests-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}

@media (min-width: 640px) {
  .friends__requests-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.friends__request {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-canvas);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.friends__request-who {
  flex: 1;
  min-width: 0;
}

.friends__request-who h3,
.friends__request-who p {
  margin: 0;
}

.friends__request-actions {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-2xs);
}

/* ------------------------------------------------------------------ */
/* Friend cards                                                        */
/* ------------------------------------------------------------------ */

.friends__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: var(--space-md);
  margin: 0;
  padding: 0;
}

.friends__card {
  position: relative; /* anchors the card cover link (see primitives.css) */
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.friends__card:hover {
  box-shadow: var(--shadow-md);
  z-index: 1;
}

.friends__card.is-hidden,
.friends-find__row.is-hidden {
  display: none;
}

/* Lifted above the card cover link so the View calendar button stays
   clickable (see primitives.css) */
.friends__card-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.friends__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-full);
  color: var(--color-on-primary);
  overflow: hidden;
}

.friends__avatar--sm {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.875rem;
}

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

.friends__id h2,
.friends__id p {
  margin: 0;
}

/* Last completed ride block ---------------------------------------- */

.friends__ride {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.friends__ride-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.friends__ride-label > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
}

.friends__ride-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The card cover link owns most of the card's hover area, so the title
   highlight fires from anywhere on the card, not just the title itself. */
.friends__ride-title a:hover,
.friends__card:hover .friends__ride-title a {
  color: var(--color-accent-route);
}

.friends__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
}

/* metrics and thumb block */

.friends__entry-metrics-n-thumb {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.friends__entry-metrics {
  display: grid;
  justify-content: space-around;
  gap: var(--space-xs);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: var(--space-xs);
  border-radius: var(--radius-xl);
  background-color: var(--color-surface-canvas);
}

.friends__metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
}

.friends__metric-value {
  font-weight: 600;
}

.friends__unit {
  font-weight: 500;
}

.friends__route-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 5.5rem;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-surface-container);
}

.friends__route-map {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Empty card variant (athlete without completed rides) --------------- */

.friends .status-dot--muted {
  background: var(--color-surface-container);
}

.friends__empty-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2xs);
  padding: var(--space-md);
  background: var(--color-surface-canvas);
  border-radius: var(--radius-lg);
}

.friends__empty-panel p {
  margin: 0;
}

.friends__empty-icon {
  display: inline-flex;
}

/* Card footer -------------------------------------------------------- */

.friends__card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  margin-top: auto;
}

.friends__card-foot > span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
}

.friends__more {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  text-decoration: none;
}

/* ------------------------------------------------------------------ */
/* Find friends popup                                                  */
/* ------------------------------------------------------------------ */

.modal__card--find-friends {
  max-width: 34rem;
}

.friends-find__search {
  margin-bottom: var(--space-md);
}

.friends-find__results {
  display: flex;
  flex-direction: column;
  max-height: 24rem;
  gap: var(--space-2xs);
  overflow-y: auto;
}

.friends-find__row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs);
  border-radius: var(--radius-lg);
}

.friends-find__row:hover {
  background: var(--color-surface-canvas);
}

.friends-find__who {
  flex: 1;
  min-width: 0;
}

.friends-find__who h3,
.friends-find__who p {
  margin: 0;
}

.friends-find__state {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  white-space: nowrap;
}

.friends-find__empty {
  margin: var(--space-sm) 0 0;
  text-align: center;
}

/* Resting state before the first qualifying query (min 3 characters). */
.friends-find__prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-lg) var(--space-sm);
  text-align: center;
}

.friends-find__prompt h3,
.friends-find__prompt p {
  margin: 0;
}

.friends-find__prompt-icon {
  font-size: 2rem;
}

/* Between request and frame load. */
.friends-find__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  margin: var(--space-sm) 0 0;
}

.friends-find__loading .material-symbols-outlined {
  animation: friends-find-spin 0.9s linear infinite;
}

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

/* Result cap note under the last row. */
.friends-find__more {
  margin: var(--space-2xs) 0 0;
  text-align: center;
}
/* ------------------------------------------------------------------ */
/* Landing page (pages/landing)                                       */
/* ------------------------------------------------------------------ */

/* Centered hero column (ref max-w-3xl) inside the app shell main */
.landing {
  max-width: 48rem;
  margin-inline: auto;
  padding-block: var(--space-2xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

@media (min-width: 768px) {
  .landing {
    padding-block: 6rem;
  }
}

/* Ref hero is text-4xl→6xl bold; Inter is loaded at 400–600, so weight 600
   with tightened tracking stands in for the synthetic bold */
.landing__title {
  font-size: 2.25rem;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: var(--space-lg);
}

@media (min-width: 640px) {
  .landing__title {
    font-size: 3rem;
  }
}

@media (min-width: 768px) {
  .landing__title {
    font-size: 3.75rem;
  }
}

.landing__lede {
  max-width: 36rem;
  font-size: 1.125rem;
  line-height: 1.75rem;
  margin: 0 auto var(--space-xl);
}

@media (min-width: 768px) {
  .landing__lede {
    font-size: 1.25rem;
  }
}

.landing__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-md);
  width: 100%;
  max-width: 21rem;
  margin-inline: auto;
}

.landing__actions .btn {
  width: 100%;
}

@media (min-width: 640px) {
  .landing__actions {
    flex-direction: row;
    justify-content: center;
    width: auto;
    max-width: none;
  }

  .landing__actions .btn {
    width: auto;
  }
}

.landing__features {
  width: 100%;
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
  border-top: 1px solid var(--color-border-subtle);
  display: grid;
  gap: var(--space-lg);
  text-align: left;
}

@media (min-width: 640px) {
  .landing__features {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.landing-card {
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.landing-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
  margin-bottom: var(--space-sm);
}

.landing-card__title {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-2xs);
}

.landing-card__text {
  font-size: 0.75rem;
  line-height: 1.125rem;
}
/* ------------------------------------------------------------------ */
/* Phase 8 — Mobile weekly calendar (.mob-wc / .mob-sheet / .app-nav-*) */
/* calendars#show renders the desktop .wc grid AND the .mob-wc layout;  */
/* CSS swaps the two at 768px (technote Phase 8). Sheets reuse the      */
/* detail page's .calendar-* grid classes; buttons/inputs reuse the     */
/* shared .btn/.input ramp. Above 768px nothing here applies.           */
/* ------------------------------------------------------------------ */

@media (max-width: 768px) {
  /* Layout swap: the desktop week view and the header nav step aside. */
  .app-nav,
  .wc,
  .app-footer {
    display: none;
  }

  .app-nav-mobile {
    display: grid;
  }

  .app-main {
    padding-bottom: calc(3rem + env(safe-area-inset-bottom));
  }

  .mob-wc {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
  }

  /* Page header + owner avatar */
  .mob-wc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
  }

  .mob-wc__subtitle {
    margin-top: var(--space-2xs);
  }

  .mob-wc__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    font-weight: 600;
    /* Transparent fill — the initials variant paints its own pip (see
       .account-avatar__initials); a photo never sits on a background */
    overflow: hidden;
  }

  .mob-wc__avatar .account-avatar__initials {
    background: var(--color-surface-container-high);
    color: var(--color-primary);
  }

  /* Phase 9 — native-share icon on my public calendar's mobile header */
  .mob-wc__share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-full);
    background: var(--color-surface-card);
  }

  /* KPI tiles (mobile mirror of .wc-telemetry) */
  .mob-wc__kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-xs);
  }

  .mob-wc__kpi {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    padding: var(--space-sm);
    background: var(--color-surface-card);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
  }

  .mob-wc__kpi-value {
    font-size: 1.125rem;
    font-weight: 600;
    white-space: nowrap;
  }

  .mob-wc__kpi-value .c-secondary {
    font-weight: 500;
  }

  /* Week stepper */
  .mob-wc__weeknav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
  }

  .mob-wc__weeknav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-full);
    background: var(--color-surface-card);
    transition: background-color 0.15s ease;
  }

  .mob-wc__weeknav-btn:hover {
    background: var(--color-surface-container);
  }

  .mob-wc__weeknav-label {
    font-weight: 600;
    text-align: center;
  }

  /* Day strip — horizontally swipeable, one pill per weekday */
  .mob-wc__strip {
    display: grid;
    grid-auto-flow: column;
    gap: var(--space-xs);
    overflow-x: auto;
    padding-bottom: var(--space-2xs);
    scrollbar-width: none;
  }

  .mob-wc__strip::-webkit-scrollbar {
    display: none;
  }

  .mob-wc__pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 3.75rem;
    padding: var(--space-xs) var(--space-2xs);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
    background: var(--color-surface-card);
    box-shadow: var(--shadow-sm);
    transition:
      background-color 0.15s ease,
      border-color 0.15s ease;
  }

  .mob-wc__pill-num {
    font-size: 1.125rem;
    font-weight: 600;
  }

  .mob-wc__pill.is-today {
    border-color: var(--color-border-strong);
  }

  .mob-wc__pill.is-selected {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
  }

  .mob-wc__pill.is-selected .mob-wc__pill-km {
    color: var(--color-on-primary);
    opacity: 0.75;
  }

  /* Day panels — one per weekday; .is-selected is the visible one */
  .mob-wc__schedule {
    display: flex;
    flex-direction: column;
  }

  .mob-wc__panel {
    display: none;
    flex-direction: column;
    gap: var(--space-md);
  }

  .mob-wc__panel.is-selected {
    display: flex;
  }

  .mob-wc__panel-date {
    margin-top: 0.25rem;
  }

  /* Rest-day empty state */
  .mob-wc__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: var(--space-lg) var(--space-md);
    text-align: center;
    background: var(--color-surface-card);
    border: 2px dashed var(--color-border-strong);
    border-radius: var(--radius-xl);
  }

  .mob-wc__empty-icon {
    font-size: 1.75rem;
  }

  /* Scheduled entry card (Friends-card style) */
  .mob-wc__entry {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--color-surface-card);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
  }

  .mob-wc__entry--completed {
    opacity: 0.75;
  }

  .mob-wc__entry--completed .mob-wc__entry-title {
    text-decoration: line-through;
    text-decoration-color: var(--color-text-tertiary);
  }

  .mob-wc__entry-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
  }

  /* Lifted above the card cover link so the check toggle, Join and Remove
     controls stay clickable (see primitives.css) */
  .mob-wc__entry-header {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
  }

  .mob-wc__entry-badges {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-xs);
  }

  .mob-wc__entry-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border: 1.5px solid var(--color-border-strong);
    border-radius: var(--radius-full);
    background: transparent;
    transition:
      background-color 0.15s ease,
      border-color 0.15s ease,
      color 0.15s ease;
  }

  .mob-wc__entry:hover .mob-wc__entry-check {
    border-color: var(--color-primary);
  }

  .mob-wc__entry--completed .mob-wc__entry-check {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
  }

  .mob-wc__entry-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--color-surface-container-high);
  }

  .mob-wc__entry-link {
    color: inherit;
  }

  /* The card cover link owns most of the card's hover area, so the title
     highlight fires from anywhere on the card, not just the title itself. */
  .mob-wc__entry-link:hover,
  .mob-wc__entry:hover .mob-wc__entry-link {
    color: var(--color-primary);
  }

  .mob-wc__entry-time {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
  }

  .mob-wc__entry-metrics-n-thumb {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .mob-wc__entry-metrics {
    display: grid;
    justify-content: space-around;
    gap: var(--space-xs);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: var(--space-xs);
    border-radius: var(--radius-xl);
    background-color: var(--color-surface-canvas);
  }

  .mob-wc__metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 0;
  }

  .mob-wc__metric-value {
    font-weight: 600;
  }

  .mob-wc__unit {
    font-weight: 500;
  }

  .mob-wc__entry-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-xs);
  }

  .mob-wc__entry-btn {
    flex: none;
  }

  .mob-wc__entry-joined {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
  }

  /* Multi-entry day: swipe slider with dot navigation */
  .mob-wc__slider {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
  }

  .mob-wc__slider-track {
    display: flex;
    gap: var(--space-xs);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .mob-wc__slider-track::-webkit-scrollbar {
    display: none;
  }

  .mob-wc__slider-slide {
    display: flex;
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .mob-wc__slider-slide > .mob-wc__entry {
    flex: 1;
  }

  .mob-wc__slider-dots {
    display: flex;
    justify-content: center;
    gap: var(--space-2xs);
  }

  .mob-wc__slider-dot {
    width: 0.5rem;
    height: 0.5rem;
    padding: 0;
    border-radius: var(--radius-full);
    background: var(--color-surface-container-highest);
    transition: background-color 0.15s ease;
  }

  .mob-wc__slider-dot.is-active {
    background: var(--color-primary);
  }

  /* Add-route tile on each day */
  .mob-wc__addtile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2xs);
    padding: var(--space-sm);
    border: 2px dashed var(--color-border-strong);
    border-radius: var(--radius-xl);
    background: transparent;
    transition:
      background-color 0.15s ease,
      color 0.15s ease;
  }

  .mob-wc__addtile:hover {
    background: var(--color-surface-container);
    color: var(--color-text-primary);
  }

  /* Routes list (library / friend's week) */
  .mob-wc__routes {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
  }

  .mob-wc__routes-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-sm);
  }

  .mob-wc__routes-title {
    font-size: 1.125rem;
    font-weight: 600;
  }

  .mob-wc__routes-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .mob-wc__routes-empty {
    padding: var(--space-md);
    text-align: center;
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-xl);
  }

  .mob-wc__route {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--color-surface-card);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
  }

  .mob-wc__route-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 5.5rem;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: var(--color-surface-container);
  }

  .mob-wc__route-map {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Lifted above the card cover link so the Schedule / GPX-download
     controls stay clickable (see primitives.css) */
  .mob-wc__route-footer {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
  }

  .mob-wc__route-sport {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
  }

  /* Bottom sheets — one container per sheet, plus the shared scrim */
  .mob-sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
  }

  .mob-sheet__backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(9, 9, 11, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .mob-sheet__backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .mob-sheet__panel {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    max-height: min(85dvh, 42rem);
    background: var(--color-surface-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-xl);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    pointer-events: auto;
  }

  .mob-sheet.is-open .mob-sheet__panel {
    transform: translateY(0);
  }

  .mob-sheet__handle {
    width: 2.5rem;
    height: 0.25rem;
    margin: var(--space-sm) auto 0;
    border-radius: var(--radius-full);
    background: var(--color-surface-container-highest);
    flex-shrink: 0;
  }

  .mob-sheet__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-xs) var(--space-md) 0;
    flex-shrink: 0;
  }

  .mob-sheet__close {
    flex-shrink: 0;
  }

  .mob-sheet__form {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md) var(--space-md);
    overflow-y: auto;
  }

  .mob-sheet__search {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    padding-inline: var(--space-sm);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    background: var(--color-surface-card);
  }

  .mob-sheet__search .input {
    flex: 1;
    padding-inline: 0;
    background: transparent;
    border: none;
    box-shadow: none;
  }

  .mob-sheet__search:focus-within {
    border-color: var(--color-border-strong);
  }

  .mob-sheet__list {
    display: flex;
    flex-direction: column;
    max-height: 16rem;
    overflow-y: auto;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
  }

  .mob-sheet__row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-subtle);
  }

  .mob-sheet__row:last-child {
    border-bottom: none;
  }

  .mob-sheet__row:hover {
    background: var(--color-surface-container);
  }

  .mob-sheet__row.is-selected {
    background: var(--color-surface-container-high);
    box-shadow: inset 3px 0 0 var(--color-primary);
  }

  .mob-sheet__radio {
    flex-shrink: 0;
    accent-color: var(--color-primary);
  }

  .mob-sheet__row-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .mob-sheet__row-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mob-sheet__subtitle {
    margin-top: var(--space-2xs);
  }

  .mob-sheet__empty {
    padding-top: var(--space-sm);
    text-align: center;
  }

  .mob-sheet__field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
  }

  .mob-sheet__calendar {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
  }

  .mob-sheet__grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--space-2xs) 0;
    justify-items: center;
  }

  .mob-sheet__grid .calendar-day {
    position: relative;
    width: 2.5rem;
    height: 2.5rem;
    margin-inline: 0;
  }

  .mob-sheet__day-dot {
    position: absolute;
    bottom: 0.25rem;
    left: 50%;
    width: 0.25rem;
    height: 0.25rem;
    margin-left: -0.125rem;
    border-radius: var(--radius-full);
    background: var(--color-primary);
  }

  .mob-sheet__grid .calendar-day--selected .mob-sheet__day-dot {
    background: var(--color-on-primary);
  }

  .mob-sheet__actions {
    display: flex;
    gap: var(--space-xs);
    padding-top: var(--space-2xs);
  }

  .mob-sheet__actions .btn {
    flex: 1;
  }

  /* Body scroll lock while a sheet is open (mob-sheet's locked class) */
  body.mob-sheet--locked {
    overflow: hidden;
  }

  /* Very narrow screens: tighter KPI values and day pills */
  @media (max-width: 360px) {
    .mob-wc__kpi-value {
      font-size: 1rem;
    }

    .mob-wc__pill {
      min-width: 3.25rem;
    }
  }
}
/* ------------------------------------------------------------------ */
/* Route detail page (Phase 6) — MY + OTHER variants, stats, calendar */
/* picker popover, gpx.studio embed                                   */
/* ------------------------------------------------------------------ */

.route-detail {
  max-width: var(--container-max);
  margin-inline: auto;
}

.route-detail__breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  margin-bottom: var(--space-sm);
}

.route-detail__crumb-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  text-decoration: none;
  color: inherit;
  transition: color 0.15s ease;
}

a.route-detail__crumb-link:hover {
  color: var(--color-text-primary);
}

.route-detail__crumb-current {
  font-weight: 500;
}

.route-detail__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding-bottom: var(--space-lg);
}

@media (min-width: 1280px) {
  .route-detail__header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.route-detail__intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  max-width: 42rem;
}

.route-detail__title {
  letter-spacing: -0.01em;
  margin: 0;
}

.route-detail__description {
  white-space: pre-line;
}

.route-detail__editable-row {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

/* Inline editors look like their static counterparts until focus */
.route-detail__title-input,
.route-detail__description-input {
  flex: 1;
  min-width: 0;
  color: var(--color-text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  padding: 0.25rem 0.375rem;
  margin-left: -0.375rem;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

/* Auto-grow controller owns the height*/
.route-detail__description-input {
  resize: none;
  max-height: 12rem;
}

.route-detail__title-input:hover,
.route-detail__description-input:hover {
  border-color: var(--color-border-subtle);
}

.route-detail__title-input:focus,
.route-detail__description-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface-card);
}

.route-detail__description-input:focus {
  color: var(--color-text-primary);
}

.route-detail__title-input::placeholder,
.route-detail__description-input::placeholder {
  color: var(--color-text-tertiary);
}

.route-detail__edit-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem;
  border-radius: var(--radius-lg);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.route-detail__edit-btn:hover,
.route-detail__edit-btn:focus-visible {
  background: var(--color-surface-container);
  color: var(--color-text-primary);
}

.route-detail__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.route-detail__btn {
  gap: var(--space-2xs);
}

/* Difficulty select with its caret */
.route-detail__tier-form {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.route-detail__select {
  appearance: none;
  background: var(--color-surface-card);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem 2rem 0.75rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.route-detail__select:hover,
.route-detail__select:focus {
  background: var(--color-surface-container-low);
  outline: none;
}

.route-detail__select-caret {
  position: absolute;
  right: 0.5rem;
  pointer-events: none;
}

/* Calendar chip + month-grid popover */
.route-detail__calendar {
  position: relative;
  display: inline-flex;
}

.route-detail__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem 0.875rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.route-detail__chip:hover,
.route-detail__chip:focus-visible {
  background: var(--color-surface-container-low);
}

/* Metric ribbon: three read-only cards + the linked duration/pace form */
.route-detail__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-xs);
  padding-bottom: var(--space-lg);
}

@media (min-width: 1024px) {
  .route-detail__stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.route-detail__stat {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  background: var(--color-surface-container-low);
  border-radius: var(--radius-lg);
  padding: 0.375rem 0.75rem;
}

.route-detail__stat-label {
  letter-spacing: 0.05em;
}

.route-detail__stat-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

/* display:contents lets the two metric cards be grid children of .stats */
.route-detail__metric-form {
  display: contents;
}

.route-detail__metric-input {
  width: 8rem;
  color: var(--color-text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 0.25rem;
  margin-left: -0.25rem;
  font-weight: 600;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.route-detail__metric-input:hover {
  border-color: var(--color-border-subtle);
}

.route-detail__metric-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface-card);
}

/* gpx.studio embed card */
.route-detail__workspace {
  padding-bottom: var(--space-2xl);
}

.route-detail__map {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.route-detail__map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  height: 2.75rem;
  padding-inline: var(--space-md);
  background: var(--color-surface-canvas);
  border-bottom: 1px solid var(--color-border-subtle);
}

.route-detail__map-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 0.25rem 0.625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.route-detail__map-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--color-track-split);
}

.route-detail__map-sub {
  display: none;
  /* Keeps the sub text and the full-screen toggle pinned right in the
     space-between head, with the pill left (FEATURES: full-screen map) */
  margin-left: auto;
}

@media (min-width: 640px) {
  .route-detail__map-sub {
    display: inline;
  }
}

/* FEATURES: open route map on full screen — icon toggle in the embed head */
.route-detail__map-expand {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem;
  border-radius: var(--radius-lg);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.route-detail__map-expand:hover,
.route-detail__map-expand:focus-visible {
  background: var(--color-surface-container);
  color: var(--color-text-primary);
}

/* Native Fullscreen API: the card fills the screen, the iframe everything
   below the 2.75rem head */
.route-detail__map:fullscreen {
  border-radius: 0;
}

.route-detail__map:fullscreen .route-detail__map-frame {
  height: calc(100% - 2.75rem);
}

/* Fallback for browsers without element fullscreen (iPhone Safari): the
   card covers the viewport like a modal. Below the upload (60) and
   verify-email (61) modals so those still interrupt. */
.route-detail__map--expanded {
  position: fixed;
  inset: 0;
  z-index: 55;
  border-radius: 0;
}

.route-detail__map--expanded .route-detail__map-frame {
  height: calc(100% - 2.75rem);
}

body.has-open-map {
  overflow: hidden;
}

.route-detail__map-frame {
  display: block;
  width: 100%;
  height: 600px;
  border: 0;
  outline: none;
}

.route-detail__map-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-2xl) var(--space-lg);
}
/* ------------------------------------------------------------------ */
/* Route library (routes/index)                                       */
/* ------------------------------------------------------------------ */

/* Visually hidden but still announced (filter labels) */
.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;
}

.btn[disabled],
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.icon-btn[disabled],
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Two-line clamped description text */
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Page column (ref: max-w-6xl mx-auto) */
.library {
  max-width: 72rem;
  margin-inline: auto;
}

/* Hero: title + lede left, primary actions right (ref px-6 pt-8 pb-6) */
.library-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding-block: 0 var(--space-lg);
}

.library-hero__lede {
  max-width: 34rem;
  margin-top: var(--space-xs);
}

.library-hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

@media (min-width: 768px) {
  .library-hero {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

/* ------------------------------------------------------------------ */
/* Stat cards (completed vs totals with progress bar)                 */
/* ------------------------------------------------------------------ */

.stat-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

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

@media (min-width: 1024px) {
  .stat-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.stat-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-xs);
}

.stat-card__label {
  font-weight: 500;
  padding-top: 0.125rem;
}

.stat-card__icon {
  flex-shrink: 0;
}

.stat-card__value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.stat-card__sep {
  margin-inline: 0.125rem;
}

.stat-card__unit {
  letter-spacing: 0.04em;
}

.stat-card__bar {
  height: 0.25rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-canvas);
  overflow: hidden;
}

.stat-card__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-text-primary);
  transition: width 0.3s ease;
}

.stat-card__fill--distance {
  background: var(--color-text-secondary);
}

.stat-card__fill--elevation {
  background: var(--color-track-elevation);
}

.stat-card__fill--routes {
  background: var(--color-track-split);
}

.stat-card__fill--synced {
  background: var(--color-accent-route);
}

/* ------------------------------------------------------------------ */
/* Filter bar (search / difficulty chips / sort)                      */
/* ------------------------------------------------------------------ */

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-lg);
}

@media (min-width: 1024px) {
  .filter-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.filter-bar__search {
  position: relative;
  display: block;
  flex: 1 1 auto;
}

.filter-bar__search-icon {
  position: absolute;
  top: 50%;
  left: 0.625rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.filter-bar__input {
  width: 100%;
  height: 2.5rem;
  padding-inline: 2.25rem var(--space-sm);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
  color: var(--color-text-primary);
}

.filter-bar__input::placeholder {
  color: var(--color-text-tertiary);
}

.filter-bar__input:focus,
.filter-bar__input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.filter-bar__right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.filter-bar__chips {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.125rem;
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
}

.filter-chip {
  height: 2rem;
  padding-inline: var(--space-sm);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition:
    color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.filter-chip:hover {
  color: var(--color-text-primary);
}

.filter-chip.is-active {
  background: var(--color-surface-card);
  color: var(--color-text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.filter-bar__sort {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  height: 2.5rem;
  padding-inline: var(--space-sm);
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
}

.filter-bar__sort select {
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
}

.filter-bar__sort select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ------------------------------------------------------------------ */
/* Route grid + route card                                            */
/* ------------------------------------------------------------------ */

.route-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

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

@media (min-width: 1024px) {
  .route-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.route-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.route-card:hover {
  box-shadow: var(--shadow-md);
  z-index: 1;
}

/* An open kebab menu must paint above neighbouring cards: the hover
   transform traps the panel's z-index inside this card's stacking
   context, so the card itself is promoted while the menu is open. */
.route-card:has(.card-menu__panel:not([hidden])) {
  z-index: 30;
}

.route-card.is-hidden {
  display: none;
}

.route-card__thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 9rem;
  border-radius: var(--radius-lg);
  background: var(--color-surface-canvas);
  overflow: hidden;
}

/* Real map image (Mapbox static render) in the thumb box. The wrapper clips
   with overflow: hidden; object-fit: cover fills the box while the render's
   auto-fit padding keeps the route clear of the cropped edges. */
.route-card__route-map {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.route-card__thumb-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
}

.route-card__thumb-overlay {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(3px);
  box-shadow: var(--shadow-sm);
}

.route-card__thumb-overlay--source {
  top: 0.5rem;
  right: 0.5rem;
}

.route-card__thumb-overlay--ago {
  bottom: 0.5rem;
  right: 0.5rem;
}

.route-card__badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs);
}

.route-card__title {
  letter-spacing: -0.01em;
}

.route-card__title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

/* The card cover link owns most of the card's hover area, so the title
   highlight fires from anywhere on the card, not just the title itself. */
.route-card__title a:hover,
.route-card:hover .route-card__title a {
  color: var(--color-accent-route);
}

.route-card__desc--empty {
  font-style: italic;
}

/* Three-up metric strip (Dist / Elev / Time) */
.route-card__metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2xs);
  padding: var(--space-xs);
  border-radius: var(--radius-lg);
  margin-top: auto;
}

.route-card__metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  text-align: center;
}

.route-card__metric-value {
  font-weight: 600;
  white-space: nowrap;
}

.route-card__metric-value--sm {
  font-size: 0.875rem;
  line-height: 1.25rem;
}

/* Lifted above the card cover link so View Map, the calendar picker and the
   kebab menu stay clickable (see primitives.css) */
.route-card__footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  padding-top: var(--space-2xs);
}

.route-card__footer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
/*
 * Explorer design system
 *
 * Extracted from design-refs/stitch_explorer_v0.2/stitch_explorer/explorer_design_system/DESIGN.md
 * (tokens: colors, typography, spacing, shapes) and the
 * route_upload_library_explorer shell markup (header, buttons, cards, footer;
 * v0.2 adds the account dropdown).
 *
 * The Stitch reference is Tailwind-based; this project serves plain CSS via
 * Sprockets, so tokens live in custom properties below and Tailwind utility
 * patterns are expressed as small semantic classes (type scale, buttons, cards).

 * IMPORTS



 









 





 */

/* ------------------------------------------------------------------ */
/* Design tokens                                                        */
/* ------------------------------------------------------------------ */

:root {
  /* Surfaces — layered neutral grounds (light palette only, per DESIGN.md) */
  --color-surface: #f9f9f9; /* app background */
  --color-surface-container-lowest: #ffffff;
  --color-surface-container-low: #f3f3f3;
  --color-surface-container: #eeeeee; /* divider rules, tonal fills */
  --color-surface-container-high: #e8e8e8;
  --color-surface-container-highest: #e2e2e2;
  --color-surface-card: #ffffff; /* raised structural cards */
  --color-surface-canvas: #f4f4f5; /* recessed wells: inputs, telemetry */
  --color-surface-variant: #e2e2e2;

  /* Content */
  --color-on-surface: #1a1c1c;
  --color-text-primary: #09090b; /* headlines, primary labels */
  --color-text-secondary: #71717a; /* supporting copy, metadata */
  --color-text-tertiary: #a1a1aa; /* placeholders, micro labels */

  /* Brand — solid carbon black CTAs (DESIGN.md §Components) */
  --color-primary: #09090b;
  --color-on-primary: #ffffff;
  --color-primary-container: #1c1b1d; /* primary hover fill */

  /* Borders */
  --color-border-subtle: #e4e4e7;
  --color-border-strong: #d4d4d8;

  /* Functional telemetry semantics */
  --color-accent-route: #e11d48; /* danger zone, destructive, section tags */
  --color-accent-route-soft: #ffdad6; /* destructive hover fill */
  --color-track-split: #10b981; /* success / live / synced states */
  --color-track-elevation: #38bdf8; /* elevation traces, map accents */
  --color-error: #ba1a1a;
  --color-on-error-container: #93000a;

  /* Typography — Inter across all levels (DESIGN.md §Typography) */
  --font-sans:
    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  /* Spacing rhythm */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --gutter-mobile: 1rem;
  --gutter-desktop: 1.5rem;
  --container-max: 80rem; /* 1280px, buffered by gutters */
  --nav-height: 4rem;

  /* Shapes — soft roundedness (DESIGN.md §Shapes) */
  --radius-sm: 0.125rem;
  --radius: 0.25rem; /* micro badges, insets */
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem; /* inputs, small controls */
  --radius-xl: 0.75rem; /* structural cards */
  --radius-full: 9999px; /* avatars, pips, toggles */

  /* Elevation — diffuse shadows on tonal surfaces (DESIGN.md §Elevation) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl:
    0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);

  --focus-ring: 0 0 0 2px rgba(9, 9, 11, 0.2);
}
