:root {
    --accent: #7c5cbf;
    --accent-dark: #5d4494;
    --surface: #ffffff;
    --background: #f4f1fa;
    --text: #2a2438;
    --muted: #6f6a7d;
    --error: #b3324b;
    --ok: #2e7d4f;
}

* {
    box-sizing: border-box;
}

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

.page {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem;
}

.upload-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 2px 12px rgba(42, 36, 56, 0.08);
}

.upload-card h1 {
    font-size: 1.4rem;
    margin: 0 0 0.25rem;
}

.hint {
    color: var(--muted);
    margin: 0 0 1rem;
}

.field {
    display: block;
    margin-bottom: 1rem;
}

.field span {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.field input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #d8d2e4;
    border-radius: 10px;
}

.file-button {
    display: block;
    text-align: center;
    background: var(--accent);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
}

.file-button:active {
    background: var(--accent-dark);
}

.file-button input {
    display: none;
}

.upload-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}

.upload-entry {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 0.25rem 0.75rem;
    align-items: center;
    padding: 0.5rem 0;
    border-top: 1px solid #eee9f6;
    cursor: zoom-in;
}

.upload-entry progress {
    grid-column: 1 / -1;
    width: 100%;
    height: 6px;
}

.tile-arriving {
    animation: tile-arriving 0.35s ease-out;
}

@keyframes tile-arriving {
    from {
        opacity: 0;
        transform: scale(0.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.upload-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #eee9f6;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.upload-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid #cfc4e6;
    border-top-color: #8f7cc0;
    border-radius: 50%;
    animation: upload-spinner 0.9s linear infinite;
    vertical-align: middle;
}

@keyframes upload-spinner {
    to {
        transform: rotate(360deg);
    }
}

.upload-remove {
    border: none;
    background: none;
    color: var(--muted);
    font-size: 1.1rem;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
}

.start-upload {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    border: none;
    background: var(--accent-dark);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
}

.start-upload:active {
    background: var(--accent);
}

.upload-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-entry.done .upload-status {
    color: var(--ok);
}

.upload-entry.failed .upload-status {
    color: var(--error);
}

.gallery {
    margin-top: 1.5rem;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border-radius: 16px;
    padding: 2.5rem 1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
}

.tile {
    position: relative;
    display: block;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: #ded7ec;
}

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

.tile-badge {
    position: absolute;
    left: 6px;
    bottom: 6px;
    background: rgba(20, 15, 30, 0.65);
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 7px;
    border-radius: 999px;
}

.tile-name {
    position: absolute;
    right: 6px;
    top: 6px;
    background: rgba(20, 15, 30, 0.55);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 999px;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.load-more {
    display: block;
    text-align: center;
    margin: 1rem auto;
    padding: 0.75rem 1.5rem;
    color: var(--accent-dark);
    font-weight: 600;
}

.detail-page {
    max-width: 900px;
    position: relative;
}

.media-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 15, 30, 0.55);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    border-radius: 50%;
    text-decoration: none;
}

.media-nav:active {
    background: var(--accent-dark);
}

.nav-newer {
    left: 0.25rem;
}

.nav-older {
    right: 0.25rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 0.75rem;
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: 600;
}

/* every item gets the same frame, whatever its shape — the content is
   letterboxed inside, so navigating never makes the page jump around */
.media-frame {
    background: #17131f;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 65vh;
    padding: 0.5rem;
}

.detail-media {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

img.detail-media {
    cursor: zoom-in;
}

.fullscreen-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: #17131f;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.fullscreen-overlay img,
.fullscreen-overlay video {
    max-width: 100%;
    max-height: 100%;
}

.fullscreen-overlay audio {
    width: min(90vw, 480px);
}

.fullscreen-close {
    position: fixed;
    top: calc(0.75rem + env(safe-area-inset-top));
    right: calc(0.75rem + env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(20, 15, 30, 0.55);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
}

.download-only {
    color: #f4f1fa;
    text-align: center;
    padding: 2rem 1rem;
}

.detail-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
}

.shared-by {
    color: var(--muted);
    margin: 0;
}

.download-button {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    padding: 0.7rem 1.1rem;
    border-radius: 10px;
    text-decoration: none;
}

.login-error {
    color: var(--error);
    font-weight: 600;
}

.admin-actions {
    display: flex;
    gap: 0.75rem;
}

.danger-button {
    background: var(--error);
    color: #fff;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.7rem 1.1rem;
    border-radius: 10px;
    cursor: pointer;
}

.quiet-button {
    background: transparent;
    color: var(--muted);
    border: 1px solid #d8d2e4;
    font-size: 1rem;
    padding: 0.7rem 1.1rem;
    border-radius: 10px;
    cursor: pointer;
}

.tile-delete {
    position: absolute;
    right: 6px;
    bottom: 6px;
}

.tile-delete button {
    background: rgba(179, 50, 75, 0.9);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
}
