:root {
    --bg: #eef1f4;
    --surface: #ffffff;
    --ink: #14202b;
    --muted: #5d6b78;
    --line: #d3dae1;
    --accent: #2f5bff;
    --accent-ink: #ffffff;
    --danger: #b8402c;
    --ok: #1e7a53;
    color-scheme: light dark;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #0f161d;
      --surface: #17212b;
      --ink: #e8edf2;
      --muted: #93a1ae;
      --line: #2a3745;
      --accent: #6b8cff;
      --accent-ink: #0b1220;
      --danger: #ef8a77;
      --ok: #58c993;
    }
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; }
  body {
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }
  .wrap { max-width: 1040px; margin: 0 auto; padding: 24px 20px 64px; }
  header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
  h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
  button {
    font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  }
  button:hover { border-color: var(--accent); }
  button:focus-visible, input:focus-visible, .drop:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
  button.danger { color: var(--danger); }
  button.link { border: 0; background: none; color: var(--muted); padding: 4px 0; text-decoration: underline; }
  [hidden] { display: none !important; }

  /* login */
  .login { max-width: 360px; margin: 14vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
  .login h1 { margin-bottom: 16px; }
  .login label { display: block; font-weight: 600; margin-bottom: 6px; }
  .login input { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); margin-bottom: 14px; }
  .login button { width: 100%; padding: 10px; }
  .error { color: var(--danger); margin: 0 0 12px; min-height: 1.5em; }

  /* envio */
  .drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 160px; padding: 24px; text-align: center; cursor: pointer;
    background: var(--surface); border: 2px dashed var(--line); border-radius: 12px; color: var(--muted);
    transition: border-color .15s, background-color .15s;
  }
  .drop strong { color: var(--ink); font-size: 1.1rem; }
  .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
  .status { margin: 12px 0 0; min-height: 1.5em; color: var(--muted); }
  .status.bad { color: var(--danger); }
  .status.good { color: var(--ok); }

  /* galeria */
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 28px; padding: 0; list-style: none; }
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
  .thumb { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; background: var(--bg); display: block; }
  .meta { padding: 10px 12px 0; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
  .meta a { color: var(--ink); }
  .actions { display: flex; gap: 8px; padding: 10px 12px 12px; margin-top: auto; }
  .actions .primary { flex: 1; }
  .empty { margin-top: 28px; color: var(--muted); }