/* Crie o seu mapa — interface do editor (identidade Cidades no Quadro).
   Papel branco no painel, parede neutra atrás do pôster, o preto da marca para ação
   e seleção, e o laranja da logo só como destaque pontual (como a rua laranja). */
:root {
  --paper: #ffffff;
  --wall: #ebebe9;
  --ink: #151c1b;
  --muted: #565c66;
  --line: #e4e6ea;
  --soft: #f4f5f7;
  --accent: #151c1b;      /* preto da marca */
  --accent-soft: #e9ebea;
  --brand: #f07444;       /* laranja da logo */
  --radius: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: grid; grid-template-columns: 392px 1fr;
  font: 14px/1.45 'Montserrat', system-ui, sans-serif; color: var(--ink);
  background: var(--wall); -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- painel ---------- */
.panel {
  height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); border-right: 1px solid var(--line);
}
.brand { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 14px; padding: 20px 22px 16px; }
.brand h1 { margin: 0 0 3px; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.brand p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); max-width: 22ch; }
.brand-logo { height: 46px; width: auto; display: block; }

/* abas do tipo de mapa */
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 22px 10px; padding: 4px; background: var(--soft); border-radius: 12px; }
.types button { border: 0; background: none; border-radius: 9px; padding: 9px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1.2; transition: background .15s var(--ease), color .15s; }
.types button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 0 0 1px var(--line); }
.types button:active { transform: scale(.97); }

.tab-tools { display: flex; justify-content: flex-end; margin: -4px 22px 4px; }
.local-ruas { display: grid; gap: 8px; }
.locate { justify-self: start; height: 34px; }

/* passos em sanfona */
.steps { flex: 1; overflow-y: auto; padding: 4px 14px 24px; overscroll-behavior: contain; }
.step { border-radius: var(--radius); margin: 2px 0; }
.step > summary {
  list-style: none; display: grid; grid-template-columns: 24px auto 1fr 14px; align-items: center; gap: 10px;
  padding: 12px 8px; border-radius: var(--radius); cursor: pointer; user-select: none;
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary::after { content: ''; width: 8px; height: 8px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s var(--ease); justify-self: end; }
.step[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.step > summary:hover { background: var(--soft); }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); }
.step[open] .n { background: var(--brand); color: #fff; }
.step .t { font-weight: 600; font-size: 14.5px; }
.step .s { color: var(--muted); font-size: 12.5px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step .body { padding: 4px 8px 16px 42px; display: grid; gap: 12px; }

/* campos */
.field { display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 10px; font-size: 13px; }
.field > span { color: var(--muted); }
.field.stack { grid-template-columns: 1fr; gap: 6px; }
.field.inline-color { grid-template-columns: 112px auto; justify-content: start; }
input:not([type]), input[type=search], select {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
}
input:not([type]):focus, input[type=search]:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center; padding-right: 30px; }
input[type=range] { width: 100%; accent-color: var(--brand); }
input[type=color] { width: 30px; height: 30px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 1px solid rgba(0, 0, 0, .12); border-radius: 50%; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.link { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 600; font-size: 12.5px; justify-self: start; cursor: pointer; text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.ghost { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 0 12px; height: 40px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.ghost:active { transform: scale(.97); }
.with-btn { display: flex; gap: 6px; }

/* busca */
.search { position: relative; }
#results { position: absolute; z-index: 10; top: 46px; left: 0; right: 0; list-style: none; margin: 0; padding: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 24, 40, .14); }
#results li { padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
#results li:hover, #results li.active { background: var(--soft); }
#results li.empty { color: var(--muted); cursor: default; }
#results li.empty:hover { background: none; }
.credit a { color: var(--muted); font-size: 11px; }

/* estilos em bolinhas */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; width: 27px; height: 27px; border-radius: 50%; border: 0; padding: 0; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .12s var(--ease); }
.swatch::before, .dots button::before { content: ''; position: absolute; inset: -8px; } /* área de toque maior que o desenho */
.swatch:active { transform: scale(.9); }
.swatch.on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.sub > summary { cursor: pointer; color: var(--ink); text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 3px; text-decoration-thickness: 1.5px; font-weight: 600; font-size: 12.5px; list-style: none; }
.sub > summary::-webkit-details-marker { display: none; }
.sub[open] > summary { margin-bottom: 10px; }
.colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 6px; margin-bottom: 8px; }
.colors label { display: grid; justify-items: center; gap: 4px; font-size: 11px; color: var(--muted); text-align: center; }

/* layouts como miniaturas */
.layouts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.layout { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 8px 4px 6px; display: grid; justify-items: center; gap: 6px; font-size: 10.5px; font-weight: 600; color: var(--muted); transition: border-color .15s, color .15s; }
.layout svg { width: 34px; height: 46px; }
.layout:active { transform: scale(.96); }
.layout.on { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }

/* chaves liga/desliga */
.toggles { display: grid; gap: 10px; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.toggle input { appearance: none; flex: none; width: 36px; height: 21px; border-radius: 21px; background: #d5d8de; position: relative; cursor: pointer; transition: background .2s var(--ease); margin: 0; }
.toggle input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(15px); }

/* segmentos (tamanho, orientação, marcador) */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--soft); border-radius: 11px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 8px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1.25; }
.seg button small { display: block; font-weight: 500; font-size: 11px; }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 0 0 1px var(--line); }
.seg button:active { transform: scale(.97); }
.dots { display: flex; gap: 10px; }
.dots button { position: relative; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.dots button.on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15), 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }

/* barra de compra: material translúcido sobre o painel */
.buybar {
  position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(18px) saturate(170%); -webkit-backdrop-filter: blur(18px) saturate(170%);
  border-top: 1px solid var(--line);
}
.price strong { display: block; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.price span { font-size: 12px; color: var(--muted); }
.primary { border: 0; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 700; padding: 13px 22px; box-shadow: 0 6px 16px rgba(21, 28, 27, .25); transition: transform .1s var(--ease), box-shadow .15s; }
.primary:active { transform: scale(.97); box-shadow: 0 3px 8px rgba(21, 28, 27, .25); }
.primary:hover { background: #0b100f; }
.primary:disabled { opacity: .6; cursor: progress; }
.status { grid-column: 1 / -1; font-size: 12.5px; }
.status:empty { display: none; }
.status a { color: var(--ink); font-weight: 700; text-decoration-color: var(--brand); }
.status.err { color: #b3261e; }
.file-opts { grid-column: 1 / -1; }
.file-opts > summary { color: var(--muted); font-weight: 500; font-size: 12px; }
.file-opts .field { margin-bottom: 8px; }
.io { display: flex; justify-content: space-between; }

/* ---------- palco ---------- */
main { height: 100vh; overflow-y: auto; padding: 40px 32px 32px; background: radial-gradient(120% 80% at 50% 30%, #f4f4f2 0%, var(--wall) 60%); }
.stage { position: relative; margin-bottom: 48px; }
#frameWrap { position: absolute; left: 50%; top: 0; transform-origin: top center; }
.frame { --frame: #161616; position: relative; line-height: 0; box-shadow: 0 30px 60px -20px rgba(16, 24, 40, .35), 0 8px 20px rgba(16, 24, 40, .12); }
.frame.tradicional { border: 18px solid var(--frame); }
.frame.caixa { border: 26px solid var(--frame); box-shadow: 0 36px 70px -20px rgba(16, 24, 40, .42), 0 10px 24px rgba(16, 24, 40, .16); }
.frame.caixa::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 8px 14px rgba(0, 0, 0, .28), inset 0 -2px 6px rgba(0, 0, 0, .12); pointer-events: none; }
.frame.filete { border: 7px solid var(--frame); }
.frame.placa { box-shadow: 4px 6px 0 #d3d6dc, 0 30px 60px -20px rgba(16, 24, 40, .35); }
.frame.none { box-shadow: 0 18px 40px -16px rgba(16, 24, 40, .3); }
.frame.glass::before { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(115deg, rgba(255, 255, 255, .3) 0%, rgba(255, 255, 255, 0) 32%, rgba(255, 255, 255, 0) 68%, rgba(255, 255, 255, .12) 100%); }
.poster .maplibregl-canvas-container canvas { outline: none; }

.history h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--muted); }
#history { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.card { background: var(--paper); border-radius: 10px; overflow: hidden; font-size: 11.5px; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.card img { width: 100%; display: block; aspect-ratio: 3/4; object-fit: cover; background: var(--soft); }
.card div { padding: 8px 10px; }
.card strong { display: block; font-size: 12.5px; }
.card a { color: var(--ink); margin-right: 8px; font-weight: 600; text-decoration-color: var(--brand); }

/* modo loja (site): sem as ferramentas internas */
.modo-loja .file-opts, .modo-loja .history { display: none !important; }

/* aviso curto (ex.: "Estilo padrão restaurado · Desfazer") */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); white-space: nowrap; }
.toast button { border: 0; background: none; color: var(--brand); font-weight: 700; padding: 6px 4px; }

/* ---------- celular: pôster fixo na metade de cima, passos rolando embaixo ---------- */
@media (max-width: 900px) {
  html, body { height: auto; }
  body { display: flex; flex-direction: column; padding-bottom: 136px; }
  .modo-loja { padding-bottom: 96px; }
  main { order: -1; position: sticky; top: 0; z-index: 5; height: 46vh; height: 46svh; overflow: hidden; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .stage { height: 100%; margin: 0; }
  .history { display: none; }
  .panel { height: auto; border-right: 0; }
  .brand { padding: 14px 16px 10px; }
  .brand h1 { font-size: 18px; }
  .brand-logo { height: 36px; }
  .types { margin: 0 16px 6px; }
  .tab-tools { margin: 0 16px 2px; }
  .steps { overflow: visible; padding: 2px 8px 16px; }
  .step .body { padding-left: 8px; padding-right: 8px; }
  .buybar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .toast { bottom: 88px; }

  /* toque: alvos de pelo menos 44 px */
  .step > summary { padding: 14px 8px; }
  .types button, .seg button { min-height: 44px; }
  input:not([type]), input[type=search], select, .ghost { height: 46px; font-size: 16px; } /* 16 px evita o zoom automático do iPhone */
  input[type=range] { height: 44px; }
  .toggle { min-height: 44px; }
  .link, .sub > summary { display: inline-block; padding: 12px 0; }
  .swatches { gap: 14px; }
  .dots { gap: 16px; }
  .layouts { gap: 6px; }
  .layout { padding: 10px 2px 8px; min-height: 44px; }
  .colors label { min-height: 44px; }
  .primary { padding: 14px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .buybar { background: var(--paper); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
