:root {
    --bg: #090b1a;
    --panel: #12182b;
    --line: rgba(255, 255, 255, 0.12);
    --text: #eef2ff;
    --muted: #94a3b8;
    --accent: #6366f1;
    --ok: #34d399;
    --warn: #f59e0b;
    --danger: #fb7185;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at 50% 0%, #15193c 0%, var(--bg) 60%);
    color: var(--text);
}

.login-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(5, 6, 14, 0.72);
    backdrop-filter: blur(10px);
}
.login-backdrop[hidden] { display: none !important; }

.login-modal {
    width: min(400px, 100%);
    padding: 1.35rem 1.4rem 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.login-brand strong { display: block; }
.login-brand small { color: var(--muted); }
.login-mark {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    color: #fff;
}
.login-mark.sm { width: 34px; height: 34px; font-size: 0.8rem; }
.login-modal h1 {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
}
.login-lead {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}
.login-modal form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.login-msg {
    min-height: 1.2em;
    margin: 0;
    color: var(--warn);
    font-size: 0.85rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--muted);
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #0a0f1d;
    color: var(--text);
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
    font: inherit;
}
textarea { resize: vertical; line-height: 1.45; }

.btn {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.app[hidden] { display: none !important; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1rem;
    align-items: end;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--line);
    background: rgba(9, 11, 26, 0.92);
    position: sticky;
    top: 0;
    z-index: 20;
}
.toolbar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 10rem;
}
.toolbar-brand strong { display: block; font-size: 0.95rem; }
.toolbar-brand small { color: var(--muted); font-size: 0.78rem; }
.toolbar-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    flex: 1;
}
.field { min-width: 10rem; }
.field span { margin-bottom: 0.2rem; }
.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}
.count { color: var(--muted); font-size: 0.85rem; margin-right: 0.25rem; }

.workspace {
    display: grid;
    grid-template-columns: 1fr;
    min-height: calc(100vh - 76px);
}
.workspace.has-editor {
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.1fr);
}

.list-panel { padding: 0.75rem 1rem 1.5rem; overflow: auto; }
.table-head, .row {
    display: grid;
    grid-template-columns: 7rem 6.5rem 6.5rem 3.4rem 1fr;
    gap: 0.5rem;
    align-items: center;
}
.table-head {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.4rem 0.65rem;
    border-bottom: 1px solid var(--line);
}
.row {
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    color: inherit;
    padding: 0.7rem 0.65rem;
    cursor: pointer;
    font: inherit;
}
.row:hover, .row.is-active { background: rgba(99, 102, 241, 0.12); }
.row .title { font-weight: 600; }
.row .sub {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    display: inline-block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
}
.badge--published { background: rgba(52, 211, 153, 0.18); color: var(--ok); }
.badge--draft { background: rgba(245, 158, 11, 0.18); color: var(--warn); }
.badge--archived { background: rgba(251, 113, 133, 0.18); color: var(--danger); }
.chip {
    font-size: 0.75rem;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
}

.editor-panel {
    border-left: 1px solid var(--line);
    background: rgba(10, 14, 28, 0.85);
    padding: 1rem 1.15rem 1.5rem;
    overflow: auto;
}
.editor-panel[hidden] { display: none !important; }
.editor-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.85rem;
}
.editor-head h2 { margin: 0; font-size: 1.15rem; }
.editor-actions { display: flex; gap: 0.45rem; }
.editor { display: flex; flex-direction: column; gap: 0.75rem; }
.grid-2, .grid-3 { display: grid; gap: 0.7rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr auto; align-items: end; }
.check {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem !important;
    padding-bottom: 0.5rem;
}
.check input { width: auto; }

.image-box {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0.9rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(9, 11, 26, 0.55);
}
.image-box__preview {
    min-height: 140px;
    border-radius: 10px;
    background: #0a0f1d;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.image-box__preview img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    display: block;
}
.image-box__actions { display: flex; flex-direction: column; gap: 0.55rem; }
.image-box__btns { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.8rem; }

.embed-hint {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    justify-content: flex-end;
}
.embed-hint code {
    display: inline-block;
    width: fit-content;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    font-size: 0.78rem;
}

.inline-box {
    margin-top: 0.35rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(9, 11, 26, 0.45);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.inline-box__head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: baseline;
}
.inline-box__form {
    display: grid;
    grid-template-columns: 120px 1fr auto auto;
    gap: 0.55rem;
    align-items: end;
}
.inline-box__list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.inline-item {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: 0.65rem;
    align-items: center;
    padding: 0.45rem;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
}
.inline-item img {
    width: 72px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    background: #0a0f1d;
}
.inline-item__meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.82rem;
}
.inline-item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.thumb {
    width: 44px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #0a0f1d;
    display: block;
}
.thumb-missing {
    width: 44px;
    height: 32px;
    border-radius: 6px;
    border: 1px dashed rgba(251, 113, 133, 0.55);
    background: rgba(251, 113, 133, 0.08);
    color: var(--danger);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gemini-backdrop {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(5, 6, 14, 0.72);
    backdrop-filter: blur(8px);
}
.gemini-backdrop[hidden] { display: none !important; }
.gemini-modal {
    width: min(560px, 100%);
    padding: 1.1rem 1.2rem 1.25rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.97);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.gemini-modal__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}
.gemini-modal__head h2 { margin: 0; font-size: 1.1rem; }
.gemini-modal__actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.gemini-modal textarea { font-size: 0.88rem; line-height: 1.45; }

.empty {
    color: var(--muted);
    padding: 1.5rem 0.65rem;
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    background: #1e293b;
    border: 1px solid var(--line);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 120;
}
.toast.is-visible { opacity: 1; }

@media (max-width: 980px) {
    .workspace.has-editor { grid-template-columns: 1fr; }
    .editor-panel { border-left: 0; border-top: 1px solid var(--line); }
    .table-head, .row { grid-template-columns: 5.2rem 4.8rem 5.2rem 3.2rem 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .image-box { grid-template-columns: 1fr; }
    .inline-box__form { grid-template-columns: 1fr; }
    .inline-item { grid-template-columns: 72px 1fr; }
}
