/* ===== MapCut — tema escuro premium ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  /* cinzas neutros escuros (estilo After Effects) — matte/premium;
     o neon VERDE-CIANO fica reservado para detalhes (bordas, foco, glow) */
  --bg0: #050805;            /* fundo principal (quase preto neutro) */
  --bg1: #0A140C;           /* fundo secundário / painéis */
  --bg2: #0D1C10;            /* cards / elevado */
  --bg3: #122415;            /* inputs */
  --hover: #183018;          /* hover de superfícies */
  --border: rgba(166,255,46,0.08);
  --border-strong: rgba(255,255,255,0.13);   /* borda neutra (estilo AE) */
  --text: #EEFBEA;           /* texto principal (cinza claro neutro) */
  --muted: #94A78F;          /* texto secundário (cinza) */
  --accent: #A6FF2E;         /* neon principal (verde-ciano) */
  --accent2: #C5FF70;        /* neon verde-ciano claro (hover/glow) */
  --cta: #86E01C;            /* verde-ciano fundo (usado só em glow/borda) */
  --grad: linear-gradient(135deg, #86E01C 0%, #A6FF2E 100%);
  --success: #A6FF2E;        /* sucesso / exportar (mesmo neon) */
  --danger: #FF5C7A;         /* erro / alerta (coral) */
  --gold: #FFD166;           /* aviso (âmbar) */
  --glow: 0 0 0 1px rgba(166,255,46,0.4), 0 0 14px rgba(166,255,46,0.28);
  --radius: 8px;
  --shadow-pop: 0 16px 48px rgba(0,0,0,.66), 0 2px 10px rgba(0,0,0,.5);
}

html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg0);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); background-clip: content-box; }

/* ===== Topbar (minimalista, menus suspensos) ===== */
#topbar {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: nowrap;
  height: 50px; padding: 0 12px;
  background: linear-gradient(180deg, #0A140A 0%, #060B06 100%);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 8px; margin-right: 8px; user-select: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  color: #081205;
  box-shadow: 0 2px 10px rgba(166,255,46,0.45);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-size: 15px; font-weight: 500; letter-spacing: .2px; }
.brand-name b { font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.tb-spacer { flex: 1 1 auto; min-width: 8px; }

/* botão de menu (Arquivo / Cena / Exportar) */
.tb-menu { position: relative; flex: 0 0 auto; }
.tb-menu-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 11px; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: var(--text);
  font-size: 13px; font-weight: 500;
}
.tb-menu-btn .ic { width: 17px; height: 17px; flex: 0 0 auto; }
.tb-menu-btn .chev { width: 13px; height: 13px; opacity: .55; transition: transform .15s; }
.tb-menu-btn:hover { background: var(--bg2); border-color: var(--border); }
.tb-menu-btn.active { background: var(--bg2); border-color: var(--border-strong); }
.tb-menu-btn.active .chev { transform: rotate(180deg); }
/* Exportar em destaque neon menta */
.tb-menu-btn.primary { color: #D6FFA6; border-color: rgba(166,255,46,0.5); background: linear-gradient(180deg, rgba(166,255,46,0.14), rgba(166,255,46,0.04)); box-shadow: 0 0 12px rgba(166,255,46,0.16); }
.tb-menu-btn.primary:hover, .tb-menu-btn.primary.active { border-color: rgba(166,255,46,0.85); box-shadow: 0 0 18px rgba(166,255,46,0.34); }

/* popover do menu */
.tb-menu-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  display: none; flex-direction: column; gap: 3px;
  min-width: 210px; padding: 7px;
  background: rgba(8,17,8,0.98); backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong); border-radius: 11px;
  box-shadow: var(--shadow-pop);
}
.tb-menu-pop.open { display: flex; }
.tb-menu-pop-wide { min-width: 250px; }
.tb-menu-pop-right { left: auto; right: 0; }
.tb-menu-pop > button {
  width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  padding: 8px 10px; border-radius: 7px; font-size: 13px; font-weight: 500;
}
.tb-menu-pop > button:hover { background: var(--bg3); border-color: var(--border); }
.tb-menu-pop > button.primary {
  background: linear-gradient(180deg, rgba(166,255,46,0.16), rgba(166,255,46,0.05));
  border-color: rgba(166,255,46,0.45); color: #D6FFA6; font-weight: 600;
}
.tb-menu-pop > button.primary:hover { border-color: rgba(166,255,46,0.85); }
.tb-pop-sep { height: 1px; background: var(--border); margin: 5px 2px; }
/* linhas rotuladas dentro do popover (selects/sliders) */
.tb-menu-pop label {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 5px 8px; color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.tb-menu-pop label select { flex: 0 1 auto; min-width: 120px; }
.tb-menu-pop label input[type=range] { flex: 0 0 120px; }
.tb-menu-pop label.chk { justify-content: space-between; }

/* botão ? de ajuda */
.tb-icon-btn {
  width: 32px; height: 32px; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-weight: 700; flex: 0 0 auto;
}
.tb-icon-btn:hover { background: var(--bg2); color: var(--text); border-color: var(--border-strong); }

/* grupos legados (mantidos p/ compat, sem uso no topbar novo) */
.tb-group { display: flex; align-items: center; gap: 6px; }

/* ===== Controles base ===== */
button, select, input[type=number], input[type=text] {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
}
select, input { cursor: auto; }
button:hover { background: var(--hover); border-color: var(--border-strong); }
button:active { transform: translateY(1px); }
/* CTA: superfície escura + borda/glow neon (nada de preenchimento chapado) */
button.primary {
  background: linear-gradient(180deg, rgba(166,255,46,0.18), rgba(166,255,46,0.05));
  border: 1px solid rgba(166,255,46,0.5);
  color: #E4FFC2;
  font-weight: 600;
  box-shadow: 0 0 14px rgba(166,255,46,0.22);
}
button.primary:hover {
  filter: none;
  background: linear-gradient(180deg, rgba(166,255,46,0.26), rgba(166,255,46,0.09));
  border-color: rgba(166,255,46,0.85);
  box-shadow: 0 0 20px rgba(166,255,46,0.42);
}
button.danger { border-color: rgba(255,92,122,0.35); color: #ff9db0; }
button.danger:hover { background: rgba(255,92,122,0.12); border-color: rgba(255,92,122,0.55); }

/* exportar = neon menta (sucesso) */
#btn-export-video {
  background: linear-gradient(180deg, rgba(166,255,46,0.15), rgba(166,255,46,0.05));
  border: 1px solid rgba(166,255,46,0.5); color: #D6FFA6; font-weight: 600;
  box-shadow: 0 0 14px rgba(166,255,46,0.20);
}
#btn-export-video:hover {
  filter: none;
  background: linear-gradient(180deg, rgba(166,255,46,0.24), rgba(166,255,46,0.08));
  border-color: rgba(166,255,46,0.85); box-shadow: 0 0 20px rgba(166,255,46,0.4);
}
#btn-export-ae { border-color: rgba(166,255,46,0.32); color: #CFFF9E; }
#btn-export-ae:hover { background: rgba(166,255,46,0.10); border-color: rgba(166,255,46,0.55); }

select:focus, input[type=number]:focus, input[type=text]:focus, textarea:focus {
  outline: none;
  border-color: rgba(166,255,46,0.6);
  box-shadow: 0 0 0 3px rgba(166,255,46,0.18);
}
input[type=color] {
  width: 34px; height: 26px; padding: 2px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg3); cursor: pointer;
  transition: border-color .15s;
}
input[type=color]:hover { border-color: var(--border-strong); }
input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ===== Layout principal ===== */
#main { display: flex; flex: 1 1 auto; min-height: 0; }

/* ===== Toolbar esquerda ===== */
#toolbar {
  width: 56px;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0;
  flex: 0 0 auto; z-index: 20;
}
.tool {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0;
}
.tool svg { width: 19px; height: 19px; display: block; }
.tool-3d { font-size: 12px; font-weight: 800; letter-spacing: .3px; }
.tool:hover { background: var(--bg2); color: var(--text); border-color: var(--border); }
.tool.active {
  background: rgba(166,255,46,0.10);
  color: var(--accent);
  border-color: rgba(166,255,46,0.42);
  box-shadow: inset 0 0 0 1px rgba(166,255,46,0.12), 0 0 12px rgba(166,255,46,0.28);
}
#tool-options {
  position: absolute; left: 62px; top: 58px; width: 268px;
  background: rgba(8,17,8,0.97);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px;
  display: none; z-index: 25;
  box-shadow: var(--shadow-pop);
  max-height: 72vh; overflow: auto;
}
#tool-options.open { display: block; }
#tool-options h4 { margin: 0 0 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
#tool-options input[type=text] { width: 100%; }
.search-results { max-height: 300px; overflow: auto; margin-top: 8px; }
.search-results div { padding: 7px 10px; border-radius: 7px; cursor: pointer; transition: background .12s; }
.search-results div:hover { background: var(--bg2); }
.icon-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 8px; }
.icon-grid button { padding: 7px; border-radius: 8px; }
.icon-grid button.sel { background: rgba(166,255,46,0.12); border-color: rgba(166,255,46,0.5); box-shadow: 0 0 10px rgba(166,255,46,0.22); }
.icon-grid svg { width: 20px; height: 20px; fill: var(--text); display: block; }

/* ===== Mapa ===== */
#map-area {
  flex: 1 1 auto; min-width: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 500px at 50% -100px, rgba(166,255,46,0.06), transparent),
    var(--bg0);
  overflow: hidden;
}
#stage {
  position: relative;
  flex: none; /* na exportação em alta o palco EXCEDE a área visível — não pode encolher */
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border-strong), 0 24px 80px rgba(0,0,0,.65);
}
#map { position: absolute; inset: 0; }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#draw-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(5,8,5,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  padding: 6px 16px;
  font-size: 12px; font-weight: 500;
  z-index: 10; pointer-events: none; white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.mapboxgl-ctrl-logo, .mapboxgl-ctrl-attrib { opacity: .3; }

/* ===== Rightbar ===== */
#rightbar {
  width: 292px; flex: 0 0 auto;
  background: var(--bg1);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; z-index: 20;
}
#rightbar h3 {
  margin: 0; padding: 10px 14px 8px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}
#rightbar h3::before {
  content: '';
  width: 3px; height: 12px; border-radius: 2px;
  background: var(--grad);
}
#props-panel { flex: 1 1 55%; min-height: 0; display: flex; flex-direction: column; }
#props-body { overflow: auto; padding: 12px 14px; flex: 1; }
#layers-panel { flex: 1 1 45%; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--border); }
#layers-list { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
#layers-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; margin-bottom: 2px;
  border-radius: 8px; cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
#layers-list li:hover { background: var(--bg2); }
#layers-list li.sel {
  background: rgba(166,255,46,0.10);
  border-color: rgba(166,255,46,0.4);
  box-shadow: inset 0 0 0 1px rgba(166,255,46,0.08);
}
#layers-list li.dragover { border-top: 2px solid var(--accent); }
#layers-list .lname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
#layers-list .swatch {
  width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
#layers-list .mini { background: none; border: none; padding: 2px 3px; font-size: 12px; opacity: .45; transition: opacity .12s; }
#layers-list .mini:hover { opacity: 1; background: none; }
#layers-list li.hidden-layer { opacity: .4; }

/* Propriedades */
.prop-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.prop-row label { flex: 0 0 92px; color: var(--muted); font-size: 12px; font-weight: 500; }
.prop-row input[type=number] { width: 66px; }
.prop-row input[type=text], .prop-row select, .prop-row textarea { flex: 1; min-width: 0; }
.prop-row textarea {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  resize: vertical; font-family: inherit; font-size: 12.5px; padding: 6px 10px;
}
.prop-sep { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.prop-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 8px; letter-spacing: .8px;
  display: flex; align-items: center; gap: 8px;
}
.prop-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.conquest-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px; margin-bottom: 6px; font-size: 12px;
}
.conquest-item .row { display: flex; gap: 6px; align-items: center; margin-top: 6px; color: var(--muted); }
.conquest-item input[type=number] { width: 58px; padding: 3px 7px; }
.muted { color: var(--muted); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.btn-row button { flex: 1; }

/* ===== Timeline ===== */
#timeline {
  flex: 0 0 auto;
  background: linear-gradient(180deg, #0A140A 0%, #060B06 100%);
  border-top: 1px solid var(--border);
  padding: 8px 12px 10px;
  z-index: 20;
}
#tl-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
#tl-controls label { color: var(--muted); display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; }
#btn-play {
  width: 38px; height: 30px;
  background: rgba(166,255,46,0.10);
  border: 1px solid rgba(166,255,46,0.5); color: var(--accent);
  font-size: 13px;
  box-shadow: 0 0 12px rgba(166,255,46,0.24);
}
#btn-play:hover { filter: none; border-color: rgba(166,255,46,0.85); box-shadow: 0 0 18px rgba(166,255,46,0.42); }
#tl-time {
  font-variant-numeric: tabular-nums; min-width: 60px;
  font-weight: 700; font-size: 13.5px;
  color: var(--accent);
}
.chk { user-select: none; }
#tl-ruler-wrap {
  position: relative; height: 76px;
  background: var(--bg0);
  border: 1px solid var(--border);
  border-radius: 9px; overflow: hidden;
}
#tl-ruler { position: absolute; inset: 0; width: 100%; height: 100%; }
#tl-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: #FF5C7A;
  box-shadow: 0 0 8px rgba(255,92,122,0.7);
  z-index: 5; pointer-events: none;
}
#tl-playhead::before {
  content: ''; position: absolute; top: 0; left: -5px;
  border: 6px solid transparent; border-top-color: #FF5C7A;
}
#tl-camkeys { position: absolute; top: 22px; left: 0; right: 0; height: 18px; }
.camkey {
  position: absolute; width: 11px; height: 11px;
  background: var(--gold);
  transform: rotate(45deg) translate(-50%, 0); transform-origin: 0 0;
  border: 1.5px solid rgba(0,0,0,0.4);
  border-radius: 2.5px; cursor: grab; z-index: 4;
  box-shadow: 0 0 6px rgba(255,209,102,0.5);
  transition: box-shadow .12s;
}
.camkey:hover { box-shadow: 0 0 12px rgba(255,209,102,0.9); }
#tl-layerbar { position: absolute; top: 46px; left: 0; right: 0; height: 20px; }
.layer-span {
  position: absolute; height: 16px; top: 2px;
  background: linear-gradient(135deg, rgba(166,255,46,0.35), rgba(166,255,46,0.3));
  border: 1px solid rgba(166,255,46,0.7);
  border-radius: 5px; cursor: grab;
}
.layer-span .hnd { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.layer-span .hnd.l { left: 0; border-right: 1px solid rgba(166,255,46,0.7); border-radius: 5px 0 0 5px; }
.layer-span .hnd.r { right: 0; border-left: 1px solid rgba(166,255,46,0.7); border-radius: 0 5px 5px 0; }
.layer-span .hnd:hover { background: rgba(166,255,46,0.35); }
.conq-mark {
  position: absolute; height: 5px; top: 62px;
  background: linear-gradient(90deg, #FF5C7A, #FF9D5D);
  border-radius: 3px; pointer-events: none;
  box-shadow: 0 0 6px rgba(255,92,122,0.5);
}

/* ===== Modal ===== */
#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2,5,2,0.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
#modal {
  background: var(--bg1);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 22px 24px;
  min-width: 400px; max-width: 660px; max-height: 80vh; overflow: auto;
  box-shadow: var(--shadow-pop);
}
#modal h2 { margin: 0 0 16px; font-size: 16px; font-weight: 700; letter-spacing: .2px; }
#modal .prop-row label { flex: 0 0 130px; }
#modal progress {
  width: 100%; height: 8px;
  border-radius: 99px; overflow: hidden;
  appearance: none; border: none;
  background: var(--bg3);
}
#modal progress::-webkit-progress-bar { background: var(--bg3); border-radius: 99px; }
#modal progress::-webkit-progress-value { background: var(--grad); border-radius: 99px; transition: width .2s; }
#modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
#modal kbd {
  background: var(--bg3); border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 7px; font-size: 11px;
  font-family: inherit; font-weight: 600;
}
#modal table { width: 100%; border-collapse: collapse; }
#modal td { padding: 5px 8px; vertical-align: top; line-height: 1.5; }

/* ===== Menu de contexto ===== */
#ctx-menu {
  position: fixed; z-index: 200;
  background: rgba(9,18,9,0.98);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  border-radius: 11px; padding: 5px;
  box-shadow: var(--shadow-pop);
  min-width: 170px;
}
#ctx-menu div { padding: 7px 13px; border-radius: 7px; cursor: pointer; font-weight: 500; transition: background .1s; }
#ctx-menu div:hover { background: var(--bg2); }
#ctx-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 8px; }

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 118px; left: 50%; transform: translateX(-50%);
  background: rgba(8,17,8,0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(166,255,46,0.4);
  border-radius: 99px;
  padding: 9px 20px;
  font-weight: 500;
  z-index: 300;
  box-shadow: 0 8px 30px rgba(0,0,0,.5), 0 0 20px rgba(166,255,46,0.12);
  transition: opacity .3s; pointer-events: none;
}

/* controle exclusivo de mobile — oculto no desktop */
#m-panels { display: none; }
#draw-actions[hidden] { display: none; }

/* barra flutuante ✓/✕ de desenho (ambas plataformas) */
#draw-actions {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 12;
}
#draw-actions button {
  padding: 11px 20px; font-size: 15px; border-radius: 99px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
#draw-cancel { background: var(--bg2); }

/* ================= MOBILE ================= */
body.mobile #m-panels {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; flex: 0 0 auto;
  background: transparent; border-color: transparent; color: var(--text);
}
body.mobile #m-panels svg { width: 22px; height: 22px; }

body.mobile #topbar { height: 54px; padding: 0 6px; gap: 2px; }
body.mobile .brand-name { display: none; }
body.mobile .brand { margin: 0 2px 0 2px; }

/* menus suspensos compactos (só ícone) no celular */
body.mobile .tb-menu-btn { padding: 0 9px; gap: 0; height: 38px; }
body.mobile .tb-menu-btn span, body.mobile .tb-menu-btn .chev { display: none; }
body.mobile .tb-menu-btn .ic { width: 20px; height: 20px; }
body.mobile .tb-menu-pop { min-width: 60vw; max-width: 84vw; max-height: 66vh; overflow-y: auto; }
body.mobile .tb-icon-btn { width: 34px; height: 34px; }

/* recursos pesados ocultos no mobile */
body.mobile .m-hide-heavy { display: none !important; }

/* layout em coluna: toolbar horizontal */
body.mobile #main { flex-direction: column; }
body.mobile #toolbar {
  width: 100%; height: 50px; flex-direction: row;
  border-right: none; border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden;
  padding: 6px 8px; gap: 4px;
  -webkit-overflow-scrolling: touch;
}
body.mobile #toolbar::-webkit-scrollbar { display: none; }
body.mobile #toolbar .tool { flex: 0 0 auto; }

/* opções da ferramenta viram folha inferior */
body.mobile #tool-options {
  position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto;
  width: auto; max-height: 56vh; z-index: 65;
}

body.mobile #map-area { flex: 1 1 auto; min-height: 0; }

/* painéis (props + camadas) viram folha inferior deslizante */
body.mobile #rightbar {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto;
  width: auto; height: 64vh;
  border-left: none; border-top: 1px solid var(--border-strong);
  border-radius: 16px 16px 0 0;
  transform: translateY(102%);
  z-index: 70; box-shadow: var(--shadow-pop);
}
body.mobile.m-ready #rightbar { transition: transform .28s ease; }
body.mobile.m-panels-open #rightbar { transform: translateY(0); }
body.mobile #rightbar::before {
  content: ''; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong);
}
body.mobile #props-panel, body.mobile #layers-panel { flex: 1 1 50%; }

/* backdrop das gavetas */
#m-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 55; opacity: 0; transition: opacity .22s;
}
#m-backdrop[hidden] { display: none; }
body.mobile.m-panels-open #m-backdrop { opacity: 1; }
/* #rightbar (z20) cria contexto de empilhamento como flex-item; sem elevá-lo
   acima do backdrop (z55), o backdrop interceptaria os toques dentro da folha */
body.mobile.m-panels-open #rightbar { z-index: 60; }

/* timeline compacta */
body.mobile #timeline { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
body.mobile #tl-controls { gap: 8px; flex-wrap: wrap; row-gap: 6px; }
body.mobile #tl-controls label { font-size: 11px; }
body.mobile #tl-ruler-wrap { height: 66px; }
body.mobile #btn-play, body.mobile #btn-stop { width: 42px; height: 34px; }
body.mobile #btn-add-camkey { font-size: 12px; padding: 6px 9px; }

/* alvos de toque maiores nas alças/keyframes da timeline */
body.mobile .camkey { width: 15px; height: 15px; }
body.mobile .layer-span .hnd { width: 14px; }

/* modais ocupam quase a tela no mobile */
body.mobile #modal { min-width: 0; width: 94vw; max-width: 94vw; padding: 18px; }
body.mobile #tool-options .icon-grid { grid-template-columns: repeat(6, 1fr); }

/* draw-actions acima da timeline no mobile */
body.mobile #draw-actions { bottom: 12px; }
body.mobile #draw-actions button { padding: 13px 22px; font-size: 16px; }

/* ===== correções mobile (v2) ===== */
/* sliders no toque: sem isso o gesto vira scroll e o slider "trava" */
input[type=range] { touch-action: none; }

/* altura dinâmica: 100vh no celular inclui a barra do navegador e cortava
   a timeline; 100dvh acompanha o viewport visível */
body.mobile #app { height: 100dvh; }
body.mobile #timeline { flex-shrink: 0; }
body.mobile #tl-ruler-wrap { height: 60px; }

/* busca de territórios / opções de ferramenta: folha no TOPO — embaixo o
   teclado virtual cobria a lista */
body.mobile #tool-options {
  top: 110px; bottom: auto;
  max-height: 46vh;
}
body.mobile #tool-options .search-results { max-height: 30vh; }

/* ================= AUTENTICAÇÃO (login) ================= */
.auth-hidden { display: none !important; }
.hidden { display: none !important; }
body.auth-open { overflow: hidden; }

.login-screen {
  position: fixed; inset: 0; z-index: 1500;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1000px 600px at 50% -10%, rgba(166,255,46,0.18), transparent 60%),
    linear-gradient(180deg, #08120A 0%, #040704 100%);
  transition: opacity .25s ease;
}
.login-screen.hidden { opacity: 0; pointer-events: none; }
.login-card {
  width: 100%; max-width: 400px;
  background: rgba(8,17,9,0.92);
  border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 30px 28px;
  box-shadow: 0 40px 90px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.03) inset;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  display: flex; flex-direction: column; gap: 22px;
}
.login-card-header { text-align: center; }
.login-logo {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: var(--grad); box-shadow: 0 8px 24px rgba(166,255,46,0.5);
}
.login-logo svg { width: 30px; height: 30px; }
.login-card-header h1 { font-size: 26px; font-weight: 500; margin: 0 0 6px; letter-spacing: .3px; }
.login-card-header h1 b { font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-card-header p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin-top: 6px; }
.login-form input {
  background: var(--bg0); border: 1px solid var(--border);
  color: var(--text); padding: 12px 14px; border-radius: 10px; font-size: 14px;
  transition: border-color .18s, box-shadow .18s;
}
.login-form input:focus { outline: none; border-color: rgba(166,255,46,.7); box-shadow: 0 0 0 3px rgba(166,255,46,.2); }
.login-submit {
  margin-top: 14px; background: var(--grad); color: #fff; border: none;
  border-radius: 999px; font-weight: 700; font-size: 15px; padding: 13px;
  cursor: pointer; box-shadow: 0 6px 22px rgba(166,255,46,0.4);
  transition: filter .18s, transform .1s, box-shadow .18s;
}
.login-submit:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 10px 30px rgba(166,255,46,0.55); }
.login-submit:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.login-help { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.login-error { min-height: 18px; font-size: 12.5px; color: #ff8b8b; font-weight: 600; margin: 2px 0 0; text-align: center; }

/* status + logout na topbar */
.auth-status {
  font-size: 11.5px; color: var(--muted); max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 6px; border-left: 1px solid var(--border);
}
.auth-status.success { color: #B9FF70; }
.btn-logout { border-color: rgba(255,93,93,0.35); color: #ff9a9a; }
.btn-logout:hover { background: rgba(255,93,93,0.12); border-color: rgba(255,93,93,0.55); }
.btn-logout[disabled] { opacity: .4; cursor: not-allowed; }
body.mobile .auth-status { display: none; }

/* ===== Estética da landing (neon lime) — só skin, sem mexer em layout ===== */
/* tipografia tech: display nos títulos, mono nos rótulos de painel */
.brand-name, #modal h2, .login-card-header h1 {
  font-family: 'Chakra Petch', 'Inter', sans-serif;
}
#tl-time { font-family: 'Chakra Petch', 'Inter', sans-serif; }
#rightbar h3, .prop-title, #tool-options h4 {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: .12em;
}
/* botão de login: texto escuro sobre o degradê lime (como os CTAs da landing) */
.login-submit { color: #081205; }
.login-submit:hover { filter: brightness(1.05); }
/* foco dos inputs de login no lime */
.login-form input:focus { border-color: rgba(166,255,46,.7); box-shadow: 0 0 0 3px rgba(166,255,46,.18); }
/* logo do login com a tinta escura da landing */
.login-logo { color: #081205; }

/* botão "Guia" (texto, não ícone) */
#btn-help { width: auto; padding: 0 12px; font-size: 12px; font-weight: 600; }

/* link "Versão antiga" — mesmo estilo do botão Guia, texto em vez de ícone */
#btn-old-version {
  width: auto; padding: 0 12px; font-size: 12px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}

/* scrub da agulha por toque: sem isso o gesto vira scroll da página */
#tl-ruler-wrap { touch-action: none; }
