/* --------------------------------------------------------------------
   Uploader - Oberflaeche
   Mobil zuerst, grosse Tippflaechen, dunkles Grundthema.
   -------------------------------------------------------------------- */

:root {
  --bg:        #0f1115;
  --bg-soft:   #161a21;
  --card:      #1a1f28;
  --card-2:    #212734;
  --line:      #2b3240;
  --text:      #e7ebf2;
  --muted:     #98a2b3;
  --accent:    #3b82f6;
  --accent-2:  #2563eb;
  --danger:    #ef4444;
  --ok:        #22c55e;
  --radius:    14px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body.lb-open { overflow: hidden; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.spacer { flex: 1 1 auto; }

pre {
  background: #0b0e13;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .8rem 1rem;
  overflow-x: auto;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

/* ---------------------------------------------------------------- Kopf */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  padding-top: max(.75rem, env(safe-area-inset-top));
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text);
  font-weight: 600;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
}

.nav { display: flex; gap: .35rem; margin-left: auto; flex-wrap: wrap; }
.nav a {
  padding: .4rem .7rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: .95rem;
}
.nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--card-2); color: var(--text); }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 3rem;
}

body.centered .page {
  min-height: 70vh;
  display: grid;
  place-items: center;
  max-width: 460px;
}

.footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .82rem;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------- Bausteine */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-head .btn { margin-left: auto; }
.back { display: inline-block; margin-bottom: .3rem; font-size: .9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .55rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #2a3140; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 54px; font-size: 1.05rem; padding: .7rem 1.4rem; }
.btn.block { width: 100%; }
.btn.danger-outline { border-color: #7f2a2a; color: #ffb4b4; background: transparent; }
.btn.danger-outline:hover { background: #3a1c1c; }

.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; margin-bottom: .3rem; font-size: .88rem; color: var(--muted); }
.field.inline { margin-bottom: 0; flex: 1 1 220px; }

input[type=text], input[type=password], input[type=email] {
  width: 100%;
  min-height: 44px;
  padding: .55rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0e1218;
  color: var(--text);
  font: inherit;
}
input[type=text]:focus, input[type=password]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: .2rem 0 1rem;
  cursor: pointer;
  font-size: .92rem;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.toolbar .check { margin: 0; }

.alert {
  border-radius: 10px;
  padding: .6rem .8rem;
  font-size: .9rem;
  margin: 0 0 .9rem;
  border: 1px solid var(--line);
  background: var(--card-2);
}
.alert.error   { border-color: #7f2a2a; background: #2a1616; color: #ffc9c9; }
.alert.success { border-color: #256b3d; background: #14261c; color: #b7f2cd; }

.progress {
  height: 8px;
  border-radius: 99px;
  background: #0d1117;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress.total { height: 12px; margin: .5rem 0 .4rem; }
.progress .bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .18s ease-out;
}

/* --------------------------------------------------------------- Upload */

.dropzone { text-align: center; padding: 2rem 1.1rem; border-style: dashed; }
.dropzone.dragging { border-color: var(--accent); background: #182234; }
.dz-icon { font-size: 2.4rem; line-height: 1; margin-bottom: .5rem; }
.dz-buttons {
  display: flex;
  gap: .6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.2rem 0 .8rem;
}
.dz-buttons .btn { flex: 1 1 220px; max-width: 320px; }
.hint { margin: 0; }

.queue-head {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: .6rem;
}
.queue-stats { text-align: right; display: flex; flex-direction: column; }
.status { margin: 0 0 .8rem; font-size: .9rem; color: var(--muted); }

.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.qitem {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .55rem .7rem;
}
.qitem.done   { border-color: #245c3b; }
.qitem.error  { border-color: #7f2a2a; }
.qitem.canceled { opacity: .5; }

.qhead { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.qname {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .92rem;
}
.qsize { flex: 0 0 auto; }
.qcancel {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.qcancel:hover { background: #33202080; color: #ffb4b4; }
.qstatus { margin-top: .35rem; }
.qitem.done .qstatus { color: var(--ok); }
.qitem.error .qstatus { color: #ff9d9d; }

/* Fertige Dateien sind eingeklappt, solange .show-done nicht gesetzt ist. */
.queue:not(.show-done) .qitem.done { display: none; }

.done-toggle {
  display: block;
  width: 100%;
  margin-top: .55rem;
  padding: .5rem .7rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .88rem;
  text-align: left;
  cursor: pointer;
}
.done-toggle:hover { color: var(--text); border-color: #3a4353; }
.done-toggle::after { content: " B8"; }
.done-toggle[aria-expanded="true"]::after { content: " BE"; }

.queue-actions { display: flex; gap: .6rem; margin-top: .9rem; flex-wrap: wrap; }

.done-card { border-color: #245c3b; }
.link-row { display: flex; gap: .5rem; margin: .8rem 0; }
.link-row input { flex: 1 1 auto; font-size: .88rem; }
.done-actions { display: flex; gap: .55rem; flex-wrap: wrap; }

.setup pre { margin: .6rem 0; }

/* -------------------------------------------------------------- Galerie */

.batches { list-style: none; margin: 0; padding: 0; }
.batch { padding: 0; overflow: hidden; }

.batch-strip {
  display: flex;
  gap: 2px;
  background: #0b0e13;
  min-height: 108px;
}
.batch-strip:hover { text-decoration: none; }
.strip-item {
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 1 / 1;
  max-height: 150px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #12161d;
}
.strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-ph, .strip-item.more {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
}
.strip-item.more { background: var(--card-2); color: var(--text); }

.batch-body {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: .85rem 1rem;
}
.batch-title { color: var(--text); font-weight: 600; }
.batch-body p { margin: .15rem 0 0; }
.batch-actions { display: flex; gap: .45rem; margin-left: auto; flex-wrap: wrap; }
.batch-actions form { margin: 0; }

.toolbar {
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
  padding-bottom: .9rem;
  margin-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .7rem;
}

.tile {
  position: relative;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tile.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.tile-pick { position: absolute; top: 6px; left: 6px; z-index: 2; cursor: pointer; }
.tile-pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.tile-pick span {
  display: block;
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 2px solid #ffffffaa;
  background: #00000066;
  backdrop-filter: blur(2px);
}
.tile-pick input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
}
.tile-pick input:checked + span::after {
  content: "";
  display: block;
  width: 6px; height: 11px;
  margin: 2px auto 0;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.tile-img {
  display: block;
  aspect-ratio: 1 / 1;
  background: #0b0e13;
}
.tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-img.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .05em;
}

.tile-meta { padding: .45rem .55rem .1rem; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.tile-name {
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-actions {
  display: flex;
  gap: .3rem;
  padding: .45rem .55rem .55rem;
  margin-top: auto;
  flex-wrap: wrap;
}
.mini {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 6px;
  padding: .2rem .45rem;
  font: inherit;
  font-size: .75rem;
  cursor: pointer;
}
.mini:hover { color: var(--text); background: #2a3140; text-decoration: none; }
.mini.danger:hover { color: #ffb4b4; background: #3a1c1c; }

.empty { text-align: center; padding: 2.5rem 1rem; }

/* ----------------------------------------------------------- Systemcheck */

.checks { width: 100%; border-collapse: collapse; font-size: .9rem; }
.checks td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.checks tr:last-child td { border-bottom: 0; }

.chk-state { width: 34px; }
.chk-state span {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 700;
  background: var(--card-2);
  color: var(--muted);
}
.chk-ok   .chk-state span { background: #14351f; color: #7ee2a8; }
.chk-warn .chk-state span { background: #3a2f14; color: #f6d071; }
.chk-fail .chk-state span { background: #3a1616; color: #ff9d9d; }

.chk-label { font-weight: 500; white-space: nowrap; }
.chk-value { color: var(--muted); word-break: break-word; }
.chk-note  { width: 42%; }

@media (max-width: 700px) {
  .checks, .checks tbody, .checks tr, .checks td { display: block; width: auto; }
  .checks tr { padding: .6rem 0; border-bottom: 1px solid var(--line); position: relative; padding-left: 34px; }
  .checks td { border: 0; padding: .1rem 0; }
  .chk-state { position: absolute; left: 0; top: .6rem; }
  .chk-note { width: auto; }
}

/* ---------------------------------------------------------- Bildbetrachter */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000000ee;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 5rem);
  object-fit: contain;
  border-radius: 6px;
}
.lb-close, .lb-prev, .lb-next {
  position: absolute;
  border: 0;
  background: #ffffff1a;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  width: 46px; height: 46px;
  font-size: 1.7rem;
  line-height: 1;
  display: grid;
  place-items: center;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: #ffffff33; }
.lb-close { top: max(1rem, env(safe-area-inset-top)); right: 1rem; }
.lb-prev  { left: 1rem;  top: 50%; transform: translateY(-50%); }
.lb-next  { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-caption {
  position: absolute;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 0; right: 0;
  text-align: center;
  color: #cbd5e1;
  font-size: .85rem;
  padding: 0 4rem;
}

/* ----------------------------------------------------------- Schmale Handys */

@media (max-width: 560px) {
  .page { padding: .75rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
  .batch-actions { margin-left: 0; width: 100%; }
  .batch-actions .btn { flex: 1 1 auto; }
  .queue-stats { text-align: left; }
  .page-head .btn { margin-left: 0; }
  .lb-prev, .lb-next { width: 40px; height: 40px; }
}

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