:root {
  color-scheme: dark;
  --ink: #ece5d8;
  --ink-soft: #a99f8f;
  --paper: #12100e;
  --paper-2: #1d1915;
  --card: #191613;
  --line: #342d26;
  --line-strong: #4c4237;
  --accent: #cf6244;
  --accent-dark: #e37c5b;
  --accent-soft: #3b221b;
  --gold: #d1a25a;
  --ok: #7fd0a3;
  --ok-soft: #163228;
  --danger: #f09386;
  --danger-soft: #3a1d1a;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -5%, rgba(207, 98, 68, 0.13) 0, transparent 42%),
    radial-gradient(circle at 100% 5%, rgba(209, 162, 90, 0.08) 0, transparent 38%),
    var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(207, 98, 68, 0.38);
  color: #fff;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3, .brand-name {
  font-family: var(--serif);
  line-height: 1.15;
  margin: 0 0 0.5em;
  font-weight: 700;
}

p { margin: 0 0 1em; }

/* Fluido de lado a lado: nunca franjas vacías a los costados. */
.container {
  width: 100%;
  margin: 0;
  padding-inline: clamp(18px, 3vw, 56px);
}

/* ---------- Top bar ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(18, 16, 14, 0.86);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .container {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
}

.brand:hover { color: var(--ink); }

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(145deg, #211c17, #15120f);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.brand-mark svg { width: 22px; height: 22px; }

.brand-name {
  font-size: 21px;
  letter-spacing: 0.02em;
  margin: 0;
}

.brand-name span { color: var(--accent); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 18px;
  font: 600 14px/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.btn-secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-secondary:hover { background: var(--paper-2); color: var(--ink); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
  padding-left: 12px;
  padding-right: 12px;
}

.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }

.btn-block { width: 100%; }
.btn-lg { padding: 13px 24px; font-size: 15px; }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Landing ---------- */
.hero { padding: 84px 0 64px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 560px);
  gap: clamp(32px, 4vw, 72px);
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 18px;
}

.eyebrow::before {
  content: '';
  width: 26px;
  height: 1px;
  background: var(--accent);
}

.hero h1 {
  font-size: clamp(40px, 6vw, 64px);
  letter-spacing: -0.015em;
  margin-bottom: 20px;
}

.hero h1 em {
  color: var(--accent);
  font-style: italic;
}

.hero-lead {
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 58ch;
  margin-bottom: 30px;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.hero-art {
  position: relative;
  width: 100%;
  max-width: 560px;
  justify-self: end;
  aspect-ratio: 1 / 1.02;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(32, 27, 22, 0.97), rgba(20, 17, 14, 0.95)),
    repeating-linear-gradient(45deg, transparent 0 14px, rgba(209, 162, 90, 0.09) 14px 15px);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.hero-art::before,
.hero-art::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(138, 47, 36, 0.18);
}

.hero-art::before { inset: 34px; }
.hero-art::after { inset: 56px; border-style: dashed; }

.compass {
  width: 54%;
  color: var(--accent);
  opacity: 0.88;
}

.hero-art-caption {
  position: absolute;
  bottom: 22px;
  left: 24px;
  right: 24px;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.features { padding: 20px 0 84px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(25, 22, 19, 0.72);
  padding: 24px;
}

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}

.feature h3 { font-size: 18px; margin-bottom: 8px; }
.feature p { color: var(--ink-soft); font-size: 14px; margin: 0; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 26px 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- Auth pages ---------- */
/* Split a sangre: panel ilustrado fluido + panel de formulario de ancho cómodo.
   El panel del formulario ocupa todo el alto y el resto lo llena la ilustración,
   así no quedan franjas vacías a los costados. */
.auth-main {
  min-height: calc(100vh - 69px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(620px, 100%);
  align-items: stretch;
}

.auth-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: clamp(24px, 5vh, 56px);
  padding: clamp(32px, 5vw, 88px);
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 18% 12%, rgba(207, 98, 68, 0.16) 0, transparent 55%),
    repeating-linear-gradient(45deg, transparent 0 18px, rgba(209, 162, 90, 0.06) 18px 19px),
    var(--paper-2);
  overflow: hidden;
}

.auth-aside-art {
  display: grid;
  place-items: center;
  color: var(--accent);
  opacity: 0.9;
}

.auth-aside-art .compass {
  width: clamp(150px, 18vw, 320px);
}

.auth-aside-quote {
  font-family: var(--serif);
  font-size: clamp(22px, 2.1vw, 36px);
  line-height: 1.25;
  color: var(--ink);
  margin: 0;
  max-width: 24ch;
}

.auth-aside-quote span { color: var(--accent); font-style: italic; }

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--card);
  border-top: 3px solid var(--accent);
  padding: clamp(32px, 4vw, 72px) clamp(24px, 3.5vw, 56px);
}

.auth-card h1 {
  font-size: clamp(28px, 3.2vw, 38px);
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--ink-soft);
  font-size: 15px;
  margin-bottom: 26px;
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 7px;
}

.field .hint {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 400;
  margin-left: 4px;
}

.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #141210;
  color: var(--ink);
  padding: 11px 13px;
  font: 15px/1.4 var(--sans);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 47, 36, 0.12);
}

.input-code {
  text-align: center;
  font-size: 28px;
  letter-spacing: 0.42em;
  font-weight: 700;
  padding: 13px 10px 13px 20px;
  font-family: 'Consolas', 'Courier New', monospace;
}

.auth-footer {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
}

.alert {
  display: none;
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.alert.show { display: block; }

.alert-error {
  background: var(--danger-soft);
  border-color: #6b342e;
  color: var(--danger);
}

.alert-success {
  background: var(--ok-soft);
  border-color: #2f5c48;
  color: var(--ok);
}

.alert-info {
  background: #201b16;
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.code-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-soft);
  margin: -4px 0 18px;
}

.code-meta strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.code-meta .expired { color: var(--danger); font-weight: 600; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 24px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- Dashboard ---------- */
.dashboard-main {
  padding: 48px 0 80px;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.dashboard-head h1 { font-size: clamp(30px, 4vw, 42px); margin-bottom: 4px; }
.dashboard-head p { color: var(--ink-soft); margin: 0; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 14px 7px 8px;
  font-size: 13px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(25, 22, 19, 0.6);
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 24px;
}

.empty-state-inner { max-width: 440px; }

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  color: var(--accent);
}

.empty-state h2 { font-size: 24px; margin-bottom: 8px; }
.empty-state p { color: var(--ink-soft); font-size: 15px; margin-bottom: 0; }

.muted { color: var(--ink-soft); }
.text-center { text-align: center; }

[hidden] { display: none !important; }

.page-shell {
  width: 100%;
  padding-inline: clamp(18px, 3vw, 56px);
}

/* ---------- Maps dashboard ---------- */
.maps-loading {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: clamp(16px, 2vw, 26px);
}

.map-skeleton {
  min-height: 330px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--card) 30%, var(--paper-2) 50%, var(--card) 70%);
  background-size: 220% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}

@keyframes skeleton {
  0% { background-position: 100% 0; }
  100% { background-position: -120% 0; }
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: clamp(16px, 2vw, 26px);
}

.map-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.map-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.map-card-media {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(circle at 30% 20%, rgba(207, 98, 68, 0.16), transparent 55%),
    var(--paper-2);
  overflow: hidden;
}

.map-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.map-card:hover .map-card-media img { transform: scale(1.025); }

.map-card-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--line-strong);
}

.map-card-body {
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.map-card-body h3 {
  font-size: 20px;
  margin: 0;
  overflow-wrap: anywhere;
}

.map-card-description {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.map-card-meta {
  margin-top: 7px;
  font-size: 12px;
  color: var(--ink-soft);
}

.map-card-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
}

.map-card-actions .btn { padding: 8px 14px; }

.icon-btn {
  margin-left: auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--danger);
  border-color: #6b342e;
  background: var(--danger-soft);
}

.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}

.modal::backdrop {
  background: rgba(5, 4, 3, 0.7);
  backdrop-filter: blur(3px);
}

.modal[open] {
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 36px);
}

.modal-card h2 {
  font-size: 28px;
  margin-bottom: 4px;
}

.modal-subtitle {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 22px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ---------- Editor ---------- */
.editor-body {
  height: 100vh;
  overflow: hidden;
  background: var(--paper);
}

.editor-layout {
  display: flex;
  width: 100%;
  height: 100vh;
}

.editor-panel {
  width: 30%;
  min-width: 310px;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 16px clamp(16px, 1.6vw, 28px) 32px;
  border-right: 1px solid var(--line);
  background: var(--card);
}

.editor-actions {
  position: sticky;
  top: -16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -16px calc(clamp(16px, 1.6vw, 28px) * -1) 0;
  padding: 16px clamp(16px, 1.6vw, 28px) 13px;
  background: linear-gradient(var(--card) 78%, rgba(25, 22, 19, 0));
}

.editor-actions .btn { padding: 9px 15px; }

.unsaved-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.unsaved-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(209, 162, 90, 0.14);
}

.editor-heading { margin: 22px 0 18px; }
.editor-heading .eyebrow { margin-bottom: 10px; }
.editor-heading h1 {
  font-size: clamp(23px, 2vw, 30px);
  margin: 0;
  overflow-wrap: anywhere;
}

.editor-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.editor-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  font: 600 14px/1.2 var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.editor-tab:hover { background: var(--paper-2); color: var(--ink); }

.editor-tab.is-active {
  background: var(--paper-2);
  border-color: var(--line);
  border-left-color: var(--accent);
  color: var(--ink);
}

.editor-tab-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--accent);
}

.editor-panels { flex: 1; }

.editor-tab-panel { animation: panel-in 0.16s ease; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.textarea {
  resize: vertical;
  min-height: 130px;
  font-family: var(--sans);
  line-height: 1.5;
}

.field-help {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
  margin: 7px 0 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}

.segmented button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 6px;
  font: 600 12px/1.2 var(--sans);
  cursor: pointer;
}

.segmented button:hover { color: var(--ink); background: var(--paper-2); }

.segmented button.is-active {
  background: var(--accent-soft);
  border-color: rgba(207, 98, 68, 0.42);
  color: var(--ink);
}

.scale-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 9px;
}

.mini-field { min-width: 0; }

.mini-field span {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 5px;
}

.scale-spacer { width: 36px; }

.chain-btn {
  width: 36px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chain-btn:hover { color: var(--ink); border-color: var(--accent); }

.chain-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.image-current { margin-bottom: 22px; }

.image-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 20%, rgba(207, 98, 68, 0.13), transparent 55%),
    var(--paper-2);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.image-thumb-placeholder { color: var(--ink-soft); font-size: 13px; }

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

.file-input {
  padding: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.file-input::file-selector-button {
  margin-right: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper-2);
  color: var(--ink);
  padding: 7px 12px;
  font: 600 12px var(--sans);
  cursor: pointer;
}

.editor-panels > .field-help { margin-top: 10px; }

/* ---------- Map workspace ---------- */
.map-workspace {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100vh;
  background: #0b0a09;
  overflow: hidden;
}

.map-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.025), transparent 60%),
    #0b0a09;
}

.map-stage.is-dragging { cursor: grabbing; }

.map-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  height: 100%;
  width: auto;
  max-width: none;
  display: block;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

.map-canvas.is-hidden { display: none; }

.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  color: var(--ink-soft);
}

.map-empty-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-2);
  color: var(--accent);
  margin: 0 auto 16px;
}

.map-empty h2 {
  color: var(--ink);
  font-size: 23px;
  margin-bottom: 6px;
}

.map-empty p { font-size: 14px; margin: 0; }

.map-zoom,
.map-reset {
  position: absolute;
  bottom: 16px;
  z-index: 4;
  border: 1px solid var(--line-strong);
  background: rgba(25, 22, 19, 0.88);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  font: 600 12px/1.2 var(--sans);
  backdrop-filter: blur(6px);
}

.map-zoom { left: 16px; font-variant-numeric: tabular-nums; }

.map-reset {
  right: 16px;
  cursor: pointer;
}

.map-reset:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Crop ---------- */
.crop-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.03), transparent 60%),
    #0b0a09;
  touch-action: none;
}

.crop-stage.is-hidden { display: none; }

.crop-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.crop-box {
  position: absolute;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 9999px rgba(5, 4, 3, 0.68);
  cursor: move;
  touch-action: none;
}

.crop-box::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px dashed rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

.crop-handle {
  position: absolute;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(5, 4, 3, 0.6);
}

.crop-handle-nw { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-handle-ne { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-handle-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-handle-se { right: -8px; bottom: -8px; cursor: nwse-resize; }

.crop-toolbar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 6;
  width: max-content;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(25, 22, 19, 0.94);
  color: var(--ink-soft);
  padding: 10px 12px;
  font-size: 12px;
  backdrop-filter: blur(8px);
}

.crop-toolbar-actions { display: flex; gap: 8px; }
.crop-toolbar .btn { padding: 8px 13px; }

/* ---------- Viewer ---------- */
.viewer-body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.viewer-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 11px clamp(16px, 3vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(18, 16, 14, 0.94);
  backdrop-filter: blur(8px);
}

.viewer-bar-left,
.viewer-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.viewer-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.viewer-title strong {
  font-family: var(--serif);
  font-size: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-title span {
  color: var(--ink-soft);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70ch;
}

.viewer-main {
  position: relative;
  flex: 1;
  min-height: 0;
}

.viewer-stage { position: absolute; inset: 0; }

.viewer-alert {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  display: none;
  border: 1px solid #6b342e;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 11px 15px;
  font-size: 14px;
  max-width: min(560px, calc(100vw - 32px));
}

.viewer-alert.show { display: block; }

@media (max-width: 900px) {
  .editor-layout { flex-direction: column; }
  .editor-panel {
    width: 100%;
    min-width: 0;
    height: 48vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .map-workspace { height: 52vh; }
  .editor-actions { top: -16px; }
  .viewer-bar { align-items: flex-start; }
  .viewer-bar-right { width: 100%; justify-content: flex-end; }
}

@media (max-width: 1024px) {
  .auth-main { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
}

@media (max-width: 860px) {
  .hero { padding: 56px 0 40px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .hero-art { max-width: 460px; margin: 0 auto; width: 100%; justify-self: center; }
  .feature-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .container { padding-inline: 14px; }
  .site-header .container { min-height: 62px; flex-wrap: wrap; row-gap: 8px; }
  .brand-name { font-size: 18px; white-space: nowrap; }
  .nav-actions { gap: 6px; margin-left: auto; }
  .nav-actions .btn { padding: 9px 12px; font-size: 13px; }
  .nav-actions .btn-ghost { display: none; }
  .user-chip { padding: 4px; gap: 0; }
  .user-chip > span:last-child { display: none; }
  .auth-card { padding: 30px 20px 44px; }
  .auth-main { min-height: calc(100vh - 63px); }
  .hero h1 { font-size: 38px; }
  .hero-lead { font-size: 16px; }
  .dashboard-head h1 { font-size: 30px; }
  .map-card-actions .btn { flex: 1; }
  .viewer-bar { padding: 9px 14px; }
  .viewer-bar-right .btn-ghost { display: none; }
  .crop-toolbar { width: calc(100% - 24px); }
}
