:root {
  --ink: #171717;
  --paper: #fafaf9;
  --line: #deddd8;
  --muted: #686762;
  --acid: #d6fa46;
  --orange: #ff724c;
  --blue: #79c8ed;
}

* { box-sizing: border-box; }
html { font-family: 'Manrope', sans-serif; }
body { min-width: 320px; margin: 0; background: var(--paper); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.page-shell { width: min(100% - 2rem, 1180px); margin: 0 auto; }
.site-header, .admin-header { border-bottom: 1px solid var(--line); }
.header-inner, .admin-header-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { color: var(--ink); font-family: 'DM Mono', monospace; font-size: 1rem; font-weight: 500; letter-spacing: 0; text-decoration: none; }
.admin-link { color: var(--ink); font-size: .82rem; font-weight: 700; text-decoration: none; }
.admin-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.header-controls { display: flex; align-items: center; gap: .8rem; }

.hero { display: grid; gap: 1.5rem; padding: 2.5rem 0 3.75rem; align-items: end; }
.eyebrow { margin: 0 0 .65rem; color: var(--muted); font-family: 'DM Mono', monospace; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(3.45rem, 8.6vw, 7.8rem); font-weight: 800; line-height: .86; }
h2 { font-size: clamp(1.55rem, 2.2vw, 2.25rem); font-weight: 800; line-height: 1; }
.hero-copy { max-width: 330px; margin: 1.5rem 0 0; color: #45443f; font-size: 1rem; line-height: 1.6; }
.hero-feature { position: relative; min-height: 385px; overflow: hidden; background: var(--acid); border-radius: 8px; background-position: 58% center; background-size: cover; }
.hero-feature::before, .hero-feature::after { position: absolute; content: ''; display: block; border: 2px solid var(--ink); border-radius: 50%; }
.hero-feature::before { width: 160px; height: 160px; right: -20px; top: -55px; }
.hero-feature::after { width: 240px; height: 240px; right: 20px; bottom: -160px; }
.hero-feature p { position: absolute; left: 1rem; bottom: 1rem; z-index: 2; margin: 0; padding: .55rem .65rem; background: var(--acid); color: var(--ink); font-family: 'DM Mono', monospace; font-size: .7rem; font-weight: 500; line-height: 1.25; text-transform: uppercase; }
.hero-feature.has-fallback { background-image: linear-gradient(0deg, rgba(0, 0, 0, .3), transparent 55%), url('/images/hero-editorial.png'); }
.hero-feature.has-fallback::before, .hero-feature.has-fallback::after, .hero-feature.has-image::before, .hero-feature.has-image::after { display: none; }
.hero-feature.has-image { background-color: var(--ink); color: #fff; }
.hero-feature.has-image::after { display: block; inset: 0; width: auto; height: auto; border: 0; border-radius: 0; background: linear-gradient(0deg, rgba(0, 0, 0, .42), transparent 58%); }

.catalog-section, .admin-list-section { padding: 2rem 0 4.5rem; }
.section-bar { display: flex; flex-direction: column; gap: 1.25rem; justify-content: space-between; margin-bottom: 1.5rem; }
.catalog-filters, .admin-filters { display: flex; flex-wrap: wrap; gap: .65rem; }
.catalog-filters[hidden] { display: none; }
select, input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); padding: .7rem .75rem; outline: none; }
select { width: auto; min-height: 40px; }
.catalog-filters select { border-color: var(--ink); border-radius: 0; font-family: 'DM Mono', monospace; font-size: .68rem; letter-spacing: .03em; text-transform: uppercase; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 2px var(--acid); }
textarea { resize: vertical; }
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.catalog-card { overflow: hidden; background: #fff; border: 1px solid #e9e7e2; border-radius: 8px; }
.catalog-card.gallery-card { border: 0; background: transparent; }
.catalog-image { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: #e6e4df; transition: transform .25s ease; }
.catalog-card:hover .catalog-image { transform: scale(1.03); }
.catalog-image-wrap { overflow: hidden; }
.catalog-image-button { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.catalog-image-button:focus-visible { outline: 3px solid var(--acid); outline-offset: -3px; }
.catalog-copy { padding: .8rem; }
.catalog-copy h3 { margin: 0; font-size: .86rem; font-weight: 800; line-height: 1.25; }
.catalog-copy p { margin: .35rem 0 0; color: var(--muted); font-size: .74rem; line-height: 1.45; }
.catalog-meta { font-family: 'DM Mono', monospace; font-size: .65rem !important; text-transform: uppercase; }
.catalog-actions { display: flex; justify-content: center; padding-top: 1.6rem; }
.status-message { margin: .5rem 0 1rem; color: var(--muted); font-size: .9rem; }
.status-message.is-empty { max-width: 430px; margin: 2rem 0 0; padding: 1.15rem 0; border-top: 1px solid var(--ink); color: var(--ink); font-family: 'DM Mono', monospace; font-size: .78rem; line-height: 1.5; }
.button { min-height: 42px; border: 1px solid var(--ink); border-radius: 4px; padding: .65rem 1rem; font-size: .82rem; font-weight: 800; transition: background .2s ease, color .2s ease, transform .2s ease; }
.button:hover { transform: translateY(-1px); }
.button-dark { background: var(--ink); color: white; }
.button-dark:hover { background: #383838; }
.button-light { background: #fff; color: var(--ink); }
.button-light:hover { background: var(--acid); }
.site-footer { border-top: 1px solid var(--line); padding: 1.4rem 0; font-family: 'DM Mono', monospace; font-size: .72rem; }
.site-footer span { color: var(--muted); }
.footer-admin-link { float: right; color: var(--muted); text-decoration: none; }
.footer-admin-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

body.lightbox-open { overflow: hidden; }
.lightbox { width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0d0d0d; color: #fff; overflow: hidden; }
.lightbox[open] { display: grid; grid-template-rows: 64px minmax(0, 1fr) 78px; }
.lightbox::backdrop { background: #0d0d0d; }
.lightbox-topbar, .lightbox-bottombar { position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; }
.lightbox-topbar { border-bottom: 1px solid rgba(255, 255, 255, .14); }
.lightbox-bottombar { border-top: 1px solid rgba(255, 255, 255, .14); }
.lightbox-counter, .lightbox-meta { margin: 0; color: rgba(255, 255, 255, .65); font-family: 'DM Mono', monospace; font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; }
.lightbox-stage { position: relative; min-height: 0; display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; align-items: center; }
.lightbox-viewport { min-width: 0; height: 100%; display: grid; place-items: center; overflow: hidden; touch-action: none; cursor: zoom-in; }
.lightbox-viewport.is-zoomed { cursor: grab; }
.lightbox-viewport.is-panning { cursor: grabbing; }
.lightbox-image { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; will-change: transform; transition: transform .16s ease; }
.lightbox-viewport.is-panning .lightbox-image { transition: none; }
.lightbox-icon-button { display: inline-grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; padding: 0; border: 1px solid rgba(255, 255, 255, .25); border-radius: 4px; background: transparent; color: #fff; }
.lightbox-icon-button:hover, .lightbox-icon-button:focus-visible { border-color: var(--acid); background: var(--acid); color: var(--ink); outline: none; }
.lightbox-icon-button:disabled { opacity: .25; pointer-events: none; }
.lightbox-icon-button svg { width: 18px; height: 18px; }
.lightbox-nav { justify-self: center; width: 48px; height: 56px; }
.lightbox-title { margin: 0 0 .25rem; font-size: .88rem; font-weight: 700; }
.lightbox-title:empty, .lightbox-meta:empty { display: none; }
.zoom-controls { display: flex; align-items: center; gap: .65rem; }
.zoom-controls input[type='range'] { width: clamp(100px, 16vw, 210px); min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; accent-color: var(--acid); }
.zoom-controls output { width: 42px; color: rgba(255, 255, 255, .75); font-family: 'DM Mono', monospace; font-size: .66rem; text-align: center; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--acid); padding: 1rem; }
.login-layout { width: min(100%, 470px); }
.login-layout > .brand { display: inline-block; margin-bottom: 2rem; }
.login-panel { background: var(--paper); border: 1px solid var(--ink); border-radius: 8px; padding: 1.5rem; }
.login-panel h1 { font-size: 2.5rem; }
.login-copy { margin: .7rem 0 1.5rem; color: var(--muted); font-size: .92rem; }
.stack-form { display: grid; gap: .7rem; }
.stack-form label, .form-grid label { display: grid; gap: .35rem; font-size: .76rem; font-weight: 800; }
.form-message { min-height: 1.2rem; margin: 0; color: #a6341d; font-size: .8rem; }
.form-message.is-success { color: #197343; }

.admin-page { background: var(--paper); }
.admin-main { padding: 2rem 0 4rem; }
.admin-intro { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.admin-intro h1 { font-size: clamp(2.2rem, 5vw, 4.3rem); }
.upload-area { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.mode-tabs { display: flex; border-bottom: 1px solid var(--line); }
.mode-tab { flex: 1; border: 0; border-right: 1px solid var(--line); background: #fff; min-height: 48px; font-size: .8rem; font-weight: 800; }
.mode-tab:last-child { border-right: 0; }
.mode-tab.is-active { background: var(--acid); }
.upload-form { padding: 1.2rem; }
.upload-form.is-hidden { display: none; }
.upload-copy h2 { font-size: 1.25rem; }
.upload-copy > p:last-child { max-width: 450px; color: var(--muted); font-size: .86rem; }
.file-drop { min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .55rem; border: 1px dashed #aaa8a0; border-radius: 4px; background: #fafaf9; cursor: pointer; text-align: center; }
.file-drop:hover { border-color: var(--ink); background: #f2f0eb; }
.file-drop svg { width: 24px; height: 24px; }
.file-drop span { font-size: .82rem; font-weight: 800; }
.file-drop small, .muted-text { color: var(--muted); font-size: .72rem; }
.preview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-top: 1rem; }
.preview-grid img { width: 100%; aspect-ratio: 1; border-radius: 4px; object-fit: cover; }
.single-preview:empty { display: none; }
.single-preview img { width: 120px; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1rem; }
.form-grid { display: grid; gap: .8rem; }
.wide-field { grid-column: 1 / -1; }
.admin-list-section { padding-bottom: 0; }
.admin-list-head { align-items: end; }
.admin-filters input { width: 135px; }
.admin-items { display: grid; gap: .75rem; }
.admin-item { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: .8rem; align-items: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: .65rem; }
.admin-item img { width: 76px; aspect-ratio: 1; border-radius: 4px; object-fit: cover; background: #e6e4df; }
.admin-item-content { min-width: 0; }
.admin-item-title { margin: 0; font-size: .84rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-item-details { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.tag { display: inline-flex; align-items: center; min-height: 21px; border: 1px solid var(--line); border-radius: 3px; padding: .1rem .35rem; font-family: 'DM Mono', monospace; font-size: .62rem; }
.tag.inactive { background: #efeee9; color: var(--muted); }
.admin-item-actions { display: flex; gap: .4rem; margin-top: .6rem; }
.icon-button { display: inline-grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); }
.icon-button:hover { background: var(--acid); border-color: var(--ink); }
.icon-button.danger:hover { background: #ffd5ca; }
.icon-button svg { width: 16px; height: 16px; }
.replace-input { display: none; }
.edit-dialog { width: min(100% - 2rem, 680px); border: 1px solid var(--ink); border-radius: 8px; padding: 0; background: var(--paper); }
.edit-dialog::backdrop { background: rgba(0, 0, 0, .48); }
.edit-dialog form { padding: 1.2rem; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }

@media (min-width: 640px) {
  .page-shell { width: min(100% - 3rem, 1180px); }
  .hero { grid-template-columns: 1.1fr .9fr; min-height: 560px; padding-top: 4rem; padding-bottom: 5rem; }
  .hero-feature { min-height: 470px; }
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
  .section-bar { flex-direction: row; align-items: end; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-form { padding: 1.5rem; }
  .admin-item { grid-template-columns: 92px minmax(0, 1fr) auto; }
  .admin-item img { width: 92px; }
  .admin-item-actions { margin-top: 0; }
}

@media (min-width: 1024px) {
  .catalog-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero { padding-top: 5rem; padding-bottom: 6rem; }
}

@media (max-width: 639px) {
  .lightbox[open] { grid-template-rows: 58px minmax(0, 1fr) auto; }
  .lightbox-topbar, .lightbox-bottombar { padding: .5rem .75rem; }
  .lightbox-stage { display: block; }
  .lightbox-viewport { width: 100%; height: 100%; padding: 0 .5rem; }
  .lightbox-nav { position: absolute; z-index: 4; top: 50%; width: 42px; height: 48px; transform: translateY(-50%); background: rgba(13, 13, 13, .6); }
  .lightbox-previous { left: .5rem; }
  .lightbox-next { right: .5rem; }
  .lightbox-bottombar { align-items: end; }
  .lightbox-info { min-width: 0; }
  .lightbox-title { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lightbox-meta { display: none; }
  .zoom-controls { gap: .4rem; }
  .zoom-controls input[type='range'] { width: 82px; }
  .zoom-controls output { display: none; }
}
