:root {
  --portal-bg:             #080c08;
  --portal-surface:        rgba(0, 0, 0, 0.22);
  --portal-surface-strong: rgba(0, 0, 0, 0.30);
  --portal-stroke:         rgba(255, 255, 255, 0.10);
  --portal-stroke-strong:  rgba(160, 220, 152, 0.25);
  --portal-text:           rgba(255, 255, 255, 0.92);
  --portal-soft:           rgba(255, 255, 255, 0.62);
  --portal-muted:          rgba(255, 255, 255, 0.38);
  --portal-green:          #a0dc98;
  --portal-green-deep:     rgba(160, 220, 152, 0.12);
  --portal-warn:           #f4b46a;
  --portal-danger:         #e3837b;
  --portal-shadow:         0 24px 64px rgba(0, 0, 0, 0.4);
}

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

html, body { min-height: 100%; margin: 0; }

body {
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--portal-text);
  background: var(--portal-bg);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

/* ── Background ── */
.portal-bg, .public-bg {
  position: fixed;
  inset: 0;
  background-image: url("../../forest.png");
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  transform: scale(1.03);
  filter: saturate(1.05) contrast(1.05);
}

.portal-bg::after, .public-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(8, 12, 8, 0.50) 0%,
    rgba(8, 12, 8, 0.72) 40%,
    rgba(8, 12, 8, 0.95) 100%
  );
}

.portal-shell, .public-shell-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ── Nav ── */
.portal-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 52px;
  padding: 0 20px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.portal-drawer {
  position: fixed;
  top: 52px; left: 0; right: 0;
  z-index: 99;
  display: flex;
  flex-direction: column;
  max-height: 0;
  overflow: hidden;
  background: rgba(6, 10, 6, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.portal-drawer.open { max-height: 480px; }

.portal-drawer a {
  padding: 15px 24px;
  font-size: 15px;
  font-weight: 500;
  color: var(--portal-soft);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: color 0.15s, background 0.15s;
}

.portal-drawer a.active,
.portal-drawer a:hover { color: var(--portal-green); background: rgba(255,255,255,0.04); }

.portal-brand-link {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--portal-text);
  white-space: nowrap;
}

.portal-brand-link span,
.portal-eyebrow,
.portal-nav-tag { color: var(--portal-green); }

.portal-nav-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.portal-nav-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.nav-menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.nav-menu-btn:hover { background: rgba(255,255,255,0.08); }
.nav-menu-btn span {
  display: block;
  height: 1.5px;
  background: rgba(255,255,255,0.72);
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
  transform-origin: center;
}
.nav-menu-btn.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-menu-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-menu-btn.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.portal-user-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(160,220,152,0.20);
  background: rgba(0,0,0,0.14);
  color: var(--portal-green);
  font-size: 13px;
  white-space: nowrap;
}

/* ── Layout ── */
.portal-main, .public-shell {
  position: relative;
  z-index: 1;
  padding: 84px 24px 80px;
}

.public-shell {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.portal-page {
  width: min(1080px, 100%);
  margin: 0 auto;
}

/* ── Glass cards ── */
.auth-card, .panel, .metric-card {
  border-radius: 18px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-stroke);
  box-shadow: var(--portal-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.auth-card {
  width: min(680px, 100%);
  padding: 32px 36px;
}

.auth-card.wide { width: min(680px, 100%); }

/* ── Metric grid ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric-card { padding: 22px 20px; }

.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--portal-muted);
}

.metric-value {
  margin-top: 10px;
  font-size: clamp(24px, 2vw, 32px);
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--portal-text);
}

.metric-detail {
  margin-top: 4px;
  font-size: 12px;
  color: var(--portal-soft);
}

/* ── Content grid ── */
.content-grid { display: grid; gap: 16px; }
.content-grid.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ── Panel ── */
.panel { padding: 26px 28px; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--portal-text);
}

.panel-head p {
  margin: 0;
  color: var(--portal-soft);
  font-size: 14px;
}

/* ── Portal header ── */
.portal-header { display: block; margin-bottom: 24px; }

.portal-header h1, .auth-card h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 6vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.portal-subtitle, .auth-copy, .form-note {
  color: var(--portal-soft);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 10px;
}

/* ── Route cards ── */
.route-card {
  padding: 20px 22px;
  border-radius: 16px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-stroke);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  display: block;
  text-decoration: none;
  color: inherit;
  margin-bottom: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.route-card:hover { border-color: rgba(255,255,255,0.18); background: rgba(0,0,0,0.30); }

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

.route-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--portal-text);
  margin: 0;
  line-height: 1.2;
}

.route-card-meta {
  font-size: 13px;
  color: var(--portal-soft);
  margin: 0 0 12px;
}

.route-card-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 13px;
  color: var(--portal-muted);
  flex-wrap: wrap;
}

.route-card-footer strong { color: var(--portal-text); }

/* ── List rows ── */
.list-stack { display: grid; gap: 10px; }

.list-row {
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  transition: background 0.15s, border-color 0.15s;
}

a.list-row:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.12); }
.list-row.static { cursor: default; }
.list-row strong { color: var(--portal-text); font-size: 15px; }
.list-row p { margin: 4px 0 0; color: var(--portal-soft); font-size: 13px; }

.row-meta { text-align: right; flex-shrink: 0; }
.row-meta span { font-size: 15px; color: var(--portal-text); font-variant-numeric: tabular-nums; }
.row-meta small { display: block; font-size: 12px; color: var(--portal-soft); margin-top: 2px; }

/* ── Ghost rows ── */
.ghost-row {
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-stroke);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: block;
  text-decoration: none;
  color: inherit;
  margin-bottom: 12px;
  transition: border-color 0.15s, background 0.15s;
}
a.ghost-row:hover { border-color: rgba(255,255,255,0.18); background: rgba(0,0,0,0.30); }

.ghost-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.ghost-row-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--portal-text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.ghost-row-time {
  font-size: 20px;
  font-weight: 600;
  color: var(--portal-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.ghost-row-sub {
  font-size: 12px;
  color: var(--portal-muted);
  margin: 0 0 8px;
}

.ghost-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ── Split dots ── */
.split-dots { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin: 8px 0 2px; }

.split-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
}
.split-dot.is-fastest { background: var(--portal-green); box-shadow: 0 0 6px rgba(160,220,152,0.5); }
.split-dot.is-fast    { background: rgba(160,220,152,0.55); }
.split-dot.is-other   { background: rgba(255,255,255,0.28); }

/* ── Split bars (ghost detail) ── */
.split-table { display: grid; gap: 10px; }
.split-row { display: flex; align-items: center; gap: 10px; }
.split-label { font-size: 11px; color: var(--portal-muted); width: 36px; flex-shrink: 0; }
.split-bar-bg { flex: 1; height: 5px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.split-bar-fill { height: 100%; border-radius: 3px; width: 0; transition: width 1.1s cubic-bezier(0.25,0.8,0.25,1); }
.split-bar-fill.fast { background: var(--portal-green); }
.split-bar-fill.slow { background: rgba(255,120,100,0.70); }
.split-time { font-size: 11px; width: 44px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.split-time.fast { color: var(--portal-green); }
.split-time.slow { color: rgba(255,140,120,0.85); }

/* ── Map container ── */
.portal-map-wrap {
  width: 100%;
  aspect-ratio: 16/6;
  min-height: 200px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0,0,0,0.30);
  border: 1px solid var(--portal-stroke);
  margin-bottom: 20px;
  position: relative;
}
#portalMapContainer { position: absolute; inset: 0; width: 100%; height: 100%; }
.mk-controls-container, .mk-map-type-control,
.mk-zoom-control, .mk-compass { display: none !important; }
.mk-attribution { opacity: 0.5; }

/* ── Visibility selector ── */
.visibility-pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }

.vis-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--portal-stroke);
  background: rgba(255,255,255,0.04);
  color: var(--portal-soft);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.vis-btn:hover { background: rgba(255,255,255,0.08); }
.vis-btn[aria-pressed="true"] {
  background: var(--portal-green-deep);
  border-color: var(--portal-stroke-strong);
  color: var(--portal-green);
}

/* ── Pills ── */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--portal-stroke);
  background: rgba(255,255,255,0.04);
  color: var(--portal-soft);
}
.pill-success { color: var(--portal-green); border-color: rgba(160,220,152,0.28); background: rgba(160,220,152,0.08); }
.pill-warn    { color: var(--portal-warn);  border-color: rgba(244,180,106,0.28); background: rgba(244,180,106,0.08); }
.pill-private { color: rgba(255,120,100,0.9); border-color: rgba(220,60,60,0.25); background: rgba(220,60,60,0.10); }
.pill-friends { color: rgba(255,190,80,0.9); border-color: rgba(244,180,106,0.28); background: rgba(244,180,106,0.08); }

/* ── Detail hero / actions ── */
.detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.detail-meta h2 {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}
.detail-meta p { margin: 0; font-size: 14px; color: var(--portal-soft); }

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
  flex-shrink: 0;
}

/* ── Detail list (dl) ── */
.detail-list { display: grid; gap: 12px; }
.detail-list div { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.detail-list dt { color: var(--portal-muted); font-size: 13px; margin: 0; }
.detail-list dd { text-align: right; font-size: 13px; color: var(--portal-text); margin: 0; }
.code-wrap { max-width: 100%; word-break: break-all; font-size: 11px; color: var(--portal-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--portal-stroke);
  border-radius: 12px;
  background: rgba(255,255,255,0.07);
  color: var(--portal-text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.12); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--portal-green-deep); color: var(--portal-green); border-color: var(--portal-stroke-strong); }
.btn-primary:hover { background: rgba(160,220,152,0.20); }
.btn-secondary { background: rgba(255,255,255,0.06); color: var(--portal-soft); }
.btn-danger { background: rgba(227,131,123,0.10); color: var(--portal-danger); border-color: rgba(227,131,123,0.24); }
.btn-danger:hover { background: rgba(227,131,123,0.18); }
.btn-mini { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13px; }

/* ── Text link ── */
.text-link { color: var(--portal-green); }
.text-link:hover { text-decoration: underline; }

/* ── Forms ── */
.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 8px; }
.form-stack span { font-size: 12px; color: var(--portal-soft); letter-spacing: 0.04em; }

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.07);
  color: var(--portal-text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.10);
}
textarea { resize: vertical; }

.checkbox-row { display: flex; justify-content: flex-start; align-items: center; gap: 10px; }
.checkbox-row input { width: 18px; height: 18px; }

/* ── Banners ── */
.banner { padding: 14px 16px; border-radius: 12px; margin-top: 16px; font-size: 14px; line-height: 1.5; }
.banner-success { background: rgba(160,220,152,0.12); border: 1px solid rgba(160,220,152,0.24); color: var(--portal-green); }
.banner-error   { background: rgba(227,131,123,0.12); border: 1px solid rgba(227,131,123,0.22); color: var(--portal-danger); }

.form-divider { height: 1px; margin: 20px 0; background: rgba(255,255,255,0.08); }

/* ── Auth ── */
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; color: var(--portal-green); font-size: 13px; }

/* ── Empty state ── */
.empty-state { padding: 28px 0 12px; text-align: center; }
.empty-state h3 { margin: 0 0 8px; font-size: 20px; color: var(--portal-text); }
.empty-state p { color: var(--portal-soft); font-size: 14px; margin: 0; }
.top-gap { color: var(--portal-soft); font-size: 14px; }

/* ── Note stack (dashboard info panel) ── */
.note-stack { display: grid; gap: 12px; font-size: 14px; color: var(--portal-soft); line-height: 1.6; }
.note-stack p { margin: 0; }
.note-stack code { font-family: ui-monospace, monospace; font-size: 12px; color: var(--portal-muted); }

/* ── Detail back link ── */
.detail-back { margin-bottom: 14px; }
.detail-back a { font-size: 13px; }

/* ── Visibility row ── */
.vis-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ── Share link row ── */
.share-link-row { display: flex; gap: 10px; align-items: stretch; }
.share-input { flex: 1; font-size: 12px; color: var(--portal-muted); cursor: text; }

/* ── Route delete zone ── */
.route-delete-zone { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--portal-stroke); }

/* ── Responsive ── */
@media (max-width: 980px) {
  .metric-grid, .content-grid.two-up { grid-template-columns: 1fr; }
  .portal-nav-meta { margin-left: 0; }
  .detail-hero { flex-direction: column; }
  .detail-actions { justify-content: flex-start; }
  .detail-list div { flex-direction: column; gap: 2px; }
  .detail-list dd { text-align: left; }
}

@media (max-width: 640px) {
  .portal-main { padding: 72px 16px 64px; }
  .public-shell { padding: 72px 16px 64px; }
  .auth-card, .panel { padding: 22px 18px; }
  .portal-nav { padding: 0 14px; }
  .portal-user-chip { display: none; }
  .auth-links { flex-direction: column; }
  .detail-hero { flex-direction: column; }
  .route-card { padding: 16px 18px; }
  .ghost-row-actions { gap: 6px; }
  .portal-map-wrap { aspect-ratio: 4/3; }
}
