:root {
  --bg: #15171c;
  --surface: #1d2027;
  --surface-2: #262a33;
  --surface-3: #2e333d;
  --border: #323742;
  --border-soft: #272b33;
  --text: #eceef2;
  --muted: #9aa1ad;
  --muted-2: #6b7280;
  /* ImagensPro23 brand identity */
  --brand-blue: #1f9be6;
  --brand-green: #6cc24a;
  --grad: linear-gradient(135deg, #1f9be6 0%, #29afc0 48%, #6cc24a 100%);
  --ink: #062231;                      /* readable text on bright brand fills */
  /* accent vars (kept as --gold* so all existing rules adopt the brand color) */
  --gold: #2aa6e6;
  --gold-soft: rgba(42, 166, 230, 0.15);
  --gold-line: rgba(42, 166, 230, 0.42);
  --green: #4fb477;
  --red: #e06a5b;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(31, 155, 230, 0.07), transparent 60%),
    radial-gradient(900px 500px at 8% -6%, rgba(108, 194, 74, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select { font-family: inherit; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(21, 23, 28, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: radial-gradient(120% 120% at 30% 0%, rgba(31,155,230,.16), rgba(108,194,74,.10) 60%, transparent),
              linear-gradient(160deg, var(--surface-3), var(--surface));
  border: 1px solid var(--border);
  display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 6px 18px -8px rgba(31,155,230,.55);
}
.brand .mark img { width: 30px; height: 30px; object-fit: contain; display: block; }
.brand .mark svg { width: 20px; height: 20px; }
.brand h1 {
  font-family: var(--display);
  font-size: 1.16rem; font-weight: 700; letter-spacing: -0.02em; margin: 0;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.brand h1 b { font-weight: 700; }
.brand .tag { font-size: .7rem; color: var(--muted-2); letter-spacing: .04em; text-transform: uppercase; }
.spacer { flex: 1; }

.dest-pill {
  display: flex; align-items: center; gap: 9px;
  max-width: 320px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: .82rem; cursor: pointer; transition: border-color .15s, background .15s;
}
.dest-pill:hover { border-color: var(--gold-line); }
.dest-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex: none; }
.dest-pill.connected .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(79, 180, 119, .18); }
.dest-pill .dest-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dest-pill.connected .dest-label { color: var(--text); }
.dest-pill .dest-name { font-family: var(--mono); font-size: .78rem; }

/* ---------- Layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: clamp(18px, 3vw, 32px) clamp(16px, 4vw, 40px) 120px; }

.setup {
  display: grid; gap: 14px;
  grid-template-columns: 1.4fr 1fr 1fr;
  margin-bottom: 22px;
}
@media (max-width: 820px) { .setup { grid-template-columns: 1fr 1fr; } .setup .field-folder { grid-column: 1 / -1; } }
@media (max-width: 540px) { .setup { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label {
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.field .hint { font-size: .72rem; color: var(--muted-2); }
.input, .select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 11px; padding: 12px 14px; font-size: .92rem;
  transition: border-color .15s, background .15s;
}
.input::placeholder { color: var(--muted-2); }
.input:focus, .select:focus { border-color: var(--gold-line); background: var(--surface-2); }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa1ad' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* segmented quality toggle */
.seg { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; background: transparent; border: 0; color: var(--muted);
  padding: 9px 10px; border-radius: 8px; font-size: .82rem; font-weight: 500; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: .15s;
}
.seg button small { font-size: .66rem; color: var(--muted-2); font-weight: 400; }
.seg button[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold); }
.seg button[aria-pressed="true"] small { color: var(--gold); opacity: .8; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), rgba(29, 32, 39, 0.4));
  padding: clamp(28px, 6vw, 54px); text-align: center; cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
  position: relative;
}
.dropzone:hover { border-color: var(--gold-line); }
.dropzone.drag { border-color: var(--gold); background: var(--gold-soft); transform: scale(1.005); }
.dropzone .dz-icon {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center;
}
.dropzone .dz-icon svg { width: 26px; height: 26px; stroke: var(--gold); }
.dropzone h2 { font-family: var(--display); font-weight: 500; font-size: 1.05rem; margin: 0 0 6px; }
.dropzone p { color: var(--muted); font-size: .86rem; margin: 0; }
.dropzone .browse { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 22px 0 14px;
}
.count-chip {
  font-family: var(--mono); font-size: .82rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 7px 12px;
}
.count-chip b { color: var(--gold); }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font-size: .85rem; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: .15s;
}
.btn:hover { border-color: var(--gold-line); background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  margin-left: auto; background: var(--grad); color: #fff; border: 1px solid transparent;
  font-weight: 600; padding: 11px 20px; font-size: .9rem;
  box-shadow: 0 10px 24px -12px rgba(31,155,230,.8);
}
.btn-primary:hover { filter: brightness(1.08) saturate(1.05); border-color: transparent; background: var(--grad); }
.btn-primary:disabled { background: var(--surface-2); color: var(--muted-2); border-color: var(--border); }
@media (max-width: 540px) { .btn-primary { margin-left: 0; width: 100%; justify-content: center; } }

/* ---------- Grid ---------- */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  position: relative; border-radius: 12px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  aspect-ratio: 1 / 1; cursor: pointer; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--gold-line); }
.card.selected { border-color: var(--gold); }
.card.selected::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--gold); border-radius: 12px; pointer-events: none; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--surface-2); }
.card .check {
  position: absolute; top: 9px; left: 9px; width: 24px; height: 24px; border-radius: 7px;
  background: rgba(21, 23, 28, 0.7); border: 1.5px solid rgba(255,255,255,.4);
  display: grid; place-items: center; backdrop-filter: blur(4px);
}
.card.selected .check { background: var(--grad); border-color: var(--brand-green); }
.card .check svg { width: 14px; height: 14px; stroke: #fff; opacity: 0; }
.card.selected .check svg { opacity: 1; }
/* sequence badge = the signature element */
.card .seq {
  position: absolute; top: 9px; right: 9px;
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
  background: var(--grad); color: #fff; padding: 3px 7px; border-radius: 6px;
  opacity: 0; transform: translateY(-3px); transition: .15s;
  letter-spacing: .03em;
}
.card.selected .seq { opacity: 1; transform: none; }
.card .meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(15, 16, 20, 0.92));
  padding: 22px 10px 8px; font-size: .68rem; color: #d7dae0;
}
.card .meta .fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta .fsize { font-family: var(--mono); color: var(--muted); font-size: .64rem; display: block; margin-top: 1px; }
.card .rm {
  position: absolute; bottom: 8px; right: 8px; width: 24px; height: 24px; border-radius: 7px;
  background: rgba(21, 23, 28, 0.78); border: 1px solid var(--border); display: grid; place-items: center;
  opacity: 0; transition: .15s;
}
.card:hover .rm { opacity: 1; }
.card .rm svg { width: 13px; height: 13px; stroke: var(--red); }

.empty { text-align: center; color: var(--muted-2); padding: 50px 0; font-size: .9rem; }

/* ---------- Progress overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(13, 14, 18, 0.78); backdrop-filter: blur(6px);
}
.overlay.show { display: flex; }
.panel {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: clamp(20px, 5vw, 26px); box-shadow: var(--shadow);
}
.panel h3 { font-family: var(--display); font-weight: 600; margin: 0 0 4px; font-size: 1.1rem; }
.panel .sub { color: var(--muted); font-size: .85rem; margin: 0 0 20px; }
.bar { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0%; border-radius: 99px;
  background: var(--grad); transition: width .2s ease; }
.prog-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; }
.prog-row .pct { font-family: var(--mono); font-size: 1.4rem; font-weight: 600; color: var(--gold); }
.prog-row .frac { font-family: var(--mono); font-size: .82rem; color: var(--muted); }
.cur-file { margin-top: 10px; font-family: var(--mono); font-size: .76rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel .done-ico { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%;
  background: rgba(79,180,119,.16); display: grid; place-items: center; }
.panel .done-ico svg { width: 28px; height: 28px; stroke: var(--green); }
.panel-actions { display: flex; gap: 10px; margin-top: 20px; }
.panel-actions .btn { flex: 1; justify-content: center; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text);
  padding: 11px 16px; border-radius: 11px; font-size: .85rem; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 9px; max-width: 90vw;
  animation: pop .25s ease;
}
.toast .ico { width: 18px; height: 18px; flex: none; }
.toast.err { border-color: var(--red); }
.toast.ok .ico { stroke: var(--green); }
.toast.err .ico { stroke: var(--red); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* note banner */
.note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gold);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 20px; font-size: .82rem; color: var(--muted);
}
.note svg { width: 16px; height: 16px; stroke: var(--gold); flex: none; margin-top: 2px; }
.note b { color: var(--text); font-weight: 600; }
.note button { background: none; border: 0; color: var(--muted-2); cursor: pointer; margin-left: auto; font-size: 1rem; line-height: 1; padding: 0 2px; }

/* ---------- Botão de navegação no cabeçalho ---------- */
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px; appearance: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 9px 15px; border-radius: 11px; font-size: .85rem; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s; white-space: nowrap;
}
.nav-btn .nav-ico { display: inline-grid; place-items: center; }
.nav-btn svg { width: 16px; height: 16px; display: block; }
.nav-btn:hover { border-color: var(--gold-line); background: var(--surface-2); }
.nav-btn.active { background: var(--gold-soft); color: var(--gold); border-color: var(--gold-line); }

/* ---------- Folders view ---------- */
.folders-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.folders-bar .crumb { font-family: var(--display); font-size: 1.05rem; font-weight: 500; }
.folders-bar .crumb b { color: var(--gold); font-weight: 600; }
.folders-loading { color: var(--muted); font-size: .88rem; padding: 30px 0; text-align: center; }

.folder-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.folder-card {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--surface); cursor: pointer; transition: border-color .15s, transform .15s;
}
.folder-card:hover { border-color: var(--gold-line); transform: translateY(-2px); }
.folder-cover {
  aspect-ratio: 4 / 3; background: var(--surface-2); position: relative;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
}
.folder-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.folder-cover .ph { display: grid; place-items: center; color: var(--muted-2); }
.folder-cover .ph svg { width: 30px; height: 30px; opacity: .5; }
.folder-cover.single { grid-template-columns: 1fr; }
.folder-info { padding: 11px 13px; display: flex; align-items: center; gap: 9px; }
.folder-info svg { width: 18px; height: 18px; stroke: var(--gold); flex: none; }
.folder-info .fn { font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-info .ct { margin-left: auto; font-family: var(--mono); font-size: .72rem; color: var(--muted); flex: none; }

/* image cards in folder view (reuse .card grid) */
.img-card {
  position: relative; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  aspect-ratio: 1 / 1; cursor: zoom-in; transition: border-color .15s;
}
.img-card:hover { border-color: var(--gold-line); }
.img-card img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s; }
.img-card img.loaded { opacity: 1; }
.img-card .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted-2); }
.img-card .ph svg { width: 26px; height: 26px; opacity: .5; }
.img-card .nm {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 9px 7px;
  background: linear-gradient(transparent, rgba(15,16,20,.9));
  font-family: var(--mono); font-size: .66rem; color: #d7dae0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 90; display: none;
  background: rgba(8, 9, 12, 0.94); backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}
.lightbox.show { display: flex; }
.lb-stage { max-width: 92vw; max-height: 84vh; display: grid; place-items: center; }
.lb-stage img { max-width: 92vw; max-height: 84vh; object-fit: contain; border-radius: 6px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.8); }
.lb-btn {
  position: absolute; background: rgba(38, 42, 51, 0.7); border: 1px solid var(--border);
  color: var(--text); width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; transition: .15s;
}
.lb-btn:hover { background: var(--grad); color: #fff; border-color: transparent; }
.lb-btn svg { width: 22px; height: 22px; }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 18px; top: 50%; transform: translateY(-50%); }
.lb-caption {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: .8rem; color: var(--muted);
  background: rgba(21,23,28,.7); border: 1px solid var(--border); padding: 7px 14px; border-radius: 9px;
  max-width: 84vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 540px) {
  .lb-btn { width: 40px; height: 40px; }
  .lb-prev { left: 8px; } .lb-next { right: 8px; } .lb-close { top: 12px; right: 12px; }
}

/* ---------- Modais ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 3vw, 24px); background: rgba(8, 9, 13, 0.66); backdrop-filter: blur(7px);
  animation: modalBackIn .22s ease both;
}
@keyframes modalBackIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: clamp(18px, 4vw, 26px); box-shadow: var(--shadow);
  max-height: 90vh; overflow: auto; color: var(--text);
  animation: modalIn .26s cubic-bezier(.21,.99,.45,1) both;
}
/* faixa de marca no topo do modal */
.modal::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--grad); border-radius: 18px 18px 0 0;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.modal-head h3 { font-family: var(--display); font-weight: 600; font-size: 1.18rem; margin: 0; flex: 1; color: var(--text); }
.modal-x {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  width: 32px; height: 32px; border-radius: 9px; font-size: 1.3rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center; flex: none; transition: .15s;
}
.modal-x:hover { color: var(--text); border-color: var(--gold-line); }
.modal-sub { color: var(--muted); font-size: .85rem; margin: 0 0 18px; line-height: 1.5; }
.modal-note { color: var(--muted-2); font-size: .78rem; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.modal-note b { color: var(--gold); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal-actions .btn { padding: 10px 18px; }
.modal label { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; display: block; margin-bottom: 7px; }

/* serviços de destino */
.svc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.svc-card {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px;
  padding: 13px 14px; cursor: pointer; color: var(--text);
  transition: border-color .15s, transform .15s, background .15s, box-shadow .15s;
}
.svc-card:hover { border-color: var(--gold-line); transform: translateY(-2px); background: var(--surface-3); box-shadow: 0 12px 26px -16px rgba(31,155,230,.7); }
.svc-card:active { transform: translateY(0) scale(.99); }
.svc-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.svc-ico svg { width: 22px; height: 22px; }
.svc-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.svc-meta .nm { font-size: .94rem; font-weight: 600; line-height: 1.2; color: var(--text); }
.svc-meta .ds { font-size: .74rem; color: var(--muted); line-height: 1.3; }

/* folder list select (mover) */
.dir-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.dir-opt {
  display: flex; align-items: center; gap: 10px; padding: 12px 13px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; transition: .15s; text-align: left;
  color: var(--text);
}
.dir-opt:hover { border-color: var(--gold-line); background: var(--surface-3); }
.dir-opt.sel { border-color: var(--gold); background: var(--gold-soft); }
.dir-opt svg { width: 17px; height: 17px; stroke: var(--gold); flex: none; }
.dir-opt .dn { font-size: .9rem; color: var(--text); }

/* tablets: cards de destino mais largos */
@media (max-width: 720px) { .svc-grid { grid-template-columns: 1fr; } .svc-meta .ds { white-space: normal; } }
/* celulares: modal vira "bottom sheet" elegante */
@media (max-width: 560px) {
  .modal-back { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none; border-radius: 20px 20px 0 0; border-bottom: 0;
    max-height: 92vh; padding: 20px clamp(16px, 5vw, 22px) calc(20px + env(safe-area-inset-bottom));
    animation: sheetIn .3s cubic-bezier(.21,.99,.45,1) both;
  }
  .modal::before { border-radius: 20px 20px 0 0; }
  .modal::after {
    content: ''; position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 99px; background: var(--border);
  }
  .modal-head { margin-top: 8px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; justify-content: center; }
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: none; } }

/* ---------- Menu de contexto ---------- */
.ctx-menu {
  position: fixed; z-index: 99; min-width: 188px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; box-shadow: var(--shadow);
}
.ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; color: var(--text); text-align: left;
  padding: 9px 11px; border-radius: 8px; font-size: .86rem; cursor: pointer;
}
.ctx-item:hover { background: var(--surface); }
.ctx-item svg { width: 16px; height: 16px; stroke: var(--muted); flex: none; }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger svg { stroke: var(--red); }
.ctx-sep { height: 1px; background: var(--border-soft); margin: 5px 4px; }

/* ---------- Ações nos cards ---------- */
.dots {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 8px;
  background: rgba(21,23,28,.8); border: 1px solid var(--border); display: grid; place-items: center;
  cursor: pointer; opacity: 0; transition: .15s; z-index: 3;
}
.img-card:hover .dots, .folder-card:hover .dots { opacity: 1; }
.dots svg { width: 16px; height: 16px; stroke: var(--text); }
.dots:hover { border-color: var(--gold-line); }
.folder-card { position: relative; }

/* ---------- Lightbox toolbar ---------- */
.lb-toolbar {
  position: absolute; top: 16px; right: 16px; z-index: 2; display: flex; gap: 8px;
  background: rgba(21,23,28,.6); border: 1px solid var(--border); padding: 6px; border-radius: 12px;
  backdrop-filter: blur(8px);
}
.lb-tool {
  width: 40px; height: 40px; border-radius: 9px; cursor: pointer;
  background: transparent; border: 0; color: var(--text); display: grid; place-items: center; transition: .15s;
}
.lb-tool:hover { background: var(--surface-3); }
.lb-tool.danger:hover { background: rgba(224,106,91,.18); color: var(--red); }
.lb-tool.lb-close:hover { background: var(--grad); color: #fff; }
.lb-tool svg { width: 19px; height: 19px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.appfoot { text-align: center; color: var(--muted-2); font-size: .75rem; padding: 26px 16px 40px; }
.appfoot button { background: none; border: 0; color: var(--gold); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.appfoot button:hover { color: var(--brand-green); }

@media (max-width: 560px) {
  .brand .tag { display: none; }
  .brand h1 { font-size: 1rem; white-space: nowrap; }
  .topbar { gap: 8px; padding: 10px 14px; }
  .dest-pill { padding: 8px 10px; font-size: .78rem; }
  .nav-btn { padding: 8px 12px; }
}
