/* ---------- buttons ---------- */

/* UI chrome that should never be text-selected: buttons, badges, chips, tabs,
   nav chrome, and other controls. Keep *content* selectable (waypoint
   names/descriptions/coords, server usernames, log line text) - buttons that
   carry selectable text opt back in with user-select: text. */
.btn,
.icon-btn,
.tab,
.modal-tab,
.modal-close,
.password-toggle,
.category-badge,
.badge,
.players-dim-badge,
.log-entry-dim,
.dim-tab,
.category-picker-trigger,
.category-filter-trigger,
.category-filter-option,
.auth-kicker,
.nav-link,
.brand,
.auth-chip,
.bottom-nav-item,
.nav-more-menu a,
.nav-more-menu button,
.sheet a,
.sheet button,
.sheet-grabber,
.log-entry-jump-btn,
.log-entry-details-toggle {
  -webkit-user-select: none;
  user-select: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: var(--fs-sm);
  background: var(--surface-3);
  color: var(--text);
  transition: transform var(--dur-fast) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent-dim);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover {
  background: #6a54a0;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(226, 104, 95, 0.25);
}
.btn-danger:hover {
  background: var(--danger-strong);
  color: #fff;
  border-color: var(--danger-strong);
  box-shadow: 0 10px 24px -8px rgba(226, 104, 95, 0.45);
}

.btn-discord {
  background: #4752c4;
  color: #fff;
}
.btn-discord:hover {
  background: #525dd0;
}

.btn-sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--fs-xs);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.icon-btn:active {
  transform: scale(0.94);
}
/* tiny inline icon buttons (copy/share on waypoint cards): desktop keeps a
   compact 22-24px, coarse pointers grow it via the min-rule in base.css */
.icon-btn--xs {
  width: 22px;
  height: 22px;
  font-size: 10px;
  border-radius: 5px;
}
.waypoint-card-share.icon-btn--xs {
  width: 28px;
  height: 28px;
  font-size: 13px;
}
.icon-btn.icon-btn--danger:hover {
  color: var(--danger);
  border-color: rgba(226, 104, 95, 0.35);
}

/* ---------- form controls ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
}

.field .field-note {
  font-weight: 400;
  color: var(--text-dim);
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0 var(--space-3);
  height: 42px;
  font-size: var(--fs-base);
  font-weight: 500;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  width: 100%;
}
textarea {
  height: auto;
  padding: var(--space-3);
  resize: vertical;
}
input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: var(--surface-3);
  /* a visible ring (the old 40%-alpha border alone was under 3:1 contrast);
     the transparent outline keeps a ring in forced-colors / high-contrast mode */
  box-shadow: 0 0 0 3px var(--accent-soft-2);
  outline: 2px solid transparent;
}
input.no-spinner::-webkit-outer-spin-button,
input.no-spinner::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input.no-spinner {
  -moz-appearance: textfield;
}

.select-wrap {
  position: relative;
}
/* ---------- custom select (styled dropdown, matches form controls) ---------- */
.custom-select {
  position: relative;
  display: inline-flex;
  max-width: 100%;
}
.custom-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0 var(--space-3);
  height: 42px;
  font-size: var(--fs-base);
  font-weight: 500;
  width: 100%;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  white-space: nowrap;
}
.custom-select-trigger:hover {
  border-color: var(--border-strong);
}
.custom-select-trigger[aria-expanded="true"] {
  border-color: var(--accent-line);
}
.custom-select-chevron {
  color: var(--text-dim);
  font-size: 0.7em;
  transition: transform var(--dur) var(--ease);
}
.custom-select--open .custom-select-chevron {
  transform: rotate(180deg);
}
.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: min(280px, calc(100vw - 32px));
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
}
.custom-select--up .custom-select-menu {
  top: auto;
  bottom: calc(100% + 6px);
}
.custom-select-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.custom-select-option:hover {
  background: var(--surface-3);
}
.custom-select-option[aria-selected="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}
.select-wrap select {
  appearance: none;
  padding-right: var(--space-7);
}
.select-wrap i {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-dim);
  font-size: 0.7em;
}

.search-field {
  position: relative;
}
.search-field i {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.85em;
}
.search-field input {
  padding-left: 34px;
}

.password-field {
  position: relative;
  display: block;
}
.password-field input {
  padding-right: 42px;
}
.password-toggle {
  position: absolute;
  right: 2px;
  top: 2px;
  bottom: 2px;
  width: 38px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  border-radius: var(--radius-xs);
}
.password-toggle:hover {
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background var(--dur) var(--ease);
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--dur) var(--ease-out), background var(--dur) var(--ease);
}
.switch input:checked + .switch-track {
  background: var(--accent-soft-2);
  border-color: var(--accent-line);
}
.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
  background: var(--accent);
}

.color-picker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  height: 42px;
}
.color-picker input[type="color"] {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.color-value {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ---------- cards / surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.card-tight {
  padding: var(--space-4);
  border-radius: var(--radius);
}

/* ---------- badges / chips ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}
.badge-online {
  background: linear-gradient(180deg, color-mix(in srgb, var(--success) 20%, var(--surface-2)), color-mix(in srgb, var(--success) 7%, var(--surface-3)));
  border-color: color-mix(in srgb, var(--success) 38%, transparent);
  color: var(--success);
}
.badge-offline {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  color: var(--text-dim);
}
.badge-warn {
  background: linear-gradient(180deg, color-mix(in srgb, var(--warn) 20%, var(--surface-2)), color-mix(in srgb, var(--warn) 7%, var(--surface-3)));
  border-color: color-mix(in srgb, var(--warn) 38%, transparent);
  color: var(--warn);
}
.badge-danger {
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 20%, var(--surface-2)), color-mix(in srgb, var(--danger) 7%, var(--surface-3)));
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
  color: var(--danger);
}
.badge-afk {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  color: var(--text-dim);
}
.badge-role {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 18%, var(--surface-2)), color-mix(in srgb, var(--accent) 6%, var(--surface-3)));
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}

.badge[data-tooltip] {
  cursor: default;
}

/* JS-driven tooltip for badges / dim dots; floats above everything and is
   positioned against the viewport so it can't clip or leave the screen. */
.player-tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-tooltip);
  width: max-content;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  font-size: var(--fs-2xs);
  font-weight: 500;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 var(--space-3);
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.chip[data-active="true"] {
  background: var(--accent-soft-2);
  border-color: var(--accent-line);
  color: var(--accent);
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: var(--space-3) var(--space-3) calc(var(--space-3) - 2px);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--dur) var(--ease);
}
.tab:hover {
  color: var(--text);
}
.tab[data-active="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---------- empty / loading / skeleton ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-4);
  color: var(--text-dim);
}
.empty-state i {
  font-size: 1.6rem;
  color: var(--text-dim);
  opacity: 0.7;
}
.empty-state span {
  font-size: var(--fs-sm);
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--text) 7%, transparent) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: skeleton-sweep 1.5s var(--ease) infinite;
}
@keyframes skeleton-sweep {
  to {
    transform: translateX(100%);
  }
}

/* skeleton look applied to an existing element - keeps its real size/shape
   while loading (used for stat values that later hold live data) */
.is-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: transparent !important;
  border-color: transparent !important;
  user-select: none;
  pointer-events: none;
}
.is-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--text) 7%, transparent) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: skeleton-sweep 1.5s var(--ease) infinite;
}

/* ---- skeleton layout building blocks (mirror the real content shapes) ---- */

.sk-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sk-avatar {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}
.sk-icon {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
}
.sk-dot {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sk-line {
  display: block;
  height: 11px;
  border-radius: var(--radius-xs);
}
.sk-line.short {
  width: 55%;
}
.sk-line.tiny {
  height: 9px;
  width: 38%;
}
.sk-tag {
  display: block;
  height: 20px;
  width: 56px;
  border-radius: var(--radius-xs);
}
.sk-lines {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.sk-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton::after,
  .is-skeleton::after {
    animation: none;
    transform: none;
  }
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 6, 0.68);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
  overscroll-behavior: contain;
  animation: fade-in var(--dur) var(--ease);
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
/* Shared exit state: dismissOverlay() adds .is-closing, waits for the
   animation, then flips `hidden`. Keeps entrances and exits symmetric. */
.modal-backdrop.is-closing {
  animation: fade-out 180ms var(--ease) forwards;
}
.modal-backdrop.is-closing .modal,
.image-lightbox-backdrop.is-closing {
  animation: modal-out 160ms var(--ease-out) forwards;
}
@keyframes modal-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: min(88dvh, 720px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-6) var(--space-5);
  animation: modal-in var(--dur-slow) var(--ease-out);
  position: relative;
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  margin: 0 0 var(--space-4);
}
.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  color: var(--text);
  background: var(--surface-3);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.modal-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
}
.modal-form .optional {
  font-weight: 400;
  color: var(--text-dim);
  text-transform: none;
}
.coord-row .optional {
  margin-left: var(--space-3);
}
.modal-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-1);
}
.modal-actions .btn-primary {
  flex: 1;
}

.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}
.modal-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: var(--space-2) var(--space-2) calc(var(--space-2) - 2px);
  border-radius: 0;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.modal-tab:hover {
  color: var(--text);
}
.modal-tab[data-active="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.confirm-modal-message {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-5);
  line-height: 1.55;
}

/* ---------- toast ---------- */

.toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-h) + var(--safe-b) + var(--space-4));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  z-index: var(--z-toast);
  width: min(92vw, 400px);
  pointer-events: none;
}
@media (min-width: 861px) {
  .toast-container {
    bottom: var(--space-5);
  }
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  cursor: pointer;
}
.toast-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.toast-leaving {
  opacity: 0;
  transform: translateY(4px) scale(0.98);
}
.toast-error {
  border-color: rgba(226, 104, 95, 0.4);
}
.toast-error i {
  color: var(--danger);
}
.toast-success i {
  color: var(--success);
}
.toast-info i {
  color: var(--accent);
}
.toast i {
  margin-top: 2px;
}

/* ---------- utility row patterns (settings-style) ---------- */

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-hairline);
}
.setting-row:last-child {
  border-bottom: none;
}
.setting-row-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.setting-row-label {
  font-weight: 600;
  font-size: var(--fs-sm);
}
.setting-row-desc {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  max-width: 46ch;
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0 0 var(--space-3);
}

.divider {
  height: 1px;
  background: var(--border-hairline);
  margin: var(--space-5) 0;
}

.avatar {
  border-radius: 6px;
  background: var(--surface-3);
  flex-shrink: 0;
  image-rendering: pixelated;
}

.mark {
  background: var(--accent-soft-2);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
}
mark {
  background: var(--accent-soft-2);
  color: var(--accent);
  border-radius: 3px;
}

/* ---------- shared waypoint card ----------
   Used identically by the map sidebar list, the map pin tooltip, and the
   profile page's waypoints tab (js/lib/waypoint-ui.js) - lives here, not in
   map.css, so every page that loads components.css can use it. */

.waypoint-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  cursor: default;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.waypoint-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.waypoint-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.waypoint-card-share {
  flex-shrink: 0;
}
.waypoint-card-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.waypoint-card-name {
  font-weight: 700;
  font-size: var(--fs-sm);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.waypoint-card-coords {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.waypoint-card-desc {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.waypoint-card-image {
  width: 100%;
  max-height: 110px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  margin: 6px 0;
  cursor: zoom-in;
  border: 1px solid var(--border);
}
/* Compact tooltip variant: aspect-ratio + fixed width reserve the image's
   layout space before it loads, so the popup is measured once at its final
   size and never re-anchors with a visible jump. */
.waypoint-card--compact .waypoint-card-image {
  max-height: none;
}
.waypoint-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.waypoint-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.waypoint-card-action-end {
  margin-left: auto;
}
.waypoint-card-author {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--text-dim);
}

/* compact variant used inside the map pin tooltip - same anatomy, tighter */
.waypoint-card--compact {
  border: none;
  padding: 0;
  cursor: default;
  background: none;
  min-width: 220px;
  max-width: 260px;
}
.waypoint-card--compact:hover {
  background: none;
}

/* horizontal "row" variant - the profile waypoints tab lays the info out in
   two compact rows instead of stacking it vertically (dimension + category on
   the right, coords + jump on the bottom), keeping the dot/name/coords/badge
   hierarchy intact */
.waypoint-card--row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-2) var(--space-3);
}
.waypoint-card-row-top,
.waypoint-card-row-bottom {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  min-width: 0;
}
.waypoint-card--row .waypoint-card-name {
  flex: 1;
  min-width: 0;
}
.waypoint-card--row .waypoint-card-meta {
  margin: 0;
  flex-shrink: 0;
}
.waypoint-card--row .waypoint-card-meta--right {
  margin-left: auto;
}
.waypoint-card--jumpable {
  cursor: pointer;
}
.waypoint-card--row .waypoint-card-coords--row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.waypoint-card--row .waypoint-card-coords--push {
  margin-left: auto;
}
.waypoint-card--row .waypoint-card-actions {
  margin: 0;
  flex-shrink: 0;
}
.waypoint-card--row .waypoint-card-desc--row {
  flex: 1;
  min-width: 0;
  margin: 0;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 700px) {
  /* flagships (500px+): the profile waypoint list breaks its "blob" cards and
     reads as a plain tappable settings list - flat rows split by hairlines */
  .waypoint-card--row {
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: var(--space-3) var(--space-1);
    border-bottom: 1px solid var(--border-hairline);
  }
  .waypoint-card--row .waypoint-card-desc--row {
    display: none;
  }
  .waypoint-card--row .waypoint-card-coords--row {
    margin-left: auto;
  }
}

.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px 3px 4px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--badge-color) 14%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--badge-color) 25%, var(--border));
  color: var(--badge-color);
}
.category-badge i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  font-size: 9px;
  background: color-mix(in srgb, var(--badge-color) 18%, transparent);
  color: inherit;
}

.category-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  flex-shrink: 0;
  margin-bottom: var(--space-3);
}
.category-filter-row .category-filter {
  flex: 1 1 190px;
  min-width: 0;
}

/* dimension segmented switch - shared between the map page's dim tabs and the
   waypoint-list dimension filter (js/lib/waypoint-ui.js) */
.dim-tabs {
  display: inline-flex;
  gap: 2px;
  background: rgba(14, 14, 18, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
  box-shadow: var(--shadow);
}
.dim-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: var(--fs-xs);
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.dim-tab[data-active="true"][data-dim="overworld"] {
  background: rgba(107, 191, 138, 0.16);
  color: var(--dim-overworld);
}
.dim-tab[data-active="true"][data-dim="nether"] {
  background: rgba(226, 104, 95, 0.16);
  color: var(--dim-nether);
}
.dim-tab[data-active="true"][data-dim="end"] {
  background: rgba(217, 199, 117, 0.16);
  color: var(--dim-end);
}
@media (max-width: 480px) {
  .dim-tab {
    padding: 7px 10px;
    font-size: 11px;
  }
}

/* custom category dropdown (js/lib/waypoint-ui.js) - replaces the native
   <select> in the waypoint-list filters; each option renders as a badge-style
   row (colored icon chip + name, like .category-badge) */
.category-filter {
  position: relative;
}
.category-filter-trigger {
  width: 100%;
  height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  color: var(--text);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.category-filter-trigger:hover,
.category-filter-trigger[aria-expanded="true"] {
  background: var(--surface-3);
}
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.category-pill-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.category-pill-icon--none {
  background: var(--surface-3);
  color: var(--text-dim);
}
.category-pill-avatar {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.category-pill-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.category-filter-chevron {
  font-size: 0.7em;
  color: var(--text-dim);
  flex-shrink: 0;
}
.category-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  padding: 4px;
}
.category-filter--up .category-filter-menu {
  top: auto;
  bottom: calc(100% + 6px);
}
.category-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 9px;
  border-radius: var(--radius-xs);
  background: none;
  border: none;
  color: var(--text);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.category-filter-option:hover,
.category-filter-option[aria-selected="true"] {
  background: var(--surface-3);
}

.players-dim-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--dim-badge-color, var(--text-muted));
  border: 1px solid color-mix(in srgb, var(--dim-badge-color, var(--text-muted)) 30%, transparent);
  background: color-mix(in srgb, var(--dim-badge-color, var(--text-muted)) 12%, transparent);
}

/* shared layout helpers used across pages (waypoint form, category form,
   loading-skeleton lists) */
.coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
}
/* 3 inputs across overflows a 320-375px modal (input min-content > column);
   drop to 2 columns with Z full width. :has() keeps 2-field rows untouched. */
@media (max-width: 560px) {
  .coord-row:has(> :nth-child(3)) {
    grid-template-columns: 1fr 1fr;
  }
  .coord-row:has(> :nth-child(3)) > :nth-child(3) {
    grid-column: 1 / -1;
  }
}

.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---------- waypoint visibility picker (map waypoint form) ---------- */

.visibility-picker-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.visibility-picker {
  display: flex;
  gap: 4px;
  width: 100%;
}

.visibility-picker-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.visibility-picker-option[data-active="true"] {
  border-color: var(--accent, #6bbf8a);
  background: color-mix(in srgb, var(--accent, #6bbf8a) 14%, transparent);
  color: var(--text);
}

.waypoint-visibility-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px 3px 4px;
  border-radius: 5px;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
}
.waypoint-visibility-badge i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  font-size: 9px;
  background: var(--surface-2);
  color: inherit;
}

.waypoint-collab-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-left: auto;
  flex-shrink: 0;
}

.waypoint-collab-badge.is-editor {
  color: var(--accent, #6bbf8a);
  border-color: color-mix(in srgb, var(--accent, #6bbf8a) 30%, transparent);
  background: color-mix(in srgb, var(--accent, #6bbf8a) 10%, transparent);
}

/* ---------- waypoint detail view (info + gallery + collaborators) ---------- */

.waypoint-detail-backdrop {
  z-index: var(--z-modal);
}

.waypoint-detail-card {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.waypoint-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 32px;
}

.waypoint-detail-dot {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.waypoint-detail-name {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waypoint-detail-visibility {
  flex-shrink: 0;
}

.waypoint-detail-desc {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: 0;
  white-space: pre-wrap;
}

.waypoint-detail-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.waypoint-detail-coords {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.waypoint-detail-conversion {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-dim);
}

.waypoint-detail-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}

.waypoint-detail-section {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.waypoint-detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.waypoint-detail-section-title {
  font-size: var(--fs-sm);
  font-weight: 700;
}

.waypoint-detail-count {
  font-size: var(--fs-2xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  vertical-align: 1px;
}

.waypoint-detail-empty {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  color: var(--text-dim);
  font-size: var(--fs-xs);
  font-style: italic;
  padding: var(--space-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
}

.waypoint-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.waypoint-gallery-tile {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  aspect-ratio: 16 / 10;
}

.waypoint-gallery-tile--display {
  outline: 2px solid #ffd700;
  outline-offset: -2px;
}

.waypoint-gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.waypoint-gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 4px 6px;
  font-size: var(--fs-2xs);
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waypoint-gallery-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
}

.waypoint-gallery-caption-edit {
  position: absolute;
  top: 5px;
  left: 36px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.waypoint-gallery-tile:hover .waypoint-gallery-caption-edit,
.waypoint-gallery-caption-edit:focus-visible {
  opacity: 1;
}
/* :hover needs a real hover - on touch the pencil would never appear */
@media (hover: none), (pointer: coarse) {
  .waypoint-gallery-caption-edit {
    opacity: 1;
  }
}

.waypoint-gallery-star {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.waypoint-gallery-star:hover,
.waypoint-gallery-star.active {
  color: #ffd700;
}

.waypoint-detail-image {
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  margin: 8px 0 2px;
  cursor: zoom-in;
  border: 1px solid var(--border);
}

.waypoint-collaborators {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.waypoint-collab-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.waypoint-collab-avatar {
  width: 26px;
  height: 26px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.waypoint-collab-name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waypoint-collab-row--creator {
  border-color: color-mix(in srgb, var(--accent, #6bbf8a) 35%, var(--border));
  background: color-mix(in srgb, var(--accent, #6bbf8a) 6%, var(--surface-2));
}

.waypoint-collab-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--accent, #6bbf8a);
  border: 1px solid color-mix(in srgb, var(--accent, #6bbf8a) 30%, var(--border));
  background: color-mix(in srgb, var(--accent, #6bbf8a) 10%, transparent);
}

.waypoint-collab-remove {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  margin-right: -2px;
}

.waypoint-person-search {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.waypoint-person-results {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

.waypoint-person-search:focus-within .waypoint-person-results {
  display: flex;
}

.waypoint-person-result {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  padding: 8px 9px;
  border: none;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.waypoint-person-result:hover {
  background: var(--surface-3);
}

.waypoint-person-result > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waypoint-person-avatar {
  width: 22px;
  height: 22px;
  border-radius: 2px;
  flex-shrink: 0;
  background: var(--surface-3);
}

.waypoint-person-empty {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  font-style: italic;
  padding: var(--space-2);
}
