:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-soft: #64748b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f172a;
    --border: #1f2937;
    --text: #e5e7eb;
    --text-soft: #94a3b8;
    --accent: #3b82f6;
    --accent-strong: #2563eb;
    --accent-soft: #1e293b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: min(1100px, 100% - 32px); margin-inline: auto; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 0; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
}
.brand h1 { font-size: 1.05rem; margin: 0; font-weight: 650; }
.tagline { margin: 0; font-size: .82rem; color: var(--text-soft); }
.badge {
  font-size: .78rem; padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 600;
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .badge { color: #bfdbfe; } }

main { padding: 28px 0 40px; display: grid; gap: 20px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 44px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); outline: none; }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dz-icon { font-size: 2.4rem; line-height: 1; }
.dz-title { margin: 12px 0 4px; font-size: 1.1rem; font-weight: 600; }
.dz-sub { margin: 0; color: var(--text-soft); font-size: .9rem; }
.link { color: var(--accent); font-weight: 600; text-decoration: underline; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-title { margin: 0 0 16px; font-size: .95rem; font-weight: 650; letter-spacing: .01em; }
.muted { color: var(--text-soft); font-weight: 400; }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.opt { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; }
.opt-label { font-weight: 600; }
.opt-hint { color: var(--text-soft); font-size: .76rem; }
.opt select, .opt input[type="text"] {
  font: inherit; font-size: .9rem; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--text);
}
.opt select:focus, .opt input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.opt input[type="range"] { accent-color: var(--accent); }
.checkrow { display: flex; align-items: center; gap: 8px; font-size: .85rem; padding: 8px 0; }
.checkrow input { width: 17px; height: 17px; accent-color: var(--accent); }

.file-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); font-size: .88rem;
}
.file-item .fi-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fi-meta { color: var(--text-soft); font-size: .8rem; margin-left: auto; white-space: nowrap; }
.file-item.is-error { border-color: var(--danger); }
.file-item .fi-remove {
  border: 0; background: none; color: var(--text-soft); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.file-item .fi-remove:hover { color: var(--danger); background: var(--bg); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions-inline { margin: 0; }
.btn {
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-small { padding: 7px 12px; font-size: .8rem; }

.progress { margin-top: 16px; }
.progress-bar { height: 7px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.progress-text { margin: 8px 0 0; font-size: .82rem; color: var(--text-soft); }

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.results-head .panel-title { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card {
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); overflow: hidden; display: flex; flex-direction: column;
}
.card-thumb {
  height: 200px;
  padding: 8px; background: #fff center/contain no-repeat;
  background-image:
    linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  display: grid; place-items: center; border-bottom: 1px solid var(--border);
}
.card-thumb img { max-width: 100%; max-height: 100%; display: block; }
.card-body { padding: 10px 12px 12px; display: grid; gap: 8px; }
.card-name { font-size: .78rem; font-weight: 600; word-break: break-all; line-height: 1.35; }
.card-meta { font-size: .72rem; color: var(--text-soft); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 10px; font-size: .86rem; font-weight: 500;
  box-shadow: var(--shadow); z-index: 50; max-width: min(520px, calc(100% - 32px));
}
.toast.is-error { background: var(--danger); color: #fff; }

.footer { padding: 0 0 32px; color: var(--text-soft); font-size: .8rem; text-align: center; }

/* O atributo hidden precisa vencer os display: flex/grid acima. */
[hidden] { display: none !important; }
