@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@600;700&display=swap');
/* ============================================================
   free.css  –  MapMaker Free poster generator
   ============================================================ */

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

html, body, #app {
  height: 100%;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  background: #edeae3;
  color: #2b2b2b;
}

a { color: #5f8d74; }

/* ── Header ── */
#free-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 18px;
  background: #ffffff;
  border-bottom: 1px solid #ddd8cd;
  gap: 12px;
}
.fh-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
#free-brand { font-family: 'Quicksand','Montserrat',sans-serif; font-size: 22px; font-weight: 700; letter-spacing: -.2px; color: #2d3251; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
#free-brand em { font-style: normal; color: #468c7c; }
.brand-mark { height: 26px; width: auto; flex: none; }
.fh-tag { font-size: 12px; color: #8a857a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pro-link {
  font-size: 12px; font-weight: 600; text-decoration: none;
  color: #5f8d74; background: #e3f1ee;
  padding: 7px 12px; border-radius: 6px; white-space: nowrap;
}
.pro-link:hover { background: #d2e8e3; }

/* ── grouped editor nav ── */
.fh-right { display: flex; align-items: center; gap: 10px; }
.editor-nav {
  display: inline-flex; align-items: center;
  background: #f0eee8; border: 1px solid #ddd8cd;
  border-radius: 8px; padding: 2px; gap: 2px;
}
.editor-nav .nav-btn {
  font-size: 12px; font-weight: 600; text-decoration: none;
  color: #6d685e; background: transparent;
  padding: 6px 11px; border-radius: 6px; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.editor-nav .nav-btn:hover { color: #2b2b2b; background: #e3e0d6; }
.editor-nav .nav-btn.active {
  color: #fff; background: #5f8d74; cursor: default;
}
.nav-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #b3ab9a; margin-right: 2px;
}
.nav-divider { width: 1px; height: 26px; background: #ddd8cd; margin: 0 4px; }

/* ── Layout ── */
#free-main {
  display: flex;
  height: calc(100% - 52px);
  overflow: hidden;
}

/* ── Controls ── */
#mm-sheet-head { display: none; }   /* phone-only sheet header (shown via the max-width:740px block) */
#free-controls {
  width: 300px;
  min-width: 280px;
  background: #ffffff;
  border-right: 1px solid #ddd8cd;
  overflow-y: auto;
  padding: 14px;
  flex-shrink: 0;
}
/* ── #7: left category icon rail (Canva-style) — groups the sidebar ── */
#cat-rail {
  width: 70px; flex-shrink: 0; background: #f6f2e9;
  border-right: 1px solid #ddd8cd; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; padding: 8px 6px;
}
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: transparent; cursor: pointer; border-radius: 9px;
  padding: 9px 4px; color: #6b6450; font-family: inherit;
  font-size: 10px; font-weight: 600; line-height: 1.15; text-align: center;
  transition: background .12s ease, color .12s ease;
}
.cat-btn .cat-ico { font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.cat-btn .cat-ico svg { width: 22px; height: 22px; display: block; }
.cat-btn:hover { background: #ece5d4; color: #3a3526; }
.cat-btn.active { background: #1f7a6b; color: #fff; box-shadow: 0 2px 6px rgba(31,122,107,0.3); }
.cat-hidden { display: none !important; }
/* one-click Styles gallery (top of the controls) */
#styles-gallery-wrap { margin-bottom: 16px; }
#styles-gallery-wrap > h3 { font-family: 'Playfair Display', Georgia, serif; font-size: 15px; margin: 0 0 8px; }
.styles-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 5px; }
.style-tile { flex: 0 0 auto; width: 66px; cursor: pointer; border: 2px solid transparent; border-radius: 9px; padding: 3px; background: #fff; }
.style-tile:hover { border-color: #d8d0c0; }
.style-tile.active { border-color: #1f7a6b; }
.style-tile .sw { display: flex; height: 36px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .08); }
.style-tile .sw i { flex: 1; }
.style-tile .nm { font-size: 9.5px; text-align: center; margin-top: 3px; color: #6b6450; line-height: 1.15; }
.styler-shuffle { margin-top: 8px; width: 100%; }
.ctl-group { margin-bottom: 18px; }
.ctl-group h3 {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: #5f8d74; margin-bottom: 8px;
  border-bottom: 1px solid #eee9de; padding-bottom: 4px;
}
/* Section headers are STATIC text — same look as the base .ctl-group h3 everywhere (the
   clickable bar + ▾ caret treatment was removed per design feedback). The .collapsed hiding
   rule stays for anything that still collapses programmatically. */
#free-controls.accordion .ctl-group.collapsed > h3 { margin-bottom: 0; }
#free-controls.accordion .ctl-group.collapsed > :not(h3) { display: none !important; }

/* golf surface rows: toggle + label on the left, recolor swatch on the right */
.golf-feat-row { display: flex; align-items: center; gap: 8px; }
.golf-feat-row .gf-toggle { flex: 1; margin: 0; }
.golf-feat-row .golf-color { width: 30px; height: 22px; flex-shrink: 0; padding: 0; border: 1px solid #d4cfc3; border-radius: 5px; background: none; cursor: pointer; }
.golf-feat-row .golf-color::-webkit-color-swatch-wrapper { padding: 2px; }
.golf-feat-row .golf-color::-webkit-color-swatch { border: none; border-radius: 3px; }

/* golf draw mode: sketch fairways/greens for courses not in OSM */
.golf-draw-block { margin-top: 4px; }
.golf-draw-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.golf-draw-btns button { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 5px 9px; border: 1px solid #d4cfc3; border-radius: 6px; background: #fff; cursor: pointer; }
.golf-draw-btns button:hover { background: #f4f0e6; }
.golf-draw-btns button.active { background: #5f8d74; color: #fff; border-color: #5f8d74; }
.golf-draw-btns .gd-sw, .golf-draw-item .gd-sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.18); flex-shrink: 0; }
.golf-draw-active { font-size: 12px; background: #f4f0e6; border: 1px solid #e4ded2; border-radius: 6px; padding: 7px 9px; margin-bottom: 6px; }
.golf-draw-active button { font-size: 12px; padding: 3px 8px; margin-left: 4px; border: 1px solid #d4cfc3; border-radius: 5px; background: #fff; cursor: pointer; }
.golf-draw-active #golf-draw-finish { background: #5f8d74; color: #fff; border-color: #5f8d74; }
.golf-draw-list { display: flex; flex-direction: column; gap: 3px; }
.golf-draw-item { display: flex; align-items: center; gap: 7px; font-size: 12px; padding: 3px 5px; border-radius: 5px; }
.golf-draw-item:hover { background: #f4f0e6; }
.golf-draw-item .gd-del { margin-left: auto; border: none; background: none; color: #b23; cursor: pointer; font-size: 13px; padding: 0 4px; }
.ctl-label {
  display: block; font-size: 11px; font-weight: 600;
  color: #6d685e; margin: 8px 0 3px;
}
.slider-label { display: flex; justify-content: space-between; }
.slider-label b { color: #5f8d74; }
.ctl-check { display: block; font-size: 12px; color: #4b463d; margin-top: 7px; cursor: pointer; }
.ctl-check input { margin-right: 6px; accent-color: #5f8d74; }
.ctl-hint { font-size: 11px; color: #8a857a; line-height: 1.5; margin-top: 8px; }

input[type="text"], select {
  width: 100%; padding: 7px 9px;
  border: 1px solid #d4cfc3; border-radius: 6px;
  font-size: 13px; font-family: inherit;
  background: #faf9f6; color: #2b2b2b;
}
input[type="text"]:focus, select:focus { outline: none; border-color: #5f8d74; }
input[type="range"] { width: 100%; accent-color: #5f8d74; margin: 2px 0 4px; }

/* Buttons */
.fbtn {
  padding: 7px 13px;
  border: 1px solid #d4cfc3; border-radius: 6px;
  background: #faf9f6; color: #2b2b2b;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
}
.fbtn:hover { background: #f0eee8; }
.fbtn-primary { background: #5f8d74; border-color: #5f8d74; color: #fff; }
.fbtn-primary:hover { background: #4b7560; }
.fbtn-full { width: 100%; margin-top: 9px; padding: 10px; font-size: 14px; }
.fbtn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Mode cards */
.mode-cards { display: flex; flex-direction: column; gap: 6px; }
.mode-card {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  align-items: center; text-align: left;
  gap: 0 8px; padding: 8px 10px;
  border: 1.5px solid #ddd8cd; border-radius: 8px;
  background: #faf9f6; cursor: pointer; font-family: inherit;
}
.mode-card:hover { border-color: #b9b2a2; }
.mode-card.active { border-color: #5f8d74; background: #e3f1ee; }
.mode-glyph { grid-row: span 2; font-size: 22px; text-align: center; }
.mode-name { font-size: 13px; font-weight: 700; color: #2b2b2b; }
.mode-desc { font-size: 11px; color: #8a857a; }

/* Search */
.search-row { display: flex; gap: 6px; }
.search-row input { flex: 1; }
#search-results {
  list-style: none; margin-top: 6px;
  border: 1px solid #ddd8cd; border-radius: 6px;
  overflow: hidden; background: #fff;
  max-height: 180px; overflow-y: auto;
}
#search-results li {
  padding: 7px 10px; font-size: 12px; cursor: pointer;
  border-bottom: 1px solid #f0ede5; line-height: 1.35;
}
#search-results li:last-child { border-bottom: none; }
#search-results li:hover { background: #e3f1ee; }
#search-results li .res-type {
  display: inline-block; font-size: 10px; font-weight: 700;
  color: #5f8d74; text-transform: uppercase; margin-right: 5px;
}
.picked {
  margin-top: 8px; padding: 8px 10px;
  background: #e3f1ee; border-radius: 6px;
  font-size: 12px; color: #14443d; line-height: 1.4;
}
.picked b { display: block; font-size: 13px; }

/* Theme swatches */
#occasion-grid, #template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.slot-row {
  border: 1px solid #eee9de; border-radius: 7px;
  padding: 8px; margin-bottom: 8px;
}
.slot-row .slot-title {
  font-size: 11px; font-weight: 700; color: #5f8d74;
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px;
}
.slot-row .search-row { margin-bottom: 5px; }
.slot-row input[type="text"] { margin-bottom: 5px; }
.slot-results {
  list-style: none; margin: 0 0 5px; padding: 0;
  border: 1px solid #ddd8cd; border-radius: 6px; overflow: hidden;
  background: #fff; max-height: 130px; overflow-y: auto;
}
.slot-results li { padding: 6px 8px; font-size: 11px; cursor: pointer; border-bottom: 1px solid #f0ede5; line-height: 1.3; }
.slot-results li:last-child { border-bottom: none; }
.slot-results li:hover { background: #e3f1ee; }
.slot-picked { font-size: 11px; color: #14443d; background: #e3f1ee; border-radius: 5px; padding: 4px 7px; margin-bottom: 5px; }
.occasion-btn {
  font-size: 11px; font-weight: 600; font-family: inherit;
  color: #4b463d; background: #faf9f6;
  border: 1.5px solid #ddd8cd; border-radius: 7px;
  padding: 8px 4px; cursor: pointer; line-height: 1.25;
  transition: background 0.12s, border-color 0.12s;
}
.occasion-btn:hover { border-color: #5f8d74; background: #e3f1ee; }
.occasion-btn.active { border-color: #5f8d74; background: #5f8d74; color: #fff; }

#shape-size-wrap { margin: 4px 0 12px; }
.shape-size-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 2px;
}
.shape-size-hint { font-size: 10.5px; color: #8a857a; white-space: nowrap; }
.shape-size-row .fbtn { padding: 5px 9px; font-size: 11px; }

#theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

/* 3D stacked-layer preview overlay */
#td-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: #12151b; display: flex; flex-direction: column;
}
#td-overlay .td-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; background: #1c2128; color: #e9e6df;
  border-bottom: 1px solid #2c333d; flex-shrink: 0;
}
#td-overlay .td-title { font-size: 13px; font-weight: 700; }
#td-overlay .td-hint { font-size: 11px; color: #8a93a0; }
#td-overlay .td-status { font-size: 12px; color: #e0b35a; margin-left: auto; }
#td-overlay .td-close {
  margin-left: 12px; font: inherit; font-size: 12px; font-weight: 600;
  color: #e9e6df; background: #2c333d; border: 1px solid #3a424d;
  border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
#td-overlay .td-close:hover { background: #3a424d; }
#td-overlay .td-stage { flex: 1; min-height: 0; position: relative; }
#td-overlay .td-stage canvas { display: block; }

/* custom poster size inputs */
#custom-size-row { margin-top: 6px; }
.mm-row { display: flex; gap: 8px; align-items: center; }
.mm-row input[type="number"] {
  width: 72px; padding: 7px 9px;
  border: 1px solid #d4cfc3; border-radius: 6px;
  font-size: 13px; font-family: inherit;
  background: #faf9f6; color: #2b2b2b;
}
.size-unit { font-size: 11px; color: #8a857a; }

/* custom presets */
.preset-save-row { display: flex; gap: 6px; margin-bottom: 8px; }
.preset-save-row input { flex: 1; }
.preset-btn {
  position: relative;
  font-size: 11px; font-weight: 600; font-family: inherit;
  color: #4b463d; background: #faf9f6;
  border: 1.5px solid #ddd8cd; border-radius: 7px;
  padding: 8px 18px 8px 8px; cursor: pointer; line-height: 1.25;
  text-align: left; width: 100%;
}
.preset-btn:hover { border-color: #5f8d74; background: #e3f1ee; }
.preset-del {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  border: none; background: transparent; color: #b3360b;
  font-size: 14px; line-height: 1; cursor: pointer; padding: 2px 4px;
}
#preset-grid { display: flex; flex-direction: column; gap: 5px; }

/* custom feature color pickers */
#color-grid, .color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  margin-bottom: 10px;
}
.color-pick {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 600; color: #6d685e; gap: 6px;
}
.color-pick input[type="color"] {
  width: 32px; height: 22px; padding: 1px; flex-shrink: 0;
  border: 1px solid #d4cfc3; border-radius: 5px;
  background: #faf9f6; cursor: pointer;
}

/* topographic color-style swatches */
#topostyle-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.topo-swatch {
  position: relative;
  height: 40px; border-radius: 7px;
  border: 2px solid #ddd8cd; cursor: pointer;
  overflow: hidden; padding: 0; font-family: inherit;
}
.topo-swatch.active { border-color: #5f8d74; box-shadow: 0 0 0 2px rgba(95, 141, 116,0.25); }
.topo-swatch .ts-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 8px; font-weight: 700; text-align: center;
  text-transform: uppercase; letter-spacing: 0.03em;
  background: rgba(255,255,255,0.82); color: #2b2b2b; padding: 1px 0;
}
.theme-swatch {
  position: relative;
  height: 44px; border-radius: 7px;
  border: 2px solid #ddd8cd; cursor: pointer;
  overflow: hidden; padding: 0; font-family: inherit;
}
.theme-swatch.active { border-color: #5f8d74; box-shadow: 0 0 0 2px rgba(95, 141, 116,0.25); }
.theme-swatch .sw-water {
  position: absolute; left: 18%; right: 18%; top: 30%; bottom: 42%;
  border-radius: 40% 55% 50% 45%;
}
.theme-swatch .sw-name {
  position: absolute; left: 0; right: 0; bottom: 2px;
  font-size: 8px; font-weight: 700; text-align: center;
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* Per-mode visibility */
[data-modes] { display: none; }
[data-modes].mode-on { display: block; }

/* Markers */
.marker-row { display: flex; gap: 6px; }
.marker-btn {
  flex: 1; height: 38px;
  font-size: 19px; line-height: 1;
  border: 1.5px solid #ddd8cd; border-radius: 8px;
  background: #faf9f6; cursor: pointer;
  color: #4b463d;
}
.marker-btn:hover { border-color: #5f8d74; background: #e3f1ee; }
.marker-color-row {
  display: flex; align-items: center; justify-content: space-between;
}
.marker-color-row input[type="color"] {
  width: 44px; height: 26px; padding: 1px;
  border: 1px solid #d4cfc3; border-radius: 5px;
  background: #faf9f6; cursor: pointer;
}

.hidden { display: none !important; }
.hidden-file { display: none; }

/* ── Preview ── */
#free-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
  padding: 22px 22px 10px;
}
#poster-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}
.wide-gen-btn {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 20; padding: 10px 18px; border: none; border-radius: 8px;
  background: #5f8d74; color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: 0 4px 16px rgba(40, 34, 20, 0.32);
}
.wide-gen-btn:hover { background: #0c6358; }
#poster-canvas {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  box-shadow: 0 10px 36px rgba(40, 34, 20, 0.28);
  background: #fff;
  cursor: grab;
}
#poster-canvas.panning { cursor: grabbing; }
/* Laser editors render an inline <svg id="laser-svg"> here instead of the canvas.
   It needs an explicit rendered size (paired with width/height attrs set in render()),
   or Safari/WebKit collapses an SVG sized only by viewBox to 0×0 and the map vanishes. */
#laser-svg {
  height: auto;   /* viewBox drives the height from the definite width below */
  width: min(100%, calc((100vh - 140px) * var(--ar, 1)));
  max-height: calc(100vh - 140px);
}
#poster-status {
  position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.94);
  border: 1px solid #ddd8cd; border-radius: 10px;
  padding: 18px 28px;
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 600; color: #4b463d;
  box-shadow: 0 6px 22px rgba(40,34,20,0.18);
  max-width: 80%;
}
.fspinner {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 3px solid #ddd8cd; border-top-color: #5f8d74;
  border-radius: 50%;
  animation: fspin 0.8s linear infinite;
}
@keyframes fspin { to { transform: rotate(360deg); } }
#poster-status.status-error .fspinner { display: none; }
#poster-status.status-error { color: #93312b; }
#poster-status.no-spin .fspinner { display: none; }   /* instructional prompts (e.g. tracing) — not a loading state */
#poster-status.no-spin .ps-bar { display: none; }      /* …and no progress bar either — nothing is loading */
/* instructional hints sit at the top so they don't block the area you're clicking/tracing */
#poster-status.no-spin {
  top: 18px; bottom: auto; transform: translateX(-50%);
  padding: 11px 20px; border-radius: 999px;
  background: rgba(255,255,255,0.96);
}

#free-foot {
  padding: 10px 0 4px;
  font-size: 10.5px; color: #9b968b; text-align: center;
}
#free-foot a { color: #8a857a; }

.frame-lbl { width: 46px; flex-shrink: 0; font-size: 12px; font-weight: 600; color: #6d685e; }
.laser-marker, .laser-svg-text { cursor: move; }

/* uploaded-icon palette (laser editors) */
.icon-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px;
}
.icon-cell {
  position: relative; aspect-ratio: 1 / 1; border: 1px solid #d9d3c7; border-radius: 7px;
  background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 5px; overflow: hidden;
}
.icon-cell:hover { border-color: #2f6f5b; box-shadow: 0 0 0 2px rgba(47,111,91,0.18); }
.icon-cell img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.icon-del {
  position: absolute; top: -1px; right: -1px; width: 16px; height: 16px; line-height: 14px;
  border: none; border-radius: 0 6px 0 6px; background: rgba(192,57,43,0.9); color: #fff;
  font-size: 12px; cursor: pointer; padding: 0;
}

/* per-label editor panel (laser editors: road/place/area name size/rotate/text) */
.label-edit {
  border: 1px solid #d9d3c7; border-radius: 8px;
  padding: 8px 10px; margin-top: 8px; background: #faf8f3;
}
.label-edit input[type="text"] { width: 100%; box-sizing: border-box; margin-bottom: 4px; }

/* ── editor toolbar: Undo / Redo / Save + autosave status (header .fh-right) ── */
.editor-tools { display: flex; align-items: center; gap: 6px; margin-right: 12px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  padding: 7px 11px; border: 1px solid #d4cfc3; border-radius: 7px;
  background: #faf9f6; color: #2b2b2b; cursor: pointer; white-space: nowrap;
}
.tool-btn svg { width: 15px; height: 15px; flex: 0 0 15px; }
.tool-btn:hover:not(:disabled) { background: #fff; border-color: #b9b2a3; }
.tool-btn:disabled { opacity: .38; cursor: default; }
.tool-btn-icon { padding: 7px; }
.tool-btn-accent { background: #5f8d74; border-color: #5f8d74; color: #fff; }
.tool-btn-accent:hover:not(:disabled) { background: #0c6457; border-color: #0c6457; }
.editor-tools .mx-sep { width: 1px; height: 20px; background: #e0dbcf; margin: 0 3px; display: inline-block; }
.lock-toggle .cat-ico { display: inline-flex; align-items: center; }
.lock-toggle .cat-ico svg { width: 15px; height: 15px; }
.lock-toggle.active { background: #e3f1ee; border-color: #bfe0d6; color: #0c6457; }
.autosave-status {
  font-size: 11px; color: #8a857a; min-width: 92px; text-align: right;
  white-space: nowrap;
}
.autosave-status.ok { color: #5f8d74; }
.autosave-status.warn { color: #b5532a; }
/* keep Undo/Redo/Save visible; shed lower-priority header items as it narrows */
@media (max-width: 1200px) { .fh-tag { display: none; } }
@media (max-width: 1100px) { #free-header .fh-right .editor-nav { display: none; } }
@media (max-width: 1000px) { #free-header .pro-link { display: none; } }
/* drop secondary cross-links (My Maps / Market) before they collide with tools */
@media (max-width: 980px) { #free-header .fh-left .editor-nav a:nth-last-of-type(-n+2) { display: none; } }
@media (max-width: 900px) {
  .autosave-status { display: none; }
  .editor-tools { margin-right: 8px; gap: 4px; }
  .editor-tools .tool-btn { padding: 6px 8px; font-size: 12px; }
  #free-header .nav-group-label { display: none; }
}

/* ── Seller dashboard left rail (injected by dashboard.js on account pages) ── */
#seller-nav {
  position: fixed; left: 0; top: 0; bottom: 0; width: 220px; z-index: 60;
  background: #faf8f3; border-right: 1px solid #e4ded2;
  padding: 12px 10px 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
#seller-nav .sn-brand {
  display: flex; align-items: center; gap: 7px; text-decoration: none;
  font-weight: 800; font-size: 17px; color: #2b2b2b; padding: 4px 8px 10px;
}
#seller-nav .sn-brand em { color: #5f8d74; font-style: normal; }
#seller-nav .sn-sec {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #b3ab9a; margin: 12px 8px 4px;
}
#seller-nav .sn-link {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px;
  border-radius: 8px; text-decoration: none; color: #5b5547;
  font-size: 13.5px; font-weight: 600; transition: background 0.12s, color 0.12s;
}
#seller-nav .sn-link:hover { background: #efe9dd; color: #2b2b2b; }
#seller-nav .sn-link.active { background: #e3f1ee; color: #0c6457; }
#seller-nav .sn-ic { width: 18px; text-align: center; flex-shrink: 0; }
body.has-seller-nav #app { margin-left: 220px; }
/* declutter the top header on dashboard pages — keep account, drop the duplicate brand + section links */
body.has-seller-nav #free-header #free-brand,
body.has-seller-nav #free-header .editor-nav .nav-btn,
body.has-seller-nav #free-header .nav-group-label,
body.has-seller-nav #free-header .nav-divider,
body.has-seller-nav #free-header .fh-tag { display: none !important; }
@media (max-width: 820px) {
  #seller-nav { position: static; width: auto; inset: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 4px; padding: 8px; border-right: none; border-bottom: 1px solid #e4ded2; }
  #seller-nav .sn-sec, #seller-nav .sn-brand { display: none; }
  body.has-seller-nav #app { margin-left: 0; }
}

/* ── 📱 phone shell (both editors): map full-screen, rail docks to the bottom,
      controls slide up as a sheet (body.mm-panel-open ← js/mobile.js) ── */
#mm-panel-close, #mm-sheet-head { display: none; }
@media (max-width: 740px) {
  #free-main { position: relative; }
  #free-preview { width: 100%; }
  #cat-rail {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; z-index: 45;
    flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden;
    border-right: none; border-top: 1px solid #eceae4; background: #fff;
    box-shadow: 0 -6px 22px rgba(40, 34, 20, 0.08);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 4px;
  }
  #cat-rail .cat-btn { min-width: 64px; padding: 7px 8px; flex-shrink: 0; border-radius: 12px; }
  #cat-rail .cat-btn .cat-ico { font-size: 24px; }
  #cat-rail .cat-btn .cat-lbl { font-size: 11px; font-weight: 600; }
  #free-controls {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; min-width: 0;
    height: 50vh; max-height: 50vh; z-index: 46; border-right: none; border-top: 1px solid #ddd8cd;
    border-radius: 16px 16px 0 0; box-shadow: 0 -12px 34px rgba(0, 0, 0, 0.2);
    transform: translateY(110%);
    padding: 0 14px calc(66px + env(safe-area-inset-bottom));   /* header supplies the top gap */
  }
  body.mm-panel-open #free-controls { transform: translateY(0) !important; }
  #free-controls .fbtn, #free-controls select, #free-controls input[type=text], #free-controls input[type=number] { min-height: 40px; }
  /* sticky sheet header (mockup): grab handle + tool title + a clear ✕ to minimize */
  #mm-sheet-head {
    display: flex; align-items: center; gap: 10px; position: relative;
    position: sticky; top: 0; z-index: 8;
    margin: 0 -14px 8px; padding: 16px 14px 10px;
    background: #fff; border-radius: 16px 16px 0 0; border-bottom: 1px solid #eef0ee;
  }
  #mm-sheet-head .mm-grab {                    /* Canva-style grab notch, centered, tappable */
    position: absolute; left: 50%; top: 6px; transform: translateX(-50%);
    width: 44px; height: 5px; border-radius: 3px; background: #d5dad7; cursor: pointer;
  }
  #mm-sheet-head .mm-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; color: #212b26;
    font-family: 'Montserrat', sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* the Save/Copy bar scrolls under the header now — no longer the sticky top row */
  #free-controls #top-save-bar { position: static; }
  #mm-panel-close {
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; width: 36px; height: 36px; align-self: center;
    border: none; background: #f2f4f2; border-radius: 999px; padding: 0;
    font-family: inherit; font-size: 15px; line-height: 1; font-weight: 600; cursor: pointer; color: #68736d;
  }
  #mm-panel-close:active { background: #e6e9e7; }
  #rail-flyout { display: none !important; }          /* hover flyouts don't exist on touch */
  /* hand ALL touches on the canvas to the editor — the browser's own scroll/zoom gesture
     was fighting our drags (the "text doesn't drag well" jank). #free-preview is the stage
     the pointer bridge (mobile.js) is attached to, so it MUST claim touches too or the page
     pinch-zooms/pans instead of the map. */
  #free-preview, #laser-svg, #poster-canvas, #poster-wrap { touch-action: none; }
  /* keep the editor app-locked — no page scroll / rubber-band "floating" behind the map */
  html:has(#free-main), body:has(#free-main) { overflow: hidden; overscroll-behavior: none; height: 100%; position: relative; }
  /* the emoji topbar hid under Safari's URL bar and eats space — editors run app-like */
  body:has(#free-main) #mapx-topbar { display: none; }
  /* the laser sheet can overflow the phone width — always fit */
  #laser-svg { max-width: calc(100vw - 16px) !important; max-height: 58vh !important; }
  #zoompan { bottom: 160px !important; right: 8px !important; transform: scale(0.9); transform-origin: bottom right; }
  body:has(#free-main) .tc-fb-btn { display: none; }  /* the pill collides with the action bar on phones — feedback lives on desktop */
  .tc-fb-btn { bottom: calc(74px + env(safe-area-inset-bottom)) !important; }   /* clear the docked rail */
  /* selected text/marker → Canva-style action bar docked ABOVE the bottom bar */
  #text-popup {
    top: auto !important; bottom: calc(78px + env(safe-area-inset-bottom)) !important;
    left: 8px !important; right: 8px; transform: none !important;
    max-width: calc(100vw - 16px); border-radius: 16px !important;
    background: #fff; box-shadow: 0 10px 34px rgba(40, 34, 20, 0.22);
    padding: 10px !important;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; justify-content: flex-start;
  }
  #text-popup::-webkit-scrollbar { display: none; }
  #text-popup > * { flex-shrink: 0; }
  #text-popup button, #text-popup select, #text-popup input { font-size: 14px !important; padding: 9px 12px !important; border-radius: 10px !important; }
  #text-popup input[type=color] { width: 42px; height: 38px; padding: 3px !important; }
  #text-popup input[type=number] { width: 62px !important; }
  #poster-wrap { padding-bottom: 72px; }              /* clear the docked rail */

  /* compact header — the icon topbar already gives global nav, so the editor header
     keeps just the brand + account; tools live in the bottom bar */
  #free-header { padding: 4px 8px; gap: 6px; }
  #free-header .editor-nav, #free-header .nav-divider, #free-header .nav-group-label,
  #free-header .fh-tag, #free-header .pro-link,
  #free-header #create-btn { display: none !important; }
  #free-header .editor-tools { margin-right: 0; gap: 3px; }      /* keep Undo/Redo/Save — compact */
  #free-header .editor-tools .tool-btn { padding: 5px 7px; font-size: 11.5px; }
  #cat-rail #rail-toggle { display: none; }                      /* desktop collapse btn — pointless on phones */
  #free-main #cat-rail .editor-tools, #free-main #cat-rail .editor-tools.in-rail {
    flex-direction: row; align-items: center; gap: 3px; flex-shrink: 0; width: auto; margin: 0 4px;
  }
  #free-main #cat-rail .editor-tools .tool-btn, #free-main #cat-rail .editor-tools.in-rail .tool-btn {
    width: auto; padding: 6px 9px; font-size: 11.5px; white-space: nowrap;
  }
  /* mobile top bar = clean & minimal (matches the mobile mockup): logo · name ·
     undo/redo · lock · Export. Everything else is reachable from the bottom tool
     rail, so trim it here instead of letting the toolbar overflow off-screen. */
  #free-header #free-brand { display: inline-flex; flex: 0 0 auto; }
  #free-header #new-map-btn,
  #free-header #top-save-png,
  #free-header #save-top-btn,
  #free-header #rail-text,
  #free-header #rail-del,
  #free-header .editor-tools .mx-sep { display: none !important; }
  #free-header .mx-filebar { flex: 1 1 auto; min-width: 40px; }
  #free-header #mapname { width: 100%; min-width: 0; }
  #free-header .lock-toggle .cat-lbl { display: none; }     /* icon-only lock on phones */
  #free-header .lock-toggle { padding: 7px; }
  #free-header { justify-content: flex-start; }
  #free-header .fh-right { margin-left: auto; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  #free-header .fh-right::-webkit-scrollbar { display: none; }
  #free-header .editor-tools { flex-wrap: nowrap; }
  #free-header .autosave-status { display: none; }
  #free-header .account-slot, #free-header #account-slot { max-width: 150px; }   /* NO overflow:hidden — it clipped the Sign-out dropdown on phones */

  /* bottom bar: buttery left-right scrolling, no scrollbar clutter */
  #cat-rail { -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  #cat-rail::-webkit-scrollbar { display: none; }
}

/* ── 🖐️ floating touch / Apple-Pencil control cluster (both editors) ──
   Reaches Setup, toggles Hold-to-pan, and reuses the editors' Undo / Redo / Delete.
   Hidden by default; shown on touch/pen or narrow viewports via body.mm-touch-tools-on
   (set in js/mobile.js). Docked top-right so it clears the zoom +/- & pan arrows. */
#mm-touch-tools { display: none; }
body.mm-touch-tools-on #mm-touch-tools {
  display: flex; flex-direction: column; gap: 8px;
  position: fixed; top: 108px; right: 10px; z-index: 44;
}
#mm-touch-tools .mm-tt-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 52px; min-height: 48px; padding: 6px 2px;
  border: 1px solid #ddd8cd; border-radius: 12px; background: #fff; color: #4a5450;
  font-family: inherit; font-size: 9.5px; font-weight: 600; line-height: 1.1; cursor: pointer;
  box-shadow: 0 3px 10px rgba(40, 34, 20, 0.14);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
#mm-touch-tools .mm-tt-btn svg { width: 22px; height: 22px; display: block; }
#mm-touch-tools .mm-tt-btn:active { background: #f1efe8; }
#mm-touch-tools .mm-tt-btn.mm-on { background: #1f7a6b; border-color: #1f7a6b; color: #fff; box-shadow: 0 3px 12px rgba(31, 122, 107, 0.4); }
#mm-touch-tools .mm-tt-btn.mm-tt-danger { color: #b4453a; }
#mm-touch-tools .mm-tt-btn.mm-tt-danger:active { background: #fbeeec; }
@media (max-width: 740px) {
  body.mm-touch-tools-on #mm-touch-tools { top: 64px; right: 8px; gap: 6px; }
  #mm-touch-tools .mm-tt-btn { width: 46px; min-height: 44px; }
}
/* On a true MOUSE desktop (fine pointer + hover) the studio chrome keeps its own top-bar
   Undo/Redo + right inspector (Delete) + left Setup panel, so the floating cluster is
   redundant and would overlap the inspector — hide it there. But a touch iPad in landscape
   ALSO renders this ≥761px layout, and that's exactly where an Apple Pencil user needs the
   cluster, so the hide is gated to fine-pointer/hover devices only (never touch). */
@media (min-width: 761px) and (hover: hover) and (pointer: fine) {
  body.mx-studio #mm-touch-tools { display: none !important; }
}
/* iPad-landscape (wide + touch): the inspector docks on the right (~300px reserved), so
   slide the cluster in to sit just LEFT of it instead of on top of it. */
@media (min-width: 761px) {
  body.mm-touch-tools-on.mx-studio #mm-touch-tools { top: 96px; right: 312px; }
}
