:root {
  --header-height: 138px;
  --shelf-height: 152px;
  --ink-light: #f3f0e9;
  --ink-dark: #161719;
  --muted-light: rgba(246, 243, 237, .68);
  --muted-dark: rgba(20, 21, 23, .66);
  --ui-border-light: rgba(255,255,255,.18);
  --ui-border-dark: rgba(18,18,20,.18);
  --read-left: .26;
  --read-right: .22;
  --theme-text: var(--ink-light);
  --theme-muted: var(--muted-light);
  --theme-border: var(--ui-border-light);
  --theme-shadow: rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; }
html { background: #090a0e; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--theme-text);
  background: #090a0e;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

.theme-root { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #090a0e; }
.theme-base, .theme-overlay, .theme-readability, .vapor-canvas { position: absolute; inset: 0; }
.theme-base {
  background: radial-gradient(circle at 50% 35%, #21395a 0%, #111a2a 38%, #080a0f 76%);
  background-position: center;
  background-size: cover;
  transform: scale(1.02);
  transition: opacity .7s ease, filter .7s ease, background-image .7s ease;
}
.theme-base::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 44%, transparent 0 28%, rgba(0,0,0,.18) 55%, rgba(0,0,0,.46) 100%);
}
.theme-overlay {
  pointer-events: none;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity .7s ease;
}
.theme-readability {
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0,0,0,var(--read-left)) 0%, transparent 34%, transparent 66%, rgba(0,0,0,var(--read-right)) 100%);
  transition: background .6s ease;
}
body.theme-light .theme-readability {
  background:
    linear-gradient(90deg, rgba(255,255,255,var(--read-left)) 0%, transparent 34%, transparent 66%, rgba(255,255,255,var(--read-right)) 100%);
}
.vapor-canvas { width: 100%; height: 100%; pointer-events: none; filter: blur(9px) saturate(1.06); opacity: .96; }

.page-shell { position: relative; z-index: 2; width: 100%; min-height: 100svh; }
.site-header {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: grid;
  grid-template-rows: 78px 46px;
  align-items: center;
  justify-items: center;
  padding: 8px 26px 4px;
  pointer-events: none;
}
.brand-wrap { height: 72px; display: grid; place-items: center; pointer-events: auto; }
.brand-image { display: block; max-height: 72px; max-width: min(560px, 72vw); object-fit: contain; filter: drop-shadow(0 6px 16px rgba(0,0,0,.28)); }
.brand-fallback { text-align: center; line-height: .8; font-weight: 800; font-size: 38px; letter-spacing: -2px; text-shadow: 0 4px 18px var(--theme-shadow); }
.brand-fallback small { display:block; font-size: 12px; letter-spacing: .54em; margin-top: 11px; opacity: .78; }
.brand-frost { color: #aeefff; }
.brand-candy { color: #ff9bdd; }

.controls {
  width: min(1040px, 94vw);
  height: 42px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 205px auto auto;
  gap: 8px;
  align-items: stretch;
  pointer-events: auto;
}
.search-box, .sort-box, .control-button {
  border: 1px solid var(--theme-border);
  background: rgba(10,11,16,.34);
  color: var(--theme-text);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  box-shadow: 0 7px 28px rgba(0,0,0,.12);
}
body.theme-light .search-box, body.theme-light .sort-box, body.theme-light .control-button { background: rgba(255,255,255,.36); }
.search-box { display:flex; align-items:center; gap:10px; padding: 0 14px; border-radius: 999px; }
.search-box svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; opacity:.72; flex:0 0 auto; }
.search-box input { width:100%; border:0; outline:0; background:transparent; color:inherit; min-width:0; }
.search-box input::placeholder { color: var(--theme-muted); }
.sort-box { border-radius: 999px; overflow:hidden; }
.sort-box select { width:100%; height:100%; padding: 0 34px 0 14px; border:0; outline:0; color:inherit; background:transparent; appearance:auto; }
.sort-box option { color:#161719; background:#fff; }
.control-button { border-radius:999px; padding: 0 17px; }
.control-button:hover { background: rgba(255,255,255,.12); }
.control-button.subtle { opacity:.82; }

.filter-panel {
  position: fixed;
  z-index: 25;
  top: 126px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1120px, 94vw);
  max-height: min(420px, 60vh);
  overflow: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 18px;
  color: #1d1d22;
  background: rgba(250,249,247,.94);
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  pointer-events: auto;
  backdrop-filter: blur(20px);
}
.filter-column h3 { margin:0 0 10px; font-size:12px; text-transform:uppercase; letter-spacing:.14em; color:#707078; }
.chip-list { display:flex; flex-wrap:wrap; gap:7px; align-content:flex-start; }
.chip { display:inline-flex; }
.chip input { position:absolute; opacity:0; pointer-events:none; }
.chip span { display:inline-flex; align-items:center; min-height:30px; padding:5px 10px; border-radius:999px; border:1px solid #d4d4d8; background:#fff; font-size:12px; cursor:pointer; user-select:none; }
.chip input:checked + span { border-color:#222229; background:#222229; color:#fff; }

.viewer {
  position: fixed;
  top: var(--header-height);
  bottom: var(--shelf-height);
  left: 0;
  right: 0;
  display: grid;
  place-items: center;
  padding: 16px clamp(22px, 5vw, 78px) 8px;
}
.hero {
  position: relative;
  width: min(1420px, 100%);
  height: min(620px, calc(100svh - var(--header-height) - var(--shelf-height) - 32px));
  min-height: 390px;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(280px, .9fr) minmax(270px, 1fr);
  gap: clamp(26px, 4vw, 72px);
  align-items: center;
}
.hero.is-switching { animation: heroFade .46s ease both; }
@keyframes heroFade { 0% { opacity:.2; transform:translateY(7px) scale(.995); } 100% { opacity:1; transform:none; } }

.admin-toolbar {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translate(-50%, -100%);
  display:flex;
  align-items:center;
  gap:7px;
  z-index:8;
  white-space:nowrap;
}
.admin-toolbar button { border:1px solid rgba(255,255,255,.5); border-radius:999px; padding:7px 12px; background:rgba(255,255,255,.88); color:#17181b; box-shadow:0 8px 24px rgba(0,0,0,.16); }
.admin-toolbar .admin-muted { opacity:.78; }
.save-status { font-size:12px; margin-left:5px; text-shadow:0 2px 7px var(--theme-shadow); }

.story-pane, .meta-pane { min-width:0; max-height:100%; color:var(--theme-text); text-shadow:0 2px 12px var(--theme-shadow); }
.story-pane { align-self:center; display:grid; grid-template-rows:auto minmax(0,1fr); max-height:min(480px, 82%); }
.eyebrow { font-size:11px; line-height:1; text-transform:uppercase; letter-spacing:.2em; color:var(--theme-muted); font-weight:700; margin-bottom:13px; }
.story-copy {
  overflow-y:auto;
  scrollbar-width:none;
  font-family: Georgia, "Times New Roman", serif;
  font-size:clamp(20px, 1.7vw, 30px);
  line-height:1.46;
  letter-spacing:-.015em;
  padding:9px 5px 26px 0;
  white-space:pre-line;
  mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 calc(100% - 24px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 calc(100% - 24px), transparent 100%);
}
.story-copy::-webkit-scrollbar { display:none; }
.story-copy:empty::before { content:"No story yet."; opacity:.5; }

.bottle-pane { margin:0; display:grid; justify-items:center; align-items:center; gap:11px; min-width:0; }
.bottle-stage { width:min(360px, 100%); height:min(500px, 54vh); display:grid; place-items:center; position:relative; }
.bottle-image { max-width:100%; max-height:100%; object-fit:contain; filter:drop-shadow(0 28px 30px rgba(0,0,0,.38)); transition:transform .35s ease, filter .35s ease; }
.bottle-stage:hover .bottle-image { transform:translateY(-4px); filter:drop-shadow(0 34px 34px rgba(0,0,0,.42)); }
.bottle-placeholder { width:76%; max-width:250px; aspect-ratio:2/3; display:grid; place-items:center; color:var(--theme-muted); opacity:.72; }
.bottle-placeholder svg { width:80%; fill:none; stroke:currentColor; stroke-width:5; }
.bottle-placeholder span { font-size:12px; letter-spacing:.16em; text-transform:uppercase; }
.image-upload { display:flex; align-items:center; justify-content:center; max-width:280px; color:var(--theme-text); font-size:12px; text-shadow:0 2px 8px var(--theme-shadow); }
.image-upload input { width:100%; max-width:280px; font-size:11px; }

.meta-pane { align-self:center; max-height:90%; overflow:auto; scrollbar-width:none; padding-right:3px; }
.meta-pane::-webkit-scrollbar { display:none; }
.meta-view h1 { font-size:clamp(36px, 4vw, 64px); line-height:.96; letter-spacing:-.045em; margin:0 0 13px; font-weight:760; }
.rating-line { display:flex; align-items:center; gap:12px; min-height:34px; margin-bottom:12px; }
.score-big { font-size:28px; font-weight:760; }
.score-big:not(:empty)::after { content:" / 10"; font-size:12px; font-weight:600; opacity:.58; letter-spacing:.02em; }
.untried-pill { border:1px solid var(--theme-border); border-radius:999px; padding:5px 9px; font-size:12px; color:var(--theme-muted); }
.description { font-size:14px; line-height:1.56; color:var(--theme-muted); max-width:52ch; margin:0 0 15px; }
.tag-row { display:flex; flex-wrap:wrap; gap:7px; margin:0 0 20px; }
.meta-tag { border:1px solid var(--theme-border); border-radius:999px; padding:5px 9px; font-size:11px; background:rgba(0,0,0,.08); }
body.theme-light .meta-tag { background:rgba(255,255,255,.18); }
.performance-grid { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:11px 22px; margin:0; }
.performance-grid div { border-top:1px solid var(--theme-border); padding-top:8px; }
.performance-grid dt { color:var(--theme-muted); font-size:10px; letter-spacing:.12em; text-transform:uppercase; }
.performance-grid dd { margin:3px 0 0; font-size:18px; font-weight:650; }

.admin-field { width:100%; border:1px solid rgba(255,255,255,.34); border-radius:9px; padding:8px 9px; background:rgba(255,255,255,.9); color:#17181b; outline:none; text-shadow:none; }
.admin-field:focus { box-shadow:0 0 0 3px rgba(142,211,255,.25); border-color:#81c9ee; }
.story-editor { min-height:300px; resize:vertical; line-height:1.45; font-family:Georgia,serif; font-size:16px; }
.meta-edit { display:grid; gap:9px; text-shadow:none; color:var(--theme-text); }
.meta-edit label { display:grid; gap:4px; font-size:11px; color:var(--theme-muted); }
.meta-edit label small { opacity:.74; }
.edit-grid { display:grid; gap:8px; }
.edit-grid.two { grid-template-columns:repeat(2,minmax(0,1fr)); }
.edit-grid.three { grid-template-columns:repeat(3,minmax(0,1fr)); }
.edit-grid.four { grid-template-columns:repeat(4,minmax(0,1fr)); }
.inline-check { display:flex !important; grid-auto-flow:column; justify-content:start; align-items:center; gap:7px !important; }
.inline-check input { width:auto; }
.theme-editor { margin-top:3px; border-top:1px solid var(--theme-border); padding-top:8px; }
.theme-editor summary { cursor:pointer; font-size:12px; color:var(--theme-muted); margin-bottom:8px; }
.color-field { height:35px; padding:3px; }

.demo-notice {
  position:absolute;
  top:4px;
  left:50%;
  transform:translateX(-50%);
  font-size:11px;
  color:var(--theme-muted);
  letter-spacing:.03em;
}
.empty-state { text-align:center; text-shadow:0 2px 10px var(--theme-shadow); }
.empty-state h2 { margin:0 0 8px; }
.empty-state p { margin:0; color:var(--theme-muted); }

.shelf-wrap {
  position: fixed;
  z-index: 18;
  bottom: 0;
  left:0;
  right:0;
  height:var(--shelf-height);
  display:flex;
  align-items:center;
  padding: 8px 0 18px;
  background:linear-gradient(to top, rgba(0,0,0,.38), transparent 78%);
}
body.theme-light .shelf-wrap { background:linear-gradient(to top, rgba(255,255,255,.38), transparent 78%); }
.shelf {
  width:100%;
  display:flex;
  align-items:flex-end;
  gap:9px;
  overflow-x:auto;
  overflow-y:hidden;
  scroll-behavior:smooth;
  scrollbar-width:none;
  padding: 0 max(30px, calc((100vw - 1120px)/2));
  outline:none;
}
.shelf::-webkit-scrollbar { display:none; }
.scent-tile {
  flex:0 0 96px;
  height:118px;
  border:0;
  padding:6px 5px 4px;
  background:transparent;
  color:var(--theme-text);
  display:grid;
  grid-template-rows:88px 20px;
  justify-items:center;
  align-items:end;
  opacity:.7;
  transform:scale(.92);
  transition:transform .2s ease, opacity .2s ease;
  text-shadow:0 2px 8px var(--theme-shadow);
}
.scent-tile:hover { opacity:1; transform:scale(.98); }
.scent-tile.selected { opacity:1; transform:scale(1.07) translateY(-2px); }
.scent-tile img { width:76px; height:84px; object-fit:contain; filter:drop-shadow(0 10px 8px rgba(0,0,0,.22)); }
.tile-placeholder { width:58px; height:75px; border:1px solid var(--theme-border); border-radius:9px 9px 13px 13px; opacity:.55; }
.scent-tile span { width:100%; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:11px; text-align:center; }
.shelf-sentinel { position:absolute; right:0; width:1px; height:1px; }

.auth-overlay {
  position:fixed;
  inset:0;
  z-index:100;
  background:#fff;
  color:#17181b;
  display:grid;
  place-items:center;
}
.auth-box { width:min(360px, calc(100vw - 40px)); display:grid; gap:12px; }
.auth-mark { font-size:27px; font-weight:800; letter-spacing:-.04em; margin-bottom:7px; }
.auth-box label { font-size:11px; text-transform:uppercase; letter-spacing:.14em; color:#74747b; }
.auth-box input { width:100%; height:45px; border:1px solid #cfcfd5; border-radius:10px; padding:0 12px; outline:none; }
.auth-box input:focus { border-color:#6eabc9; box-shadow:0 0 0 3px rgba(93,170,211,.16); }
.auth-actions { display:flex; gap:8px; justify-content:flex-end; }
.auth-actions button { border:1px solid #cfcfd5; background:#fff; color:#17181b; border-radius:999px; padding:8px 16px; }
.auth-actions .auth-enter { background:#17181b; color:#fff; border-color:#17181b; }
.auth-message { min-height:18px; font-size:12px; color:#a12525; }

body.theme-light {
  --theme-text: var(--ink-dark);
  --theme-muted: var(--muted-dark);
  --theme-border: var(--ui-border-dark);
  --theme-shadow: rgba(255,255,255,.58);
}

@media (max-width: 980px) {
  :root { --header-height: 128px; --shelf-height: 138px; }
  .site-header { grid-template-rows:68px 48px; padding-left:14px; padding-right:14px; }
  .brand-wrap { height:62px; }
  .brand-image { max-height:62px; }
  .controls { grid-template-columns:minmax(170px,1fr) 170px auto; width:96vw; }
  #clearFiltersButton { display:none !important; }
  .filter-panel { top:116px; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .hero { grid-template-columns:minmax(190px,.9fr) minmax(230px,.8fr) minmax(230px,1fr); gap:22px; }
  .story-copy { font-size:clamp(18px,2vw,24px); }
  .meta-view h1 { font-size:clamp(30px,4vw,50px); }
  .edit-grid.four { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

@media (max-width: 720px) {
  body { overflow:auto; }
  :root { --header-height: 154px; --shelf-height: 132px; }
  .site-header { position:relative; height:auto; min-height:var(--header-height); grid-template-rows:68px auto; padding-bottom:10px; }
  .controls { height:auto; grid-template-columns:1fr 1fr; }
  .search-box { grid-column:1/-1; height:42px; }
  .sort-box, .control-button { height:40px; }
  .filter-panel { top:145px; grid-template-columns:1fr; max-height:calc(100svh - 175px); }
  .viewer { position:relative; top:auto; bottom:auto; min-height:calc(100svh - var(--header-height)); padding:18px 20px calc(var(--shelf-height) + 26px); display:block; }
  .hero { height:auto; min-height:0; grid-template-columns:1fr; grid-template-areas:"bottle" "meta" "story"; gap:24px; }
  .bottle-pane { grid-area:bottle; }
  .meta-pane { grid-area:meta; max-height:none; overflow:visible; }
  .story-pane { grid-area:story; max-height:none; }
  .story-copy { max-height:300px; }
  .bottle-stage { height:42svh; max-height:390px; }
  .meta-view h1 { font-size:42px; }
  .performance-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .admin-toolbar { position:sticky; top:10px; transform:none; left:auto; grid-area:bottle; align-self:start; justify-self:center; z-index:12; flex-wrap:wrap; justify-content:center; }
  .edit-grid.two, .edit-grid.three, .edit-grid.four { grid-template-columns:1fr 1fr; }
  .shelf-wrap { height:var(--shelf-height); }
  .scent-tile { flex-basis:88px; }
  .theme-readability { background:linear-gradient(to bottom, rgba(0,0,0,.1), rgba(0,0,0,.24)); }
  body.theme-light .theme-readability { background:linear-gradient(to bottom, rgba(255,255,255,.12), rgba(255,255,255,.3)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior:auto !important; animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; }
  .vapor-canvas { display:none; }
}
