:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ecebe6;
  --ink: #16181a;
  --muted: #62676c;
  --line: #dfddd6;
  --accent: #0f6b5c;
  --accent-press: #0b5549;
  --accent-soft: #e1efeb;
  --on-accent: #ffffff;
  --danger: #b93a2e;
  --danger-soft: #fbe9e7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 26, .06), 0 4px 16px rgba(20, 24, 26, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101314;
    --surface: #181c1e;
    --surface-2: #22282a;
    --ink: #eceeed;
    --muted: #9aa3a1;
    --line: #2b3234;
    --accent: #3cc4a2;
    --accent-press: #31a98b;
    --accent-soft: #15302a;
    --on-accent: #062019;
    --danger: #f07a6c;
    --danger-soft: #3a1c19;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101314; --surface: #181c1e; --surface-2: #22282a; --ink: #eceeed; --muted: #9aa3a1;
  --line: #2b3234; --accent: #3cc4a2; --accent-press: #31a98b; --accent-soft: #15302a;
  --on-accent: #062019; --danger: #f07a6c; --danger-soft: #3a1c19; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom));
}

.head h1 {
  margin: 8px 0 6px;
  font-size: 1.65rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.lead { margin: 0 0 20px; color: var(--muted); }

/* ---------- picker ---------- */
.picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 32px 16px;
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .1s;
  user-select: none;
}
.picker:hover, .picker.is-drag { border-color: var(--accent); background: var(--accent-soft); }
.picker:active { transform: scale(.99); }
#file-input:focus-visible + .picker { outline: 3px solid var(--accent); outline-offset: 2px; }
.picker-ico { width: 56px; height: 56px; color: var(--accent); margin-bottom: 6px; }
.picker-title { font-size: 1.1rem; font-weight: 650; }
.picker-sub { font-size: .9rem; color: var(--muted); }

.picker.compact {
  flex-direction: row;
  justify-content: center;
  padding: 14px 16px;
  gap: 10px;
}
.picker.compact .picker-ico { width: 30px; height: 30px; margin: 0; }
.picker.compact .picker-sub { display: none; }
.picker.compact .picker-title { font-size: 1rem; }
.picker.is-disabled { pointer-events: none; opacity: .5; }

/* ---------- summary ---------- */
.summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 18px 2px 10px;
  font-size: .95rem;
  color: var(--muted);
}
.link {
  background: none; border: 0; padding: 4px 0; font: inherit; color: var(--accent);
  font-weight: 600; cursor: pointer;
}
.link:disabled { opacity: .4; }

/* ---------- grid ---------- */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}
.tile .thumb {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; background: var(--surface-2);
}
.tile .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.tile::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 46%;
  background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0));
  pointer-events: none;
}
.tile .meta {
  position: absolute; left: 8px; bottom: 9px; z-index: 1;
  color: #fff; font-size: .72rem; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.tile .meta svg { width: 12px; height: 12px; }
.tile .remove {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 18px; line-height: 30px;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.tile .bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px; z-index: 2;
  background: rgba(255,255,255,.25); display: none;
}
.tile .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.tile .state {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  display: none; place-items: center; font-weight: 800; font-size: 14px;
}
.tile .err {
  position: absolute; inset: 0; z-index: 1; display: none;
  padding: 10px; align-items: center; justify-content: center; text-align: center;
  background: rgba(120, 20, 10, .72); color: #fff; font-size: .78rem; font-weight: 600; line-height: 1.3;
}

.sending .tile .remove { display: none; }
.tile.is-wait .thumb { opacity: .55; }
.tile.is-active .bar, .tile.is-wait .bar { display: block; }
.tile.is-done .state { display: grid; background: var(--accent); color: var(--on-accent); }
.tile.is-done .state::before { content: "✓"; }
.tile.is-done .remove, .tile.is-error .remove { display: none; }
.tile.is-error .err { display: flex; }
.tile.is-error .state { display: grid; background: var(--danger); color: #fff; }
.tile.is-error .state::before { content: "!"; }

/* ---------- fields ---------- */
.fields { margin-top: 22px; display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .9rem; font-weight: 600; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field input, .field textarea {
  width: 100%;
  font: inherit; font-size: 16px; /* fără zoom pe iOS */
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field.has-error input { border-color: var(--danger); }
.note { margin: 18px 2px 0; font-size: .85rem; color: var(--muted); display: flex; gap: 6px; }
.note::before { content: "🔒"; }

/* ---------- dock ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.dock-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.dock-status { flex: 1; min-width: 0; }
.dock-text { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-text small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; white-space: normal; }
.progress { margin-top: 6px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .25s; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 50px; padding: 0 24px;
  border-radius: 12px;
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 700; font-size: 1rem;
  white-space: nowrap;
  transition: background-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); background: var(--accent-press); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn-ghost:active { background: var(--accent-soft); }

/* ---------- done ---------- */
.done { text-align: center; padding: 28px 8px 0; }
.done-ico { width: 76px; height: 76px; color: var(--accent); }
.done h2 { margin: 14px 0 6px; font-size: 1.45rem; letter-spacing: -0.01em; }
.done p { margin: 0 auto; max-width: 420px; color: var(--muted); }
.done p strong { color: var(--ink); }
.done .ico-warn { display: none; }
.done.is-partial .done-ico { color: var(--danger); }
.done.is-partial .ico-ok { display: none; }
.done.is-partial .ico-warn { display: inline; }
.failed-list {
  list-style: none; margin: 18px auto 0; padding: 12px 14px; max-width: 460px; text-align: left;
  background: var(--danger-soft); border-radius: 12px; font-size: .9rem;
}
.failed-list li + li { margin-top: 4px; }
.failed-list span { color: var(--muted); }
.done-actions { display: grid; gap: 10px; max-width: 360px; margin: 26px auto 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; top: max(16px, env(safe-area-inset-top)); z-index: 20;
  max-width: 560px; margin: 0 auto;
  background: var(--danger); color: #fff; font-weight: 600; font-size: .95rem;
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow);
}

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
  .head h1 { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
