:root {
    --bg: #faf3e0;
    --bg-deep: #f5e6c4;
    --panel: #ffffff;
    --ink: #2e1f15;
    --ink-soft: #5a4438;
    --muted: #8b7a6e;
    --line: #2e1f15;
    --line-soft: #e3d5b8;
    --terra: #e85a3c;
    --terra-deep: #c4422a;
    --mustard: #f4b942;
    --pink: #d97aa5;
    --sage: #7a9b6e;
    --danger: #c4422a;
    --success: #5e7d54;
    --serif: 'Fraunces', Georgia, serif;
    --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --shadow-xs: 3px 3px 0 var(--ink);
    --shadow-sm: 4px 4px 0 var(--ink);
}

* { 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;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 600;
    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: .75rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--terra);
    font-weight: 700;
}
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-deep);
    padding: 1px 6px;
    color: var(--ink);
    word-break: break-all;
    border-radius: 4px;
}
a { color: var(--terra); text-decoration: none; }
ol, ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Header ---------- */
.admin-header {
    background: var(--ink);
    color: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 3px solid var(--ink);
}
.admin-bar {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 16px 32px;
    max-width: 1280px;
    margin: 0 auto;
}
.admin-title {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 600;
    flex-shrink: 0;
    color: var(--bg);
    font-size: .98rem;
}
.admin-flower {
    color: var(--mustard);
    font-size: 1.5rem;
    animation: spin 18s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.admin-title .muted { color: rgba(250, 243, 224, 0.5); font-weight: 400; }
.admin-nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}
.admin-nav a {
    color: rgba(250, 243, 224, 0.78);
    padding: 6px 12px;
    font-size: .85rem;
    white-space: nowrap;
    transition: color .15s;
    font-weight: 500;
}
.admin-nav a:hover { color: var(--mustard); }
.admin-actions { display: flex; gap: 8px; flex-shrink: 0; }
.admin-header .btn-ghost {
    color: rgba(250, 243, 224, 0.85);
    border-color: rgba(250, 243, 224, 0.25);
    background: transparent;
}
.admin-header .btn-ghost:hover { background: rgba(250, 243, 224, 0.1); color: var(--bg); }

/* ---------- Main / panels ---------- */
.admin-main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 36px 32px 100px;
}
.panel {
    background: var(--panel);
    border: 3px solid var(--ink);
    border-radius: 18px;
    padding: 32px 36px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
    scroll-margin-top: 96px;
}
.panel > h2:first-child { margin-bottom: 6px; }
.panel > .muted { margin-bottom: 22px; }

/* ---------- 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: .76rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--ink);
    font-weight: 600;
}
input[type=text], input[type=email], input[type=url], input[type=password], select, textarea, input[type=file] {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 11px 14px;
    border: 2px solid var(--line);
    border-radius: 10px;
    font-family: var(--sans);
    font-size: .95rem;
    color: var(--ink);
    background: #fff;
    transition: all .15s;
}
input[type=file] { padding: 7px 10px; background: var(--bg); cursor: pointer; }
select {
    -webkit-appearance: none;
    appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%232e1f15' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") right 12px center / 12px no-repeat;
    padding-right: 34px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--terra);
    box-shadow: var(--shadow-xs);
}

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

/* ---------- Stats edit ---------- */
.stats-edit { display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; }
.stat-row input { margin-top: 0; }

/* ---------- Items (repeaters) ---------- */
.items { display: flex; flex-direction: column; gap: 20px; }
.item {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 22px;
    padding: 22px;
    background: var(--bg);
    border: 2px solid var(--line);
    border-radius: 14px;
    align-items: start;
}
.item.compact { grid-template-columns: 1fr; }
.item-media {
    width: 150px;
    aspect-ratio: 5 / 4;
    overflow: hidden;
    background: var(--bg-deep);
    border: 2px solid var(--line);
    border-radius: 8px;
}
.item-media img { width: 100%; height: 100%; object-fit: cover; }
.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: .88rem;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid var(--ink);
    border-radius: 999px;
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    font-family: var(--sans);
    transition: all .15s;
    line-height: 1;
}
.btn-primary {
    background: var(--ink);
    color: var(--bg);
}
.btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--terra); }
.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line);
    box-shadow: none;
}
.btn-ghost:hover { background: var(--bg-deep); color: var(--ink); }
.btn-danger {
    background: #fff;
    color: var(--danger);
    border-color: var(--danger);
    box-shadow: 2px 2px 0 var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn-danger.small { padding: 4px 9px; font-size: .76rem; line-height: 1; }

/* ---------- Save bar ---------- */
.save-bar {
    position: sticky;
    bottom: 0;
    background: rgba(250, 243, 224, 0.95);
    backdrop-filter: blur(8px);
    border-top: 2px solid var(--line);
    padding: 18px 0;
    margin: 24px -36px -32px;
    padding-left: 36px;
    padding-right: 36px;
    display: flex;
    gap: 12px;
    z-index: 30;
}
.save-bar .btn-primary { padding: 13px 26px; font-size: .92rem; }

/* ---------- Inline / 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;
    border: 2px solid var(--line);
    border-radius: 10px;
    background: var(--bg-deep);
}
.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: 22px;
    font-size: .95rem;
    border: 2px solid var(--ink);
    border-radius: 10px;
    box-shadow: var(--shadow-xs);
    font-weight: 500;
}
.alert-success { background: var(--mustard); color: var(--ink); }
.alert-error   { background: #fbe9e6; color: var(--danger); }

/* ---------- Login ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 10% 20%, var(--mustard) 0, transparent 4%),
        radial-gradient(circle at 90% 30%, var(--pink) 0, transparent 4%),
        radial-gradient(circle at 80% 80%, var(--sage) 0, transparent 4%),
        var(--bg);
}
.login-card {
    background: #fff;
    padding: 52px 48px;
    width: 100%;
    max-width: 420px;
    border: 3px solid var(--ink);
    border-radius: 22px;
    box-shadow: 8px 8px 0 var(--ink);
}
.login-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.login-flower {
    font-size: 2.4rem;
    color: var(--terra);
    animation: spin 14s linear infinite;
    display: inline-block;
}
.login-card h1 {
    font-family: var(--serif);
    font-size: 1.5rem;
    color: var(--ink);
    font-weight: 600;
}
.login-card .muted { margin-bottom: 28px; }
.login-card label { margin-bottom: 18px; }
.login-card .btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--terra);
    color: #fff;
    margin-top: 10px;
    box-shadow: var(--shadow-sm);
}
.login-card .btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); background: var(--ink); }
.login-card .hint {
    font-size: .82rem;
    color: var(--muted);
    margin-top: 24px;
    padding-top: 22px;
    border-top: 2px dashed var(--line-soft);
}
.login-card .back { text-align: center; margin: 18px 0 0; font-size: .85rem; }
.login-card .back a { color: var(--muted); }
.login-card .back a:hover { color: var(--terra); }

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

/* ---------- 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: 22px 18px 80px; }
    .panel { padding: 22px; }
    .row.two, .row.three, .stats-edit { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: 100px 1fr; }
    .image-field-grid { grid-template-columns: 1fr; }
    .image-preview { width: 100%; }
    .item { grid-template-columns: 1fr; }
    .item-media { 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; }
}
