:root {
  --bg: #14161a;
  --surface: #1d2026;
  --surface-2: #262a32;
  --line: #343a45;
  --text: #e8eaee;
  --muted: #99a1ae;
  --accent: #5b9dff;
  --danger: #e2564d;
  --ok: #4bb87a;
  --radius: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --line: #d7dbe2;
    --text: #1b1e24;
    --muted: #626a78;
  }
}

* {
  box-sizing: border-box;
}

/* Muss nach den Layoutregeln greifen, sonst zeigt ein display: grid weiter
   unten ein Element trotz hidden-Attribut an. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 {
  font-size: 1.25rem;
  margin: 0;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 0.75rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button {
  font: inherit;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: #08101f;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

button:focus-visible,
input:focus-visible,
.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Login ---------- */

.page-login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.card p {
  margin-top: 0.35rem;
}

form label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

form button {
  width: 100%;
  margin-top: 1.4rem;
}

.error {
  margin-top: 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  background: rgba(226, 86, 77, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 0.9rem;
}

/* ---------- App ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

section + section {
  margin-top: 2.5rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-head h2 {
  margin: 0;
}

/* ---------- Pfadleiste und Ordner ---------- */

.crumbs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
}

.crumbs li + li::before {
  content: "/";
  color: var(--muted);
  margin-right: 0.25rem;
}

.crumbs li.current {
  font-weight: 600;
}

.crumbs-actions {
  display: flex;
  gap: 0.5rem;
}

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.small-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.target {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
}

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

.folder-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem 0.35rem 0.25rem;
}

.folder-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  color: var(--text);
  font-weight: 500;
  text-align: left;
  overflow-wrap: anywhere;
}

.folder-icon {
  color: var(--accent);
}

.no-preview {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.85rem;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.dropzone p {
  margin: 0.2rem 0;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.queue {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.queue li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.25rem 1rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.queue .state {
  color: var(--muted);
}

.queue .state.ok {
  color: var(--ok);
}

.queue .state.fail {
  color: var(--danger);
}

progress {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  height: 6px;
}

/* Der Ersetzen-Knopf wird erst nach einem Konflikt angehaengt und gehoert
   trotzdem in die erste Zeile neben die Meldung. */
.queue .small-btn {
  grid-row: 1;
  grid-column: 3;
}

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

.card-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thumb {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-meta {
  padding: 0.6rem 0.75rem 0;
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.card-meta .name {
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  margin-top: auto;
}

.card-actions button {
  flex: 1;
  padding: 0.4rem 0.5rem;
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
