/* Verwaltung Illing & Vosbeck – Apple-Stil: helle Flächen, Milchglas, große Rundungen, ruhiges Blau */
:root {
    color-scheme: light dark;
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.72);
    --text: #1d1d1f;
    --muted: #6e6e73;
    --line: rgba(0, 0, 0, 0.1);
    --fill: rgba(0, 0, 0, 0.05);
    --blue: #0071e3;
    --blue-hover: #0077ed;
    --glow: rgba(80, 190, 255, 0.55);
    --red: #d70015;
    --radius: 18px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 30px rgba(0, 0, 0, 0.08);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Dunkel: automatisch nach Systemeinstellung, sofern nicht per Schalter „Hell“ gewählt ist */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #000000;
        --surface: #1c1c1e;
        --surface-glass: rgba(28, 28, 30, 0.72);
        --text: #f5f5f7;
        --muted: #98989d;
        --line: rgba(255, 255, 255, 0.14);
        --fill: rgba(255, 255, 255, 0.08);
        --blue: #0a84ff;
        --blue-hover: #409cff;
        --red: #ff453a;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 30px rgba(0, 0, 0, 0.5);
    }
}

/* Dunkel per Schalter (hat Vorrang vor der Systemeinstellung) */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-glass: rgba(28, 28, 30, 0.72);
    --text: #f5f5f7;
    --muted: #98989d;
    --line: rgba(255, 255, 255, 0.14);
    --fill: rgba(255, 255, 255, 0.08);
    --blue: #0a84ff;
    --blue-hover: #409cff;
    --red: #ff453a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 30px rgba(0, 0, 0, 0.5);
}

:root[data-theme="light"] {
    color-scheme: light;
}

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

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}

[hidden] {
    display: none !important;
}

svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ---------- Bausteine ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: #8fd8ff;
    color: #04293f;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    box-shadow: 0 0 10px 2px var(--glow), 0 0 26px 6px rgba(80, 190, 255, 0.28);
}

.badge__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #04293f;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: var(--fill);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

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

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

.button:disabled {
    opacity: 0.5;
    cursor: default;
}

.button:focus-visible,
.field:focus-visible,
.tile:focus-visible,
.crumbs button:focus-visible {
    outline: 3px solid rgba(0, 113, 227, 0.5);
    outline-offset: 2px;
}

.button--primary {
    background: var(--blue);
    color: #fff;
}

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

.button--danger {
    color: var(--red);
}

.button--ghost {
    background: transparent;
}

.button--wide {
    width: 100%;
}

.field {
    width: 100%;
    min-height: 46px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.field:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.2);
}

/* ---------- Hell/Dunkel-Schalter ---------- */
.theme-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 25;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-glass);
    color: var(--text);
    cursor: pointer;
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    transition: transform 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.06);
}

.theme-toggle:focus-visible {
    outline: 3px solid rgba(0, 113, 227, 0.5);
    outline-offset: 2px;
}

.theme-toggle .icon-moon {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

/* In der Verwaltung sitzt der Schalter in der Kopfzeile neben „Abmelden“ */
.topbar .theme-toggle {
    position: static;
    width: 36px;
    height: 36px;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#theme-slot {
    display: inline-flex;
}

/* Editorseite: leuchtend hellblau wie der Editor selbst */
.button--editor {
    background: #8fd8ff;
    color: #04293f;
    font-weight: 600;
    box-shadow: 0 0 10px 2px var(--glow), 0 0 26px 6px rgba(80, 190, 255, 0.28);
    text-decoration: none;
}

.button--editor:hover {
    background: #b2e6ff;
}

@media (max-width: 600px) {
    .button--editor {
        padding: 0 12px;
    }
}

/* ---------- Anmeldung ---------- */
.login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(900px 500px at 20% 0%, rgba(80, 190, 255, 0.28), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(0, 113, 227, 0.18), transparent 60%),
        var(--bg);
}

.login__card {
    width: 100%;
    max-width: 380px;
    padding: 36px 32px 32px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--surface-glass);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
    box-shadow: var(--shadow), 0 0 60px rgba(80, 190, 255, 0.25);
    text-align: center;
}

.login__card.is-wrong {
    animation: shake 0.4s ease;
}

.login__title {
    margin: 22px 0 6px;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.login__text {
    margin: 0 0 22px;
    color: var(--muted);
}

.login__error {
    min-height: 1.5em;
    margin: 10px 0 8px;
    color: var(--red);
    font-size: 13px;
}

@keyframes shake {
    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }
}

/* ---------- Kopfzeile ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 max(20px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
    background: var(--surface-glass);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar__title {
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ---------- Inhalt ---------- */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 20px 80px;
}

.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin-bottom: 18px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.crumbs button {
    padding: 2px 6px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}

.crumbs button:hover {
    color: var(--text);
}

.crumbs [aria-current] {
    color: var(--text);
    cursor: default;
}

.crumbs__sep {
    color: var(--muted);
    font-weight: 400;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.toolbar__group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.toolbar__count {
    color: var(--muted);
    font-size: 13px;
}

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

/* ---------- Raster ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 16px;
}

.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}

.tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.tile.is-selected {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.35);
}

.tile__visual {
    position: relative;
    flex: none;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    background: var(--fill);
    color: var(--blue);
}

.tile__visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile__visual svg {
    width: 44px;
    height: 44px;
    stroke-width: 1.4;
}

.tile__label {
    padding: 10px 12px 12px;
}

.tile__name {
    display: block;
    overflow: hidden;
    font-size: 13px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile__meta {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.tile__check {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.tile:hover .tile__check,
.tile:focus-within .tile__check,
.tile.is-selected .tile__check,
.has-selection .tile__check {
    opacity: 1;
}

.tile.is-selected .tile__check {
    border-color: var(--blue);
    background: var(--blue);
}

.tile__check svg {
    width: 14px;
    height: 14px;
    stroke-width: 3;
    opacity: 0;
}

.tile.is-selected .tile__check svg {
    opacity: 1;
}

.empty {
    padding: 70px 0;
    color: var(--muted);
    text-align: center;
}

/* ---------- Ablegen von Dateien ---------- */
.dropzone {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 113, 227, 0.12);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.dropzone__box {
    padding: 56px 70px;
    border: 2px dashed var(--blue);
    border-radius: 28px;
    background: var(--surface-glass);
    font-size: 20px;
    font-weight: 600;
    box-shadow: 0 0 60px var(--glow);
}

/* ---------- Dialoge ---------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    animation: fade 0.25s ease both;
}

.sheet {
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 26px;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow), 0 30px 80px rgba(0, 0, 0, 0.3);
    animation: rise 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sheet--wide {
    max-width: 760px;
}

.sheet__title {
    margin: 0 0 6px;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sheet__text {
    margin: 0 0 16px;
    color: var(--muted);
}

.sheet__error {
    min-height: 1.4em;
    margin: 10px 0 0;
    color: var(--red);
    font-size: 13px;
}

.sheet__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.sheet__preview {
    display: block;
    max-width: 100%;
    max-height: 60vh;
    margin: 0 auto 16px;
    border-radius: 14px;
    object-fit: contain;
}

.queue {
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
    max-height: 46vh;
    overflow: auto;
}

.queue li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.queue img,
.queue__icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--fill);
    object-fit: cover;
    flex: none;
}

.queue__name {
    min-width: 0;
    flex: 1;
}

.queue__name strong {
    display: block;
    overflow: hidden;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue__name span {
    color: var(--muted);
    font-size: 12px;
}

.queue__warn {
    color: #c93400 !important;
}

.switch {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    cursor: pointer;
}

.switch input {
    width: 18px;
    height: 18px;
    accent-color: var(--blue);
}

.progress {
    height: 8px;
    margin-top: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--fill);
}

.progress__bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--blue);
    transition: width 0.2s ease;
}

/* ---------- Veröffentlichung (Restzeit) ---------- */
.publish {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
    height: 34px;
    margin: 0 12px;
    padding: 0 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 500;
}

.publish__bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: rgba(80, 190, 255, 0.35);
    transition: width 1s linear;
}

.publish__text {
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.publish.is-done {
    border-color: #30a46c;
}

.publish.is-done .publish__bar {
    width: 100% !important;
    background: rgba(48, 164, 108, 0.22);
}

/* ---------- Hinweis-Pop-up (z. B. GitHub lehnt gerade ab) ---------- */
.notice {
    position: fixed;
    top: 76px;
    left: 50%;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: min(440px, calc(100vw - 32px));
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-left: 4px solid #ff9f0a;
    border-radius: 18px;
    background: var(--surface-glass);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
    box-shadow: var(--shadow), 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateX(-50%);
    animation: rise 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.notice strong {
    font-size: 16px;
}

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

.notice .button {
    align-self: flex-end;
    margin-top: 6px;
    min-height: 34px;
}

/* ---------- Banner: Zwei-Faktor noch nicht aktiv ---------- */
.banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 159, 10, 0.5);
    border-radius: 16px;
    background: rgba(255, 159, 10, 0.1);
}

.field--code {
    margin-bottom: 14px;
    font-size: 22px;
    letter-spacing: 0.3em;
    text-align: center;
}

.switch--center {
    justify-content: center;
    color: var(--muted);
    font-size: 14px;
}

.qr {
    display: flex;
    justify-content: center;
    margin: 4px 0 14px;
}

.qr svg {
    width: 200px;
    height: 200px;
    padding: 10px;
    border-radius: 14px;
    background: #fff;
}

.secret {
    display: block;
    margin: 0 0 14px;
    padding: 10px 12px;
    overflow-wrap: anywhere;
    border-radius: 12px;
    background: var(--fill);
    font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.04em;
    text-align: center;
    user-select: all;
}

.steps {
    margin: 0 0 14px;
    padding-left: 20px;
    color: var(--muted);
}

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

@media (max-width: 760px) {
    .publish {
        display: none;
    }
}

/* ---------- Hinweis ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 40;
    max-width: calc(100vw - 40px);
    padding: 12px 20px;
    border-radius: 999px;
    background: rgba(29, 29, 31, 0.92);
    color: #fff;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@keyframes fade {
    from {
        opacity: 0;
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }
}

@media (max-width: 600px) {
    .topbar__title {
        display: none;
    }

    .crumbs {
        font-size: 19px;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .publish__bar,
    .notice,
    .theme-toggle,
    .overlay,
    .sheet,
    .login__card.is-wrong {
        animation: none;
    }

    .tile,
    .toast,
    .button {
        transition: none;
    }
}
