:root {
    --bg: #f8f3f0;
    --bg-2: #f2e9e5;
    --surface: #ffffff;
    --ink: #2e2330;
    --ink-2: #5c4d5a;
    --muted: #8d7d88;
    --line: #eadfdb;
    --line-2: #ddcfca;
    --accent: #7a3e5a;
    --accent-2: #94506f;
    --accent-ink: #fff;
    --accent-soft: #f3e4ea;
    --gold: #b6936a;
    --danger: #b3434f;
    --danger-soft: #fbe9ea;
    --ok: #4f8a6b;
    --shadow-sm: 0 1px 2px rgba(60, 30, 45, .06);
    --shadow: 0 1px 2px rgba(60, 30, 45, .05), 0 8px 24px -8px rgba(60, 30, 45, .14);
    --shadow-lg: 0 24px 60px -12px rgba(40, 18, 30, .35);
    --r: 14px;
    --r-sm: 9px;
    --serif: "Cormorant Garamond", Georgia, serif;
    --sans: "Jost", "Segoe UI", system-ui, sans-serif;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #17121a;
        --bg-2: #1e1821;
        --surface: #241d27;
        --ink: #f3eaee;
        --ink-2: #cdbfc7;
        --muted: #9a8a95;
        --line: #342a36;
        --line-2: #43374a;
        --accent: #d593b0;
        --accent-2: #e2a9c2;
        --accent-ink: #2a1520;
        --accent-soft: #3a2632;
        --gold: #cfb08a;
        --danger: #e57f89;
        --danger-soft: #3a2226;
        --ok: #7cc39c;
        --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -8px rgba(0,0,0,.5);
        --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.7);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 400 15px/1.55 var(--sans);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: .005em; line-height: 1.15; margin: 0; }
code { font-size: .85em; background: var(--bg-2); padding: 1px 5px; border-radius: 5px; }
[hidden] { display: none !important; }

.ico { width: 18px; height: 18px; flex: none; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border-radius: 999px; border: 1px solid transparent;
    background: var(--surface); color: var(--ink);
    font-weight: 500; font-size: 14px; letter-spacing: .01em;
    cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px -8px var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.soft:hover { background: var(--accent); color: var(--accent-ink); }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.small .ico { width: 15px; height: 15px; }
.btn.done { background: var(--ok); color: #fff; box-shadow: none; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px; border-radius: 50%;
    border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.tiny { width: 26px; height: 26px; }
.icon-btn.tiny .ico { width: 15px; height: 15px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Brand + top bar */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
    background: linear-gradient(145deg, var(--accent), #5d2c45); color: #f6e9e2;
}
.brand-mark .ico { width: 20px; height: 20px; }
.brand-name { font-family: var(--serif); font-size: 25px; font-weight: 600; font-style: italic; letter-spacing: .01em; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    height: 64px; padding: 0 24px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.top-links { display: flex; align-items: center; gap: 10px; }
.who { display: inline-flex; align-items: center; gap: 9px; padding-left: 8px; font-weight: 500; }
.avatar {
    display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); font-family: var(--serif); font-weight: 600; font-size: 17px;
}
.viewing { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

/* Layout */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 64px); }
.sidebar {
    position: sticky; top: 64px; align-self: start;
    height: calc(100vh - 64px); overflow-y: auto;
    display: flex; flex-direction: column;
    padding: 24px 16px 20px;
    border-right: 1px solid var(--line);
}
.side-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 8px 10px; color: var(--muted);
    font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
}
.cat-nav { display: flex; flex-direction: column; gap: 2px; }
.cat-link {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 10px; border-radius: var(--r-sm);
    color: var(--ink-2); flex: 1; min-width: 0;
    transition: background .15s, color .15s;
}
.cat-link span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-link:hover { background: var(--bg-2); color: var(--ink); }
.cat-link.active, .cat-row.active .cat-link { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-link.active .count, .cat-row.active .count { color: var(--accent); }
.cat-row { position: relative; display: flex; align-items: center; }
.cat-tools { position: absolute; right: 4px; display: none; gap: 0; background: inherit; }
.cat-row:hover .cat-tools, .cat-row:focus-within .cat-tools { display: flex; }
.cat-row:hover .count, .cat-row:focus-within .count { visibility: hidden; }
.divider { height: 1px; background: var(--line); margin: 8px 10px; }
.add-cat {
    display: flex; align-items: center; gap: 8px; margin-top: 10px;
    padding: 9px 10px; border: 1px dashed var(--line-2); border-radius: var(--r-sm);
    background: none; color: var(--muted); cursor: pointer; font-size: 14px;
}
.add-cat:hover { color: var(--accent); border-color: var(--accent); }
.add-cat .ico { width: 16px; height: 16px; }
.side-foot { margin-top: auto; padding: 16px 10px 0; font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.collar-state { display: flex; align-items: center; gap: 7px; }
.collar-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.collar-state.on .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }

.main { padding: 32px 36px 60px; min-width: 0; position: relative; }
.main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 12px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; }
.main-head h1 { font-size: 40px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.head-tools { display: flex; align-items: center; gap: 10px; }
.search {
    display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
    transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: 0; outline: 0; background: none; width: 170px; color: var(--ink); }
.search .ico { width: 16px; height: 16px; }

/* Grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px; }
.card {
    display: flex; flex-direction: column;
    background: var(--surface); border-radius: var(--r); overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    animation: rise .35s ease both;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow), 0 14px 30px -12px rgba(122, 62, 90, .3); }
.card-img {
    position: relative; display: block; width: 100%; padding: 0; border: 0; cursor: pointer;
    aspect-ratio: 4 / 5; background: var(--bg-2); overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.card:hover .card-img img { transform: scale(1.035); }
.badge {
    position: absolute; top: 10px; right: 10px;
    display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,.92); color: var(--accent); box-shadow: var(--shadow-sm);
}
.badge .ico { width: 15px; height: 15px; }
.card-body { padding: 12px 14px 4px; }
.card-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; padding: 8px 14px 14px; margin-top: auto; }
.card-actions .btn { flex: 1; }
.card-body:last-child { padding-bottom: 14px; }

.no-results, .empty p { color: var(--muted); }
.empty { text-align: center; padding: 70px 20px; border: 1.5px dashed var(--line-2); border-radius: 20px; }
.empty-art {
    display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); margin-bottom: 14px;
}
.empty-art .ico { width: 34px; height: 34px; }
.empty h2 { font-size: 28px; }
.empty .btn { margin-top: 8px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Upload */
.upload-panel {
    background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
    padding: 16px 18px; margin-bottom: 24px;
}
.upload-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.upload-head span { color: var(--muted); }
#upload-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 220px; overflow-y: auto; }
#upload-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
#upload-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#upload-list .state { color: var(--muted); }
#upload-list .state.ok { color: var(--ok); }
#upload-list .state.err { color: var(--danger); }
.bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--bg-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .2s; }

.drop-overlay {
    position: fixed; inset: 0; z-index: 50; display: none; place-items: center;
    background: color-mix(in srgb, var(--accent) 16%, transparent); backdrop-filter: blur(3px);
}
.drop-overlay > div {
    padding: 40px 60px; border: 2px dashed var(--accent); border-radius: 24px;
    background: var(--surface); color: var(--accent); text-align: center; box-shadow: var(--shadow-lg);
}
.drop-overlay .ico { width: 40px; height: 40px; }
.drop-overlay p { margin: 10px 0 0; font-family: var(--serif); font-size: 24px; font-weight: 600; }
body.dragging .drop-overlay { display: grid; }

/* Modals */
.modal {
    border: 0; padding: 0; border-radius: 20px;
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
    max-width: calc(100vw - 32px); max-height: calc(100vh - 32px);
}
.modal::backdrop { background: rgba(30, 14, 24, .5); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .22s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 28px; }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.spacer { flex: 1; }

.edit-modal { width: 900px; }
.edit-layout { display: grid; grid-template-columns: 1fr 1fr; min-height: 520px; }
.edit-preview { position: relative; background: var(--bg-2); display: grid; place-items: center; overflow: hidden; }
.edit-preview img { width: 100%; height: 100%; object-fit: contain; max-height: calc(100vh - 32px); }
.edit-size {
    position: absolute; left: 12px; bottom: 12px; padding: 3px 9px; border-radius: 999px;
    background: rgba(0,0,0,.5); color: #fff; font-size: 12px;
}
.edit-fields { padding: 22px 26px; overflow-y: auto; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field small { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
input:not([type=search]):not([type=file]), select, textarea, #ask-input {
    width: 100%; padding: 10px 13px;
    background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-sm);
    outline: 0; transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.share-row { display: flex; gap: 8px; }

.small-modal { width: 420px; }
.small-modal form { padding: 24px; }
.small-modal h2 { font-size: 26px; margin-bottom: 6px; }
.small-modal p { color: var(--ink-2); margin: 0 0 14px; }
.small-modal p:empty { display: none; }

/* Share modal */
.share-modal { width: 540px; }
.share-body { padding: 24px 26px 22px; }
.share-intro { color: var(--ink-2); margin: 0 0 18px; }
.share-modal[data-on="1"] .share-off-view, .share-modal[data-on="0"] .share-on-view { display: none; }
.link-box { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 14px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 999px; }
.link-box input#share-url { border: 0 !important; background: none !important; box-shadow: none !important; padding: 6px 0 !important; font-size: 13.5px; color: var(--ink-2); min-width: 0; }
.switch-row { display: flex; gap: 14px; align-items: flex-start; margin-top: 18px; padding: 14px 16px; border-radius: var(--r-sm); background: var(--bg); cursor: pointer; }
.switch-row strong { display: block; font-weight: 500; }
.switch-row small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 2px; }
.switch { position: relative; flex: none; width: 42px; height: 24px; margin-top: 1px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.fine-print { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }

/* Lightbox */
.lightbox { width: min(1100px, calc(100vw - 32px)); background: var(--surface); }
.lb-inner { position: relative; display: grid; grid-template-columns: 1fr 300px; min-height: 60vh; max-height: calc(100vh - 32px); }
.lb-img { background: #0f0b10; display: grid; place-items: center; overflow: hidden; }
.lb-img img { max-height: calc(100vh - 32px); width: 100%; object-fit: contain; }
.lb-info { padding: 60px 26px 26px; display: flex; flex-direction: column; overflow-y: auto; }
.lb-info h2 { font-size: 30px; }
.lb-info p { color: var(--ink-2); white-space: pre-line; }
.lb-actions { display: grid; gap: 8px; margin-top: auto; }
.lb-actions .btn { height: 46px; }
.lb-close { position: absolute; top: 10px; right: 10px; z-index: 2; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; background: rgba(255,255,255,.12); color: #fff; }
.lb-nav:hover { background: rgba(255,255,255,.25); color: #fff; }
.lb-nav.prev { left: 12px; }
.lb-nav.next { left: calc(100% - 300px - 50px); }

/* Toasts */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
    display: flex; align-items: center; gap: 10px; max-width: min(460px, calc(100vw - 32px));
    padding: 11px 18px; border-radius: 999px;
    background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px;
    animation: toast .25s ease;
}
.toast.err { background: var(--danger); color: #fff; }
.toast .ico { width: 17px; height: 17px; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toast { from { opacity: 0; transform: translateY(10px); } }

/* Single card pages */
.center-page {
    min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
    background:
        radial-gradient(900px 500px at 15% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
        radial-gradient(700px 500px at 100% 100%, color-mix(in srgb, var(--gold) 14%, transparent), transparent 70%),
        var(--bg);
}
.notice-card {
    width: 100%; max-width: 480px; padding: 40px 38px;
    background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg); text-align: center;
}
.notice-card .brand { margin-bottom: 26px; }
.notice-card h1 { font-size: 36px; margin-bottom: 10px; }
.notice-card p { color: var(--ink-2); margin: 0; }
.steps { display: grid; gap: 10px; margin: 26px 0; text-align: left; }
.steps div { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--bg); }
.steps span {
    display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%;
    background: var(--accent); color: var(--accent-ink); font-weight: 500; font-size: 14px;
}
.fine { font-size: 13px; color: var(--muted) !important; }

/* Share page */
.share-page { background: var(--bg); }
.share { max-width: 980px; margin: 0 auto; padding: 36px 20px; }
.share figure { margin: 0; background: var(--surface); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-lg); }
.share img { width: 100%; height: auto; max-height: 82vh; object-fit: contain; background: #0f0b10; }
.share figcaption { padding: 22px 28px 26px; }
.share h1 { font-size: 32px; }
.share figcaption p { margin: 8px 0 0; color: var(--ink-2); }
.share footer { display: flex; justify-content: center; margin-top: 26px; opacity: .8; }

/* Admin */
.admin { max-width: 1200px; margin: 0 auto; padding: 36px 24px 60px; }
.admin h1 { font-size: 40px; margin-bottom: 20px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { padding: 16px 18px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); color: var(--muted); font-size: 13px; }
.stat span { display: block; font-family: var(--serif); font-size: 30px; font-weight: 600; color: var(--ink); }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th { text-align: left; font-weight: 500; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--line); }
.users td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users tr:last-child td { border-bottom: 0; }
.users small { display: block; color: var(--muted); font-size: 12px; }
.row-tools { white-space: nowrap; text-align: right; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.pill.on { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.off { background: var(--danger-soft); color: var(--danger); }

/* Phones and small windows */
@media (max-width: 860px) {
    .topbar { padding: 0 16px; }
    .top-links .btn span, .who-name { display: none; }
    .top-links .btn { width: 40px; padding: 0; }
    .viewing span { display: none; }
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static; height: auto; padding: 14px 16px 0; border-right: 0;
        overflow-x: auto; overflow-y: hidden;
    }
    .side-head, .side-foot, .divider { display: none; }
    .cat-nav { flex-direction: row; gap: 6px; }
    .cat-link { flex: none; border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 14px; }
    .cat-tools { display: none !important; }
    .cat-row:hover .count { visibility: visible; }
    .add-cat { display: none; }
    .main { padding: 20px 16px 50px; }
    .main-head h1 { font-size: 32px; }
    .head-tools { width: 100%; }
    .search { flex: 1; }
    .search input { width: 100%; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
    .edit-layout, .lb-inner { grid-template-columns: 1fr; }
    .edit-preview { max-height: 38vh; }
    .lb-img img { max-height: 55vh; }
    .lb-nav.next { left: auto; right: 12px; top: 27vh; }
    .lb-nav.prev { top: 27vh; }
    .lb-info { padding: 20px; }
    .row-tools { white-space: normal; }
}
