* { box-sizing: border-box; }

:root {
    --panel-bg: #f3f4f6;
    --panel-fg: #111827;
    --panel-muted: #6b7280;
    --panel-border: #e5e7eb;
    --panel-primary: #3c195c;
    --panel-primary-hover: #5b37a3;
    --panel-accent: #fff;
}

body.panel-body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    background: var(--panel-bg);
    color: var(--panel-fg);
    font-size: 14px;
}

a { color: var(--panel-primary); }

.panel-header {
    background: #fff;
    border-bottom: 1px solid var(--panel-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.panel-header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.panel-brand {
    font-size: 18px;
    font-weight: 800;
    color: var(--panel-fg);
    text-decoration: none;
}

.panel-brand span {
    color: var(--panel-primary);
}

.panel-nav {
    display: flex;
    gap: 4px;
}

.panel-nav a {
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--panel-muted);
    font-weight: 600;
}

.panel-nav a:hover { background: var(--panel-bg); color: var(--panel-fg); }

.panel-nav a.active {
    background: var(--panel-primary);
    color: var(--panel-accent);
}

.panel-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--panel-muted);
}

.panel-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
}

.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}

.btn-primary { background: var(--panel-primary); color: #fff; }
.btn-primary:hover { background: var(--panel-primary-hover); }

.btn-ghost { background: #fff; border-color: var(--panel-border); color: var(--panel-fg); }
.btn-ghost:hover { background: var(--panel-bg); }

.btn-danger { background: #fff; border-color: #fecaca; color: #b91c1c; }
.btn-danger:hover { background: #fef2f2; }

.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

.btn[disabled] { opacity: .5; pointer-events: none; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h1 { font-size: 22px; margin: 0; }

/* ---------- landing list ---------- */

.landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.landing-card {
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.landing-card h3 { margin: 0; font-size: 16px; }

.landing-card .slug {
    color: var(--panel-muted);
    font-size: 13px;
    word-break: break-all;
}

.landing-card .meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--panel-muted);
}

.badge {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-published { background: #ecfdf5; color: #065f46; }
.badge-draft { background: #f3f4f6; color: #4b5563; }

.landing-card .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--panel-border);
}

/* ---------- create form ---------- */

.create-card {
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.create-card label { flex: 1; display: block; font-weight: 600; font-size: 13px; color: var(--panel-muted); }

.create-card input {
    width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    font-size: 14px;
}

/* ---------- forms ---------- */

label.field { display: block; margin-bottom: 14px; }

label.field > span {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--panel-muted);
    margin-bottom: 6px;
}

input[type="text"], input[type="email"], input[type="password"], textarea, select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}

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

input[type="checkbox"] { width: 18px; height: 18px; }

.field-hint { font-size: 12px; color: var(--panel-muted); margin-top: 4px; }

/* ---------- editor layout ---------- */

.editor-layout {
    display: grid;
    grid-template-columns: 300px minmax(380px, 480px) 1fr;
    gap: 16px;
    align-items: start;
    height: calc(100vh - 70px);
}

.editor-col {
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.editor-col > .editor-col-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--panel-border);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.editor-col-body { overflow-y: auto; padding: 14px; }

/* section list */

.section-list { list-style: none; margin: 0; padding: 6px; }

.section-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    margin-bottom: 8px;
    background: #fff;
    cursor: pointer;
    user-select: none;
}

.section-list-item.dragging { opacity: .4; }
.section-list-item.drag-over { border-color: var(--panel-primary); background: #f5f3fa; }

.section-list-item .drag-handle {
    cursor: grab;
    color: var(--panel-muted);
    font-size: 16px;
    letter-spacing: -3px;
}

.section-list-item .section-type-label { font-weight: 600; flex: 1; }

.section-list-item.active {
    border-color: var(--panel-primary);
    background: #f5f3fa;
}

.section-list-item .remove-section {
    border: none;
    background: none;
    color: #b91c1c;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 6px;
}

.section-list-item .remove-section:hover { background: #fef2f2; }

.add-section {
    margin: 10px;
    display: flex;
    gap: 8px;
}

.add-section select { flex: 1; }

/* editor forms */

.editor-form { display: flex; flex-direction: column; gap: 4px; }

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

.editor-form h2 { margin: 0; font-size: 15px; }

.repeater { border: 1px solid var(--panel-border); border-radius: 8px; padding: 10px; margin-bottom: 14px; }

.repeater-item {
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: #fafafa;
}

.repeater-item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--panel-muted);
}

.repeater-item-head button, .repeater-add button {
    border: none;
    background: var(--panel-primary);
    color: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.repeater-add button { background: #fff; color: var(--panel-primary); border: 1px dashed var(--panel-primary); width: 100%; padding: 8px; }

/* image field */

.image-field { display: flex; gap: 10px; align-items: center; }

.image-field img.preview {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
}

.image-field .image-actions { display: flex; flex-direction: column; gap: 6px; }

/* tabs (settings / theme) */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--panel-border); padding: 0 12px; }

.tabs button {
    border: none;
    background: none;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 13px;
    color: var(--panel-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tabs button.active { color: var(--panel-primary); border-bottom-color: var(--panel-primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.settings-grid { display: grid; gap: 12px; padding: 14px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }

/* preview */

.editor-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* ---------- media ---------- */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.media-card {
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    overflow: hidden;
}

.media-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.media-card .media-meta { padding: 8px 10px; font-size: 12px; color: var(--panel-muted); }
.media-card .media-meta .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card .media-actions { padding: 8px 10px; display: flex; gap: 6px; border-top: 1px solid var(--panel-border); }

.upload-zone {
    border: 2px dashed var(--panel-border);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    color: var(--panel-muted);
    cursor: pointer;
    margin-bottom: 20px;
    background: #fff;
    transition: border-color .15s;
}

.upload-zone:hover, .upload-zone.dragover { border-color: var(--panel-primary); color: var(--panel-primary); }

.pagination { margin-top: 20px; display: flex; gap: 6px; }

.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--panel-fg);
    background: #fff;
}

.pagination span.current { background: var(--panel-primary); color: #fff; border-color: var(--panel-primary); }

/* picker mode */

body.picker-body { margin: 0; background: #fff; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 12px; }
.picker-grid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--panel-border);
    cursor: pointer;
    transition: border-color .15s;
}
.picker-grid img:hover { border-color: var(--panel-primary); }
.picker-search { padding: 12px; border-bottom: 1px solid var(--panel-border); display: flex; gap: 8px; }
.picker-search input { flex: 1; }
.picker-empty { padding: 30px; text-align: center; color: var(--panel-muted); }

/* modal */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-backdrop.open { display: flex; }

.modal {
    background: #fff;
    border-radius: 12px;
    width: min(900px, 94vw);
    height: min(700px, 88vh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.modal-head button { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--panel-muted); }
.modal-body { flex: 1; overflow: hidden; }
.modal-body iframe { width: 100%; height: 100%; border: none; }

/* login */

body.login-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e0e2d 0%, #3c195c 60%, #5b37a3 100%);
    font-family: Inter, system-ui, sans-serif;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 36px;
    width: min(400px, 92vw);
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-sub { color: var(--panel-muted); margin: 0 0 20px; }
.login-form { display: grid; gap: 14px; }
.login-form label { font-weight: 600; font-size: 13px; color: var(--panel-muted); }
.login-form input { margin-top: 6px; }
