:root {
    --bg: #070b16;
    --bg-2: #0d1424;
    --panel: rgba(255, 255, 255, 0.06);
    --panel-strong: rgba(255, 255, 255, 0.1);
    --line: rgba(255, 255, 255, 0.14);
    --text: #f7f9ff;
    --muted: rgba(247, 249, 255, 0.75);
    --accent: #6c63ff;
    --accent-2: #5fbbe8;
    --danger: #ff5d73;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: "SF Pro Text", "SF Pro Display", "SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 8%, rgba(108, 99, 255, 0.2), transparent 34%),
        radial-gradient(circle at 86% 8%, rgba(95, 187, 232, 0.16), transparent 30%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

a {
    color: #9ab7ff;
    text-decoration: none;
}

a:hover {
    color: #bfd0ff;
}

.container {
    width: min(1120px, calc(100% - 2rem));
    margin: 32px auto;
}

.page-shell {
    min-height: 100vh;
    padding: 22px 0 34px;
}

.card,
.top-bar,
.panel {
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 20px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.35);
}

.top-bar,
.panel {
    padding: clamp(1rem, 2.8vw, 1.7rem);
}

.page-title {
    margin: 0;
    letter-spacing: -0.02em;
    font-size: clamp(1.7rem, 4vw, 2.6rem);
}

.page-subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.65;
}

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

input[type="text"],
input[type="password"],
input[type="file"],
input[type="number"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(108, 99, 255, 0.8);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.18);
}

.form-stack {
    display: grid;
    gap: 12px;
    width: 100%;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px transparent;
    border-radius: 999px;
    padding: 11px 18px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    transition: transform 0.16s ease, opacity 0.16s ease, filter 0.16s ease;
    cursor: pointer;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--line);
    color: var(--text);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn.danger {
    background: rgba(255, 93, 115, 0.16);
    border-color: rgba(255, 93, 115, 0.35);
    color: #ffd8de;
}

.helper-text {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.gallery,
.messages-grid,
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-top: 18px;
    padding-bottom: 18px;
}

.image-card,
.gallery img,
.gallery-grid img {
    width: 100%;
    border-radius: 14px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.gallery img,
.gallery-grid img {
    height: 150px;
}

.image-card {
    position: relative;
    overflow: hidden;
}

.image-card img.selected {
    box-shadow: 0 0 0 3px rgba(255, 93, 115, 0.68);
}

.image-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 22px;
    height: 22px;
    accent-color: #8fa8ff;
    z-index: 3;
}

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 5, 12, 0.92);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.lightbox.show {
    display: flex !important;
}

.lightbox img {
    max-width: 90%;
    max-height: 84%;
    border-radius: 14px;
    border: 1px solid var(--line);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 66px;
    height: 66px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.nav-btn.prev { left: 18px; }
.nav-btn.next { right: 18px; }

.message-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-meta {
    color: var(--muted);
    font-size: 0.84rem;
}

.message-text {
    color: var(--text);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.spinner {
    border: 7px solid rgba(255, 255, 255, 0.16);
    border-top: 7px solid var(--accent);
    border-radius: 50%;
    width: 54px;
    height: 54px;
    animation: spin 0.9s linear infinite;
}

#loadingOverlay {
    transition: opacity 0.3s;
}

.flash-list {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.flash {
    border: 1px solid rgba(255, 93, 115, 0.4);
    background: rgba(255, 93, 115, 0.14);
    color: #ffdce2;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.92rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 700px) {
    .container {
        width: calc(100% - 1rem);
        margin: 14px auto;
    }

    .page-shell {
        padding: 10px 0 20px;
    }

    .top-bar,
    .panel,
    .card {
        border-radius: 14px;
        padding: 14px;
    }

    .actions-row {
        flex-direction: column;
        align-items: stretch;
    }

    .actions-row .btn,
    .actions-row button,
    .form-stack .btn,
    .form-stack button {
        width: 100%;
    }

    input[type="text"],
    input[type="password"],
    input[type="file"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px;
    }

    .nav-btn {
        width: 46px;
        height: 46px;
        font-size: 1.4rem;
    }

    .gallery,
    .messages-grid,
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .lightbox img {
        max-width: 96%;
        max-height: 78%;
    }
}

