/* Layout: app de duas colunas — coleções à esquerda, grade de capas à direita, painel de edição deslizando da direita */
:root {
  --bg: #0c0c0e;
  --panel: #131316;
  --raise: #1b1b20;
  --line: #26262d;
  --line-2: #33333c;
  --fg: #f2f1ee;
  --muted: #8d8c96;
  --accent: #f2b544;
  --accent-ink: #1b1305;
  --ok: #4ccf8a;
  --warn: #f2b544;
  --bad: #ef6a5b;
  --ui: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, Menlo, monospace;
  --r: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px; background: rgba(12,12,14,.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-mark { width: 22px; height: 14px; border-radius: 3px; background: linear-gradient(135deg, var(--accent), #e8603c); box-shadow: 0 0 18px rgba(242,181,68,.35); }
.status { cursor: pointer; display: inline-flex; align-items: center; gap: 8px; background: var(--raise); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--muted); min-width: 0; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.status.busy .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.status.bad .dot { background: var(--bad); }
.status span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { 50% { opacity: .3; } }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--raise); border-radius: 9px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #4a4a55; background: #212127; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #f6c464; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--raise); cursor: pointer; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12px; cursor: pointer; text-align: left; }
.link:hover { color: var(--fg); text-decoration: underline; }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100% - 57px); }
.cols { border-right: 1px solid var(--line); padding: 14px 10px 100px; position: sticky; top: 57px; height: calc(100vh - 57px); overflow: auto; }
.search input { width: 100%; background: var(--raise); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; margin-bottom: 10px; }
.cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cols li button { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; text-align: left; color: var(--muted); }
.cols li button:hover { background: var(--raise); color: var(--fg); }
.cols li button[aria-current="true"] { background: var(--raise); color: var(--fg); box-shadow: inset 2px 0 0 var(--accent); }
.cols .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols .ct { font: 11px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.cols .ct b { color: var(--accent); font-weight: 500; }

.main { padding: 22px 24px 120px; min-width: 0; }
.colhead { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px 24px; margin-bottom: 18px; }
.colhead-title { display: grid; gap: 2px; min-width: 0; }
.col-label { font-size: 26px; font-weight: 700; letter-spacing: -.02em; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; margin-left: -7px; width: min(560px, 100%); }
.col-label:hover { border-color: var(--line); }
.col-label:focus { border-color: var(--accent); outline: none; background: var(--raise); }
.col-orig { font-size: 12px; color: var(--muted); }
.colhead-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sel { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
select, input[type=text], input:not([type]), input[type=password], input[type=search], input[type=url] { background: var(--raise); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }

/* ---------- grade ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px 16px; }
.grid.posters { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.card { display: grid; gap: 8px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r); overflow: hidden; background: var(--raise); outline: 1px solid var(--line); transition: transform .18s ease, outline-color .18s; }
.card.poster .thumb { aspect-ratio: 2 / 3; }
.card:hover .thumb { transform: translateY(-3px); outline-color: var(--line-2); }
.card[aria-current="true"] .thumb { outline: 2px solid var(--accent); }
.thumb img, .thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .shimmer { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.05) 50%, transparent 70%) var(--raise); background-size: 200% 100%; animation: sh 1.4s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.badge { position: absolute; top: 8px; left: 8px; font: 500 10.5px var(--mono); letter-spacing: .04em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; background: rgba(12,12,14,.78); backdrop-filter: blur(6px); color: var(--muted); }
.badge.on { color: var(--accent-ink); background: var(--accent); }
.badge.err { left: auto; right: 8px; background: var(--bad); color: #fff; }
.badge.chg { left: auto; right: 8px; background: var(--fg); color: var(--bg); }
.card-meta { display: grid; gap: 1px; min-width: 0; }
.card-meta .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--muted); padding: 40px 0; }

/* ---------- painel ---------- */
.drawer { position: fixed; z-index: 30; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -30px 0 60px rgba(0,0,0,.45); animation: slide .22s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 12px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 2px 0 0; font-size: 18px; letter-spacing: -.01em; }
.eyebrow { font: 500 11px var(--mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.drawer-body { flex: 1; min-height: 0; overflow: auto; padding: 14px 18px 120px; display: grid; grid-auto-rows: max-content; gap: 16px; align-content: start; }
.tabs { display: flex; gap: 4px; background: var(--raise); border-radius: 9px; padding: 3px; }
.tabs button { flex: 1; border: 0; background: none; border-radius: 7px; padding: 6px 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--line-2); color: var(--fg); }
.preview { position: relative; border-radius: var(--r); overflow: hidden; outline: 1px solid var(--line); background: #08080a; display: grid; place-items: center; min-height: 120px; }
.preview canvas { display: block; width: 100%; height: auto; max-height: 56vh; object-fit: contain; }
.preview.logo { background-color: #2a2a31; background-image: conic-gradient(#33333b 25%, transparent 0 50%, #33333b 0 75%, transparent 0); background-size: 18px 18px; padding: 22px 16px; }
.preview .loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(12,12,14,.7); color: var(--muted); font-size: 13px; }
.featured-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-height: 28px; }
.featured-row b { color: var(--fg); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.block { display: grid; gap: 10px; }
.block h4 { margin: 0; font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.style-opt { border: 0; background: none; padding: 0; cursor: pointer; display: grid; gap: 4px; text-align: left; color: var(--muted); font-size: 11.5px; }
.style-opt canvas { width: 100%; aspect-ratio: 16 / 9; border-radius: 7px; outline: 1px solid var(--line); background: var(--raise); }
.style-opt[aria-pressed="true"] { color: var(--fg); }
.style-opt[aria-pressed="true"] canvas { outline: 2px solid var(--accent); }
.field { display: grid; gap: 5px; min-width: 0; }
.field label, .lbl { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.field output { font: 11.5px var(--mono); color: var(--fg); }
.hint { color: var(--warn); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--raise); border-radius: 999px; padding: 5px 11px; font-size: 12px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 600; }
input[type=range] { accent-color: var(--accent); width: 100%; }
input[type=color] { width: 40px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--raise); cursor: pointer; }
.pos { display: grid; grid-template-columns: repeat(3, 26px); gap: 4px; }
.pos button { width: 26px; height: 18px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--raise); cursor: pointer; padding: 0; }
.pos button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); outline: 1px solid var(--line-2); cursor: pointer; padding: 0; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- barra de salvar ---------- */
.savebar { position: fixed; z-index: 40; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; align-items: center; gap: 18px; background: #1d1d23; border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 10px 10px 18px; box-shadow: 0 20px 50px rgba(0,0,0,.55); max-width: calc(100vw - 32px); }
.savebar span { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.savebar-actions { display: flex; gap: 6px; flex: none; }

/* ---------- modal, login, toast ---------- */
.modal, .login { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(5,5,7,.72); backdrop-filter: blur(6px); }
.login { background: radial-gradient(60% 60% at 50% 0%, rgba(242,181,68,.12), transparent 70%), var(--bg); }
.modal-box, .login-box { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; padding: 20px; display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.login-box { width: min(380px, 100%); }
.login-box p { margin: 0; color: var(--muted); }
.login-box label { font-size: 12px; color: var(--muted); margin-bottom: -8px; }
.err { color: var(--bad) !important; font-size: 13px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 18px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: #d6d5d0; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; font: 12px var(--mono); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; }
.toast { position: fixed; z-index: 70; left: 50%; top: calc(70px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: calc(100vw - 32px); }

/* ---------- celular ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .cols { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 16px; overflow: visible; }
  .cols ul { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .cols li button { white-space: nowrap; border: 1px solid var(--line); }
  .cols li button[aria-current="true"] { box-shadow: none; border-color: var(--accent); }
  .cols .nm { overflow: visible; }
  .main { padding: 16px 16px 120px; }
  .top { flex-wrap: wrap; padding-inline: 16px; }
  .top-actions { margin-left: 0; width: 100%; }
  .top-actions .btn { flex: 1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px 10px; }
  .savebar { left: 16px; right: 16px; transform: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

.status:hover { border-color: var(--line-2); color: var(--fg); }
.gm-h { margin: 4px 0 0; font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.gm-errors { margin: 0; padding-left: 18px; max-height: 200px; overflow: auto; display: grid; gap: 4px; font-size: 13px; }
.gm-errors span { color: var(--muted); }
