:root {
  --bg: #0f1210;
  --bg-elevated: #171c18;
  --bg-panel: #1e2520;
  --border: #2e3a32;
  --text: #e8ebe6;
  --text-muted: #9aa89e;
  --accent: #c4a35a;
  --accent-dim: #8a7340;
  --danger: #c45a5a;
  --pin-mg-spot: #d94f3d;
  --pin-mg-spot-glow: rgba(217, 79, 61, 0.55);
  --pin-climb: #4a7ec4;
  --pin-climb-glow: rgba(74, 126, 196, 0.55);
  --pin-location: #3dad5c;
  --pin-location-glow: rgba(61, 173, 92, 0.55);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --font-display: "Barlow Condensed", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse at top, #1a221c 0%, var(--bg) 55%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 16, 0.92);
  backdrop-filter: blur(8px);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.header__tag {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: linear-gradient(145deg, #252d27, #171c18);
}

.header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.header__subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.header__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 0.25rem;
  padding-right: 0.75rem;
  border-right: 1px solid var(--border);
}

.header__avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.header__user-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-gate {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 65px);
  padding: 2rem 1rem;
}

.auth-gate__card {
  width: min(420px, 100%);
  padding: 2rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-gate__logo {
  margin: 0 auto 1rem;
}

.auth-gate__card h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-gate__message {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.btn--steam {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(180deg, #2a475e 0%, #1b2838 100%);
  border: 1px solid #3d6b8e;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.btn--steam:hover {
  filter: brightness(1.08);
}

.btn--steam__icon {
  width: 1.1rem;
  height: 1.1rem;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 2C6.48 2 2 6.15 2 11.2c0 2.86 1.44 5.41 3.68 7.02l-.96 2.9 3.18-1.03c.98.27 2.02.41 3.1.41 5.52 0 10-4.15 10-9.2S17.52 2 12 2zm4.84 6.45l-1.1 3.2-3.55-.05-2.75 2.55-.55-3.35 2.95-2.35 4-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

#app-root.hidden {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 65px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow: auto;
  padding: 1rem;
}

.sidebar__section + .sidebar__section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar__hint {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.sidebar__select-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sidebar__select-label--compact {
  margin-top: 0.75rem;
}

.sidebar__select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121612;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font: inherit;
}

.sidebar__select:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
}

.toggle-row input {
  accent-color: var(--accent);
}

.pin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pin-list__row {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
}

.pin-list__item {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: inherit;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.pin-list__edit {
  flex-shrink: 0;
  padding: 0.45rem 0.6rem;
  font-size: 0.75rem;
}

.pin-list__item:hover,
.pin-list__item.is-active {
  border-color: var(--accent-dim);
  transform: translateX(2px);
}

.pin-list__item.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-panel));
  box-shadow: inset 3px 0 0 var(--accent);
}

.pin-list__row.is-active .pin-list__edit {
  border-color: var(--accent);
}

.tag-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.tag-filter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 4.25rem;
  padding: 0.45rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.68rem;
  line-height: 1.2;
  text-transform: lowercase;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.tag-filter:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

.tag-filter.is-active.tag-filter--mg-spot {
  color: #ffb4a8;
  border-color: rgba(217, 79, 61, 0.45);
  background: rgba(217, 79, 61, 0.18);
}

.tag-filter.is-active.tag-filter--climb {
  color: #a8c8f5;
  border-color: rgba(74, 126, 196, 0.45);
  background: rgba(74, 126, 196, 0.18);
}

.tag-filter.is-active.tag-filter--location {
  color: #a8e8b8;
  border-color: rgba(61, 173, 92, 0.45);
  background: rgba(61, 173, 92, 0.18);
}

.tag-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.tag-swatch--mg-spot {
  background: var(--pin-mg-spot);
}

.tag-swatch--climb {
  background: var(--pin-climb);
}

.tag-swatch--location {
  background: var(--pin-location);
}

.pin-list__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pin-list__tag {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.pin-list__tag--mg-spot {
  color: #ffb4a8;
  background: rgba(217, 79, 61, 0.18);
  border-color: rgba(217, 79, 61, 0.45);
}

.pin-list__tag--climb {
  color: #a8c8f5;
  background: rgba(74, 126, 196, 0.18);
  border-color: rgba(74, 126, 196, 0.45);
}

.pin-list__tag--location {
  color: #a8e8b8;
  background: rgba(61, 173, 92, 0.18);
  border-color: rgba(61, 173, 92, 0.45);
}

.pin-list__title {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
}

.pin-list__meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pin-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.pin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pin-form input,
.pin-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121612;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font: inherit;
}

.pin-form input:focus,
.pin-form textarea:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

.pin-form__coords {
  font-size: 0.78rem;
  color: var(--accent);
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: rgba(196, 163, 90, 0.08);
  border: 1px dashed var(--accent-dim);
}

.pin-form__actions {
  display: flex;
  gap: 0.5rem;
}

.pin-form__tags {
  border: none;
  margin: 0;
  padding: 0;
}

.pin-form__tags legend,
.pin-form__video-source legend {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.pin-form__video-source {
  border: none;
  margin: 0;
  padding: 0;
}

.pin-form__video-options {
  margin-top: 0.35rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: linear-gradient(180deg, #d4b76a, #a8873f);
  color: #1a1408;
  border-color: #c4a35a;
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.btn--icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: var(--bg-panel);
  border-color: var(--border);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
}

.btn--icon:hover {
  border-color: var(--accent-dim);
}

.map-shell {
  position: relative;
  min-width: 0;
  background:
    linear-gradient(0deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 24px,
      rgba(255, 255, 255, 0.02) 24px,
      rgba(255, 255, 255, 0.02) 25px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 24px,
      rgba(255, 255, 255, 0.02) 24px,
      rgba(255, 255, 255, 0.02) 25px
    );
}

.map-toolbar {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 10px;
  background: rgba(15, 18, 16, 0.88);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.map-toolbar__zoom {
  min-width: 3rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.map-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.map-viewport.is-dragging {
  cursor: grabbing;
}

.map-viewport.is-edit-mode {
  cursor: crosshair;
}

.map-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.map-image {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

.map-overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-grid-image {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.overlay-strongpoint {
  position: absolute;
  display: block;
  pointer-events: none;
}

.overlay-strongpoint-label {
  position: absolute;
  display: block;
  pointer-events: none;
  z-index: 1;
  image-rendering: auto;
}

.map-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-pin {
  position: absolute;
  width: 28px;
  height: 28px;
  margin: -28px 0 0 -14px;
  border: none;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  z-index: 5;
  transform: scale(1);
  transform-origin: 50% 100%;
  transition: transform 0.35s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.map-pin::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50% 50% 50% 0;
  background: var(--pin-color, var(--pin-climb));
  transform: rotate(-45deg);
  box-shadow: 0 0 0 3px rgba(15, 18, 16, 0.85), 0 0 14px var(--pin-glow, var(--pin-climb-glow));
  transition: box-shadow 0.35s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.map-pin--mg-spot {
  --pin-color: var(--pin-mg-spot);
  --pin-glow: var(--pin-mg-spot-glow);
}

.map-pin--climb {
  --pin-color: var(--pin-climb);
  --pin-glow: var(--pin-climb-glow);
}

.map-pin--location {
  --pin-color: var(--pin-location);
  --pin-glow: var(--pin-location-glow);
}

.map-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: #fff3ee;
  transition: transform 0.35s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.map-pin:hover,
.map-pin.is-highlighted {
  z-index: 10;
}

.map-pin:hover {
  transform: scale(4.6);
}

.map-pin:hover::before {
  box-shadow: 0 0 0 3px rgba(15, 18, 16, 0.85), 0 0 22px var(--pin-glow, var(--pin-climb-glow));
}

.map-pin.is-highlighted {
  transform: scale(5.8);
}

.map-pin.is-highlighted::before {
  box-shadow: 0 0 0 4px rgba(15, 18, 16, 0.9), 0 0 28px var(--pin-glow, var(--pin-climb-glow));
}

.map-pin.is-highlighted:hover {
  transform: scale(5.8);
}

.map-crosshair {
  position: absolute;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
  z-index: 15;
  box-shadow: 0 0 0 4px rgba(196, 163, 90, 0.15);
}

.map-crosshair::before,
.map-crosshair::after {
  content: "";
  position: absolute;
  background: var(--accent);
}

.map-crosshair::before {
  left: 50%;
  top: 3px;
  bottom: 3px;
  width: 2px;
  margin-left: -1px;
}

.map-crosshair::after {
  top: 50%;
  left: 3px;
  right: 3px;
  height: 2px;
  margin-top: -1px;
}

.preview-tooltip {
  position: fixed;
  z-index: 50;
  width: min(320px, calc(100vw - 2rem));
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(18, 22, 18, 0.96);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.preview-tooltip__media {
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.preview-tooltip__media img,
.preview-tooltip__media video,
.preview-tooltip__media iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  background: #000;
}

.preview-loading,
.preview-error {
  margin: 0;
  padding: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.video-modal__player .preview-error a {
  color: var(--accent);
}

.preview-tooltip__body {
  padding: 0.65rem 0.75rem 0.75rem;
}

.preview-tooltip__body strong {
  display: block;
  font-size: 0.88rem;
}

.preview-tooltip__body p {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.video-modal {
  width: min(960px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
}

.video-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
}

.video-modal__inner {
  position: relative;
  padding: 1rem 1rem 1.1rem;
}

.video-modal__close {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.video-modal__close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.video-modal__header {
  padding-right: 2rem;
  margin-bottom: 0.75rem;
}

.video-modal__header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.video-modal__header p {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.video-modal__edit {
  margin-top: 0.65rem;
}

.video-modal__player {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.video-modal__player iframe,
.video-modal__player video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    max-height: 28vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
