/* ═══════════════════════════════════════════════════════════════════════
   Uploader foto-huwi.ch

   Gestaltung angelehnt an foto-huwi.ch: Lato, Orange #f29100, kantige
   Flächen. Eigenständig genug, um auch allein zu stehen.

   Aufbau: 1 Grundlagen · 2 Kopf/Fuss · 3 Karten · 4 Formular ·
           5 Dateiauswahl · 6 Dateiliste · 7 Fortschritt · 8 Abschluss ·
           9 Meldungen · 10 Eingebetteter Modus
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Schrift ──────────────────────────────────────────────────────── */
@font-face {
    font-family: 'Lato';
    src: url('../fonts/lato-300.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Lato';
    src: url('../fonts/lato-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Lato';
    src: url('../fonts/lato-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Lato';
    src: url('../fonts/lato-900.woff2') format('woff2');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

/* ─── 1 Grundlagen ─────────────────────────────────────────────────── */
:root {
    --accent: #f29100;
    --accent-strong: #d97f00;
    --accent-soft: rgba(242, 145, 0, .1);

    --bg: #f2f1ef;
    --card: #ffffff;
    --text: #1c1c1c;
    --muted: #6b6b6b;
    --line: #e2e0dd;
    --line-strong: #c9c6c2;
    --danger: #c0392b;
    --success: #2e7d32;

    --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 12px 32px rgba(0, 0, 0, .06);
    --wrap: 720px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121211;
        --card: #1c1c1b;
        --text: #ececea;
        --muted: #a3a09b;
        --line: #302f2d;
        --line-strong: #46443f;
        --danger: #ff8a7a;
        --success: #7bc47f;
        --accent-soft: rgba(242, 145, 0, .14);
        --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .35);
    }
}

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

/* Muss sein: Regeln wie ".filelist-head { display: flex }" würden das
   hidden-Attribut sonst aushebeln und ausgeblendete Bereiche zeigen. */
[hidden] { display: none !important; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1 {
    font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -.02em;
    margin: 0 0 .4em;
}

p { margin: 0 0 1em; }
a { color: var(--accent-strong); }

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

/* ─── 2 Kopf und Fuss ──────────────────────────────────────────────── */
/* Dieselbe Breite und dasselbe Innenmass wie .wrap darunter — so beginnt das
   Logo exakt an der Kante, an der auch das helle Feld beginnt. */
.site-header {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 28px 20px 0;
}
.site-header.is-wide { max-width: min(1500px, 100%); }

.brand {
    display: block;
    text-decoration: none;
}

/* Zwei Fassungen desselben Logos: die Schrift der Vorlage ist dunkel und
   wäre im Dunkelmodus unsichtbar. Umgeschaltet wird über die Systemeinstellung
   des Besuchers, nicht über einen Filter — ein invertiertes Bild würde auch
   das Orange verfälschen. */
.logo {
    display: block;
    width: auto;
    height: 38px;
    max-width: 100%;
}
.logo-dark { display: none; }

@media (prefers-color-scheme: dark) {
    .logo-light { display: none; }
    .logo-dark { display: block; }
}

@media (max-width: 560px) {
    .logo { height: 32px; }
}

.site-footer {
    margin-top: auto;
    padding: 32px 20px 40px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent-strong); text-decoration: underline; }

/* ─── 3 Karten ─────────────────────────────────────────────────────── */
.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 32px 20px 8px;
}

.panel {
    background: var(--card);
    box-shadow: var(--shadow);
    padding: clamp(24px, 5vw, 44px);
}

.panel-head { margin-bottom: 28px; }
.lead {
    color: var(--muted);
    margin: 0;
    font-size: 16px;
}

/* ─── 4 Formular ───────────────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 28px;
}
.field-wide { grid-column: 1 / -1; }

@media (max-width: 560px) {
    .grid { grid-template-columns: 1fr; }
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 7px;
}
.req { color: var(--accent); }
.opt {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--muted);
    font-size: 12px;
}

input[type=text], input[type=email], input[type=tel], textarea {
    width: 100%;
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line-strong);
    padding: 12px 14px;
    border-radius: 0;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 88px; }

input:hover, textarea:hover { border-color: var(--muted); }

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

.field.invalid input, .field.invalid textarea { border-color: var(--danger); }

.err {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--danger);
    min-height: 0;
}
.err:empty { display: none; }

/* Honigtopf: vom Bildschirm genommen, aber nicht display:none —
   manche Bots werten das aus. */
.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ─── 5 Dateiauswahl ───────────────────────────────────────────────── */
.drop {
    border: 2px dashed var(--line-strong);
    padding: 44px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .15s;
    color: var(--muted);
}
.drop:hover, .drop:focus-visible {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.drop.dragging {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(1.005);
}
.drop-icon {
    width: 44px;
    height: 44px;
    color: var(--accent);
    margin-bottom: 10px;
}
.drop-title {
    margin: 0 0 2px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.drop-sub { margin: 0; font-size: 14px; }
.drop .link {
    color: var(--accent-strong);
    text-decoration: underline;
    text-underline-offset: 2px;
}

@media (max-width: 560px) {
    .drop { padding: 32px 18px; }
}

/* ─── 6 Dateiliste ─────────────────────────────────────────────────── */
.filelist-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 22px 0 8px;
    font-size: 14px;
    color: var(--muted);
}

.filelist {
    list-style: none;
    margin: 0;
    padding: 0;
}
.filelist li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
}
.filelist li:first-child { border-top: 1px solid var(--line); }

.f-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 400;
}
.f-size {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.f-remove {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    border-radius: 0;
}
.f-remove:hover { color: var(--danger); background: var(--accent-soft); }

.f-state {
    flex: 0 0 auto;
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    min-width: 56px;
    text-align: right;
}
.f-state.ok { color: var(--success); }
.f-state.fail { color: var(--danger); }

.linkbtn {
    border: 0;
    background: none;
    color: var(--accent-strong);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 4px;
}

/* ─── 7 Aktionen und Fortschritt ───────────────────────────────────── */
.actions { margin-top: 30px; }

.btn {
    font: inherit;
    font-weight: 700;
    font-size: 16px;
    padding: 15px 34px;
    border: 1px solid transparent;
    border-radius: 0;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    min-height: 48px;
}
.btn-primary {
    /* Dunkler Text auf Orange: kräftig und gut lesbar. */
    background: var(--accent);
    color: #141414;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

/* ─── 7b Der Absende-Bereich ───────────────────────────────────────────
   Der häufigste Bedienfehler bei Upload-Formularen: Dateien werden
   ausgewählt, und der Absende-Knopf wird übersehen — der Kunde glaubt,
   fertig zu sein. Darum tritt dieser Bereich deutlich hervor, sobald
   etwas bereitliegt. */
.send-area {
    padding-top: 4px;
    transition: background .2s, padding .2s;
}
.send-area.is-ready {
    background: var(--accent-soft);
    border-top: 2px solid var(--accent);
    padding: 22px clamp(16px, 3vw, 24px) 20px;
    margin-top: 26px;
}

.send-note {
    margin: 0 0 16px;
    font-size: 15px;
    color: var(--text);
}
.send-note strong { font-weight: 700; }

.btn-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 17px;
    padding: 17px 40px;
    min-height: 56px;
}
.btn-send .btn-arrow {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    transition: transform .15s;
}
.btn-send:hover:not(:disabled) .btn-arrow { transform: translateX(4px); }

/* Einmaliger Impuls, wenn der Knopf gerade nutzbar geworden ist. */
@keyframes send-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(242, 145, 0, .55); }
    70%  { box-shadow: 0 0 0 16px rgba(242, 145, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(242, 145, 0, 0); }
}
.btn-send.pulse { animation: send-pulse 1.1s ease-out 2; }

@media (max-width: 560px) {
    .btn-send { width: 100%; }
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }

.hint {
    margin: 14px 0 0;
    font-size: 13px;
    color: var(--muted);
}

.bar {
    height: 10px;
    background: var(--line);
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .25s ease-out;
}
.bar-meta {
    display: flex;
    justify-content: space-between;
    margin: 10px 0 24px;
    font-size: 14px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
#progressText { font-weight: 700; color: var(--text); }

.filelist-progress li { font-size: 14px; }

/* ─── 8 Abschluss ──────────────────────────────────────────────────── */
.panel-done { text-align: center; }
.panel-done .filelist { text-align: left; }
.panel-done .actions { display: flex; justify-content: center; }

.done-mark {
    color: var(--success);
    width: 68px;
    height: 68px;
    margin: 0 auto 20px;
}
.done-mark svg { width: 100%; height: 100%; }

.filelist-done li { font-size: 14px; }

/* ─── 9 Meldungen ──────────────────────────────────────────────────── */
.alert {
    margin: 20px 0 0;
    padding: 16px 18px;
    background: var(--card);
    border-left: 4px solid var(--danger);
    box-shadow: var(--shadow);
    font-size: 15px;
}
.alert strong { display: block; margin-bottom: 3px; }

/* ─── 9b Sendungs- und Verwaltungsseiten ───────────────────────────── */
.wrap > .panel + .panel { margin-top: 24px; }

.panel-narrow { max-width: 420px; margin: 0 auto; }

.h-small { font-size: 1.15rem; font-weight: 700; letter-spacing: 0; }

.meta-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 15px;
    margin: 0 0 24px;
}
.meta-table th {
    text-align: left;
    font-weight: 400;
    color: var(--muted);
    padding: 5px 20px 5px 0;
    white-space: nowrap;
    vertical-align: top;
    width: 1%;
}
.meta-table td { padding: 5px 0; }

.quote {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    padding: 16px 18px;
    margin: 0 0 24px;
    font-size: 15px;
}
.quote-label {
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
    text-decoration: none;
    display: inline-block;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

a.btn { text-decoration: none; display: inline-block; }

.actions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}
.actions-row .hint { flex: 1 1 240px; margin: 0; }

.confirm-form { margin: 0; }

.alert-info { border-left-color: var(--accent); }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 0 0 16px;
    margin: 0 0 6px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    color: var(--muted);
}
.toolbar a {
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
}
.toolbar a:hover { color: var(--text); }
.toolbar a.is-active { color: var(--text); border-bottom-color: var(--accent); font-weight: 700; }
.toolbar-right { margin-left: auto; }

/* Nutzt die verfügbare Fensterbreite bis zu einer Obergrenze, ab der Tabellen
   nur noch auseinandergezogen würden. Kein fester Wert: auf einem schmalen
   Fenster wurde die Aktionsspalte sonst abgeschnitten. */
.wrap-wide { max-width: min(1500px, 100%); }

.backlink {
    margin: 0 0 16px;
    font-size: 14px;
}
.backlink a {
    color: var(--muted);
    text-decoration: none;
}
.backlink a:hover { color: var(--accent-strong); }

/* Zur Not scrollt die Tabelle für sich — die Seite selbst nie. */
.table-scroll { overflow-x: auto; }

.list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.list-table th {
    text-align: left;
    font-size: 12px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
    padding: 12px 12px 10px 0;
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
}
.list-table td {
    padding: 12px 12px 12px 0;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.list-table .col-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list-table .col-check { width: 28px; padding-right: 8px; }
.list-table .col-actions { text-align: right; white-space: nowrap; }
.list-table .sub { color: var(--muted); font-size: 13px; }
.list-table .is-unfinished td { opacity: .72; }

.row-link {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
    font-weight: 400;
}
.row-link:hover { color: var(--accent-strong); border-bottom-color: var(--accent); }

/* Sinnbilder statt Textlinks: die Spalte bleibt schmal, und die Bedeutung
   erschliesst sich auf einen Blick. Beschriftet sind sie über title und
   aria-label am Link. */
.col-actions { white-space: nowrap; }
.col-actions a,
.f-action {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--muted);
    text-decoration: none;
    transition: color .15s, background .15s;
}
.col-actions a:hover,
.col-actions a:focus-visible,
.f-action:hover,
.f-action:focus-visible {
    color: var(--accent-strong);
    background: var(--accent-soft);
}
.col-actions a.is-danger:hover,
.col-actions a.is-danger:focus-visible {
    color: #fff;
    background: var(--danger);
}
.icon { display: block; }
/* Über allem: ein Bedienelement darf nie von einem Nachbarn überdeckt werden. */
.f-action {
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
}

/* ─── Dateiliste mit Vorschaubildern ───────────────────────────────────
   Die Kachel ist quadratisch und behält ihren Platz, auch bevor das Bild
   geladen ist — sonst würde die Liste beim Nachladen springen. */
.filelist-preview li {
    gap: 16px;
    padding: 12px 0;
    /* Die Zeilenhöhe steht von Anfang an fest — auch bevor ein einziges
       Vorschaubild geladen ist. Sonst wächst die Liste beim Nachladen, alles
       rutscht nach unten, und ein Klick landet dort, wo eben noch etwas
       anderes war. */
    min-height: 124px;
}
.f-thumb {
    /* Feste Fläche, unverhandelbar: nicht schrumpfen, nicht wachsen.
       overflow: hidden ist das Sicherheitsnetz — selbst ein unerwartet grosses
       Bild kann so nie über seine Fläche hinausragen und die Bedienelemente
       daneben verdecken. */
    flex: 0 0 100px;
    width: 100px;
    height: 100px;
    overflow: hidden;
    /* Bewusst position:relative statt Grid oder Flex: das Bild wird darin
       absolut auf die volle Fläche gelegt. Als Grid-Element hatte "height:100%"
       keine Wirkung — ein Hochformat blieb 131 statt 100 Punkte hoch und wurde
       vom overflow oben und unten abgeschnitten. */
    position: relative;
    display: block;
    /* Ruhige Fläche hinter dem Bild. Sie macht sichtbar, wo ein Hoch- oder
       Panoramaformat schmaler ist als das Feld — ohne selbst aufzufallen. */
    background: var(--bg);
    border: 1px solid var(--line);
}
/* Das Bildelement deckt die Fläche exakt ab, der Bildinhalt wird von
   object-fit:contain hineingerechnet: vollständig sichtbar, im Originalformat,
   mittig — nie beschnitten, nie verzerrt. */
.f-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.f-ext {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .05em;
    color: var(--accent-strong);
}

@media (max-width: 560px) {
    .f-thumb { width: 72px; height: 72px; }
}
.filelist-preview .f-name {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}
.filelist-preview .f-name:hover {
    color: var(--accent-strong);
    border-bottom-color: var(--accent);
}

.tag {
    display: inline-block;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 1px 7px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
}

.danger-link { color: var(--danger); text-decoration: none; border-bottom: 1px solid currentColor; }

.empty { color: var(--muted); padding: 24px 0; margin: 0; }

input[type=password] {
    width: 100%;
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line-strong);
    padding: 12px 14px;
}
input[type=password]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

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

/* Auf schmalen Bildschirmen wird die Tabelle sonst unlesbar gequetscht. */
@media (max-width: 560px) {
    .list-table { min-width: 520px; }
}

/* ─── 10 Eingebetteter Modus ───────────────────────────────────────── */
.is-embedded {
    background: transparent;
    min-height: 0;
}
.is-embedded .wrap { padding: 0; max-width: none; }
.is-embedded .panel { box-shadow: none; padding: clamp(20px, 4vw, 32px); }

/* ─── Bewegung sparsam ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
