*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #e8ecf4;
    --bg-soft: #f2f5fb;
    --bg-card: #ffffff;
    --bg-card-hover: #f7f9fd;
    --bg-input: #ffffff;
    --border: #d5dbe8;
    --border-focus: #4c64d8;
    --text: #1c2230;
    --text-secondary: #4a5568;
    --text-muted: #8b93a7;
    --accent: #4a5fd9;
    --accent-hover: #3d50c4;
    --accent-glow: rgba(74, 95, 217, 0.12);
    --danger: #d94a4a;
    --danger-hover: #c73d3d;
    --success: #2d9d5a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(28, 34, 48, 0.08);
    --shadow-card: 0 2px 12px rgba(28, 34, 48, 0.06);
    --transition: 0.2s ease;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* ============ AUTH SCREEN ============ */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 60% at 15% 40%, rgba(74, 95, 217, 0.08) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 90% 10%, rgba(74, 95, 217, 0.06) 0%, transparent 50%),
        linear-gradient(165deg, var(--bg-soft) 0%, var(--bg) 50%, #dfe6f2 100%);
    background-repeat: no-repeat;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 520px;
    text-align: center;
    box-shadow: var(--shadow), var(--shadow-card);
}

/* Логотип + слово InfoVPN */
.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.brand-lockup--auth {
    flex-direction: column;
    justify-content: center;
    width: 100%;
    margin-bottom: 8px;
}

.brand-mark {
    display: block;
    flex-shrink: 0;
}

.brand-type {
    display: inline-flex;
    align-items: baseline;
    font-size: 1.75rem;
}

.brand-lockup--auth .brand-type {
    font-size: 2rem;
}

.brand-type__info {
    color: var(--text);
}

.brand-type__vpn {
    background: linear-gradient(110deg, #4a5fd9 0%, #6b5acd 45%, #3d8b9e 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.auth-intro {
    text-align: left;
    margin-bottom: 24px;
    padding: 16px 18px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.auth-intro p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.65;
    margin-bottom: 10px;
}

.auth-intro p:last-child {
    margin-bottom: 0;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    font-weight: 500;
}

.input-group {
    margin-bottom: 16px;
}

.auth-card input,
.admin-form input,
.admin-form textarea,
.modal-card input,
.modal-card textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.auth-card input:focus,
.admin-form input:focus,
.admin-form textarea:focus,
.modal-card input:focus,
.modal-card textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-card input::placeholder,
.admin-form input::placeholder,
.admin-form textarea::placeholder,
.modal-card input::placeholder,
.modal-card textarea::placeholder {
    color: var(--text-muted);
}

#auth-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
}

#auth-btn:hover {
    background: var(--accent-hover);
}

#auth-btn:active {
    transform: scale(0.98);
}

#auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

.attempts-info {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
    min-height: 18px;
}

/* ============ HEADER ============ */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.header-left .brand-lockup--header .brand-type {
    font-size: 1.35rem;
}

.header-badge {
    font-size: 11px;
    font-weight: 600;
    color: #9a3d3d;
    background: rgba(217, 74, 74, 0.1);
    border: 1px dashed rgba(180, 71, 71, 0.35);
    padding: 5px 11px;
    border-radius: 20px;
    max-width: 200px;
    line-height: 1.25;
    text-align: center;
}

.header-right {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--bg-card-hover);
}

.btn-icon.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-glow);
}

/* ============ ADMIN PANEL ============ */
.admin-panel {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-panel-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.admin-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.admin-panel-head h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-secondary);
}

.btn-exit-admin {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.btn-exit-admin:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--bg-card);
}

/* Текст по центру, мемы по бокам */
.mood-layout {
    display: grid;
    grid-template-columns: minmax(300px, 460px) minmax(280px, 1fr) minmax(300px, 460px);
    gap: 22px 28px;
    max-width: 1680px;
    margin: 0 auto 24px;
    padding: 0 20px;
    align-items: start;
}

.mood-rail-main {
    min-width: 0;
}

.mood-rail .meme-figure {
    position: sticky;
    top: 88px;
}

/* Декоративные «настроечные» подписи */
.mood-board {
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.mood-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
}

.mood-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.mood-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

.mood-card p {
    margin: 0 0 8px;
}

.mood-card p:last-child {
    margin-bottom: 0;
}

.mood-card-tagline {
    margin-top: 12px !important;
    font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
    font-size: 12px;
    font-style: italic;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.mood-card--whisper::before {
    background: linear-gradient(180deg, #5a6fd9, #8b7bc4);
}

.mood-card--bazaar::before {
    background: linear-gradient(180deg, #c97a3a, #d4a04a);
}

.mood-card--garage {
    grid-column: 1 / -1;
    width: min(100%, 560px);
    margin-inline: auto;
    text-align: center;
}

.mood-card--garage::before {
    background: linear-gradient(180deg, #3d8b7a, #5aaa8f);
}

.meme-figure {
    margin: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.meme-figure img {
    width: 100%;
    height: auto;
    object-fit: contain;
    object-position: center;
    display: block;
    background: linear-gradient(180deg, var(--bg-soft) 0%, #fff 40%);
}

/* Крупные боковые мемы — правило ниже базового, чтобы не обрезало высоту */
.meme-figure.meme-figure--rail img {
    max-height: min(88vh, 820px);
    width: 100%;
}

.meme-caption {
    padding: 10px 14px 12px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
}

.meme-caption--prominent {
    font-size: 14px;
    font-style: normal;
    font-weight: 500;
    color: var(--text);
    text-align: left;
    line-height: 1.55;
    padding: 14px 16px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-form textarea {
    resize: vertical;
    min-height: 80px;
}

.admin-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    padding: 10px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-danger {
    padding: 10px 24px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-danger:hover {
    background: var(--danger-hover);
}

/* ============ CARDS ============ */
main {
    max-width: 1680px;
    margin: 0 auto;
    padding: 28px 0 32px;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    padding: 0 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: border-color var(--transition), box-shadow var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
    box-shadow: var(--shadow-card);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.card:hover {
    border-color: #c5cce0;
    box-shadow: var(--shadow-card);
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    flex: 1;
}

.card-date {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-top: 3px;
}

/* Превью текста + кнопка копирования в одной строке */
.card-body-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.card-preview-col {
    flex: 1;
    min-width: 0;
}

.card-preview-surface {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.card-preview-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.card-preview-text.is-clamped {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
    overflow: hidden;
}

.card-preview-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.45;
    text-align: left;
}

.card-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 4px;
}

.card-footer:has(.btn-edit) {
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.card-footer:empty {
    display: none;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(74, 95, 217, 0.22);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-copy-side {
    flex-shrink: 0;
    align-self: flex-start;
    padding: 10px 14px;
    min-width: 118px;
}

.btn-copy:hover {
    background: rgba(74, 95, 217, 0.16);
    border-color: var(--accent);
}

.btn-copy.copied {
    color: var(--success);
    border-color: rgba(45, 157, 90, 0.35);
    background: rgba(45, 157, 90, 0.08);
}

.btn-edit,
.btn-delete {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-edit {
    color: var(--text-secondary);
}

.btn-edit:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-delete {
    color: var(--text-muted);
}

.btn-delete:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ============ EMPTY STATE ============ */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state span {
    font-size: 14px;
}

/* ============ TOAST ============ */
.copy-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    border: 1px solid rgba(45, 157, 90, 0.28);
    color: var(--success);
    padding: 12px 24px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow), 0 12px 40px rgba(28, 34, 48, 0.12);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 999;
}

.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 34, 48, 0.45);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeInOverlay 0.2s ease;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow), var(--shadow-card);
}

.modal-card-wide {
    max-width: 560px;
}

.modal-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-card > p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.modal-card input,
.modal-card textarea {
    margin-bottom: 12px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 960px) {
    .mood-layout {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0 16px;
        margin-bottom: 20px;
        gap: 14px;
    }

    .mood-rail-main {
        flex: 1 1 100%;
        order: 1;
    }

    .mood-rail {
        flex: 1 1 calc(50% - 7px);
        max-width: calc(50% - 7px);
        order: 2;
    }

    .mood-rail .meme-figure {
        position: static;
    }

    .mood-rail .meme-figure.meme-figure--rail img {
        max-height: min(68vh, 560px);
    }

    .mood-board {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .auth-card {
        padding: 36px 24px;
    }

    .header-inner {
        padding: 12px 16px;
    }

    .header-badge {
        flex: 1 1 100%;
        margin-top: 2px;
        max-width: none;
    }

    main {
        padding: 20px 0 24px;
    }

    .mood-rail .meme-figure.meme-figure--rail img {
        max-height: min(62vh, 480px);
    }

    .meme-caption--prominent {
        font-size: 13px;
        padding: 12px 14px 14px;
    }

    .mood-card {
        padding: 16px 18px;
    }

    .cards-container {
        grid-template-columns: 1fr;
        padding: 0 16px;
    }

    .card {
        padding: 20px;
    }

    .card-body-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-copy-side {
        flex-direction: row;
        width: 100%;
        min-width: unset;
    }

    .admin-panel-inner {
        padding: 20px 16px;
    }

    .modal-card {
        padding: 24px;
    }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============ SELECTION ============ */
::selection {
    background: rgba(74, 95, 217, 0.22);
    color: var(--text);
}
