:root {
    --bg: #f4f1eb;
    --panel: #ffffff;
    --ink: #1a1817;
    --ink-soft: #4a4541;
    --muted: #8b8580;
    --line: #e3ddd2;
    --gold: #b08654;
    --gold-soft: #d4a574;
    --danger: #b94432;
    --success: #2e6a3a;
    --serif: 'Playfair Display', Georgia, serif;
    --sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 500;
    color: var(--ink);
    line-height: 1.15;
}
h2 { font-size: 1.7rem; }
h3 { font-size: 1.25rem; }
h3.sub {
    margin-top: 32px;
    font-family: var(--sans);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .18em;
    color: var(--gold);
    font-weight: 500;
}
p { margin-bottom: 1em; color: var(--ink-soft); }
.muted { color: var(--muted); }
.muted.small { font-size: .8rem; margin: 6px 0 0; }
code {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: .82em;
    background: var(--bg);
    padding: 1px 6px;
    color: var(--ink-soft);
    word-break: break-all;
}
a { color: var(--gold); text-decoration: none; }
ol, ul { list-style: none; }
button { font-family: inherit; }

/* ---------- Header ---------- */
.admin-header {
    background: #0e0d0c;
    color: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid #1a1817;
}
.admin-bar {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 18px 36px;
    max-width: 1320px;
    margin: 0 auto;
}
.admin-title {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--bg);
    font-weight: 400;
    flex-shrink: 0;
    font-size: .95rem;
}
.admin-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--gold-soft);
    color: var(--gold-soft);
    font-family: var(--serif);
    font-style: italic;
    font-size: .9rem;
    border-radius: 50%;
}
.admin-title .muted { color: rgba(244, 241, 235, 0.5); font-weight: 300; }
.admin-nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}
.admin-nav a {
    color: rgba(244, 241, 235, 0.72);
    padding: 6px 12px;
    font-size: .8rem;
    letter-spacing: .04em;
    white-space: nowrap;
    transition: color .15s;
}
.admin-nav a:hover { color: var(--gold-soft); }
.admin-actions { display: flex; gap: 8px; flex-shrink: 0; }
.admin-header .btn-ghost {
    color: rgba(244, 241, 235, 0.78);
    border-color: rgba(244, 241, 235, 0.2);
    background: transparent;
}
.admin-header .btn-ghost:hover { color: var(--gold-soft); border-color: var(--gold-soft); background: transparent; }

/* ---------- Main / panels ---------- */
.admin-main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 36px 100px;
}
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 36px;
    margin-bottom: 22px;
    scroll-margin-top: 96px;
}
.panel > h2:first-child { margin-bottom: 6px; }
.panel > .muted { margin-bottom: 26px; }

/* ---------- Form rows ---------- */
.row { margin-bottom: 18px; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.row.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.row .span-2 { grid-column: span 2; }

label {
    display: block;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--muted);
    font-weight: 500;
}
input[type=text], input[type=email], input[type=url], input[type=password], textarea, input[type=file] {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 0;
    font-family: var(--sans);
    font-size: .94rem;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
input[type=file] { padding: 7px 10px; background: var(--bg); cursor: pointer; }
textarea { resize: vertical; min-height: 68px; }
input:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(176, 134, 84, 0.12);
}

/* ---------- Image field ---------- */
.image-field { padding-top: 8px; }
.image-field .field-label {
    display: block;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 12px;
}
.image-field-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    align-items: flex-start;
}
.image-preview {
    width: 240px;
    aspect-ratio: 4 / 3;
    background: var(--bg);
    border: 1px solid var(--line);
    overflow: hidden;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Items (repeaters) ---------- */
.items { display: flex; flex-direction: column; gap: 20px; }
.item {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 24px;
    padding: 24px;
    background: var(--bg);
    border: 1px solid var(--line);
    align-items: start;
}
.item.compact { grid-template-columns: 1fr; }
.item-media {
    width: 160px;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: var(--line);
}
.item-media-wide {
    width: 200px;
    aspect-ratio: 16 / 10;
}
.item-media img { width: 100%; height: 100%; object-fit: cover; }
.item.slide-item { grid-template-columns: 200px 1fr; }
.item-fields .row { margin-bottom: 12px; }
.item-fields .row:last-child { margin-bottom: 0; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost, .btn-danger {
    display: inline-block;
    padding: 11px 22px;
    font-size: .8rem;
    font-weight: 400;
    letter-spacing: .16em;
    text-transform: uppercase;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    font-family: var(--sans);
    transition: all .2s ease;
    border-radius: 0;
}
.btn-primary {
    background: #0e0d0c;
    color: var(--bg);
    border-color: #0e0d0c;
}
.btn-primary:hover { background: var(--gold); border-color: var(--gold); }
.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg); color: var(--ink); border-color: var(--ink-soft); }
.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(185, 68, 50, 0.35);
}
.btn-danger:hover { background: rgba(185, 68, 50, 0.08); border-color: var(--danger); }
.btn-danger.small { padding: 4px 8px; font-size: .76rem; letter-spacing: .04em; line-height: 1; }

/* ---------- Save bar ---------- */
.save-bar {
    position: sticky;
    bottom: 0;
    background: rgba(244, 241, 235, 0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    padding: 18px 0;
    margin: 24px -36px -36px;
    padding-left: 36px;
    padding-right: 36px;
    display: flex;
    gap: 12px;
    z-index: 30;
}
.save-bar .btn-primary { padding: 13px 28px; }

/* ---------- Add/delete forms ---------- */
.inline-form { margin-bottom: 18px; }
.delete-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.del-form { display: inline; }

/* ---------- Gallery edit ---------- */
.gallery-edit {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 18px;
}
.gallery-edit-item {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--line);
}
.gallery-edit-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-edit-item .del-form { position: absolute; top: 6px; right: 6px; }

/* ---------- Alerts ---------- */
.alert {
    padding: 14px 18px;
    margin-bottom: 24px;
    font-size: .92rem;
    border-left: 3px solid;
}
.alert-success {
    background: #eaf2e8;
    color: var(--success);
    border-color: var(--success);
}
.alert-error {
    background: #fbe9e6;
    color: var(--danger);
    border-color: var(--danger);
}

/* ---------- Login ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0e0d0c;
    color: var(--bg);
    padding: 24px;
}
.login-card {
    background: #1a1817;
    padding: 56px 48px;
    width: 100%;
    max-width: 420px;
    border: 1px solid #2a2724;
}
.login-card * { color: var(--bg); }
.login-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.login-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border: 1px solid var(--gold-soft);
    color: var(--gold-soft);
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.1rem;
    border-radius: 50%;
}
.login-card h1 {
    font-family: var(--serif);
    font-size: 1.5rem;
    color: var(--bg);
    font-weight: 400;
}
.login-card .muted { color: rgba(244, 241, 235, 0.5); margin-bottom: 32px; }
.login-card label { color: var(--gold-soft); }
.login-card input {
    background: transparent;
    border: 0;
    border-bottom: 1px solid #2a2724;
    color: var(--bg);
    padding: 12px 0;
    margin-top: 6px;
}
.login-card input:focus { border-color: var(--gold-soft); box-shadow: none; }
.login-card .btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--gold-soft);
    color: #0e0d0c;
    border-color: var(--gold-soft);
    margin-top: 12px;
}
.login-card .btn-primary:hover {
    background: transparent;
    color: var(--gold-soft);
}
.login-card .hint {
    font-size: .8rem;
    color: rgba(244, 241, 235, 0.5);
    margin-top: 24px;
    padding-top: 22px;
    border-top: 1px solid #2a2724;
}
.login-card .hint code {
    background: rgba(244, 241, 235, 0.08);
    color: var(--gold-soft);
}
.login-card .back { text-align: center; margin: 18px 0 0; font-size: .82rem; }
.login-card .back a { color: rgba(244, 241, 235, 0.5); }
.login-card .back a:hover { color: var(--gold-soft); }
.login-card .alert {
    background: rgba(185, 68, 50, 0.12);
    color: #f4a59a;
    border-color: #b94432;
}

/* ---------- Checkbox ---------- */
label.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-transform: none;
    letter-spacing: 0;
    font-size: .92rem;
    font-weight: 400;
    color: var(--bg);
    cursor: pointer;
    margin: 0;
    font-family: var(--sans);
}
label.checkbox input[type=checkbox] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--gold-soft);
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .admin-bar { flex-wrap: wrap; padding: 14px 18px; }
    .admin-nav { order: 3; width: 100%; padding-bottom: 4px; }
    .admin-main { padding: 24px 18px 80px; }
    .panel { padding: 24px; }
    .row.two, .row.three { grid-template-columns: 1fr; }
    .image-field-grid { grid-template-columns: 1fr; }
    .image-preview { width: 100%; }
    .item, .item.slide-item { grid-template-columns: 1fr; }
    .item-media, .item-media-wide { width: 100%; aspect-ratio: 16 / 10; }
    .save-bar { margin-left: -18px; margin-right: -18px; padding-left: 18px; padding-right: 18px; }
    .login-card { padding: 36px 28px; }
}
