:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --error-bg: #fef2f2;
    --error-text: #b91c1c;
    --success-bg: #f0fdf4;
    --success-text: #15803d;
    --border: #e5e7eb;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

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

.logout-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
}
.logout-link:hover { color: var(--text); text-decoration: underline; }

main {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

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

form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

input[type="file"],
input[type="password"] {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    flex: 1;
    min-width: 200px;
}

button {
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
}
button:hover { background: var(--primary-dark); }

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

.error {
    background: var(--error-bg);
    color: var(--error-text);
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.success {
    background: var(--success-bg);
    color: var(--success-text);
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

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

th, td {
    text-align: left;
    padding: 0.5rem 0.4rem;
    border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 600; }

.download-btn {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.download-btn:hover { text-decoration: underline; }

.delete-form { margin: 0; }

.delete-btn {
    background: none;
    border: none;
    color: var(--error-text);
    font-weight: 600;
    padding: 0;
    cursor: pointer;
    font-size: 0.9rem;
}
.delete-btn:hover { text-decoration: underline; }

.share-form {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: nowrap;
}

.share-form select {
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
}

.share-btn {
    background: none;
    border: 1px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}
.share-btn:hover { background: var(--primary); color: white; }

.share-created {
    border: 1px solid var(--success-text);
    border-radius: var(--radius);
    padding: 0.9rem;
    margin-bottom: 1rem;
}

.link-copy-row {
    display: flex;
    gap: 0.5rem;
}

.link-copy-row input[type="text"] {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.copy-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}
.copy-btn:hover { background: var(--bg); }

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.auth-box h1 { margin: 0 0 0.25rem 0; font-size: 1.2rem; }

.auth-box form {
    flex-direction: column;
    align-items: stretch;
}

.auth-box label { font-size: 0.85rem; color: var(--muted); }

/* ---------- Mobile Optimierung ---------- */

@media (max-width: 640px) {
    .top-bar {
        padding: 0.85rem 1rem;
    }

    main {
        margin: 1rem auto;
        padding: 0 0.75rem;
        gap: 1rem;
    }

    section {
        padding: 1rem;
        border-radius: 8px;
    }

    /* Upload-Formular untereinander statt nebeneinander */
    .upload-section form {
        flex-direction: column;
        align-items: stretch;
    }

    input[type="file"] {
        min-width: 0;
    }

    /* Größere Touch-Ziele für Buttons und Links */
    button,
    .download-btn,
    .share-btn,
    .copy-btn {
        min-height: 44px;
    }

    .download-btn {
        display: inline-flex;
        align-items: center;
    }

    /* Tabellen als gestapelte Karten statt horizontalem Scrollen */
    table, thead, tbody, th, td, tr {
        display: block;
        width: 100%;
    }

    .file-list table thead,
    .share-list table thead {
        position: absolute;
        left: -9999px; /* für Screenreader erhalten, visuell ausgeblendet */
    }

    .file-list table tr,
    .share-list table tr {
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 0.75rem;
        padding: 0.25rem 0.75rem;
    }

    .file-list table tr:last-child,
    .share-list table tr:last-child {
        margin-bottom: 0;
    }

    .file-list td,
    .share-list td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--border);
        text-align: right;
    }

    .file-list td:last-child,
    .share-list td:last-child {
        border-bottom: none;
    }

    .file-list td::before,
    .share-list td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        text-align: left;
        flex-shrink: 0;
    }

    .share-form {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .share-form select {
        min-height: 40px;
    }

    /* Link + Kopieren-Button untereinander, damit der Link lesbar bleibt */
    .link-copy-row {
        flex-direction: column;
        width: 100%;
    }

    .link-copy-row input[type="text"] {
        width: 100%;
    }

    .copy-btn {
        width: 100%;
    }

    .auth-box {
        max-width: 100%;
        margin: 0 1rem;
    }
}
