:root {
  --ink: #1d1915;
  --ink-soft: #39312a;
  --gold: #c58a16;
  --gold-dark: #94630b;
  --gold-soft: #f7ebcf;
  --paper: #ffffff;
  --cream: #f8f5ef;
  --line: #e6ded3;
  --muted: #716960;
  --success: #22734a;
  --danger: #b53a31;
  --sidebar: 250px;
  --heading: "Barlow Condensed", sans-serif;
  --body: "Manrope", sans-serif;
  --shadow: 0 18px 55px rgba(44, 35, 24, 0.09);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--body); font-size: 15px; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid #e0a62e; outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; left: 1rem; top: -4rem; padding: 0.8rem 1rem; background: var(--ink); color: white; text-decoration: none; }
.skip-link:focus { top: 1rem; }
.eyebrow { margin: 0 0 0.3rem; color: var(--gold-dark); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.17em; text-transform: uppercase; }

.boot-screen, .access-state { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 1rem; padding: 2rem; text-align: center; background: var(--paper); }
.boot-screen img, .access-state img { object-fit: contain; }
.boot-screen p, .access-state p { max-width: 460px; margin: 0; color: var(--muted); line-height: 1.65; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--gold-soft); border-top-color: var(--gold); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-soft); color: var(--gold-dark); font-size: 1.6rem; }
.state-icon.danger { background: #fbe6e3; color: var(--danger); }
.access-state h1 { margin: 0; font: 800 clamp(2.4rem, 5vw, 4rem)/0.9 var(--heading); text-transform: uppercase; }
.access-state > a { color: var(--ink); }

.admin-app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar); display: flex; flex-direction: column; padding: 1.25rem 0.9rem; background: var(--ink); color: white; }
.brand-block { display: grid; justify-items: start; gap: 0.35rem; padding: 0 0.65rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-block img { width: 140px; height: 58px; object-fit: contain; object-position: left center; }
.brand-block span { color: #ddc894; font-size: 0.62rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.side-nav { display: grid; gap: 0.25rem; padding-top: 1rem; overflow-y: auto; }
.side-nav button { position: relative; display: flex; align-items: center; gap: .8rem; min-height: 44px; padding: .65rem .75rem; border: 0; border-radius: 8px; background: transparent; color: rgba(255,255,255,.68); text-align: left; }
.side-nav button:hover { background: rgba(255,255,255,.07); color: white; }
.side-nav button.active { background: var(--gold); color: #171411; font-weight: 800; }
.side-nav button i { font-size: 1.1rem; }
.side-nav button b { margin-left: auto; min-width: 20px; padding: .15rem .35rem; border-radius: 10px; background: #fff; color: var(--danger); font-size: .65rem; text-align: center; }
.sidebar-footer { display: grid; gap: .8rem; margin-top: auto; padding: 1rem .65rem 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-footer a { color: #f4dfac; font-size: .78rem; text-decoration: none; }
.sidebar-footer small { color: rgba(255,255,255,.48); overflow-wrap: anywhere; }

.workspace { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; min-height: 86px; padding: 1rem clamp(1rem, 3vw, 2.5rem); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(15px); }
.topbar h1 { margin: 0; font: 800 1.9rem/1 var(--heading); text-transform: uppercase; }
.menu-button { display: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: white; font-size: 1.3rem; }
.topbar-status { display: flex; align-items: center; gap: .45rem; margin-left: auto; color: var(--muted); font-size: .7rem; font-weight: 700; }
.topbar-status span { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.topbar-status.dirty span { background: var(--gold); }
.topbar-status.error span { background: var(--danger); }
.content-area { width: min(1180px, 100%); margin: 0 auto; padding: clamp(1.2rem, 3vw, 2.5rem); }

.view-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.5rem; }
.view-heading h2 { margin: 0; font: 800 clamp(2.2rem, 5vw, 3.6rem)/.95 var(--heading); text-transform: uppercase; }
.view-heading p:not(.eyebrow) { max-width: 610px; margin: .65rem 0 0; color: var(--muted); line-height: 1.6; }
.view-actions { display: flex; flex-wrap: wrap; gap: .65rem; }

.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.metric-card, .panel, .form-card { border: 1px solid var(--line); background: var(--paper); box-shadow: 0 8px 28px rgba(49, 38, 24, .04); }
.metric-card { min-height: 150px; padding: 1.3rem; }
.metric-card i { color: var(--gold); font-size: 1.45rem; }
.metric-card strong { display: block; margin-top: 1.5rem; font: 800 2rem/1 var(--heading); text-transform: uppercase; }
.metric-card span { color: var(--muted); font-size: .72rem; }
.dashboard-wide { grid-column: span 2; }
.panel { padding: clamp(1.1rem, 2.5vw, 1.8rem); }
.panel h3, .form-card h3 { margin: 0 0 .35rem; font: 800 1.55rem/1 var(--heading); text-transform: uppercase; }
.panel > p, .form-card > p { margin: 0 0 1.2rem; color: var(--muted); font-size: .78rem; line-height: 1.6; }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; margin-top: 1rem; }
.quick-actions button { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: .8rem 1rem; border: 1px solid var(--line); background: var(--cream); color: var(--ink); font-weight: 700; text-align: left; }
.quick-actions button:hover { border-color: var(--gold); }

.form-stack { display: grid; gap: 1rem; }
.form-card { padding: clamp(1rem, 2.4vw, 1.7rem); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.1rem; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: .45rem; align-content: start; }
.field > span, .field-label { color: var(--ink-soft); font-size: .69rem; font-weight: 800; }
.field small { color: var(--muted); font-size: .64rem; line-height: 1.45; }
.field input, .field textarea, .field select, .select-control { width: 100%; min-height: 44px; padding: .72rem .78rem; border: 1px solid #d9cfc2; border-radius: 6px; background: white; color: var(--ink); }
.field textarea { min-height: 112px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--gold); outline: 2px solid rgba(197,138,22,.2); }
.field input[readonly] { background: #f3efe8; color: var(--muted); }
.field-with-action { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .55rem; }
.image-field-preview { height: 150px; margin-bottom: .55rem; border: 1px solid var(--line); background: var(--cream); overflow: hidden; }
.image-field-preview img { width: 100%; height: 100%; object-fit: cover; }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); font-size: 1.1rem; }
.icon-button:hover { border-color: var(--gold); color: var(--gold-dark); }
.save-bar { position: sticky; bottom: 1rem; z-index: 12; display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.2rem; padding: .9rem 1rem; border: 1px solid #dbc9a4; background: rgba(255,253,248,.96); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.save-bar p { margin: 0; color: var(--muted); font-size: .72rem; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .72rem 1rem; border: 1px solid transparent; border-radius: 5px; font-size: .72rem; font-weight: 800; text-decoration: none; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-dark { background: var(--ink); color: white; }
.button-gold { background: var(--gold); color: #171411; }
.button-quiet { border-color: var(--line); background: white; color: var(--ink); }
.button-danger { background: var(--danger); color: white; }
.button:hover:not(:disabled) { transform: translateY(-1px); }

.camp-selector { display: flex; gap: .5rem; margin-bottom: 1rem; overflow-x: auto; padding-bottom: .3rem; }
.camp-selector button { flex: 0 0 auto; padding: .65rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: white; font-size: .7rem; font-weight: 800; }
.camp-selector button.active { border-color: var(--ink); background: var(--ink); color: white; }
.gallery-editor { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-top: 1rem; }
.gallery-item { position: relative; min-width: 0; border: 1px solid var(--line); background: var(--cream); }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.gallery-item-actions { position: absolute; right: .35rem; top: .35rem; display: flex; gap: .25rem; }
.gallery-item-actions button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(29,25,21,.9); color: white; }
.gallery-item-actions button:disabled { opacity: .42; cursor: not-allowed; }
.gallery-item p { margin: 0; padding: .55rem; color: var(--muted); font-size: .62rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-state { display: grid; justify-items: center; gap: .6rem; padding: 2.5rem 1rem; border: 1px dashed #cfbfab; background: var(--cream); text-align: center; }
.empty-state i { color: var(--gold); font-size: 1.8rem; }
.empty-state strong { font: 800 1.3rem var(--heading); text-transform: uppercase; }
.empty-state p { max-width: 420px; margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.55; }

.repeater { display: grid; gap: .85rem; }
.repeater-item { border: 1px solid var(--line); background: white; }
.repeater-head { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: var(--cream); }
.repeater-head strong { font: 800 1.15rem var(--heading); text-transform: uppercase; }
.repeater-head .icon-button { margin-left: auto; }
.repeater-body { padding: 1rem; }
.check-field { display: flex; align-items: center; gap: .65rem; min-height: 44px; }
.check-field input { width: 20px; height: 20px; accent-color: var(--gold); }

.media-upload { border: 2px dashed #d6c5a9; background: #fffcf5; }
.upload-row { display: grid; grid-template-columns: 220px 1fr; gap: 1.2rem; margin-top: 1rem; }
.drop-zone { min-height: 180px; display: grid; place-items: center; align-content: center; gap: .5rem; padding: 1rem; border: 1px dashed var(--gold); background: white; text-align: center; }
.drop-zone i { color: var(--gold); font-size: 2rem; }
.drop-zone input { max-width: 100%; font-size: .68rem; }
.upload-queue { display: grid; gap: .6rem; }
.upload-queue-item { display: grid; grid-template-columns: 58px 1fr; gap: .65rem; align-items: center; padding: .6rem; border: 1px solid var(--line); background: white; }
.upload-queue-item img { width: 58px; height: 58px; object-fit: cover; }
.upload-queue-item input { min-height: 38px; width: 100%; padding: .45rem; border: 1px solid var(--line); }
.progress { height: 5px; margin-top: .4rem; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .25s; }
.media-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .7rem; margin: 1.2rem 0 .8rem; }
.media-library, .picker-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .75rem; }
.media-card { min-width: 0; border: 1px solid var(--line); background: white; }
.media-card > button:first-child { width: 100%; padding: 0; border: 0; background: var(--cream); }
.media-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.media-card-body { padding: .65rem; }
.media-card-body strong { display: block; font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card-body small { color: var(--muted); font-size: .58rem; }
.media-card-actions { display: flex; justify-content: end; padding: 0 .55rem .55rem; }
.media-card.pending { opacity: .58; }

.publish-card { max-width: 780px; padding: clamp(1.3rem,4vw,2.5rem); border: 1px solid var(--line); background: white; box-shadow: var(--shadow); }
.publish-card h2 { margin: 0; font: 800 clamp(2.5rem,7vw,5rem)/.88 var(--heading); text-transform: uppercase; }
.publish-list { display: grid; gap: .5rem; margin: 1.5rem 0; padding: 0; list-style: none; }
.publish-list li { display: flex; align-items: center; gap: .6rem; padding: .65rem; background: var(--cream); }
.publish-list i { color: var(--gold-dark); }
.consent-box { display: flex; align-items: flex-start; gap: .7rem; margin: 1.2rem 0; padding: 1rem; border: 1px solid #dbc9a4; background: #fffbf2; line-height: 1.55; }
.consent-box input { flex: 0 0 auto; width: 21px; height: 21px; accent-color: var(--gold); }

dialog { width: min(900px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; background: white; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(24,20,17,.72); backdrop-filter: blur(3px); }
.media-picker { padding: 1.2rem; }
.dialog-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.dialog-head h2, .confirm-dialog h2 { margin: 0; font: 800 2rem/1 var(--heading); text-transform: uppercase; }
.confirm-dialog { width: min(460px, calc(100% - 2rem)); padding: 1.5rem; }
.confirm-dialog p { color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: end; gap: .6rem; margin-top: 1.3rem; }

.toast-region { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: grid; gap: .6rem; width: min(390px, calc(100% - 2rem)); }
.toast { display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: start; padding: .9rem; border-left: 4px solid var(--success); background: var(--ink); color: white; box-shadow: var(--shadow); }
.toast.error { border-color: var(--danger); }
.toast button { border: 0; background: transparent; color: white; }
.sidebar-scrim { display: none; }

@media (max-width: 980px) {
  .admin-app { grid-template-columns: 1fr; }
  .workspace { grid-column: 1; }
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  .sidebar.open { transform: none; }
  .menu-button { display: grid; place-items: center; }
  .sidebar-scrim { position: fixed; z-index: 25; inset: 0; display: block; width: 100%; border: 0; background: rgba(29,25,21,.52); }
  .dashboard-grid { grid-template-columns: repeat(2,1fr); }
  .media-library, .picker-grid { grid-template-columns: repeat(3,1fr); }
}

@media (max-width: 680px) {
  .topbar { min-height: 74px; }
  .topbar h1 { font-size: 1.45rem; }
  .topbar-status { max-width: 105px; font-size: .6rem; }
  .content-area { padding: 1rem; }
  .view-heading { align-items: start; flex-direction: column; }
  .dashboard-grid, .form-grid { grid-template-columns: 1fr; }
  .dashboard-wide, .form-grid .full { grid-column: auto; }
  .quick-actions { grid-template-columns: 1fr; }
  .gallery-editor { grid-template-columns: repeat(2,1fr); }
  .media-library, .picker-grid { grid-template-columns: repeat(2,1fr); }
  .upload-row { grid-template-columns: 1fr; }
  .save-bar { align-items: stretch; flex-direction: column; bottom: .5rem; }
  .save-bar .button { width: 100%; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
