* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    color-scheme: dark;
    --bg-deep: #07111f;
    --bg-deep-2: #0c1728;
    --bg-surface: rgba(14, 25, 42, 0.86);
    --bg-surface-strong: rgba(19, 32, 52, 0.94);
    --bg-glass: rgba(255, 255, 255, 0.06);
    --primary: #5ea7ff;
    --primary-strong: #2d7ff9;
    --danger: #ff6b6b;
    --text: #f5f7fb;
    --text-muted: #9fb0c8;
    --border: rgba(163, 184, 208, 0.16);
    --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.22);
    --shadow-strong: 0 24px 60px rgba(0, 0, 0, 0.34);
    --fab-offset: calc(env(safe-area-inset-bottom) + 18px);
    --top-offset: calc(env(safe-area-inset-top) + 14px);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background:
        radial-gradient(circle at top, rgba(94, 167, 255, 0.18), transparent 34%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-deep-2) 100%);
}

body {
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, sans-serif;
    color: var(--text);
    background: transparent;
    overflow-x: hidden;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

img {
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

.container {
    width: min(100%, 1120px);
    margin: 0 auto;
    padding: var(--top-offset) 12px calc(env(safe-area-inset-bottom) + 108px);
}

.page-header {
    position: sticky;
    top: 0;
    z-index: 20;
    margin-bottom: 12px;
    padding-top: 4px;
}

.topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 14px 11px;
    border: 1px solid rgba(163, 184, 208, 0.1);
    border-radius: 24px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015)),
        var(--bg-surface);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(18px);
}

.title-row {
    display: flex;
    justify-content: center;
    width: 100%;
}

.title-trigger {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    width: auto;
    max-width: 100%;
    appearance: none;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: center;
}

.title-text {
    color: #8fd2ff;
    font-size: clamp(1.5rem, 4.5vw, 2.1rem);
    line-height: 1;
    letter-spacing: -0.045em;
    font-weight: 780;
}

.title-separator {
    color: rgba(159, 176, 200, 0.72);
    font-size: 1rem;
    line-height: 1;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.1;
    white-space: nowrap;
    opacity: 0.78;
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    padding-top: 0;
    opacity: 0.34;
    transition: opacity 160ms ease;
    position: relative;
}

.status-row::before {
    content: "";
    width: 100%;
    max-width: 180px;
    height: 1px;
    border-radius: 999px;
    background: rgba(159, 176, 200, 0.14);
}

.status-row.is-active {
    opacity: 1;
}

.status-row.is-active::before {
    display: none;
}

.state-pill,
.admin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(8, 16, 30, 0.76);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(14px);
    white-space: nowrap;
}

.state-pill {
    max-width: min(100%, 420px);
    color: #f3fbff;
    font-size: 0.82rem;
    font-weight: 700;
    padding-right: 10px;
    opacity: 1;
    transform: scale(1);
    transition:
        opacity 280ms ease,
        transform 280ms ease;
}

.state-pill.is-fading {
    opacity: 0;
    transform: scale(0.95);
}

.state-pill::before {
    content: none;
}

.state-pill-label {
    white-space: nowrap;
    color: #f5fbff;
    text-shadow: 0 0 14px rgba(143, 210, 255, 0.18);
}

.state-pill-track {
    display: block;
    width: 64px;
    height: 4px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(143, 210, 255, 0.08);
}

.state-pill-fill {
    display: block;
    height: 100%;
    width: var(--progress, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, #9ce1ff, #6eb5ff);
    box-shadow: 0 0 12px rgba(110, 181, 255, 0.32);
    transform: scaleY(var(--progress-scale, 1));
    transform-origin: center;
    transition:
        width 300ms cubic-bezier(0.22, 0.61, 0.36, 1),
        transform 300ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.state-pill.is-system::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 0 rgba(94, 167, 255, 0.55);
    animation: pulse-dot 1.4s infinite;
}

.admin-badge {
    color: #d7f6e3;
    background: rgba(17, 49, 36, 0.78);
    border-color: rgba(83, 206, 138, 0.28);
}

.admin-badge-label {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.admin-badge-action,
.viewer-nav,
.viewer-delete,
.viewer-close,
.admin-modal-close,
.btn-primary {
    appearance: none;
    border: none;
    cursor: pointer;
}

.admin-badge-action {
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: inherit;
    font-size: 0.78rem;
    font-weight: 700;
}

.upload-fab {
    position: fixed;
    right: 16px;
    bottom: var(--fab-offset);
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 0 18px 0 16px;
    border: 1px solid rgba(94, 167, 255, 0.34);
    border-radius: 999px;
    background: rgba(8, 16, 29, 0.88);
    color: #dfeeff;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(18px);
    transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.upload-fab-plus {
    color: #8fd2ff;
    font-size: 1.34rem;
    line-height: 1;
    font-weight: 500;
}

.upload-fab.is-uploading {
    border-color: rgba(94, 167, 255, 0.42);
    background: rgba(10, 20, 34, 0.92);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.16);
}

.upload-fab[disabled],
.upload-fab.is-uploading {
    cursor: progress;
}

.upload-fab[disabled] {
    opacity: 0.82;
}

.upload-fab.is-uploading .upload-fab-plus {
    animation: fab-pulse 1.15s infinite ease-in-out;
}

.upload-fab-label {
    font-size: 0.9rem;
    font-weight: 760;
    letter-spacing: 0.01em;
}

.toast-viewport {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--fab-offset) + 72px);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    pointer-events: none;
    min-height: 1px;
}

.toast {
    align-self: center;
    width: min(100%, 420px);
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid rgba(163, 184, 208, 0.16);
    background: rgba(9, 17, 30, 0.92);
    color: var(--text);
    box-shadow: var(--shadow-strong);
    line-height: 1.35;
    animation: toast-in 180ms ease-out;
    pointer-events: auto;
}

.toast-error {
    background: rgba(84, 16, 22, 0.92);
    border-color: rgba(255, 125, 125, 0.26);
    color: #ffe1e1;
}

@keyframes pulse-dot {
    0% {
        box-shadow: 0 0 0 0 rgba(94, 167, 255, 0.55);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(94, 167, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(94, 167, 255, 0);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fab-pulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.88);
        opacity: 0.72;
    }
}

@media (min-width: 700px) {
    .container {
        padding-left: 18px;
        padding-right: 18px;
    }

    .topbar {
        padding: 14px 18px 12px;
    }

    .toast-viewport {
        left: auto;
        right: 18px;
        width: 420px;
        bottom: calc(var(--fab-offset) + 78px);
        align-items: flex-end;
    }

    .toast {
        width: 100%;
    }
}
