:root {
    --bg: #f4f5f9;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #16181d;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --success-bg: #ecfdf3;
    --success-text: #067647;
    --error-bg: #fef2f2;
    --error-text: #b91c1c;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

* {
    box-sizing: border-box;
}

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

/* ---------- Navbar ---------- */

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 32px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.navbar .brand {
    text-decoration: none;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    color: var(--text);
}

.brand-mark {
    color: var(--primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 22px;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: color 0.15s ease;
}

.nav-links a:hover {
    color: var(--text);
}

.nav-links .nav-cta {
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
}

.nav-links .nav-cta:hover {
    background: var(--primary-hover);
    color: #fff;
}

.nav-logout {
    color: var(--text-muted) !important;
}

/* ---------- Layout ---------- */

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

h1 {
    margin: 0 0 6px 0;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-muted);
    margin: 0 0 28px 0;
    font-size: 0.95rem;
}

/* ---------- Hero (Startseite) ---------- */

.hero {
    text-align: center;
    padding: 80px 20px;
}

.hero h1 {
    font-size: 2.4rem;
    margin-bottom: 14px;
}

.hero .accent {
    color: var(--primary);
}

.hero p {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 480px;
    margin: 0 auto 30px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ---------- Flash Messages ---------- */

.flashes {
    margin-bottom: 20px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.flash-error {
    background: var(--error-bg);
    color: var(--error-text);
}

/* ---------- Buttons ---------- */

button, .button {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.05s ease;
}

button:hover, .button:hover {
    background: var(--primary-hover);
}

button:active, .button:active {
    transform: scale(0.98);
}

.button-block {
    width: 100%;
}

.button-small {
    padding: 7px 14px;
    font-size: 0.83rem;
}

.button-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.button-ghost:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* ---------- Forms (Auth) ---------- */

.auth-page {
    display: flex;
    justify-content: center;
    padding-top: 40px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px;
    width: 100%;
    max-width: 380px;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 24px;
}

.share-card {
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    gap: 6px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

/* ---------- Inputs ---------- */

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    font-family: inherit;
    font-size: 0.92rem;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 100%;
    transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    font-family: inherit;
}

.description-input {
    margin: 14px 0;
}

/* ---------- Upload Form + Dropzone ---------- */

.upload-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 32px;
}

.category-select-wrapper {
    position: relative;
    z-index: 2;
    margin-bottom: 18px;
}

.category-select-wrapper label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.dropzone {
    position: relative;
    isolation: isolate;
    z-index: 1;
    margin-bottom: 18px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 32px 20px;
    text-align: center;
    background: var(--bg);
    transition: border-color 0.15s ease, background 0.15s ease;
    cursor: pointer;
}

.dropzone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone.has-file {
    border-color: var(--success-text);
    border-style: solid;
}

.dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-content {
    pointer-events: none;
}

.dropzone-icon {
    width: 34px;
    height: 34px;
    color: var(--primary);
    margin-bottom: 8px;
}

.dropzone-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.dropzone-text strong {
    color: var(--text);
}

.dropzone-small {
    padding: 16px 12px;
}

.dropzone-small .dropzone-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.dropzone-small .dropzone-text {
    font-size: 0.82rem;
}

.dropzone-filename {
    margin: 8px 0 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    min-height: 1.1em;
}

/* ---------- File Grid / Cards ---------- */

.file-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.file-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}

.file-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.file-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.file-icon-large {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    font-weight: 600;
    font-size: 0.98rem;
    word-break: break-word;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.file-description {
    margin: 10px 0 0 0;
    font-size: 0.88rem;
    color: var(--text-muted);
    white-space: pre-wrap;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.link-action {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.link-action:hover {
    text-decoration: underline;
    background: none;
}

.link-danger {
    color: var(--danger);
}

.inline-form {
    display: inline;
}

.collapsible-box {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.collapsible-box.hidden {
    display: none;
}

.edit-form, .report-form, .share-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 420px;
}

.edit-form label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    gap: 5px;
}

.report-form, .share-form {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
}

.share-links {
    list-style: none;
    padding: 0;
    margin: 12px 0 0 0;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.share-links li {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.share-links code {
    background: var(--bg);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
}

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

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 0.92rem;
}

/* ---------- Admin Tabelle ---------- */

.file-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.file-table th, .file-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.file-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
}

.file-table tr:last-child td {
    border-bottom: none;
}

.badge {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 6px;
}

/* ---------- Forum: Suche, Kategorien, Tags, Thumbnails ---------- */

.search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.search-input {
    flex: 1 1 260px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    background: var(--surface);
}

.search-select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    background: var(--surface);
}

.upload-extra-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 10px 0;
}

.upload-extra-field {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.upload-extra-field input[type="text"] {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text, inherit);
}

.upload-thumbnail-field {
    margin-bottom: 10px;
}

.category-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
    width: fit-content;
}

.category-badge:hover {
    background: #c7d2fe;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tag-badge {
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 600;
    text-decoration: none;
}

.tag-badge:hover {
    background: var(--border);
}

.file-thumbnail {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

/* ---------- Forum-Übersicht: Kategorien als Unterforen-Kacheln ---------- */

.section-heading {
    font-size: 1.1rem;
    margin: 8px 0 14px 0;
}

.back-link {
    display: inline-block;
    margin-bottom: 14px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.category-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.category-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.category-tile-name {
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--primary);
}

.category-tile-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.category-tile-muted .category-tile-name {
    color: var(--text-muted);
}

.create-category-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 6px 0 26px 0;
}

.create-category-form input[type="text"] {
    flex: 1 1 240px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}