:root {
    --ink: #16130f;
    --paper: #f6f1e8;
    --gold: #b8893a;
    --gold-deep: #8a6424;
    --line: rgba(22, 19, 15, 0.12);
    --muted: #6f675d;
    --danger: #9a3b32;
    --ok: #2f6b45;
    --shadow: 0 24px 60px rgba(22, 19, 15, 0.16);
    font-family: "Outfit", sans-serif;
    color: var(--ink);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
}

a { color: inherit; }

button, input, textarea {
    font: inherit;
}

body.viewer-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #f3f0ea;
    color: var(--ink);
}

.topbar, .dock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 28px;
}

.brand {
    font-family: "Fraunces", serif;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    text-decoration: none;
}

.ghost-link {
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(247, 241, 231, 0.25);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.92rem;
}

model-viewer {
    display: block;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #f3f0ea;
    --poster-color: #f3f0ea;
}

.viewer-loading {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 22px;
    background: #f3f0ea;
    transition: opacity 0.35s ease;
}

.viewer-loading.is-done {
    opacity: 0;
    pointer-events: none;
}

.viewer-loading img {
    width: min(220px, 60vw);
    height: auto;
    max-height: 120px;
    object-fit: contain;
}

.viewer-loading-track {
    width: 160px;
    height: 3px;
    border-radius: 999px;
    background: rgba(22, 19, 15, 0.12);
    overflow: hidden;
}

.viewer-loading-track span {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--gold-deep);
    transform: scaleX(0);
    transform-origin: left center;
}

.logo-preview {
    width: 180px;
    height: auto;
    max-height: 90px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}

.empty-stage {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 8px;
    text-align: center;
    padding: 24px;
}

.empty-stage p { color: var(--muted); }

.dock {
    align-items: end;
}

.product-copy h1 {
    margin: 0 0 6px;
    font-family: "Fraunces", serif;
    font-weight: 500;
    font-size: 1.8rem;
}

.product-copy p {
    margin: 0;
    max-width: 460px;
    color: rgba(247, 241, 231, 0.72);
}

.hint {
    margin-top: 10px;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gold);
}

.switcher {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chip {
    text-decoration: none;
    border-radius: 999px;
    padding: 8px 12px;
    border: 1px solid rgba(247, 241, 231, 0.2);
    color: rgba(247, 241, 231, 0.8);
}

.chip.is-active {
    background: var(--gold);
    color: #1a140c;
    border-color: var(--gold);
}

body.admin-body {
    background: #f4f5f7;
    font-family: "Outfit", sans-serif;
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px 1fr;
}

.side {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #fff;
    color: #1c1c1c;
    border-right: 1px solid #e4e6ea;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.side .brand {
    display: grid;
    gap: 2px;
    padding: 8px 12px 14px;
    color: #111;
    border-bottom: 1px solid #e4e6ea;
}

.side .brand small {
    font-family: "Outfit", sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: none;
    color: #6b7280;
}

.nav-label {
    margin: 8px 12px 0;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(246, 241, 232, 0.45);
}

.side nav { display: grid; gap: 4px; }

.side a {
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 6px;
    color: #1c1c1c;
}

.side a.is-active { background: #e8eef9; color: #1d4ed8; }
.side a:hover:not(.is-active) { background: #f3f4f6; }

.logout {
    margin-top: auto;
    background: transparent;
    color: #1c1c1c;
    border: 1px solid #e4e6ea;
    border-radius: 6px;
    padding: 9px 12px;
    text-align: left;
    cursor: pointer;
}

.admin-main { min-width: 0; }

.admin-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 32px;
    background: rgba(255, 252, 247, 0.9);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.eyebrow {
    margin: 0 0 2px;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.admin-top h1, .admin-body .card h2, .modal h2 {
    font-family: "Outfit", sans-serif;
    font-weight: 600;
    font-size: 1.15rem;
    margin: 0;
}

.admin-content { padding: 28px 32px 48px; }

.page-head, .row-actions, .form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.button, .button-quiet, .button-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 10px;
    padding: 10px 14px;
    border: 0;
    cursor: pointer;
}

.admin-body .button { background: #1d4ed8; color: #fff; border-radius: 6px; }
.admin-body .button-quiet { background: #fff; color: #1c1c1c; border: 1px solid #d0d5dd; border-radius: 6px; }
.button-danger { background: transparent; color: var(--danger); border: 0; padding: 8px 10px; cursor: pointer; }
.button-solid-danger { background: #b42318; color: #fff; border: 0; border-radius: 6px; padding: 10px 14px; cursor: pointer; }

.panel, .auth-card {
    background: white;
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.panel { margin-top: 22px; overflow: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th { font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 0.8rem;
    background: #efe7da;
}

.badge.is-on { background: #e5f3ea; color: var(--ok); }

.flash {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #e5f3ea;
    color: var(--ok);
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 180px));
    gap: 12px;
    margin-bottom: 18px;
}

.stat {
    background: white;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.stat span { color: var(--muted); font-size: 0.82rem; }
.stat strong { display: block; margin-top: 4px; font-size: 1.6rem; font-family: "Fraunces", serif; font-weight: 500; }

.product-name { display: block; }
.product-name + .current-file { display: block; margin-top: 4px; }

.share { min-width: 220px; }
.share summary { cursor: pointer; font-weight: 500; }
.share .embed-box { margin-top: 10px; }

.editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.editor-wide { grid-column: 1 / -1; }

.card {
    background: white;
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 22px;
    display: grid;
    gap: 14px;
    align-content: start;
}

.card.form { max-width: 560px; }

.card-note {
    margin: -6px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.checks, .choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.choice {
    display: inline-flex;
    margin: 0;
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice span {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.choice input:checked + span {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
}

.choice-field { display: grid; gap: 8px; }
.choice-label { font-size: 0.92rem; font-weight: 600; }

.field-grid, .checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.field-grid { grid-template-columns: 1fr 1fr; }

.save-bar { margin-top: 16px; }

.form {
    display: grid;
    gap: 16px;
}

.settings {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.settings legend {
    padding: 0 6px;
    font-family: "Fraunces", serif;
}

.settings .wide { grid-column: 1 / -1; }

select {
    width: 100%;
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    padding: 12px 14px;
}

label { display: grid; gap: 8px; font-size: 0.92rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, input[type="file"] {
    width: 100%;
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    padding: 12px 14px;
}

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

.errors {
    margin: 0;
    padding-left: 18px;
    color: var(--danger);
}

.current-file { color: var(--muted); font-size: 0.88rem; }

.embed-box, .embed-panel { display: grid; gap: 10px; min-width: 280px; }

.embed-panel { margin-top: 28px; max-width: 760px; }

.embed-panel h2 {
    margin: 0;
    font-family: "Fraunces", serif;
    font-weight: 500;
    font-size: 1.3rem;
}

.embed-box textarea { resize: vertical; min-height: 72px; }

.modal {
    width: min(520px, calc(100vw - 32px));
    border: 0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.24);
}

.modal::backdrop { background: rgba(15, 23, 42, 0.45); }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.modal p { margin: 0 0 16px; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top, rgba(184, 137, 58, 0.28), transparent 40%),
        var(--paper);
}

.auth-card { width: min(420px, 100%); padding: 32px; display: grid; gap: 16px; }
.auth-demo .button { width: 100%; }

.auth-card p { color: var(--muted); }

@media (max-width: 900px) {
    .settings, .editor, .field-grid, .stat-row { grid-template-columns: 1fr; }
    .editor-wide { grid-column: auto; }
    .admin-shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; }
    .admin-top, .admin-content { padding-left: 16px; padding-right: 16px; }
    .dock, .topbar { align-items: start; flex-direction: column; }
    .switcher { justify-content: flex-start; }
    model-viewer { height: 100dvh; }
}
