:root {
    --bg: #0b0f19;
    --card: rgba(15, 20, 35, 0.72);
    --text: #f8fafc;
    --muted: #94a3b8;
    --fb: #1877f2;
    --fb-deep: #0c4aa6;
    --ok: #34d399;
    --danger: #fb7185;
    --border: rgba(255, 255, 255, 0.08);
    --input: rgba(10, 15, 25, 0.65);
    --radius: 18px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    min-height: 100%;
}

body {
    font-family: Inter, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: #93c5fd;
}

code {
    font-size: 0.85em;
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 6px;
    border-radius: 6px;
}

.background-elements {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(110px);
    opacity: 0.38;
    border-radius: 50%;
}

.blob-1 {
    width: 480px;
    height: 480px;
    top: -12%;
    left: -8%;
    background: radial-gradient(circle, #1877f2, transparent 70%);
}

.blob-2 {
    width: 520px;
    height: 520px;
    bottom: -16%;
    right: -10%;
    background: radial-gradient(circle, #4c1d95, transparent 70%);
}

.topbar {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 20px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--fb), var(--fb-deep));
    color: #fff;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-chip {
    font-size: 0.9rem;
    color: var(--muted);
}

.view {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 20px 48px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.45);
}

.connect-card {
    max-width: 640px;
    margin: 24px auto 0;
    padding: 36px 32px;
}

.connect-card h1,
.pane-head h2 {
    font-size: 1.45rem;
    font-weight: 700;
}

.lead {
    color: var(--muted);
    margin: 10px 0 22px;
    font-size: 0.95rem;
}

.connect-form,
.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.connect-form {
    gap: 16px;
}

.field span,
.section-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.section-label {
    margin: 18px 0 8px;
}

input, textarea, button {
    font-family: inherit;
}

input[type="text"],
input[type="password"],
input[type="numeric"],
textarea {
    width: 100%;
    background: var(--input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 13px 14px;
    font-size: 0.95rem;
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

input:focus, textarea:focus {
    border-color: var(--fb);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.25);
}

.copy-row {
    display: flex;
    gap: 8px;
}

.copy-row input {
    flex: 1;
}

button {
    border: 0;
    cursor: pointer;
    border-radius: 12px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--fb), var(--fb-deep));
    color: #fff;
    font-weight: 700;
    padding: 13px 18px;
    width: 100%;
    font-size: 0.95rem;
}

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

.ghost-btn,
.icon-btn,
.chip {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 14px;
    font-size: 0.85rem;
    font-weight: 600;
}

.icon-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
}

.ghost-btn:hover,
.icon-btn:hover,
.chip:hover {
    background: rgba(255, 255, 255, 0.05);
}

.howto {
    margin-top: 22px;
    color: var(--muted);
    font-size: 0.9rem;
}

.howto ol {
    margin: 10px 0 0 18px;
    display: grid;
    gap: 6px;
}

.form-error {
    color: var(--danger);
    min-height: 1.2em;
    font-size: 0.88rem;
}

.success {
    color: var(--ok);
    font-size: 0.9rem;
    margin-top: 10px;
}

.workspace {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    align-items: start;
}

.pages-pane,
.composer-pane {
    padding: 20px;
}

.pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.char-count {
    color: var(--muted);
    font-size: 0.8rem;
}

.pages-list {
    display: grid;
    gap: 8px;
}

.page-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: inherit;
    padding: 10px;
    border-radius: 14px;
}

.page-item img,
.fb-preview header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #1e293b;
}

.page-item small {
    display: block;
    color: var(--muted);
    font-weight: 400;
}

.page-item.is-active {
    border-color: var(--fb);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.2);
}

.empty-state {
    color: var(--muted);
    font-size: 0.9rem;
}

.bg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.chip.is-active {
    background: rgba(24, 119, 242, 0.2);
    border-color: var(--fb);
    color: #dbeafe;
}

.color-pick {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--muted);
}

.color-pick input {
    width: 42px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.preset {
    height: 56px;
    border-radius: 12px;
    border: 2px solid transparent;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.preset.is-active {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--fb);
}

.hint {
    color: var(--muted);
    font-size: 0.8rem;
    min-height: 1.2em;
    margin-top: 8px;
}

.dropzone {
    display: grid;
    place-items: center;
    gap: 4px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 14px;
    padding: 22px 12px;
    color: var(--muted);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
}

.dropzone input {
    display: none;
}

.dropzone.is-drag {
    border-color: var(--fb);
    background: rgba(24, 119, 242, 0.08);
}

.dropzone span {
    font-size: 0.8rem;
}

.media-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.media-thumb {
    position: relative;
    width: 88px;
    height: 88px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #111827;
}

.media-thumb img,
.media-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-thumb button {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 14px;
    line-height: 1;
}

.fb-preview {
    background: #1c1e21;
    border-radius: 12px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.fb-preview header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.fb-preview header small {
    display: block;
    color: #b0b3b8;
    font-size: 0.75rem;
}

.preview-caption {
    white-space: pre-wrap;
    margin-bottom: 10px;
}

.preview-card {
    min-height: 220px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    padding: 28px;
    text-align: center;
    font-weight: 800;
    font-size: 1.35rem;
    line-height: 1.35;
}

.preview-media {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}

.preview-media img,
.preview-media video {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: 8px;
}

.composer-actions {
    margin-top: 16px;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #0f172a;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 360px;
    z-index: 20;
}

@media (max-width: 860px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .connect-card {
        padding: 24px 18px;
    }
}
