/* Visual HofGlow (tema escuro): degradê preto → azul-noite, rosé, dourado, Jost. */
:root {
  --brand-gradient: linear-gradient(180deg, #000000 0%, #03050c 40%, #0c1736 100%);
  --rose: #ebbab5;
  --gold: #d8b26e;
  --gold-light: #f1d59c;
  --gold-deep: #b8863f;
  --night: #0c1736;
  --text: #f4ecea;
  --text-2: #c9b6b8;
  --card: linear-gradient(160deg, #0f1838 0%, #080d22 100%);
  --card-line: rgba(216, 178, 110, 0.22);
  --field: #070b1c;
  --radius: 20px;
  --font: Jost, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { background: #03050c; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--brand-gradient);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- topo ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 8px;
}
.brandmark { font-size: 22px; letter-spacing: 0.22em; }
.bm-a { color: var(--rose); font-weight: 300; }
.bm-b { color: var(--gold); font-weight: 400; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--card-line);
  background: rgba(15, 24, 56, 0.6);
  display: grid; place-items: center; cursor: pointer;
  transition: transform 0.12s;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg, .tab svg, .chip svg {
  width: 20px; height: 20px; fill: none; stroke: var(--gold); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- área de trabalho ---------- */
.workspace {
  display: flex; flex-direction: column; gap: 10px;
  padding: 0 12px calc(92px + var(--safe-b));
  max-width: 1200px; margin: 0 auto;
}
.stage-col { display: flex; flex-direction: column; gap: 8px; }
.layouts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.layout-btn {
  border: 1px solid var(--card-line); border-radius: 14px;
  background: rgba(15, 24, 56, 0.55);
  padding: 8px 4px 6px; min-height: 58px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-2);
}
.layout-btn svg { width: 26px; height: 22px; fill: none; stroke: var(--text-2); stroke-width: 1.5; stroke-linejoin: round; }
.layout-btn.on { border-color: var(--gold); color: var(--gold-light); background: rgba(216, 178, 110, 0.12); }
.layout-btn.on svg { stroke: var(--gold); }

.stage {
  display: flex; justify-content: center; align-items: center;
  border-radius: 16px; padding: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-line);
}
#canvas {
  display: block; max-width: 100%; max-height: 58vh;
  border-radius: 6px; touch-action: none; cursor: grab;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
#canvas.dragging { cursor: grabbing; }
.hint { margin: 0; text-align: center; font-size: 13px; color: var(--text-2); min-height: 18px; }

/* ---------- abas e painel ---------- */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding-bottom: 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--card-line); border-radius: 999px;
  background: rgba(15, 24, 56, 0.55); padding: 10px 14px; min-height: 44px;
  cursor: pointer; color: var(--text-2); font-size: 14px;
}
.tab.on { background: linear-gradient(180deg, #f1d59c, #d8b26e 55%, #b8863f); color: var(--night); border-color: transparent; }
.tab.on svg { stroke: var(--night); }

.panel {
  margin-top: 8px; background: var(--card); border: 1px solid var(--card-line);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}
.group { display: flex; flex-direction: column; gap: 8px; }
.group-title {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--rose); font-weight: 400;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.nowrap { flex-wrap: nowrap; }
.muted { color: var(--text-2); font-size: 13px; line-height: 1.4; margin: 0; }
.sep { height: 1px; background: var(--card-line); margin: 2px 0; }

.btn {
  border: 1px solid var(--card-line); border-radius: 999px; min-height: 44px; padding: 10px 16px;
  background: rgba(15, 24, 56, 0.7); cursor: pointer; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(180deg, #f1d59c, #d8b26e 55%, #b8863f);
  color: var(--night); border-color: transparent; font-weight: 500;
}
.btn.danger { color: #ffb4ae; border-color: rgba(255, 140, 130, 0.35); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.grow { flex: 1; }

.chip {
  border: 1px solid var(--card-line); border-radius: 999px; min-height: 38px; padding: 6px 12px;
  background: rgba(7, 11, 28, 0.7); cursor: pointer; color: var(--text-2); font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { border-color: var(--gold); color: var(--gold-light); background: rgba(216, 178, 110, 0.14); }
.swatch-dot { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.35); display: inline-block; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.field input[type='text'], .field textarea, .field select, select.select, input.text {
  background: var(--field); border: 1px solid var(--card-line); border-radius: 14px;
  padding: 11px 12px; min-height: 44px; width: 100%; color: var(--text); font-size: 16px;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.4; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px !important; }

.slider { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.slider output { text-align: right; font-variant-numeric: tabular-nums; }
input[type='range'] { width: 100%; accent-color: var(--gold); height: 32px; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; cursor: pointer; font-size: 15px; }
.toggle input { appearance: none; width: 48px; height: 28px; border-radius: 999px; background: #1b2347; position: relative; transition: background 0.15s; flex: 0 0 auto; border: 1px solid var(--card-line); }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s, background 0.15s; }
.toggle input:checked { background: rgba(216, 178, 110, 0.35); }
.toggle input:checked::after { transform: translateX(20px); background: var(--gold-light); }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 180px)); gap: 10px; }
.slot {
  border: 1px dashed var(--card-line); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 6px; align-items: stretch;
  background: rgba(7, 11, 28, 0.6);
}
.slot.on { border-style: solid; border-color: var(--gold); }
.slot-img { aspect-ratio: 4/5; border-radius: 10px; background: #0a1028 center/cover no-repeat; display: grid; place-items: center; color: var(--text-2); font-size: 13px; cursor: pointer; }
.slot-name { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--rose); text-align: center; }

.item-list { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; border: 1px solid var(--card-line); background: rgba(7, 11, 28, 0.6); cursor: pointer; min-height: 44px; }
.item.on { border-color: var(--gold); }
.item .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-mini { width: 40px; height: 40px; border-radius: 10px; background: #0a1028 center/cover; flex: 0 0 auto; }

.palette-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.preset { border: 1px solid var(--card-line); border-radius: 14px; padding: 8px 10px; background: rgba(7, 11, 28, 0.6); cursor: pointer; display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; color: var(--text-2); }
.preset.on { border-color: var(--gold); color: var(--gold-light); }
.preset .dots { display: flex; gap: 4px; }
.preset .dots span { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); }
.colors { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.color-field { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 14px; border: 1px solid var(--card-line); background: rgba(7, 11, 28, 0.6); font-size: 14px; color: var(--text-2); }
.color-field input[type='color'] { width: 40px; height: 34px; border: none; padding: 0; background: none; border-radius: 8px; cursor: pointer; }
.color-field small { display: block; font-size: 11px; color: var(--text-2); opacity: 0.8; }

.logo-preview { width: 84px; height: 84px; border-radius: 16px; background: #fff center/contain no-repeat; border: 1px solid var(--card-line); flex: 0 0 auto; }
.logo-preview.empty { background: rgba(7, 11, 28, 0.6); display: grid; place-items: center; color: var(--text-2); font-size: 12px; }
.counter { font-size: 12px; color: var(--text-2); text-align: right; }
.counter.warn { color: #ffb4ae; }

/* ---------- barra de salvar ---------- */
.exportbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 8px; justify-content: center;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: linear-gradient(180deg, rgba(3, 5, 12, 0) 0%, rgba(3, 5, 12, 0.92) 30%);
}
.exportbar .btn { flex: 1; max-width: 300px; min-height: 52px; font-size: 16px; }

/* ---------- ajustes ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--brand-gradient); overflow-y: auto; }
.sheet-inner { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px calc(40px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: relative; padding-bottom: 8px; }
.sheet-head::after { content: ''; position: absolute; left: 0; bottom: 0; width: 120px; height: 1px; background: linear-gradient(90deg, var(--gold), transparent); }
.sheet h1 { margin: 0; font-weight: 300; letter-spacing: 0.18em; text-transform: uppercase; color: var(--rose); font-size: 24px; }
.sheet .panel { margin-top: 0; }
.sheet h2 { margin: 0; font-weight: 400; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--rose); }

/* ---------- aviso e carregando ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%);
  background: #0f1838; border: 1px solid var(--gold); color: var(--text); padding: 12px 18px; border-radius: 999px;
  z-index: 40; font-size: 14px; max-width: 92vw; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.busy { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.72); display: grid; place-items: center; }
.busy-card { background: var(--card); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 22px; width: min(320px, 86vw); display: flex; flex-direction: column; gap: 14px; text-align: center; }
.result { width: min(420px, 92vw); max-height: 92vh; overflow-y: auto; }
.result h3 { margin: 0; font-weight: 300; letter-spacing: 0.16em; text-transform: uppercase; color: var(--rose); font-size: 16px; }
.result img, .result video { width: 100%; max-height: 48vh; object-fit: contain; border-radius: 10px; background: #000; }
.result .btn { width: 100%; }
.bar { height: 6px; border-radius: 999px; background: #1b2347; overflow: hidden; }
.bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--rose), var(--gold)); transition: width 0.15s; }

/* ---------- tablet e computador ---------- */
@media (min-width: 900px) {
  .workspace { flex-direction: row; align-items: flex-start; gap: 18px; padding-bottom: 100px; }
  .stage-col { flex: 1.1; position: sticky; top: 8px; }
  .panel-col { flex: 1; min-width: 360px; }
  #canvas { max-height: calc(100vh - 220px); }
}
