:root {
    --bg: linear-gradient(125deg, #0b0f19 0%, #180c2e 45%, #0b2233 100%);
    --panel: rgba(20, 23, 35, 0.82);
    --panel-strong: rgba(29, 34, 50, 0.9);
    --border: rgba(255, 255, 255, 0.1);
    --text: #f7fbff;
    --muted: #9aa9c0;
    --accent: #5865f2;
    --cyan: #66c0f4;
    --danger: #ff4d6d;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.admin-shell {
    width: min(1120px, calc(100% - 28px));
    margin: 0 auto;
    padding: 28px 0 44px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    margin-bottom: 18px;
}

.login-panel {
    width: min(430px, 100%);
    margin: 16vh auto 0;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.kicker {
    margin: 0 0 6px;
    color: var(--cyan);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1, h2 {
    margin: 0;
    line-height: 1.1;
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: 1.35rem; }
.muted { color: var(--muted); line-height: 1.55; }
.muted.compact { margin: 7px 0 0; font-size: 0.9rem; }

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.stack {
    display: grid;
    gap: 12px;
}

.grid {
    display: grid;
    gap: 14px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
    outline: none;
}

textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: rgba(102, 192, 244, 0.75); }

button, .header-actions a, .upload-btn {
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    background: var(--accent);
    color: white;
    padding: 11px 16px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: 0.22s;
    white-space: nowrap;
}

button:hover, .header-actions a:hover, .upload-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

button.ghost, .header-actions a {
    background: rgba(255, 255, 255, 0.07);
}

button.danger {
    background: rgba(255, 77, 109, 0.12);
    border-color: rgba(255, 77, 109, 0.45);
    color: #ffd5de;
}

.full { width: 100%; margin-top: 12px; }
.upload-btn input { display: none; }
.upload-btn.is-loading { opacity: 0.72; pointer-events: none; }

.editor-list {
    display: grid;
    gap: 12px;
}

.editor-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel-strong);
}

.editor-row.nav-row {
    grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.35fr) minmax(175px, 0.8fr) minmax(145px, 0.65fr) auto;
}

.row-actions {
    display: flex;
    gap: 7px;
    align-items: center;
}

.row-actions button {
    min-width: 42px;
    padding: 11px 12px;
}

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

.gallery-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--panel-strong);
}

.gallery-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.gallery-card .gallery-fields {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.post-editor {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel-strong);
}

.post-editor-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 170px auto auto;
    gap: 10px;
    align-items: end;
}

.check-field {
    min-height: 46px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    white-space: nowrap;
}

.check-field input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.post-text-field { gap: 7px; }
.post-text-field textarea { min-height: 230px; line-height: 1.55; }
small { color: var(--muted); font-weight: 500; line-height: 1.45; }

.format-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.format-toolbar button {
    min-width: 42px;
    padding: 7px 10px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.07);
}

.sub-editor {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: rgba(7, 10, 20, 0.18);
}

.sub-editor-title {
    color: var(--text);
    font-size: 0.96rem;
    font-weight: 800;
}

.nested-row {
    display: grid;
    gap: 9px;
    align-items: end;
}

.media-row { grid-template-columns: 120px minmax(210px, 1.25fr) minmax(140px, 0.75fr) 150px 145px minmax(200px, auto); }
.media-actions { flex-wrap: wrap; justify-content: flex-end; }
.media-actions button:first-child { background: rgba(88, 101, 242, 0.34); }
.button-row { grid-template-columns: minmax(160px, 0.65fr) minmax(0, 1.35fr) auto; }
.sub-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sub-actions button, .compact-upload { padding: 9px 12px; border-radius: 11px; }

.admin-comment-list { display: grid; gap: 9px; color: var(--muted); }
.admin-comment-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,0.04); }
.admin-comment-item strong { color: var(--cyan); font-size: 0.82rem; }
.admin-comment-item p { margin: 6px 0 0; color: var(--text); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(420px, calc(100% - 36px));
    padding: 13px 16px;
    border-radius: 14px;
    background: rgba(12, 18, 30, 0.95);
    border: 1px solid var(--border);
    color: var(--text);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: 0.2s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1050px) {
    .media-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .media-actions { justify-content: stretch; }
}

@media (max-width: 720px) {
    .admin-header, .section-title {
        align-items: stretch;
        flex-direction: column;
    }
    .grid.two, .editor-row, .post-editor-top, .nested-row {
        grid-template-columns: 1fr;
    }
    .editor-row.nav-row { grid-template-columns: 1fr; }
    .row-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .check-field { min-height: 46px; }
    .sub-actions { display: grid; grid-template-columns: 1fr; }
    .sub-actions > * { width: 100%; text-align: center; }
}
