:root {
    --bg: #0f1115;
    --surface: #161a22;
    --surface-2: #1d2230;
    --border: #2a3142;
    --text: #e6e8ee;
    --muted: #9aa3b2;
    --accent: #6aa2ff;
    --accent-2: #4f7ad6;
    --success: #4ade80;
    --warn: #fbbf24;
    --error: #f87171;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --transition: 200ms ease;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f6f7fb;
        --surface: #ffffff;
        --surface-2: #f0f2f8;
        --border: #d9dde6;
        --text: #1a1d24;
        --muted: #5b6473;
        --accent: #2f6bff;
        --accent-2: #1a4fd6;
        --shadow: 0 6px 18px rgba(28, 38, 66, 0.08);
    }
}

* { box-sizing: border-box; }

/* Browser-Default für [hidden] greift sonst nicht, weil unsere
   .btn-Regel mit display:inline-flex die gleiche Spezifität hat. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.topbar {
    padding: 36px 24px 32px;
    text-align: center;
    background: linear-gradient(135deg, #0f1115 0%, #1a2236 55%, #1f2a44 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-inner {
    max-width: 880px;
    margin: 0 auto;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/*  MB-Logo aus public/assets/img/MB_Logo.svg.
    Wir nutzen das Original als CSS-Mask und füllen die Form
    mit Weiß – so bleibt die Datei unverändert und das Logo
    ist garantiert auf allen Hintergründen sauber farbig. */
.brand-logo {
    display: inline-block;
    width: 38px;
    height: 30px;
    background-color: #fff;
    -webkit-mask: url('/assets/img/MB_Logo.svg') center / contain no-repeat;
            mask: url('/assets/img/MB_Logo.svg') center / contain no-repeat;
    flex-shrink: 0;
}

.tagline {
    margin: 10px 0 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
}

.logout-form {
    margin: 14px 0 0;
}

.logout-link {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
}

.logout-link:hover {
    color: #fff;
}

.container {
    max-width: 880px;
    margin: 0 auto;
    padding: 24px 16px 80px;
    display: grid;
    gap: 20px;
}

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

.panel h2 {
    margin: 0 0 14px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.options {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    align-items: center;
}

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

.opt {
    display: grid;
    gap: 6px;
}

.opt small { color: var(--muted); font-size: 12px; }

.opt input[type="range"] {
    accent-color: var(--accent);
    width: 100%;
}

.opt.switch {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
}

.opt.switch input { transform: scale(1.2); accent-color: var(--accent); }

/* Dropzone */
.dropzone {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
    outline: none;
}

.dropzone:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}

.dropzone.is-dragover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    transform: scale(1.005);
}

.dz-icon {
    width: 44px;
    height: 44px;
    fill: var(--accent);
    margin-bottom: 8px;
}

.dz-headline { margin: 0; font-weight: 600; font-size: 18px; }

.dz-sub { margin: 8px 0 4px; color: var(--muted); }

.link {
    background: none;
    border: 0;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
    font: inherit;
    padding: 0;
}

.dz-meta { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

/* Queue */
.queue { display: grid; gap: 12px; }
.queue:empty { display: none; }

.item {
    display: grid;
    grid-template-columns: 88px 1fr auto;
    gap: 14px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
}

@media (max-width: 600px) {
    .item {
        grid-template-columns: 64px 1fr;
    }
    .item .controls {
        grid-column: 1 / -1;
        display: flex;
        gap: 8px;
        justify-content: flex-end;
    }
}

.thumb {
    width: 88px;
    height: 88px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface-2);
    display: grid;
    place-items: center;
}

@media (max-width: 600px) {
    .thumb { width: 64px; height: 64px; }
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.meta { min-width: 0; }
.meta .name {
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.meta .info { margin: 0 0 8px; color: var(--muted); font-size: 12px; }

.progress {
    height: 6px;
    width: 100%;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 8px;
}
.bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 200ms ease;
}

.status { margin: 0; font-size: 12px; color: var(--muted); min-height: 1em; }
.status.success { color: var(--success); }
.status.warn { color: var(--warn); }
.status.error { color: var(--error); }

.controls { display: flex; flex-wrap: wrap; gap: 8px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }

.btn.primary {
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: #fff;
}

.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; font-size: 13px; }

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

.privacy {
    margin: 12px auto 0;
    max-width: 640px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.auth-container {
    min-height: 52vh;
    align-items: center;
}

.login-panel {
    width: min(100%, 420px);
    margin: 18px auto 0;
}

.login-panel h1 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.login-copy {
    margin: 0 0 18px;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 16px;
}

.password-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}

.password-input:focus {
    outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-color: var(--accent);
}

.login-error {
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--error) 45%, var(--border));
    border-radius: 10px;
    background: color-mix(in srgb, var(--error) 12%, var(--surface));
    color: var(--error);
    font-size: 14px;
}

.footer {
    text-align: center;
    color: var(--muted);
    padding: 24px;
}

.item[data-state="success"] { border-color: color-mix(in srgb, var(--success) 30%, var(--border)); }
.item[data-state="error"]   { border-color: color-mix(in srgb, var(--error) 35%, var(--border)); }

/* === Modal & Vergleichsansicht ============================================ */
.modal {
    border: 0;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border-radius: 16px;
    width: min(1100px, 96vw);
    max-height: 92vh;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.modal-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#compareClose {
    font-size: 22px;
    line-height: 1;
    width: 36px;
    height: 36px;
    padding: 0;
}

.modal-body {
    padding: 16px;
    display: grid;
    gap: 14px;
    overflow: auto;
    max-height: calc(92vh - 60px);
}

.compare {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    user-select: none;
    touch-action: none;
    cursor: ew-resize;
    outline: none;
    /* Aspect-Ratio wird per JS aus Bilddimensionen gesetzt. */
}

.compare:focus-visible {
    box-shadow: 0 0 0 3px var(--accent);
}

.compare img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
}

.compare-after {
    position: relative;
}

.compare-before {
    position: absolute;
    inset: 0;
    /* clipPath wird per JS gesteuert (Wert in Prozent) */
    clip-path: inset(0 50% 0 0);
}

.compare-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: rgba(255, 255, 255, 0.95);
    transform: translateX(-50%);
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    display: grid;
    place-items: center;
}

.compare-handle svg {
    width: 18px;
    height: 18px;
    fill: #1a1d24;
}

.compare-label {
    position: absolute;
    top: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
    backdrop-filter: blur(4px);
}
.compare-label-before { left: 12px; }
.compare-label-after  { right: 12px; }

.compare-controls {
    padding: 0 4px;
}

#compareRange {
    width: 100%;
    accent-color: var(--accent);
}

.compare-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px 16px;
    margin: 0;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
}

.compare-meta div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.compare-meta dt {
    color: var(--muted);
    margin: 0;
}

.compare-meta dd {
    margin: 0;
    font-weight: 600;
}

/* Disabled-Look für Aktions-Buttons nach Lösch-Confirm. */
.btn.small.download.disabled,
.btn.small.download[aria-disabled="true"],
.btn.small.compare.disabled,
.btn.small.compare[aria-disabled="true"] {
    opacity: 0.55;
    pointer-events: none;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .modal { width: 100vw; max-height: 100vh; border-radius: 0; }
    .modal-body { max-height: calc(100vh - 60px); }
    .compare-handle { width: 34px; height: 34px; }
}
