:root {
  color-scheme: light;
  font: 15px/1.55 system-ui, sans-serif;
  color: #292321;
  background: #f5f1ed;
  --wine: #5e2333;
  --wine-dark: #29151c;
  --line: #e5dbd4;
  --muted: #6e625c;
  --surface: #fffdfb;
  --accent: #d7ab81;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
:focus-visible { outline: 2px solid #a55e77; outline-offset: 3px; }

h1, h2 { margin: 0; font-weight: 400; line-height: 1.1; }
h1, .editor-heading h2, .editor-placeholder h2 {
  color: var(--wine);
  font-family: Georgia, serif;
  letter-spacing: -.035em;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-size: 14px;
  font-weight: 650;
}

.brand-logo-filter { position: absolute; }

.brand-crest {
  display: block;
  flex: 0 0 40px;
  width: 40px;
  height: 45px;
  overflow: hidden;
}

.brand-crest img {
  display: block;
  width: 176px;
  max-width: none;
  height: auto;
  transform: translate(-68px, -6px);
  filter: url('#brand-logo-transparency') brightness(0) invert(1);
}

.login-panel .brand-crest {
  background: #59030e;
  border-radius: 5px;
}

.login {
  display: grid;
  width: min(100% - 36px, 880px);
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  margin: clamp(32px, 12vh, 128px) auto 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 56px rgb(41 21 28 / 10%);
}

.login-panel { padding: clamp(24px, 5vw, 64px); }
.login-photo { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 76% center; }
.login h1 { margin: 30px 0 22px; font-size: clamp(34px, 5vw, 49px); }
.login form { display: grid; gap: 9px; }
.login form > button { margin-top: 9px; }
#login-error, #startup-error, .notice.error { color: #9d2638; }
#login-error { margin: 0; font-size: 14px; }
#startup-error { margin: 18px; }
#login-error:empty, #startup-error:empty, .notice:empty, .section-parent:empty { display: none; }

.workspace {
  display: grid;
  min-height: 100svh;
  grid-template-columns: minmax(218px, 246px) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100svh;
  min-width: 0;
  flex-direction: column;
  gap: 22px;
  align-self: start;
  padding: 25px 16px 18px;
  background: var(--wine-dark);
  color: #fcf4ed;
}

.sidebar .brand-lockup { padding: 0 7px 19px; border-bottom: 1px solid rgb(255 244 237 / 15%); }
.cms-menu-toggle, .cms-menu-backdrop, .cms-drawer-heading { display: none; }
.sidebar-menu-panel { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 22px; }
.sidebar nav { display: grid; align-content: start; gap: 4px; overflow: auto; }
.sidebar nav button, .home-nav-group summary, .sidebar .quiet {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 11px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  text-align: left;
}

.home-nav-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}

#collections > button[data-collection="showrooms"],
#collections > button[data-collection="insights"] { font-weight: 650; }
.home-nav-group summary::-webkit-details-marker { display: none; }

.home-nav-group summary::after {
  width: 7px;
  height: 7px;
  margin-right: 3px;
  border-right: 1px solid #dbc5bc;
  border-bottom: 1px solid #dbc5bc;
  content: '';
  transform: rotate(-45deg);
}

.home-nav-group[open] summary::after { transform: translateY(-2px) rotate(45deg); }
.sidebar nav button:hover, .home-nav-group summary:hover, .sidebar .quiet:hover { background: #3c232d; }

.sidebar nav button[aria-pressed="true"] {
  border-color: rgb(215 171 129 / 34%);
  background: #50303d;
  color: #fff4e7;
  box-shadow: inset 2px 0 var(--accent);
}

.home-nav-sections {
  display: grid;
  gap: 3px;
  margin: 3px 0 5px 13px;
  border-left: 1px solid rgb(255 244 237 / 18%);
  padding-left: 7px;
}

.sidebar .home-nav-sections button { min-height: 37px; padding-block: 6px; color: #eee0d9; }
.sidebar-account { display: grid; gap: 8px; margin-top: auto; }
.sidebar-user { display: flex; min-width: 0; align-items: center; gap: 9px; padding-inline: 12px; font-size: 13px; overflow-wrap: anywhere; }
.sidebar-user-icon { display: grid; width: 29px; height: 29px; flex: none; place-items: center; border: 1px solid rgb(255 244 237 / 25%); border-radius: 50%; color: #fff4ed; }
.sidebar-user strong { color: #fff4ed; }
.sidebar .quiet { border-color: rgb(255 244 237 / 20%); }

.main { width: min(100%, 1560px); margin-inline: auto; padding: clamp(21px, 3.6vw, 54px); }

.heading {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.heading h1 { font-size: clamp(34px, 4vw, 52px); }
.section-parent { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.notice { margin: -8px 0 16px; color: #2f6247; font-size: 14px; }

.layout {
  display: grid;
  grid-template-columns: minmax(238px, .78fr) minmax(0, 1.6fr);
  align-items: start;
  gap: clamp(15px, 2vw, 26px);
}

.entries, .editor {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 2px 4px rgb(41 21 28 / 3%);
}

.entries { position: sticky; top: 18px; padding: 15px 12px 10px; }
.entries-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px 10px; }
.entries-heading h2 { font-size: 16px; font-weight: 675; }
.entries-heading span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.entry-search { position: relative; }

.entry-search::before {
  position: absolute;
  top: 13px;
  left: 13px;
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  content: '';
  pointer-events: none;
}

.entry-search::after {
  position: absolute;
  top: 25px;
  left: 23px;
  width: 6px;
  height: 1px;
  background: var(--muted);
  content: '';
  pointer-events: none;
  transform: rotate(45deg);
}

#search { padding-left: 36px; }

.entries ul {
  display: grid;
  max-height: min(64vh, 680px);
  gap: 4px;
  margin: 11px 0 0;
  overflow: auto;
  padding: 2px;
  list-style: none;
}

.entry-button {
  display: flex;
  width: 100%;
  min-height: 60px;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px;
  background: transparent;
  color: #392b2c;
  text-align: left;
}

.entry-button:hover { background: #faf4f1; }

.entry-button[aria-pressed="true"] {
  border-color: #e5cbd2;
  background: #f7ebee;
  box-shadow: inset 2px 0 #a96278;
}

.entry-thumb {
  display: block;
  width: 47px;
  height: 47px;
  flex: 0 0 47px;
  border-radius: 6px;
  background: #ebdfd6;
  object-fit: cover;
}

.entry-text { display: grid; min-width: 0; justify-items: start; gap: 4px; }
.entry-title { overflow-wrap: anywhere; font-size: 14px; font-weight: 675; line-height: 1.35; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.status::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ''; }
.status.published { border-color: #d9e7de; background: #edf5ef; color: #2d6247; }
.status.draft { border-color: #efdfc6; background: #fbf2e1; color: #765322; }

.editor { container-type: inline-size; --editor-inset: clamp(17px, 2.7vw, 32px); }
.editor-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: var(--editor-inset); border-bottom: 1px solid var(--line); }
.editor-heading h2 { font-size: clamp(24px, 3vw, 35px); overflow-wrap: anywhere; }
.editor-state { display: flex; flex: 0 0 auto; flex-direction: column; align-items: end; gap: 5px; }
.editor-dirty { color: #785523; font-size: 12px; }
.editor-placeholder { min-height: 260px; display: grid; align-content: center; gap: 8px; padding: var(--editor-inset); text-align: center; }
.editor-placeholder h2 { font-size: 28px; }
.editor-placeholder p, .empty { margin: 0; color: var(--muted); font-size: 14px; }
.entries .empty { padding: 10px; }

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 19px 15px;
  padding: var(--editor-inset);
}

.fields > label, .product-picker-row > select { min-width: 0; }
.fields .wide { grid-column: 1 / -1; }
label { color: #493b36; font-size: 13px; font-weight: 650; }

input, select, textarea {
  width: 100%;
  min-height: 43px;
  border: 1px solid #d9cbc3;
  border-radius: 7px;
  padding: 9px 11px;
  background: #fff;
  color: #292321;
  font-size: 14px;
  font-weight: 400;
}

.fields :is(input, select, textarea) { display: block; margin-top: 6px; }
input[type="file"] { overflow: hidden; text-overflow: ellipsis; }
textarea { line-height: 1.65; resize: vertical; }
:where(input, select, textarea):focus { border-color: #9e576d; }
.thumb { display: block; width: 100%; max-height: 184px; aspect-ratio: 16 / 9; margin-top: 9px; border-radius: 7px; background: #f0e7df; object-fit: contain; }

.actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 11px 11px;
  padding: 13px var(--editor-inset);
  background: var(--surface);
}

.primary, .secondary, .danger {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 675;
}

.primary { border-color: var(--wine); background: var(--wine); color: #fff; }
.primary:hover { border-color: #723044; background: #723044; }
.secondary, .danger { background: #fff; color: var(--wine); }
.secondary:hover, .danger:hover { background: #f8eeef; }
.danger { margin-left: auto; color: #92344a; }

.product-picker { min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.product-picker legend { padding: 0 6px; color: #493b36; font-size: 13px; font-weight: 650; }
.product-picker-rows { display: grid; gap: 8px; }
.product-picker-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.product-picker-row select { margin-top: 0; }
.product-picker > button { margin-top: 10px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (width <= 950px) {
  .workspace { grid-template-columns: 190px minmax(0, 1fr); }
  .main { padding: 26px 18px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .entries { position: static; }
  .entries ul { max-height: 30vh; }
}

@container (width < 440px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .editor-heading { flex-wrap: wrap; }
  .editor-state { align-items: start; }
}

@media (width <= 780px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
  }
  .sidebar .brand-lockup { border: 0; padding: 0; }
  .cms-menu-toggle {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 9px;
    border: 1px solid rgb(255 244 237 / 28%);
    border-radius: 7px;
    padding: 8px 12px;
    background: transparent;
    color: inherit;
  }
  .cms-menu-toggle span {
    width: 15px;
    height: 11px;
    border-block: 1px solid currentColor;
    background: linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat;
  }
  body:has(.cms-menu-toggle[aria-expanded="true"]) { overflow: hidden; }
  .cms-menu-toggle[aria-expanded="false"] ~ .sidebar-menu-panel { display: none; }
  .cms-menu-toggle[aria-expanded="true"] ~ .cms-menu-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: block;
    background: rgb(24 12 17 / 56%);
  }
  .sidebar-menu-panel {
    position: fixed;
    z-index: 21;
    inset: 0 auto 0 0;
    width: min(322px, calc(100% - 44px));
    max-width: 100%;
    gap: 8px;
    padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
    background: var(--wine-dark);
    box-shadow: 10px 0 32px rgb(0 0 0 / 24%);
  }
  .cms-drawer-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-inline: 6px;
    color: #fff4ed;
    font-weight: 650;
  }
  .cms-drawer-heading button {
    width: 44px;
    height: 44px;
    flex: none;
    border: 1px solid rgb(255 244 237 / 24%);
    border-radius: 7px;
    background: transparent;
    color: inherit;
    font-size: 22px;
    line-height: 1;
  }
  .sidebar nav {
    flex: 1;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 4px;
    padding: 4px;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .sidebar nav button, .sidebar .home-nav-sections button, .home-nav-group summary, .sidebar .quiet { min-height: 44px; }
  .home-nav-group { min-width: 0; }
  .home-nav-group[open] > summary { background: #3c232d; }
  .home-nav-sections {
    grid-template-columns: minmax(0, 1fr);
    margin: 5px 0 8px 14px;
    padding-left: 10px;
  }
  .sidebar .home-nav-sections button { padding: 8px 12px; overflow-wrap: anywhere; }
  .sidebar-account { display: contents; }
  .sidebar-user {
    order: -1;
    padding: 10px 6px;
    border-bottom: 1px solid rgb(255 244 237 / 15%);
  }
  .cms-drawer-heading { order: -2; }
  .sidebar .quiet { margin-top: 4px; }
  .main { padding: 22px clamp(12px, 4vw, 24px) 28px; }
  .entries ul { max-height: min(29svh, 240px); }
  .editor-placeholder { min-height: 160px; }
}

@media (width <= 640px) {
  .login {
    width: calc(100% - 24px);
    grid-template-columns: minmax(0, 1fr);
    margin-block: 14px 24px;
  }
  .login-panel { padding: clamp(18px, 5vw, 28px); }
  .login-photo { grid-row: 1; height: clamp(96px, 20svh, 150px); object-position: 75% 47%; }
  .login h1 { margin-block: 20px 16px; }
  .heading { gap: 12px; margin-bottom: 16px; }
  .heading h1 { font-size: clamp(27px, 8vw, 38px); overflow-wrap: anywhere; }
  .notice { overflow-wrap: anywhere; }
  .fields { gap: 15px; }
  input, select, textarea { font-size: 16px; }
  .actions { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .primary, .secondary, .danger { min-height: 44px; }
  .danger { margin-left: 0; }
}
