/* ================================================================
   Product editor — glass modal (.nse-*)
   Reparented to <body> by noir-store-editor.js, so it CANNOT inherit
   the .nsm tokens. It carries its own light/dark set, stamped on as
   .nse--light / .nse--dark from the shell it was opened in.
   ================================================================ */

.nse-scrim {
  --nse-text:    #1B1712;
  --nse-muted:   #5F594E;      /* measured ≥4.5:1 on the composited glass */
  --nse-surface: rgba(255, 255, 255, .74);
  --nse-raise:   rgba(255, 255, 255, .55);
  --nse-line:    rgba(27, 23, 18, .12);
  --nse-field:   rgba(255, 255, 255, .70);
  --nse-accent:  #CB360F;
  --nse-scrim-bg: rgba(20, 16, 12, .46);

  position: fixed; inset: 0; z-index: 99999;
  display: grid; place-items: center; padding: 24px;
  background: var(--nse-scrim-bg);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.nse-scrim[hidden] { display: none; }

.nse-scrim.nse--dark {
  --nse-text:    #F4F0E8;
  --nse-muted:   rgba(244, 240, 232, .66);
  --nse-surface: rgba(28, 25, 22, .82);
  --nse-raise:   rgba(244, 240, 232, .055);
  --nse-line:    rgba(244, 240, 232, .13);
  --nse-field:   rgba(244, 240, 232, .06);
  --nse-accent:  #E8703F;
  --nse-scrim-bg: rgba(8, 7, 6, .62);
}

body.nse-locked { overflow: hidden; }

/* ── the tile ───────────────────────────────────────────────── */
.nse {
  width: min(760px, 100%); max-height: min(88vh, 900px);
  display: flex; flex-direction: column;
  color: var(--nse-text);
  background: var(--nse-surface);
  -webkit-backdrop-filter: saturate(1.5) blur(20px);
          backdrop-filter: saturate(1.5) blur(20px);
  border: 1px solid var(--nse-line);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .34);
  overflow: hidden;
  animation: nse-in .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes nse-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.nse__head {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--nse-line);
}
.nse__eyebrow {
  margin: 0 0 3px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--nse-accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch;
}
.nse__title { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.nse__x {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 26px; line-height: 1; color: var(--nse-muted); padding: 0 4px;
}
.nse__x:hover { color: var(--nse-text); }

/* ── panes ──────────────────────────────────────────────────── */
.nse__tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--nse-line); }
.nse__tab {
  background: none; border: none; cursor: pointer;
  padding: 9px 14px 11px; font-size: 13.5px; font-weight: 600;
  color: var(--nse-muted); border-bottom: 2px solid transparent;
}
.nse__tab.is-on { color: var(--nse-text); border-bottom-color: var(--nse-accent); }
.nse__count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  margin-left: 5px; padding: 0 5px; border-radius: 999px;
  background: var(--nse-accent); color: #fff; font-size: 11px; font-weight: 700;
}

.nse__form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.nse__body { overflow-y: auto; padding: 20px 22px; flex: 1; }
.nse__pane { display: none; }
.nse__pane.is-on { display: block; }

/* ── fields ─────────────────────────────────────────────────── */
.nse-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.nse-row:has(> .nse-field:nth-child(2):last-child) { grid-template-columns: repeat(2, 1fr); }
.nse-field { margin: 0 0 14px; display: flex; flex-direction: column; gap: 5px; }
.nse-field > label { font-size: 12px; font-weight: 600; color: var(--nse-muted); }
.nse-hint { display: block; font-size: 11.5px; font-weight: 400; color: var(--nse-muted); margin-top: 2px; }
.nse-lede { font-size: 13.5px; line-height: 1.6; color: var(--nse-muted); margin: 0 0 16px; max-width: 66ch; }
.nse-lede strong { color: var(--nse-text); }

.nse-scrim input[type="text"], .nse-scrim input[type="number"],
.nse-scrim select, .nse-scrim textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 14px;
  color: var(--nse-text); background: var(--nse-field);
  border: 1px solid var(--nse-line); border-radius: 10px;
}
.nse-scrim textarea { resize: vertical; }
.nse-scrim input:focus, .nse-scrim select:focus, .nse-scrim textarea:focus {
  outline: 2px solid var(--nse-accent); outline-offset: 1px; border-color: transparent;
}
.nse-scrim input::placeholder, .nse-scrim textarea::placeholder { color: var(--nse-muted); opacity: .75; }

.nse-files { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.nse-files input[type="file"] { font-size: 12px; color: var(--nse-muted); }
.nse-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.nse-thumbs img { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; border: 1px solid var(--nse-line); }

.nse-check { display: flex; gap: 10px; align-items: flex-start; margin-top: 4px; cursor: pointer; }
.nse-check input { margin-top: 3px; flex-shrink: 0; }
.nse-check > span { font-size: 13.5px; }

/* ── variation builder ──────────────────────────────────────── */
.nse-group {
  background: var(--nse-raise); border: 1px solid var(--nse-line);
  border-radius: 14px; padding: 12px 13px; margin: 0 0 10px;
}
.nse-group__head { display: flex; gap: 8px; align-items: center; }
.nse-group__name { flex: 1; font-weight: 600; }
/* Two classes, so this beats the generic `.nse-scrim select { width:100% }`
   (2 classes > 1 class + 1 type). Without it the select claims the whole row
   and — being flex-shrink:0 — squeezes the name input down to a sliver. */
.nse-scrim .nse-group__sel { width: auto; flex-shrink: 0; }
.nse-group__x, .nse-val__x {
  background: none; border: none; cursor: pointer; color: var(--nse-muted);
  font-size: 20px; line-height: 1; padding: 0 5px; flex-shrink: 0;
}
.nse-group__x:hover, .nse-val__x:hover { color: #c45c6a; }
.nse-group__rules {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  margin: 10px 0; font-size: 12.5px; color: var(--nse-muted);
}
.nse-toggle, .nse-inline { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.nse-inline select { width: auto; padding: 4px 8px; font-size: 12.5px; }

.nse-vals { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.nse-val { display: grid; grid-template-columns: 1fr 96px 36px 92px 28px; gap: 6px; align-items: center; }
/* Explicit columns: the swatch is display:none unless the group style is
   "swatch", and without these every later cell slides one column left —
   which is what truncated the Stock field to "Sto". */
.nse-val__label { grid-column: 1; }
.nse-val__delta { grid-column: 2; }
.nse-val__sw    { grid-column: 3; }
.nse-val__stock { grid-column: 4; }
.nse-val__x     { grid-column: 5; }
.nse-val__delta { position: relative; display: flex; align-items: center; }
.nse-val__delta i {
  position: absolute; left: 9px; font-style: normal; font-size: 12px;
  color: var(--nse-muted); pointer-events: none;
}
.nse-val__delta input { padding-left: 22px; }
.nse-val__sw {
  width: 36px; height: 36px; padding: 2px; border-radius: 9px;
  border: 1px solid var(--nse-line); background: var(--nse-field); cursor: pointer;
}

.nse-empty { text-align: center; padding: 26px 16px; color: var(--nse-muted); }
.nse-empty__ico { font-size: 26px; opacity: .5; margin-bottom: 6px; }
.nse-empty p { margin: 0; font-size: 13.5px; }

.nse-addrow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.nse-presets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nse-presets .nse-hint { display: inline; margin: 0; }
.nse-chip {
  padding: 4px 10px; border-radius: 999px; cursor: pointer; font-size: 12px;
  color: var(--nse-text); background: var(--nse-field);
  border: 1px solid var(--nse-line);
}
.nse-chip:hover { border-color: var(--nse-accent); color: var(--nse-accent); }

/* ── buyer preview ──────────────────────────────────────────── */
.nse-preview {
  margin-top: 18px; padding: 14px; border-radius: 14px;
  background: var(--nse-raise); border: 1px dashed var(--nse-line);
}
.nse-preview__h {
  margin: 0 0 10px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--nse-muted);
}
.nse-pgroup { margin-bottom: 10px; }
.nse-pgroup__n { font-size: 12.5px; font-weight: 600; }
.nse-pgroup__n em { font-style: normal; font-weight: 400; color: var(--nse-muted); font-size: 11.5px; }
.nse-pchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.nse-pchip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px;
  background: var(--nse-field); border: 1px solid var(--nse-line);
}
.nse-pchip i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--nse-line); }
.nse-pchip b { font-weight: 600; color: var(--nse-accent); }

/* ── footer ─────────────────────────────────────────────────── */
.nse__foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px calc(14px + var(--noir-safe-bottom, 0px));
  border-top: 1px solid var(--nse-line);
  background: var(--nse-raise);
}
.nse__foothint { flex: 1; font-size: 12px; color: var(--nse-accent); }
.nse-btn {
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; border: 1px solid transparent;
}
.nse-btn--primary { background: var(--nse-accent); color: #fff; }
.nse-btn--primary:disabled { opacity: .6; cursor: default; }
.nse-btn--ghost { background: none; color: var(--nse-text); border-color: var(--nse-line); }
.nse-btn--ghost:hover { border-color: var(--nse-text); }
.nse-btn--tiny { padding: 5px 11px; font-size: 12.5px; background: var(--nse-field); border-color: var(--nse-line); color: var(--nse-text); }

/* ── mobile: bottom sheet ───────────────────────────────────── */
@media (max-width: 640px) {
  .nse-scrim { padding: 0; place-items: end stretch; }
  .nse {
    /* Cap against the VISIBLE viewport so the sticky footer (Publish item)
       stays reachable while the keyboard is up — 94vh includes the keyboard. */
    width: 100%;
    max-height: min(94vh, calc(var(--noir-vh, 100svh) - 12px));
    border-radius: 22px 22px 0 0;
    animation: nse-up .26s cubic-bezier(.2, .9, .3, 1);
  }
  @keyframes nse-up { from { transform: translateY(100%); } to { transform: none; } }
  .nse-row { grid-template-columns: 1fr; }
  .nse-val { grid-template-columns: 1fr 84px 34px 28px; }
  .nse-val__stock { display: none; }   /* per-choice stock is a desktop refinement */
  .nse__foot { flex-wrap: wrap; }
  .nse__foothint { flex-basis: 100%; }
}

/* Frost is decoration; contrast is not. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nse-scrim { background: rgba(20, 16, 12, .7); }
  .nse-scrim.nse--light .nse { background: #FBF8F2; }
  .nse-scrim.nse--dark  .nse { background: #17140F; }
}
@media (prefers-reduced-motion: reduce) {
  .nse { animation: none; }
}
