/* =====================================================================
   Keeper's desk — admin panel
   ===================================================================== */
:root {
    --forest-950: #0a1611;
    --forest-900: #0e1f18;
    --forest-800: #142a20;
    --forest-700: #1c3a2c;
    --ivory: #f6efe3;
    --ivory-2: #efe5d3;
    --paper: #fffaf1;
    --ink: #1a251f;
    --ink-soft: #56625a;
    --line: #e3d7c3;
    --copper: #b8734a;
    --copper-dark: #9a5d3a;
    --rose: #c9727a;
    --gold: #c9a86a;
    --gold-2: #e4cb95;
    --ok: #3f7a5a;
    --danger: #b0473f;
    --serif: "Cormorant Garamond", Georgia, serif;
    --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(26, 37, 31, .05), 0 12px 30px -18px rgba(26, 37, 31, .25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); font-size: .95rem; line-height: 1.6; color: var(--ink); background: var(--ivory); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; }
h1, h2, h3 { margin: 0; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 99; padding: .6rem 1rem; border-radius: 999px; background: var(--forest-900); color: var(--ivory); text-decoration: none; }
.skip-link:focus { top: 1rem; }

.eyebrow { margin: 0 0 .6rem; font-size: .68rem; font-weight: 600; letter-spacing: .26em; text-transform: uppercase; color: var(--copper); }
.muted { color: var(--ink-soft); margin: 0; }
.tiny { font-size: .75rem; color: var(--ink-soft); margin: .6rem 0 0; }
.link { color: var(--copper-dark); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer; white-space: nowrap;
    padding: .7rem 1.25rem; border-radius: 999px; border: 1px solid var(--line); background: var(--paper);
    font-size: .82rem; font-weight: 600; text-decoration: none; color: var(--ink); transition: background .2s, border-color .2s, color .2s, transform .2s;
}
.btn:hover { border-color: var(--copper); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn--primary { background: var(--forest-800); border-color: var(--forest-800); color: var(--ivory); }
.btn--primary:hover { background: var(--copper); border-color: var(--copper); }
.btn--ghost { background: transparent; }
.btn--gold { background: #f6ead0; border-color: var(--gold); color: #6d5423; }
.btn--gold:hover { background: var(--gold-2); }
.btn--danger { color: var(--danger); background: transparent; }
.btn--danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--quiet { background: transparent; }
.btn--small { padding: .38rem .8rem; font-size: .75rem; }
.btn--block { width: 100%; padding-block: .9rem; }

/* ---------------------------------------------------------------------
   Layout: sidebar + shell
   ------------------------------------------------------------------- */
.side {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: 264px; display: flex; flex-direction: column; gap: 2rem;
    padding: 1.8rem 1.2rem 1.4rem; color: var(--ivory); overflow-y: auto;
    background:
        radial-gradient(90% 40% at 0% 0%, rgba(184, 115, 74, .22), transparent 70%),
        radial-gradient(80% 40% at 100% 100%, rgba(201, 114, 122, .14), transparent 70%),
        var(--forest-900);
}
.side__brand { display: grid; gap: .1rem; padding: 0 .6rem; text-decoration: none; }
.side__mono { font-family: var(--serif); font-style: italic; font-size: 2rem; line-height: 1; }
.side__sub { font-size: .64rem; letter-spacing: .3em; text-transform: uppercase; color: var(--gold-2); }
.side__nav { display: grid; gap: .2rem; }
.side__nav a {
    position: relative; padding: .7rem .9rem; border-radius: 10px; text-decoration: none; color: rgba(246, 239, 227, .72);
    font-weight: 500; transition: background .2s, color .2s;
}
.side__nav a:hover { background: rgba(246, 239, 227, .06); color: var(--ivory); }
.side__nav a.is-active { background: rgba(246, 239, 227, .1); color: var(--ivory); }
.side__nav a.is-active::before { content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 2px; border-radius: 2px; background: var(--gold-2); }
.side__foot { margin-top: auto; display: grid; gap: .8rem; padding: 1.1rem .6rem 0; border-top: 1px solid rgba(246, 239, 227, .1); }
.side__preview { color: var(--gold-2); text-decoration: none; font-weight: 600; font-size: .85rem; }
.side__who { margin: 0; font-size: .78rem; color: rgba(246, 239, 227, .55); }
.side__who strong { color: var(--ivory); font-weight: 600; }
.side__logout { width: 100%; padding: .6rem; border-radius: 10px; border: 1px solid rgba(246, 239, 227, .2); background: transparent; color: var(--ivory); cursor: pointer; font-size: .8rem; }
.side__logout:hover { border-color: var(--rose); background: rgba(201, 114, 122, .15); }
.side-scrim { display: none; }

.shell { margin-left: 264px; min-height: 100vh; padding: 0 clamp(1rem, 3vw, 2.6rem) 4rem; }
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: 1.3rem 0 1.1rem; background: linear-gradient(var(--ivory) 70%, rgba(246, 239, 227, 0)); }
.bar__title { font-family: var(--serif); font-weight: 500; font-size: clamp(1.8rem, 3vw, 2.3rem); line-height: 1.1; }
.bar__preview { margin-left: auto; }
.bar__menu { display: none; padding: .5rem .95rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; font-weight: 600; font-size: .8rem; }
.content { display: grid; gap: 1.4rem; max-width: 1100px; }

@media (max-width: 960px) {
    .side { transform: translateX(-100%); transition: transform .35s cubic-bezier(.22, .8, .24, 1); width: min(290px, 86vw); }
    .side.is-open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, .35); }
    .side-scrim { position: fixed; inset: 0; z-index: 39; background: rgba(10, 22, 17, .5); }
    .side.is-open + .side-scrim { display: block; }
    .shell { margin-left: 0; }
    .bar__menu { display: inline-flex; }
    .bar__preview { display: none; }
    body.side-open { overflow: hidden; }
}

/* ---------------------------------------------------------------------
   Flash messages
   ------------------------------------------------------------------- */
.flashes { display: grid; gap: .6rem; max-width: 1100px; margin-bottom: 1.2rem; }
.flash { margin: 0; padding: .85rem 1.1rem; border-radius: 12px; border: 1px solid; font-weight: 500; animation: flash-in .4s ease; }
.flash--success { background: #e7f1ea; border-color: #b8d6c3; color: #245239; }
.flash--error { background: #f8e6e2; border-color: #e8bfb7; color: #7e2f26; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------------------------------------------------------------------
   Panels, stats, dashboard
   ------------------------------------------------------------------- */
.panel { margin: 0; padding: clamp(1.1rem, 2.4vw, 1.8rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); min-width: 0; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel__head h2 { font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
.panel__serif { font-family: var(--serif); font-weight: 500; font-size: 1.65rem; line-height: 1.15; margin-bottom: .5rem; }
.panel__legend { float: left; width: 100%; margin-bottom: 1.2rem; padding: 0; font-family: var(--serif); font-size: 1.55rem; font-weight: 500; }
.panel__legend + * { clear: both; }
fieldset.panel { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.4rem; }

.welcome {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
    padding: clamp(1.5rem, 3.5vw, 2.6rem); border-radius: 20px; color: var(--ivory); overflow: hidden; position: relative;
    background:
        linear-gradient(100deg, rgba(14, 31, 24, .96) 30%, rgba(14, 31, 24, .55)),
        url("https://images.unsplash.com/photo-1470252649378-9c29740c9fa8?auto=format&fit=crop&w=1400&q=70") center 60% / cover;
}
.welcome .eyebrow { color: var(--gold-2); }
.welcome__title { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; max-width: 18ch; }
.welcome__title em { color: var(--gold-2); }
.welcome__lede { margin: .9rem 0 0; max-width: 52ch; color: rgba(246, 239, 227, .75); }
.welcome .btn--primary { background: var(--ivory); color: var(--forest-900); border-color: var(--ivory); }
.welcome .btn--primary:hover { background: var(--gold-2); border-color: var(--gold-2); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat { display: grid; gap: .2rem; padding: 1.2rem 1.3rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); text-decoration: none; box-shadow: var(--shadow); transition: transform .25s, border-color .25s; }
.stat:hover { transform: translateY(-2px); border-color: var(--copper); }
.stat__num { font-family: var(--serif); font-size: 2.6rem; line-height: 1; color: var(--forest-800); }
.stat__num small { font-size: 1.3rem; color: var(--ink-soft); }
.stat__label { font-size: .78rem; color: var(--ink-soft); }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.thumb { display: grid; gap: .25rem; text-decoration: none; }
.thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; transition: transform .3s; }
.thumb:hover img { transform: scale(1.02); }
.thumb span { font-weight: 600; font-size: .88rem; }
.thumb time { font-size: .74rem; color: var(--ink-soft); }

.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.quick a { display: grid; gap: .3rem; padding: 1.2rem 1.3rem; border-radius: var(--radius); background: var(--forest-800); color: var(--ivory); text-decoration: none; transition: background .25s; }
.quick a:hover { background: var(--forest-700); }
.quick strong { font-family: var(--serif); font-size: 1.35rem; font-weight: 500; }
.quick span { font-size: .82rem; color: rgba(246, 239, 227, .65); }

/* ---------------------------------------------------------------------
   Lists
   ------------------------------------------------------------------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.toolbar .muted { max-width: 62ch; }
.crumbs { margin: 0; }
.crumbs a { color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: .85rem; }
.crumbs a:hover { color: var(--copper); }
.section-title { font-family: var(--serif); font-weight: 500; font-size: 1.9rem; }

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.item {
    display: flex; align-items: center; gap: 1rem; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--paper); box-shadow: var(--shadow); transition: box-shadow .2s, border-color .2s, opacity .2s;
}
.items--sortable .item { cursor: grab; }
.item.is-dragging { opacity: .45; border-style: dashed; }
.item.is-over { border-color: var(--copper); box-shadow: 0 0 0 3px rgba(184, 115, 74, .15); }
.item__handle { flex: none; width: 12px; height: 20px; opacity: .45; background: radial-gradient(circle, var(--ink) 1.2px, transparent 1.6px) 0 0 / 6px 5px; }
.item__thumb { flex: none; width: 76px; height: 60px; object-fit: cover; border-radius: 8px; }
.item__body { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.item__body strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__meta { font-size: .78rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { justify-self: start; display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: #f6ead0; color: #6d5423; font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.row-actions { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.inline-form { display: inline; margin: 0; }
.empty { display: grid; justify-items: center; gap: 1rem; padding: 3rem 1rem; text-align: center; }
.empty p { margin: 0; font-family: var(--serif); font-size: 1.4rem; font-style: italic; color: var(--ink-soft); }

@media (max-width: 720px) {
    .item { flex-wrap: wrap; }
    .item__body { flex-basis: calc(100% - 120px); }
    .row-actions { width: 100%; justify-content: flex-start; padding-left: 28px; }
    .items--sortable .item { cursor: default; }
}

.savebar { position: sticky; bottom: 1rem; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .9rem 1rem .9rem 1.3rem; border-radius: 999px; background: var(--forest-900); color: var(--ivory); box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .5); }
.savebar p, .savebar .muted { margin: 0; color: rgba(246, 239, 227, .7); }
.savebar .btn--primary { background: var(--copper); border-color: var(--copper); }
.savebar .btn--primary:hover { background: var(--gold); border-color: var(--gold); color: var(--forest-900); }
.savebar[hidden] { display: none; }
@media (max-width: 600px) { .savebar { border-radius: 16px; } }

/* ---------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------- */
.stack { display: grid; gap: 1.4rem; max-width: 1100px; }
.jump { display: flex; gap: .4rem; flex-wrap: wrap; }
.jump a { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: .75rem; font-weight: 600; text-decoration: none; color: var(--ink-soft); }
.jump a:hover { border-color: var(--copper); color: var(--copper); }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 1.4rem; }
.field { display: grid; gap: .4rem; align-content: start; min-width: 0; }
.field--wide, .field--check { grid-column: 1 / -1; }
@media (max-width: 720px) { .fields { grid-template-columns: 1fr; } }
.field__label { font-size: .78rem; font-weight: 600; color: var(--ink); }
.field__label span { color: var(--copper); }
.field__help { margin: 0; font-size: .76rem; color: var(--ink-soft); }
.field__error { margin: 0; font-size: .78rem; font-weight: 600; color: var(--danger); }
.field input[type="text"], .field input[type="password"], .field input[type="date"], .field input[type="number"], .field select, .field textarea {
    width: 100%; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 5rem; line-height: 1.65; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px rgba(184, 115, 74, .15); }
.field.has-error input, .field.has-error textarea, .field.has-error select { border-color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--copper); }

.image-field { display: grid; grid-template-columns: 1fr 140px; gap: .8rem; align-items: start; }
.image-field__preview { margin: 0; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; border: 1px dashed var(--line); background: var(--ivory-2); display: grid; place-items: center; position: relative; }
.image-field__preview img { width: 100%; height: 100%; object-fit: cover; display: none; }
.image-field__preview figcaption { position: absolute; font-size: .7rem; color: var(--ink-soft); }
.image-field__preview.has-image { border-style: solid; }
.image-field__preview.has-image img { display: block; }
.image-field__preview.has-image figcaption { display: none; }
@media (max-width: 520px) { .image-field { grid-template-columns: 1fr; } }

.editor { display: grid; gap: 1.4rem; }
.editor__actions { display: flex; justify-content: flex-end; gap: .6rem; padding-top: .6rem; border-top: 1px solid var(--line); }

/* Constellation position picker (dreams) */
.sky-picker { display: grid; gap: .5rem; }
.sky-picker__sky {
    position: relative; height: 260px; border-radius: 12px; cursor: crosshair; overflow: hidden;
    background: radial-gradient(60% 70% at 50% 60%, #16302a, #07110f);
}
.sky-picker__star { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: #f6f1e6; box-shadow: 0 0 8px 2px rgba(246, 241, 230, .6); }
.sky-picker__star.is-done { background: var(--gold-2); box-shadow: 0 0 10px 3px rgba(228, 203, 149, .7); }
.sky-picker__star--me { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: var(--rose); box-shadow: 0 0 0 4px rgba(201, 114, 122, .35), 0 0 16px 4px rgba(201, 114, 122, .6); }

/* ---------------------------------------------------------------------
   Login
   ------------------------------------------------------------------- */
.login { display: grid; grid-template-columns: 1.1fr .9fr; min-height: 100vh; background: var(--ivory); }
.login__art { position: relative; overflow: hidden; background: var(--forest-900); }
.login__art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: drift 30s ease-in-out infinite alternate; }
.login__art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 22, 17, .1), rgba(10, 22, 17, .82)); }
@keyframes drift { from { transform: scale(1.02); } to { transform: scale(1.12) translateY(-2%); } }
.login__quote { position: absolute; left: clamp(1.5rem, 4vw, 3.5rem); right: clamp(1.5rem, 4vw, 3.5rem); bottom: clamp(1.5rem, 5vw, 3.5rem); z-index: 1; color: var(--ivory); }
.login__quote p { margin: 0 0 .6rem; font-family: var(--serif); font-style: italic; font-size: clamp(1.6rem, 3vw, 2.6rem); line-height: 1.15; max-width: 18ch; }
.login__quote span { font-size: .7rem; letter-spacing: .3em; text-transform: uppercase; color: var(--gold-2); }
.login__panel { display: grid; place-items: center; padding: 3rem clamp(1.2rem, 5vw, 4rem); }
.login__card { width: min(400px, 100%); display: grid; gap: 1.1rem; }
.login__eyebrow { margin: 0; font-size: .68rem; font-weight: 600; letter-spacing: .3em; text-transform: uppercase; color: var(--copper); }
.login__title { font-family: var(--serif); font-weight: 400; font-size: clamp(2.6rem, 5vw, 3.4rem); line-height: 1; }
.login__title em { color: var(--copper); }
.login__lede { margin: 0 0 .6rem; color: var(--ink-soft); }
.login__form { display: grid; gap: 1rem; }
.login__back { justify-self: start; color: var(--ink-soft); text-decoration: none; font-size: .85rem; font-weight: 600; }
.login__back:hover { color: var(--copper); }
@media (max-width: 820px) {
    .login { grid-template-columns: 1fr; }
    .login__art { min-height: 34vh; }
    .login__quote p { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
