/* Schriften liegen auf dem eigenen Server. Es wird nichts von Google oder anderen Dritten geladen. */

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/instrument-sans-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/instrument-sans-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/instrument-sans-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/instrument-sans-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --paper: #f6f5f2;
  --surface: #ffffff;
  --ink: #1f2024;
  --muted: #7a776f;
  --line: #d9d5cd;
  --line-strong: #b9b3a8;
  --brass: #8c6f3f;
  --danger: #8a3a2e;
  --ok: #3c6146;
  --grid: rgba(31, 32, 36, 0.055);
  --radius: 2px;
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: clamp(2rem, 1.4rem + 3vw, 2.5rem);
  /* Seitenrand. Auf Geräten mit Notch nie kleiner als der sichere Bereich. */
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --pad-l: max(var(--gutter), env(safe-area-inset-left, 0px));
  --pad-r: max(var(--gutter), env(safe-area-inset-right, 0px));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
}

a {
  color: inherit;
}

button {
  font: inherit;
  cursor: pointer;
}

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

.sheet {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(1.25rem + env(safe-area-inset-top, 0px)) var(--pad-r) 1.25rem var(--pad-l);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 245, 242, 0.85);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.wordmark {
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
}

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

.ghost-link {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.3rem 0.7rem;
  background: var(--surface);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.ghost-link:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.sheet-body {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: clamp(2rem, 8vh, 5rem) var(--pad-r) 3rem var(--pad-l);
}

.sheet-foot {
  padding: 1rem var(--pad-r) calc(1.5rem + env(safe-area-inset-bottom, 0px)) var(--pad-l);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Öffentliche Seite */

.panel {
  width: 100%;
  max-width: 34rem;
}

.panel[hidden] {
  display: none;
}

h1 {
  font-size: var(--step-3);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 0.6rem;
  overflow-wrap: anywhere;
}

.lede {
  margin: 0 0 2.5rem;
  color: var(--muted);
  max-width: 44ch;
}

.field {
  display: block;
  margin-bottom: 1.5rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

#code-input,
.code-input {
  width: 100%;
  font-family: var(--mono);
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  transition: border-color 0.18s ease;
}

#code-input::placeholder,
.code-input::placeholder {
  color: #c9c4ba;
  letter-spacing: 0.18em;
}

#code-input:focus,
.code-input:focus {
  border-color: var(--brass);
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: #33353b;
  border-color: #33353b;
}

.btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

.btn-wide {
  width: 100%;
}

.btn-quiet {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-quiet:hover {
  background: #efece6;
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: #d8c3bd;
}

.btn-danger:hover {
  background: #f6ece9;
  color: var(--danger);
  border-color: #c9a79f;
}

.message {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.9rem;
  border-left: 2px solid var(--danger);
  background: #f7eeeb;
  color: var(--danger);
  font-size: 0.9rem;
}

.message[hidden] {
  display: none;
}

.message.is-ok {
  border-left-color: var(--ok);
  background: #eef3ef;
  color: var(--ok);
}

.file-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  border-top: 1px solid var(--line);
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.file-row > div {
  min-width: 0;
}

.file-row .btn {
  flex-shrink: 0;
}

.file-name {
  overflow-wrap: anywhere;
}

.file-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* Galerie: Dateiliste als Kacheln, sobald Bilder mit Vorschau dabei sind */

.panel.is-gallery {
  max-width: 64rem;
}

.file-list.is-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
  border-top: 0;
}

.file-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.tile-figure {
  position: relative;
  display: block;
  flex: none;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  cursor: zoom-in;
}

/* Absolut gesetzt, damit die Kachel ihr Seitenverhältnis behält, egal wie das Bild geschnitten ist. */
.tile-figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0.5rem;
  /* Grundrisse nie beschneiden */
  object-fit: contain;
}

.tile-figure:focus-visible {
  outline-offset: -2px;
}

.tile-figure.is-plain {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  cursor: default;
}

.tile-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem 0.8rem;
}

.tile-body > div {
  min-width: 0;
}

.tile-body .file-name {
  font-size: 0.9rem;
  line-height: 1.35;
}

.tile-body .btn {
  flex-shrink: 0;
}

/* Große Ansicht */

.viewer {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--paper);
}

.viewer[open] {
  display: flex;
  flex-direction: column;
}

.viewer::backdrop {
  background: var(--paper);
}

html:has(.viewer[open]) {
  overflow: hidden;
}

.viewer-head,
.viewer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-left: var(--pad-l);
  padding-right: var(--pad-r);
}

.viewer-head {
  padding-top: calc(0.8rem + env(safe-area-inset-top, 0px));
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.viewer-foot {
  justify-content: center;
  padding-top: 0.8rem;
  padding-bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}

.viewer-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.viewer-title .file-name {
  font-size: 0.95rem;
}

.viewer-stage {
  flex: 1;
  min-height: 0;
  padding: clamp(0.5rem, 2vw, 1.5rem);
}

.viewer-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

/* Solange nur das kleine Bild da ist, leicht zurücknehmen. */
.viewer-stage.is-loading img {
  opacity: 0.55;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  margin: 0 0 2rem;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.summary div {
  display: flex;
  gap: 0.4rem;
}

.summary dd {
  margin: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Kopfzeile der Dateiansicht: links die Eckdaten, rechts die Aktionen in klein */
.files-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 2rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.files-bar .summary {
  margin: 0;
}

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

/* Bei wenigen Dateien wären die Knöpfe unten nur eine Wiederholung in Sichtweite. */
.panel.is-short .actions {
  display: none;
}

/* In der Listenansicht zieht die Liste selbst die Linie. */
.files-bar:has(+ .file-list:not(.is-gallery)) {
  padding-bottom: 0;
  border-bottom: 0;
}

.fade-in {
  animation: rise 0.35s ease-out both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    animation: none;
  }
  * {
    transition-duration: 0.01ms !important;
  }
}

/* Adminbereich */

.admin-body {
  display: grid;
  grid-template-columns: clamp(14rem, 28vw, 22rem) minmax(0, 1fr);
  gap: 0;
  flex: 1;
  align-items: stretch;
}

.admin-aside {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 1.25rem clamp(1rem, 2vw, 1.5rem) calc(1.25rem + env(safe-area-inset-bottom, 0px))
    max(clamp(1rem, 2vw, 1.5rem), env(safe-area-inset-left, 0px));
  overflow-y: auto;
}

.admin-detail {
  min-width: 0;
}

/* Die Tabellen richten sich nach der Breite dieser Spalte, nicht nach der
   des Bildschirms. Siehe @container weiter unten. */
.admin-main {
  container-type: inline-size;
  container-name: detail;
  padding: 1.25rem max(clamp(1rem, 3vw, 2rem), env(safe-area-inset-right, 0px))
    calc(3rem + env(safe-area-inset-bottom, 0px)) clamp(1rem, 3vw, 2rem);
}

.back-link {
  display: none;
}

.search-input {
  display: block;
  width: 100%;
  margin-bottom: 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  border-color: var(--brass);
  outline: none;
}

.section-title {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.code-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.code-card {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color 0.15s ease;
}

.code-card:hover {
  border-color: var(--line-strong);
}

.code-card.is-active {
  border-color: var(--brass);
  box-shadow: inset 2px 0 0 var(--brass);
}

.code-card .code-value {
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

.code-card .code-label {
  font-size: 0.82rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
}

.status.is-ok {
  color: var(--ok);
}

.status.is-blocked {
  color: var(--danger);
}

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

.card h2 {
  font-size: var(--step-1);
  font-weight: 500;
  margin: 0 0 1rem;
}

.card h3 {
  font-size: 0.95rem;
  font-weight: 500;
  margin: 1.5rem 0 0.6rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.9rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
}

.form-grid input:focus,
.form-grid textarea:focus {
  border-color: var(--brass);
  outline: none;
}

.form-grid .span-all {
  grid-column: 1 / -1;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.card h2 + .hint {
  margin: 0 0 1rem;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.78rem;
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.5rem 0.4rem 0;
}

.table td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.5rem 0.5rem 0;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table td.num,
.table th.num {
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* Lange IPv6-Adressen dürfen umbrechen, statt die Namensspalte zu zerdrücken. */
.table td.cell-ip {
  white-space: normal;
  max-width: 11rem;
}

.table .cell-main {
  min-width: 9rem;
}

.toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1rem;
}

.dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  background: var(--paper);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.touch-only {
  display: none;
}

.dropzone .btn {
  gap: 0;
}

.dropzone.is-over {
  border-color: var(--brass);
  background: #f2ece1;
  color: var(--ink);
}

.progress {
  height: 2px;
  background: var(--line);
  margin-top: 0.75rem;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brass);
  transition: width 0.2s ease;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.inbox-card {
  margin-bottom: 1.5rem;
}

.table tr.is-marked td {
  background: #f2ece1;
}

.table tr.is-marked td:first-child {
  box-shadow: inset 2px 0 0 var(--brass);
  padding-left: 0.5rem;
}

.row-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: min(22rem, 100%);
}

.login-card input {
  width: 100%;
  font: inherit;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  margin-bottom: 0.9rem;
}

/* ---------- Schmale Detailspalte: Tabellen werden zu gestapelten Zeilen ---------- */

@container detail (max-width: 52rem) {
  .table-stack,
  .table-stack tbody {
    display: block;
  }

  .table-stack thead {
    display: none;
  }

  .table-stack tbody {
    border-top: 1px solid var(--line);
  }

  .table-stack tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.9rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
  }

  .table-stack td {
    display: block;
    padding: 0;
    border: 0;
  }

  .table-stack td:empty {
    display: none;
  }

  .table-stack .cell-main {
    order: 1;
    flex: 1 1 100%;
    min-width: 0;
  }

  .table-stack .cell-sub {
    order: 2;
    flex: 1 1 100%;
    font-size: 0.82rem;
    color: var(--muted);
  }

  .table-stack td.num {
    order: 3;
    color: var(--muted);
    white-space: normal;
    max-width: none;
  }

  .table-stack .cell-actions {
    order: 4;
    flex: 1 1 100%;
    margin-top: 0.45rem;
  }

  .table-stack .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .table-stack tr.is-marked {
    background: #f2ece1;
    box-shadow: inset 2px 0 0 var(--brass);
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }

  .table-stack tr.is-marked td,
  .table-stack tr.is-marked td:first-child {
    background: none;
    box-shadow: none;
    padding-left: 0;
  }
}

/* ---------- Touch-Geräte: größere Tippflächen, kein Zoom beim Fokussieren ---------- */

@media (pointer: coarse) {
  .btn {
    min-height: 2.75rem;
  }

  .btn-small,
  .ghost-link {
    min-height: 2.5rem;
  }

  .ghost-link {
    display: inline-flex;
    align-items: center;
  }

  .sheet-head {
    align-items: center;
    padding-top: calc(0.7rem + env(safe-area-inset-top, 0px));
    padding-bottom: 0.7rem;
  }

  /* iOS zoomt in Felder mit weniger als 16px Schrift hinein. */
  .form-grid input,
  .form-grid textarea,
  .inline-form input,
  .search-input,
  .login-card input {
    font-size: 1rem;
    min-height: 2.75rem;
  }

  .text-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
  }

  .tab {
    min-height: 2.75rem;
  }

  .form-grid input[type='date'] {
    -webkit-appearance: none;
    appearance: none;
  }

  .form-grid input::-webkit-date-and-time-value {
    text-align: left;
  }

  .code-card {
    padding: 0.85rem 0.9rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  .drop-hint {
    display: none;
  }

  .touch-only {
    display: inline;
  }
}

/* ---------- Handy: Admin zeigt entweder Übersicht oder Detail ---------- */
/* Der Wert muss zu narrowLayout in admin.js passen. */

@media (max-width: 699.98px) {
  .admin-body {
    display: block;
  }

  .admin-aside {
    border-right: 0;
    overflow: visible;
    padding-left: var(--pad-l);
    padding-right: var(--pad-r);
  }

  .admin-main {
    padding-left: var(--pad-l);
    padding-right: var(--pad-r);
    padding-top: 1rem;
  }

  .admin-body[data-pane='list'] .admin-detail,
  .admin-body[data-pane='detail'] .admin-aside {
    display: none;
  }

  .back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0 var(--pad-r) 0 var(--pad-l);
    border: 0;
    border-bottom: 1px solid var(--line);
    background: none;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: left;
  }

  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .toolbar .btn {
    flex: 1 1 auto;
  }

  .dropzone {
    padding: 1.1rem;
  }
}

/* ---------- Handy: Kundenseite ---------- */

@media (max-width: 640px) {
  .sheet-body {
    padding-top: clamp(1.5rem, 5vh, 3rem);
    padding-bottom: 2rem;
  }

  .lede {
    margin-bottom: 2rem;
  }

  .files-bar {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
  }

  .actions-top {
    display: none;
  }

  /* Am Handy sind die Knöpfe nur unten, also dort immer zeigen. */
  .panel.is-short .actions {
    display: flex;
  }

  /* Die Aktionen bleiben am unteren Rand stehen, damit der ZIP-Download auch
     bei langen Dateilisten ohne Scrollen erreichbar ist. */
  .actions {
    position: sticky;
    bottom: 0;
    margin: 0 calc(-1 * var(--pad-r)) 0 calc(-1 * var(--pad-l));
    padding: 0.75rem var(--pad-r) calc(0.75rem + env(safe-area-inset-bottom, 0px)) var(--pad-l);
    background: rgba(246, 245, 242, 0.94);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--line);
    gap: 0.5rem;
  }

  .actions .btn {
    flex: 1 1 auto;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
    white-space: nowrap;
  }

  .file-list {
    margin-bottom: 0;
  }

  .file-row:last-child {
    border-bottom: 0;
  }

  .file-list.is-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
  }

  .tile-body {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.6rem;
  }

  .tile-body .file-name {
    font-size: 0.82rem;
  }

  /* Knöpfe einer Reihe auf gleicher Höhe, auch bei unterschiedlich langen Namen */
  .tile-body .btn {
    margin-top: auto;
  }

  .viewer-foot .btn {
    flex: 1 1 0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .sheet-foot {
    flex-direction: column;
    gap: 0.25rem;
  }
}

/* Sehr schmale Handys: beide Knöpfe passen nicht in eine Zeile, die Leiste
   würde zu viel Platz nehmen. Dann steht sie normal unter der Liste. */
@media (max-width: 359.98px) {
  .actions {
    position: static;
  }

  .actions-top {
    display: flex;
  }
}

/* Handy im Querformat: wenig Höhe, deshalb nichts festkleben. */
@media (max-height: 480px) {
  .sheet-head,
  .actions {
    position: static;
  }

  .actions-top {
    display: flex;
  }
}

[hidden] {
  display: none !important;
}

/* ---------- Kundenbereich (/kunde) ---------- */

.text-input {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  transition: border-color 0.18s ease;
}

.text-input::placeholder {
  color: #c9c4ba;
}

.text-input:focus {
  border-color: var(--brass);
  outline: none;
}

.text-input.is-code {
  font-family: var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.quiet-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
}

.text-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.text-link:hover {
  color: var(--ink);
}

.text-link:disabled {
  opacity: 0.5;
  cursor: progress;
}

.quiet-links + .hint {
  margin-top: 0.9rem;
}

.panel-area {
  max-width: 40rem;
}

.panel-area .lede {
  margin-bottom: 1.75rem;
  max-width: none;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 1.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.tab {
  margin-bottom: -1px;
  padding: 0.6rem 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected='true'],
.tab.is-current {
  color: var(--ink);
  border-bottom-color: var(--brass);
}

.tab-count {
  margin-left: 0.2rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.tab-count:empty {
  display: none;
}

/* Die Galerie darf breit werden, das Senden bleibt eine schmale Spalte. */
.send-view {
  max-width: 34rem;
}

.dropzone-large {
  padding: 2.25rem 1.5rem;
}

.dropzone-large .drop-title {
  margin: 0;
  color: var(--ink);
}

.dropzone-large .hint {
  margin-top: 0.75rem;
}

.dropzone.is-busy {
  opacity: 0.55;
  pointer-events: none;
}

.upload-queue {
  margin: 1.25rem 0 0;
}

.upload-row > div:first-child {
  flex: 1;
}

.upload-row .progress {
  margin-top: 0.5rem;
}

.upload-status {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.upload-row.is-done .upload-status {
  color: var(--ok);
}

.upload-row.is-failed .upload-status {
  color: var(--danger);
}

.upload-error {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: var(--danger);
}

.list-title {
  margin: 2.25rem 0 0.6rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Admin: Kunden ---------- */

.customer-list {
  margin-bottom: 1.5rem;
}

.customer-list .empty {
  margin: 0;
  font-size: 0.82rem;
}

.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.35rem;
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  color: var(--brass);
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.5;
  vertical-align: 0.1em;
  white-space: nowrap;
}

.invite-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.invite-box .code-display {
  font-family: var(--mono);
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  letter-spacing: 0.12em;
  user-select: all;
}

.invite-box .hint {
  margin: 0;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.inline-form input {
  flex: 1 1 12rem;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
}

.inline-form input:focus {
  border-color: var(--brass);
  outline: none;
}

.code-card .customer-name {
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .tabs {
    gap: 1.25rem;
  }

  .dropzone-large {
    padding: 1.5rem 1rem;
  }
}

/* ---------- Kundenseite: Auswahl vor dem Senden ---------- */

.upload-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}

.upload-side .text-link {
  font-size: 0.8rem;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.upload-actions + .hint {
  margin-top: 0.75rem;
}

/* ---------- Admin: Startseite und Bereiche ---------- */

.area-nav {
  display: flex;
  gap: 1.75rem;
  padding: 0 var(--pad-r) 0 var(--pad-l);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 245, 242, 0.85);
  overflow-x: auto;
}

.area-nav .tab {
  margin-bottom: 0;
  padding: 0.7rem 0;
}

.admin-home {
  flex: 1;
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 6vh, 4rem) var(--pad-r) 3rem var(--pad-l);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

.home-tile {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.4rem 1.4rem 1.5rem;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.home-tile:hover {
  border-color: var(--brass);
  box-shadow: inset 0 2px 0 var(--brass);
}

.home-label {
  font-size: var(--step-1);
  font-weight: 500;
}

.home-number {
  margin-top: 0.75rem;
  font-family: var(--mono);
  font-size: var(--step-3);
  line-height: 1.1;
}

.home-tile .status.is-new {
  color: var(--brass);
}

.home-text {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Auf der Startseite gibt es weder Liste noch Detail. */
.admin-body[data-area='home'] {
  display: none;
}

/* Der Eingang hat keine Liste: das Detail nutzt die ganze Breite. */
.admin-body[data-area='inbox'] {
  grid-template-columns: minmax(0, 1fr);
}

.admin-body[data-area='inbox'] .admin-aside {
  display: none;
}

@media (max-width: 699.98px) {
  .admin-body[data-area='inbox'] .admin-detail {
    display: block;
  }

  .area-nav {
    gap: 1.25rem;
  }

  .home-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .upload-actions .btn {
    flex: 1 1 auto;
  }
}

/* ---------- Kundenseite: einloggen und registrieren nebeneinander ---------- */

.login-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
