/* Layout: eine ruhige Spalte. Oben die Gruppe mit ablaufendem Zündschnur-Timer,
   darunter die Ablage (Drop-Zone) und die Liste mit fünf "Fächern". */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/ibm-plex-sans.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #eef1f4;
  --surface: #ffffff;
  --ink: #141c26;
  --muted: #5a6676;
  --line: #d3dae2;
  --accent: #2346c4;
  --accent-ink: #ffffff;
  --accent-soft: #e2e8fa;
  --warn: #a8510a;
  --warn-soft: #fbeedd;
  --danger: #bf2530;
  --danger-soft: #fbe5e6;
  --ok: #1d7a4c;
  --shadow: 0 1px 2px rgb(20 28 38 / 0.06), 0 8px 24px rgb(20 28 38 / 0.06);

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: 2.5rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0e1319;
    --surface: #161e27;
    --ink: #e6ebf1;
    --muted: #93a0af;
    --line: #2a3542;
    --accent: #7f9cff;
    --accent-ink: #0e1319;
    --accent-soft: #1c284a;
    --warn: #f2a65a;
    --warn-soft: #3a2a17;
    --danger: #ff7a7f;
    --danger-soft: #3b1d21;
    --ok: #5fd39a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0e1319;
  --surface: #161e27;
  --ink: #e6ebf1;
  --muted: #93a0af;
  --line: #2a3542;
  --accent: #7f9cff;
  --accent-ink: #0e1319;
  --accent-soft: #1c284a;
  --warn: #f2a65a;
  --warn-soft: #3a2a17;
  --danger: #ff7a7f;
  --danger-soft: #3b1d21;
  --ok: #5fd39a;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding-block: 2.5rem 2rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
main { flex: 1; }

h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
}

.eyebrow {
  display: block;
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

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

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
}
.wordmark {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark span { color: var(--accent); }
.tagline { margin: 0; color: var(--muted); }

/* --- Buttons & Felder ---------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font: 600 var(--step-0) / 1.2 var(--font-body);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-weight: 500; }
.field input {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  width: 100%;
}
.field input:focus-visible { outline-offset: 0; border-color: var(--accent); }

.alert {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9375rem;
}

/* --- Anmeldung ----------------------------------------------------- */

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 30rem;
}
.login-card h1 { font-size: var(--step-2); }
.lead { margin: -0.4rem 0 0; color: var(--muted); max-width: 60ch; }

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 0.4rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.facts dt { font-size: var(--step--1); color: var(--muted); }
.facts dd { margin: 0; font-family: var(--font-mono); font-size: 0.875rem; font-weight: 500; }

/* --- Gruppe -------------------------------------------------------- */

.group { display: flex; flex-direction: column; gap: 1.25rem; }

.group-head {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: end;
  gap: 1rem 1.5rem;
  padding-bottom: 1.1rem;
}
.group-id { min-width: 0; }
.group-id h1 {
  font-size: var(--step-3);
  overflow-wrap: anywhere;
}
.timer { text-align: right; }
.countdown {
  font-family: var(--font-mono);
  font-size: var(--step-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.timer.is-low .countdown { color: var(--warn); }
.timer.is-critical .countdown { color: var(--danger); }

.fuse {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.fuse-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  transition: transform 1s linear, background-color 0.3s;
}
.timer.is-low ~ .fuse .fuse-fill { background: var(--warn); }
.timer.is-critical ~ .fuse .fuse-fill { background: var(--danger); }

/* Drop-Zone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.2rem;
  padding: 2rem 1rem;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.dropzone:hover { border-color: var(--muted); }
.dropzone.is-over {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  color: var(--accent);
}
.dropzone.is-full { cursor: not-allowed; opacity: 0.65; }
.dropzone.is-busy { cursor: progress; }
.drop-icon { width: 2.5rem; height: 2.5rem; margin-bottom: 0.35rem; color: var(--accent); }
.drop-title { font-family: var(--font-display); font-size: var(--step-1); font-weight: 600; color: var(--ink); }
.drop-limits { margin-top: 0.4rem; font-family: var(--font-mono); font-size: var(--step--1); }

.notice {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.9375rem;
}
.notice.is-error { background: var(--danger-soft); color: var(--danger); }
.notice ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }

/* Dateiliste */
.files { display: flex; flex-direction: column; gap: 0.6rem; }
.files-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.files-head h2 { font-size: var(--step-1); }
.files-hint { margin: -0.3rem 0 0.2rem; color: var(--muted); font-size: 0.9375rem; }

.slots {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
}
.slot { width: 14px; height: 18px; border-radius: 3px; border: 1.5px solid var(--line); }
.slot.is-used { background: var(--accent); border-color: var(--accent); }
.slots-label { margin-left: 0.4rem; font-variant-numeric: tabular-nums; }

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.file-list:empty { display: none; }

.file {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.8rem 0.9rem;
  border-top: 1px solid var(--line);
}
.file:first-child { border-top: 0; }
.file[draggable="true"] { cursor: grab; }
.file[draggable="true"]:active { cursor: grabbing; }
.file.is-new { animation: arrive 0.6s ease-out; }
@keyframes arrive { from { background: var(--accent-soft); } to { background: transparent; } }

.ext {
  width: 3rem;
  height: 3.4rem;
  display: grid;
  place-items: end center;
  padding-bottom: 0.45rem;
  border-radius: 4px 12px 4px 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  overflow: hidden;
}

.file-main { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.file-name {
  font-weight: 600;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.file-meta .size { display: inline-flex; align-items: center; gap: 0.45rem; }
.size-text { min-width: 4.2em; text-align: right; }
.size-bar { width: 3.5rem; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.size-bar span { display: block; height: 100%; background: var(--muted); }

.file-actions { display: flex; gap: 0.35rem; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn svg { width: 1.15rem; height: 1.15rem; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.icon-btn.is-confirm {
  width: auto;
  padding: 0 0.7rem;
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
  font: 600 var(--step--1) / 1 var(--font-body);
}

.empty {
  margin: 0;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.foot { color: var(--muted); font-size: var(--step--1); }

/* --- Schmale Bildschirme ------------------------------------------ */

@media (max-width: 560px) {
  .page { padding-block: 1.5rem; gap: 1.5rem; }
  .group-head { grid-template-columns: 1fr auto; }
  .group-head .btn-ghost { grid-column: 1 / -1; justify-self: start; grid-row: 3; }
  .group-id h1 { font-size: var(--step-2); }
  .facts { grid-template-columns: 1fr; gap: 0.4rem; }
  .facts div { display: flex; justify-content: space-between; gap: 1rem; }
  .file { gap: 0.7rem; padding: 0.7rem; }
  .file-actions { flex-direction: column; }
  .ext { width: 2.5rem; height: 2.9rem; }
}

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