/* ==========================================================================
   ARDEZENMADE — admin styles (admin.html), on top of assets/styles.css
   ========================================================================== */

/* The admin is an app-style screen: it fills the window and never scrolls
   as a page — only the pieces list (and, on short screens, the form)
   scroll inside their own cards. Phones fall back to a normal page. */
:root {
  --radius: 14px;
  --field-h: 2.6rem;
  --danger: #A13A2B;
  --ring: 0 0 0 3px rgba(21, 20, 19, .08);
}
html, body { height: 100%; }
body { background: var(--surface); }
html { scrollbar-gutter: auto; }

/* ---------- small building blocks ---------- */
.label { display: block; margin-bottom: .4rem; font: 500 .66rem/1.2 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.label span { text-transform: none; letter-spacing: 0; }
.input {
  width: 100%; height: var(--field-h); padding: 0 .85rem; border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; font: 400 .92rem/1.4 var(--sans); color: var(--ink);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
textarea.input { height: auto; padding: .65rem .85rem; resize: none; }
select.input { appearance: none; padding-right: 2.2rem; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236F6A64' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right .7rem center / 1rem; }
.input::placeholder { color: #A8A29B; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: var(--ring); }

.a-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 2.35rem; padding: 0 1.1rem; border: 1px solid var(--line-strong); border-radius: 999px;
  background: #fff; color: var(--ink); font: 500 .7rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap; transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.a-btn:hover { border-color: var(--ink); }
.a-btn--solid { border-color: var(--ink); background: var(--ink); color: #fff; }
.a-btn--solid:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.a-btn--lg { height: 2.9rem; width: 100%; font-size: .72rem; }
.a-btn:disabled { opacity: .45; cursor: not-allowed; }
.a-btn svg { width: .95rem; height: .95rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.status { min-height: 1.3em; font-size: .82rem; color: var(--muted); }
.status.is-error { color: var(--danger); }
.count { padding: .15rem .55rem; border-radius: 999px; background: var(--surface); font: 500 .72rem/1.4 var(--sans); color: var(--muted); }

/* ---------- login ---------- */
.login { display: grid; place-items: center; min-height: 100%; padding: 2rem 1rem; }
.login__card { width: min(100%, 23rem); padding: 2.5rem 2rem 2rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; text-align: center; box-shadow: 0 20px 50px -30px rgba(21, 20, 19, .25); }
.login__brand { font: 400 1.5rem/1 var(--serif); }
.login__sub { margin: .55rem 0 1.8rem; font: 500 .66rem/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.login__card .input { height: 2.9rem; margin-bottom: .75rem; text-align: center; letter-spacing: .08em; }
.login__card .status { margin-top: .75rem; }
.login__back { display: inline-block; margin-top: 1rem; font-size: .8rem; color: var(--muted); }
.login__back:hover { color: var(--ink); }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 3.75rem; padding: 0 1.75rem; border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: .7rem; }
.brand__name { font: 400 1.4rem/1 var(--serif); }
.brand__tag { padding: .3rem .6rem; border-radius: 999px; background: var(--surface); font: 500 .6rem/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.topbar__actions { display: flex; align-items: center; gap: .6rem; }

.workspace {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem;
  width: 100%; max-width: 1400px; min-height: 0; margin: 0 auto; padding: 1.25rem 1.75rem;
}
.side { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 1.25rem; min-height: 0; }

.card { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.4rem 0; }
.card__title { display: flex; align-items: center; gap: .6rem; font: 400 1.45rem/1.1 var(--serif); }
.card__hint { font-size: .78rem; color: var(--muted); }
.card__body { flex: 1; min-height: 0; padding: 1rem 1.4rem 1.2rem; overflow: auto; }
.card__foot { display: grid; gap: .45rem; padding: .9rem 1.4rem 1rem; border-top: 1px solid var(--line); }

/* ---------- new piece form ---------- */
/* The description + details row takes whatever height is left, so the
   card is filled on big screens and still fits on small laptops. */
.card__body--fill { display: flex; flex-direction: column; }
.form { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto auto minmax(5.5rem, 1fr); gap: .9rem 1rem; }
.form .span-2 { grid-column: 1 / -1; }
.grow { display: flex; flex-direction: column; min-height: 0; }
.grow textarea { flex: 1; min-height: 5.5rem; }

.drop {
  display: flex; align-items: center; gap: 1rem; padding: .9rem 1rem;
  border: 1px dashed var(--line-strong); border-radius: 12px; background: #FBFAF8; cursor: pointer;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.drop:hover, .drop.is-over { border-color: var(--ink); background: #fff; }
.drop__icon { display: grid; place-items: center; flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: #fff; border: 1px solid var(--line); }
.drop__icon svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.drop__text { display: grid; gap: .15rem; font-size: .88rem; }
.drop__text strong { font-weight: 500; }
.drop__text small { color: var(--muted); font-size: .76rem; }

.previews { display: flex; gap: .5rem; margin-top: .6rem; overflow-x: auto; }
.previews:empty { display: none; }
.preview { position: relative; flex: none; width: 3.9rem; aspect-ratio: 4 / 5; border-radius: 8px; overflow: hidden; background: var(--surface); }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview button {
  position: absolute; top: .2rem; right: .2rem; display: grid; place-items: center; width: 1.25rem; height: 1.25rem; padding: 0;
  border: 0; border-radius: 50%; background: rgba(21, 20, 19, .72); color: #fff; font-size: .8rem; line-height: 1; cursor: pointer;
}
.preview__tag { position: absolute; left: 0; right: 0; bottom: 0; padding: .12rem 0; background: rgba(255, 255, 255, .9); font-size: .55rem; letter-spacing: .12em; text-align: center; text-transform: uppercase; }

.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.link-btn { padding: 0; border: 0; background: none; color: var(--ink); font: 500 .72rem/1.2 var(--sans); letter-spacing: .06em; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--muted); }
.ways { display: grid; gap: .75rem; }
.way { display: grid; gap: .6rem; }
.ways.is-multi .way { padding: .75rem; border: 1px solid var(--line); border-radius: 12px; background: #FDFCFA; }
.way__head { display: flex; align-items: center; gap: .6rem; }
.way__swatch { position: relative; flex: none; width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--line-strong); overflow: hidden; cursor: pointer; }
.way__swatch input { position: absolute; inset: -.5rem; width: 3rem; height: 3rem; padding: 0; border: 0; cursor: pointer; }
.way__dot { display: flex; flex: none; align-items: center; gap: .3rem; }
.way__split { flex: none; width: 1.6rem; height: 1.6rem; padding: 0; border: 1px dashed var(--line-strong); border-radius: 50%; background: linear-gradient(135deg, transparent 50%, var(--line) 50%); color: var(--muted); font-size: .9rem; line-height: 1; cursor: pointer; }
.way__split:hover { border-style: solid; color: var(--ink); }
.way__split[aria-pressed="true"] { border-style: solid; background: transparent; }
.way__name { flex: 1; height: 2.2rem; }
.way__remove { flex: none; width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.way__remove:hover { background: #FBF1EF; color: var(--danger); }
.ways.is-multi .drop { padding: .6rem .8rem; }
/* per-colour details (materials / price / description) */
.way-details { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, .8fr); gap: .5rem .6rem; }
.way-details .span-2 { grid-column: 1 / -1; }
.way-details .input { height: 2.2rem; font-size: .86rem; }
.way-details textarea.input { height: auto; min-height: 3.6rem; resize: vertical; }
.way-details small { grid-column: 1 / -1; margin-top: -.15rem; font-size: .72rem; color: var(--muted); }
.editor__way-card { display: grid; gap: .55rem; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: 12px; background: #FDFCFA; }
.ways.is-multi .drop__icon { width: 2rem; height: 2rem; }
.banner { padding: .8rem 1rem; margin-bottom: 1rem; border-radius: 10px; background: #FBF1EF; color: var(--danger); font-size: .84rem; }

/* ---------- categories ---------- */
.cat-add { display: flex; gap: .5rem; }
.cat-add .input { border-radius: 999px; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .85rem 0 0; padding: 0; list-style: none; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: .45rem; height: 2rem; padding: 0 .3rem 0 .8rem; border: 1px solid var(--line); border-radius: 999px; background: #FBFAF8; font-size: .84rem; }
.chip small { min-width: 1.2rem; padding: .05rem .35rem; border-radius: 999px; background: #fff; color: var(--muted); font-size: .7rem; text-align: center; }
.chip button { display: grid; place-items: center; width: 1.45rem; height: 1.45rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: .95rem; line-height: 1; cursor: pointer; }
.chip button:hover { background: var(--danger); color: #fff; }
.cat-status { margin-top: .6rem; }
.cat-status:empty { display: none; }

/* ---------- pieces list ---------- */
.list { display: grid; gap: .1rem; margin: 0; padding: 0; list-style: none; }
.item { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: .9rem; padding: .55rem .5rem; border-radius: 10px; transition: background-color .2s var(--ease); }
.item:hover { background: #FBFAF8; }
.item img { width: 2.9rem; height: 3.6rem; border-radius: 8px; object-fit: cover; background: var(--surface); }
.item__name { overflow: hidden; font: 400 1.12rem/1.2 var(--serif); white-space: nowrap; text-overflow: ellipsis; }
.item__meta { margin-top: .15rem; font-size: .78rem; color: var(--muted); }
.item__ways { display: flex; gap: .3rem; margin-top: .35rem; }
.item__ways span { width: .7rem; height: .7rem; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(21, 20, 19, .18); }
.item button { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; padding: 0; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; transition: all .2s var(--ease); }
.item button:hover { border-color: #F0D5D0; background: #FBF1EF; color: var(--danger); }
.item button svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty { display: grid; place-items: center; height: 100%; min-height: 6rem; color: var(--muted); font-size: .88rem; text-align: center; }

/* ---------- short laptop screens: tighter spacing so it all still fits ---------- */
@media (min-width: 901px) and (max-height: 800px) {
  :root { --field-h: 2.35rem; }
  .topbar { height: 3.25rem; }
  .workspace, .side { gap: .9rem; }
  .workspace { padding-top: .9rem; padding-bottom: .9rem; }
  .card__head { padding-top: .85rem; }
  .card__title { font-size: 1.3rem; }
  .card__body { padding-top: .7rem; padding-bottom: .9rem; }
  .card__foot { padding-top: .7rem; padding-bottom: .7rem; }
  .form { gap: .65rem 1rem; grid-template-rows: auto auto auto auto minmax(4.5rem, 1fr); }
  .grow textarea { min-height: 4.5rem; }
  .drop { padding: .6rem .9rem; }
  .drop__icon { width: 2.2rem; height: 2.2rem; }
  .a-btn--lg { height: 2.6rem; }
}

/* ---------- photo + colour editor for published pieces ---------- */
.item__actions { display: flex; gap: .15rem; }
.count--home { background: #FBF1EF; color: #7A2A2A; }
.item[draggable="true"] { cursor: grab; }
.item.is-dragging { opacity: .35; }
.item.is-over-top { box-shadow: 0 -2px 0 var(--ink); }
.item.is-over-bottom { box-shadow: 0 2px 0 var(--ink); }
.item__grip { flex: none; width: .9rem; color: var(--line-strong); font-size: 1.1rem; line-height: 1; letter-spacing: -.1em; user-select: none; }
.item__home[aria-pressed="true"] { color: #9B1B30; }
.item__home[aria-pressed="true"]:hover { border-color: #F0D5D0; background: #FBF1EF; color: #9B1B30; }
.item__home svg { fill: none; }
.item__home[aria-pressed="true"] svg { fill: currentColor; }
.item__actions button:not(:last-child):hover { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.editor { width: min(64rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 0; border-radius: var(--radius); background: #fff; color: var(--ink); box-shadow: 0 30px 80px -30px rgba(21, 20, 19, .45); }
.editor::backdrop { background: rgba(21, 20, 19, .35); }
.editor__inner { display: flex; flex-direction: column; max-height: calc(100dvh - 2rem); }
.editor__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.4rem .9rem; border-bottom: 1px solid var(--line); }
.editor__body { display: grid; gap: 1.4rem; padding: 1.1rem 1.4rem 1.4rem; overflow: auto; }
.editor__foot { display: flex; align-items: center; gap: .6rem; padding: .9rem 1.4rem; border-top: 1px solid var(--line); }
.editor__foot .status { flex: 1; }
.editor__hint { margin: .1rem 0 .7rem; font-size: .82rem; color: var(--muted); }
.editor__ways { display: grid; gap: .6rem; }
.editor__piece { display: grid; grid-template-columns: auto 8rem 1fr; align-items: center; gap: .4rem .9rem; }
.editor__piece .label { margin: 0; }
.editor__piece .input { height: 2.3rem; }
.editor__piece textarea.input { height: auto; grid-column: 2 / -1; resize: vertical; }
.editor__piece textarea.input + small { grid-column: 2 / -1; }
.editor__piece small { font-size: .76rem; color: var(--muted); }
.editor__way { display: flex; align-items: center; gap: .6rem; }
.editor__way small { flex: none; min-width: 4.5rem; font-size: .78rem; color: var(--muted); text-align: right; }
.editor__group + .editor__group { margin-top: 1.1rem; }
.editor__group-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .55rem; font: 400 1.1rem/1.2 var(--serif); }
.editor__group-head i { width: .85rem; height: .85rem; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(21, 20, 19, .2); }
.editor__group-empty { padding: .8rem; border: 1px dashed var(--line-strong); border-radius: 10px; font-size: .82rem; color: var(--muted); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .8rem; }
.photo { display: grid; gap: .4rem; }
.photo__frame { position: relative; aspect-ratio: 4 / 5; border-radius: 10px; overflow: hidden; background: var(--surface); }
.photo__frame img { width: 100%; height: 100%; object-fit: cover; }
.photo__tag { position: absolute; left: .35rem; bottom: .35rem; padding: .15rem .45rem; border-radius: 999px; background: rgba(255, 255, 255, .92); font-size: .58rem; letter-spacing: .12em; text-transform: uppercase; }
.photo__tag--new { left: auto; right: .35rem; top: .35rem; bottom: auto; background: var(--ink); color: #fff; }
.photo__del { position: absolute; top: .35rem; left: .35rem; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; padding: 0; border: 0; border-radius: 50%; background: rgba(21, 20, 19, .72); color: #fff; font-size: .85rem; line-height: 1; cursor: pointer; }
.photo__del:hover { background: var(--danger); }
.photo__row { display: flex; align-items: center; justify-content: space-between; gap: .4rem; min-height: 1.4rem; }
.photo__dots { display: flex; flex-wrap: wrap; gap: .3rem; }
.photo__dot { position: relative; width: 1.05rem; height: 1.05rem; padding: 0; border: 0; border-radius: 50%; background: var(--dot); box-shadow: inset 0 0 0 1px rgba(21, 20, 19, .2); cursor: pointer; }
.photo__dot[aria-pressed="true"]::after { content: ""; position: absolute; inset: -3px; border: 1.5px solid var(--ink); border-radius: 50%; }
.photo__main { padding: 0; border: 0; background: none; color: var(--muted); font-size: .7rem; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; white-space: nowrap; }
.photo__main:hover { color: var(--ink); }
.add-photos { display: grid; place-items: center; gap: .3rem; aspect-ratio: 4 / 5; border: 1px dashed var(--line-strong); border-radius: 10px; background: #FBFAF8; color: var(--muted); font-size: .78rem; text-align: center; cursor: pointer; }
.add-photos:hover, .add-photos.is-over { border-color: var(--ink); color: var(--ink); background: #fff; }
.add-photos strong { font-size: 1.4rem; font-weight: 300; line-height: 1; }

/* ---------- Pieces | Process tabs ---------- */
.tabs { display: flex; gap: .25rem; padding: .25rem; border-radius: 999px; background: var(--surface); }
.tabs__btn { height: 2rem; padding: 0 1.1rem; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 500 .68rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; cursor: pointer; }
.tabs__btn[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(21, 20, 19, .12); }

/* ---------- process chapter form ---------- */
.chapter-form { display: grid; gap: 1.1rem; }
.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
@media (max-width: 560px) { .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.slot { position: relative; display: grid; place-items: center; aspect-ratio: 1; border: 1px dashed var(--line-strong); border-radius: 10px; background: #FBFAF8; color: var(--muted); font-size: .78rem; text-align: center; cursor: pointer; overflow: hidden; transition: border-color .2s var(--ease), background-color .2s var(--ease); }
.slot:hover, .slot.is-over { border-color: var(--ink); background: #fff; color: var(--ink); }
.slot.is-filled { border-style: solid; border-color: var(--line); }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot__no { position: absolute; top: .4rem; left: .4rem; z-index: 1; display: grid; place-items: center; min-width: 1.5rem; height: 1.5rem; padding: 0 .4rem; border-radius: 999px; background: #fff; color: var(--ink); font: 500 .7rem/1 var(--sans); box-shadow: 0 0 0 1px var(--line); }
.slot__del { position: absolute; top: .4rem; right: .4rem; z-index: 1; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; padding: 0; border: 0; border-radius: 50%; background: rgba(21, 20, 19, .72); color: #fff; font-size: .85rem; line-height: 1; cursor: pointer; }
.slot__del:hover { background: var(--danger); }
.slot__move { position: absolute; bottom: .4rem; left: 50%; z-index: 1; display: flex; gap: .3rem; transform: translateX(-50%); }
.slot__move button { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--ink); font-size: .95rem; line-height: 1; cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.slot__move button:hover { background: var(--ink); color: #fff; }
.chapter-actions { display: flex; gap: .6rem; }
.chapter-actions .a-btn--lg { flex: 1; }
.chapter-actions [data-chapter-cancel] { height: 2.9rem; }
.chapter-list .item.is-editing { background: #FBFAF8; box-shadow: inset 3px 0 0 var(--ink); }

/* ---------- chapter list ---------- */
.chapter-list .item { grid-template-columns: minmax(0, 1fr) auto; }
.chapter-list .item__name { white-space: normal; }
.item__strip { display: flex; gap: .25rem; margin-top: .45rem; }
.item__strip img { width: 2.2rem; height: 2.2rem; border-radius: 4px; object-fit: cover; background: var(--surface); }
.item__actions button:disabled { opacity: .3; cursor: default; }

/* ---------- polish: cards size to their content, calmer chrome ---------- */
.workspace > form.card,
.workspace[data-view="process"] > section.card { align-self: start; max-height: 100%; }
.workspace > form.card .card__body--fill { display: block; }
.form { grid-template-rows: none; }
.grow textarea { min-height: 7.5rem; max-height: 14rem; }
.card__head { padding: 1.15rem 1.4rem .15rem; }
.card__title { font-size: 1.4rem; }
.card__body { padding-top: .9rem; }
.topbar .a-btn { height: 2.15rem; padding: 0 1rem; font-size: .64rem; }
.tabs__btn { height: 1.9rem; padding: 0 1.05rem; font-size: .64rem; }
.brand__name { font-size: 1.3rem; }
.chapter-list .item { padding: .7rem .5rem; }
.chapter-list .item__meta { margin: 0 0 .2rem; font: 500 .6rem/1.2 var(--sans); letter-spacing: .16em; text-transform: uppercase; }
.item__strip { gap: .3rem; margin-top: .55rem; }
.item__strip img { width: 2.9rem; height: 2.9rem; border-radius: 6px; }
.slot span:not([class]) { font-size: .74rem; }

/* ---------- smaller screens: a normal scrolling page ---------- */
@media (max-width: 900px) {
  .shell { height: auto; min-height: 100dvh; }
  .workspace { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
  .side { grid-template-rows: auto auto; }
  .card__body { overflow: visible; }
  .form { grid-template-rows: none; }
  .topbar { position: sticky; top: 0; z-index: 5; padding: 0 1rem; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding-top: .6rem; padding-bottom: .6rem; }
  .tabs { order: 3; width: 100%; justify-content: center; }
}
@media (max-width: 520px) {
  .card__head span.card__hint, .label-row .card__hint { display: none; }
  .form { grid-template-columns: minmax(0, 1fr); }
  .brand__tag, .topbar__view span { display: none; }
}

/* ---------- phones ---------- */
@media (max-width: 600px) {
  /* 16px text in fields stops iOS zooming in on every tap */
  .input, .way-details .input { font-size: 16px; }
  .workspace { gap: 1rem; padding: .75rem .75rem calc(1rem + env(safe-area-inset-bottom)); }
  .card__head { padding: 1rem 1rem .1rem; }
  .card__body { padding: .85rem 1rem 1rem; }
  .card__foot { padding: .8rem 1rem calc(.9rem + env(safe-area-inset-bottom)); }
  .card__title { flex-wrap: wrap; font-size: 1.3rem; }
  .drop { gap: .75rem; padding: .75rem; }
  .way-details { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .way-details > :first-child { grid-column: 1 / -1; }

  /* Pieces / chapters: text beside the photo, buttons on their own row */
  .list { gap: 0; }
  .item { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "img text" "img actions"; align-items: start; gap: .35rem .85rem; padding: .8rem .1rem; border-radius: 0; }
  .item + .item { border-top: 1px solid var(--line); }
  .item:hover { background: transparent; }
  .item > img { grid-area: img; width: 3.6rem; height: 4.5rem; }
  .item > div:not(.item__actions) { grid-area: text; min-width: 0; }
  .item__grip { display: none; }
  .item__name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 1.08rem; }
  .item__meta { font-size: .76rem; line-height: 1.45; }
  .item__actions { grid-area: actions; gap: .35rem; margin-left: -.3rem; }
  .item__actions button { width: 2.5rem; height: 2.5rem; border-color: var(--line); }
  .chapter-list .item { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "actions"; }
  .item__strip { flex-wrap: wrap; }

  /* editor: full screen, one column */
  .editor { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border-radius: 0; }
  .editor__inner { height: 100%; max-height: 100%; }
  .editor__head { padding: calc(.9rem + env(safe-area-inset-top)) 1rem .75rem; }
  .editor__body { flex: 1; padding: 1rem; }
  .editor__foot { flex-wrap: wrap; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); }
  .editor__foot .status { flex-basis: 100%; }
  .editor__foot .status:empty { display: none; }
  .editor__foot .a-btn { flex: 1; height: 2.75rem; }
  .editor__piece { grid-template-columns: minmax(0, 1fr); gap: .35rem; }
  .editor__piece textarea.input, .editor__piece textarea.input + small { grid-column: auto; }
  .editor__piece small + .label { margin-top: .6rem; }
  .editor__way { flex-wrap: wrap; }
  .editor__way small { min-width: 0; }
  .photos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .photo__dot { width: 1.5rem; height: 1.5rem; }
  .photo__del { width: 1.9rem; height: 1.9rem; }
}

/* ---------- edit piece: name, category, price… plus Sold / Hidden ---------- */
.editor__piece .editor__wide,
.editor__piece .editor__wide + small,
.editor__flags { grid-column: 2 / -1; }
.editor__flags { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--ink); cursor: pointer; }
.check small { color: var(--muted); }

/* ---------- messages: an inbox beside the open message ---------- */
.tabs__btn { display: inline-flex; align-items: center; }
.tabs__badge { display: inline-grid; place-items: center; min-width: 1.15rem; height: 1.15rem; margin: -.1rem -.35rem 0 .45rem; padding: 0 .32rem; border-radius: 999px; background: #9B1B30; color: #fff; font: 600 .6rem/1 var(--sans); letter-spacing: 0; }

.workspace--single { grid-template-columns: minmax(0, 1fr); }
.workspace--inbox { max-width: 84rem; }
.workspace--inbox > .inbox { overflow: hidden; }
.inbox__head { flex-wrap: wrap; padding-bottom: .95rem; }
.inbox > .banner { margin: 0 1.4rem .9rem; line-height: 1.5; }
.banner code { padding: .05rem .3rem; border-radius: 4px; background: rgba(255, 255, 255, .7); font: 500 .8em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.banner--soft { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; background: var(--surface); color: var(--ink-hover); }
.banner--soft code { background: #fff; }
.banner--soft .link-btn { flex: none; margin-top: .1rem; }
.inbox__status { padding: 0 1.4rem .75rem; }
.inbox__status:empty { min-height: 0; padding-bottom: 0; }
.inbox__status .link-btn { font-size: .8rem; }

.segmented { display: flex; gap: .2rem; padding: .22rem; border-radius: 999px; background: var(--surface); }
.segmented__btn { display: inline-flex; align-items: center; gap: .4rem; height: 1.85rem; padding: 0 .95rem; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 500 .62rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; cursor: pointer; transition: color .2s var(--ease); }
.segmented__btn:hover { color: var(--ink); }
.segmented__btn[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(21, 20, 19, .12); }
.segmented__btn small { color: #9B1B30; font: 600 .66rem/1 var(--sans); letter-spacing: 0; }

.inbox__body { flex: 1; display: grid; grid-template-columns: minmax(17rem, 24rem) minmax(0, 1fr); min-height: 0; border-top: 1px solid var(--line); }
.inbox__side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.inbox__search {
  flex: none; width: auto; height: 2.35rem; margin: .8rem .8rem .45rem; padding-left: 2.15rem; border-color: var(--line); border-radius: 999px; background: #FBFAF8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236F6A64' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4 4'/%3E%3C/svg%3E") no-repeat .8rem center / .95rem;
}
.inbox__search:focus { background-color: #fff; }
.inbox__search::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 1rem; height: 1rem; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236F6A64' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E") no-repeat center / 1rem;
}
/* no grey/blue flash when a phone taps these */
.tabs__btn, .segmented__btn, .inbox__row, .a-btn, .link-btn { -webkit-tap-highlight-color: transparent; }
.inbox__list { flex: 1; display: grid; align-content: start; gap: .15rem; min-height: 0; margin: 0; padding: .2rem .55rem .8rem; list-style: none; overflow: auto; overscroll-behavior: contain; }
.inbox__row {
  position: relative; display: grid; gap: .22rem; width: 100%; padding: .8rem .85rem .85rem 1.65rem;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
  transition: background-color .2s var(--ease);
}
.inbox__row:hover { background: #FBFAF8; }
.inbox__row[aria-current="true"] { background: var(--surface); }
.inbox__row:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.is-unread .inbox__row::before { content: ""; position: absolute; top: 1.16rem; left: .7rem; width: .45rem; height: .45rem; border-radius: 50%; background: #9B1B30; }
.inbox__line { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; min-width: 0; }
.inbox__name { overflow: hidden; font-size: .9rem; white-space: nowrap; text-overflow: ellipsis; }
.is-unread .inbox__name { font-weight: 600; }
.inbox__time { flex: none; font-size: .72rem; color: var(--muted); }
.is-unread .inbox__time { color: var(--ink); }
.inbox__subject { overflow: hidden; font: 400 1.04rem/1.25 var(--serif); white-space: nowrap; text-overflow: ellipsis; }
.is-unread .inbox__subject { font-weight: 600; }
.inbox__snippet { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .8rem; line-height: 1.45; color: var(--muted); }
.inbox__empty { padding: 2.5rem 1rem; color: var(--muted); font-size: .86rem; line-height: 1.5; text-align: center; }

.inbox__detail { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.inbox__placeholder { display: grid; place-items: center; align-content: center; gap: .8rem; height: 100%; min-height: 16rem; padding: 2rem; color: var(--muted); font-size: .88rem; text-align: center; }
.inbox__placeholder-icon { width: 2.6rem; height: 2.6rem; fill: none; stroke: var(--line-strong); stroke-width: 1.2; stroke-linejoin: round; }

/* one message */
.msg { display: grid; gap: 1.5rem; padding: 0 2rem 2.25rem; }
.msg > :not(.msg__bar) { max-width: 46rem; }
.msg__bar {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: .5rem;
  margin: 0 -2rem; padding: .75rem 2rem; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.msg__back { display: none; margin-right: auto; }
.msg__tools { display: flex; flex-wrap: wrap; gap: .4rem; }
.msg__bar .a-btn { height: 2.1rem; padding: 0 1rem; font-size: .62rem; }
.a-btn--icon, .msg__bar .a-btn--icon { width: 2.1rem; padding: 0; }
.a-btn--danger:hover { border-color: #F0D5D0; background: #FBF1EF; color: var(--danger); }
.msg__kind { font: 500 .62rem/1.2 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.msg__subject { margin-top: .5rem; font: 400 clamp(1.55rem, 2.3vw, 2rem)/1.12 var(--serif); overflow-wrap: anywhere; }
.msg__subject:focus { outline: none; }
.msg__from { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .9rem; margin-top: 1.2rem; }
.msg__avatar { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--surface); color: var(--ink); font: 500 .78rem/1 var(--sans); letter-spacing: .08em; }
.msg__who { display: grid; gap: .15rem; min-width: 0; }
.msg__who strong { overflow: hidden; font-size: .98rem; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.msg__contact { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .8rem; font-size: .84rem; color: var(--muted); }
.msg__reach { display: inline-flex; align-items: baseline; gap: .55rem; min-width: 0; }
.msg__value { color: var(--ink-hover); overflow-wrap: anywhere; user-select: all; } /* one click selects it all */
.msg__copy { color: var(--muted); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; text-decoration: none; }
.msg__date { font-size: .78rem; color: var(--muted); text-align: right; }

.msg__piece { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: .65rem 1.1rem .65rem .65rem; border: 1px solid var(--line); border-radius: 12px; background: #FBFAF8; color: inherit; text-decoration: none; transition: border-color .2s var(--ease), background-color .2s var(--ease); }
a.msg__piece:hover { border-color: var(--ink); background: #fff; }
.msg__piece img { width: 3.6rem; height: 4.5rem; border-radius: 8px; background: #fff; object-fit: contain; }
.msg__piece--text { grid-template-columns: minmax(0, 1fr) auto; padding: .9rem 1.1rem; } /* a piece with no photo to show */
.msg__piece-text { display: grid; gap: .25rem; min-width: 0; }
.msg__piece-text small { font: 500 .6rem/1.2 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.msg__piece-text strong { font: 400 1.2rem/1.2 var(--serif); }
.msg__piece-go { font: 500 .62rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
a.msg__piece:hover .msg__piece-go { color: var(--ink); }

.msg__facts { margin: 0; border-top: 1px solid var(--line); }
.msg__facts div { display: grid; grid-template-columns: 9rem minmax(0, 1fr); align-items: baseline; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.msg__facts dt { font: 500 .62rem/1.2 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.msg__facts dd { margin: 0; font-size: .96rem; }
.msg__body { font-size: 1rem; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg__note { padding-top: 1.25rem; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }

/* short laptop screens */
@media (min-width: 901px) and (max-height: 800px) {
  .msg { gap: 1.2rem; }
  .inbox__row { padding-top: .65rem; padding-bottom: .7rem; }
}

/* small screens: the list, then the message on its own, with a way back */
@media (max-width: 900px) {
  .workspace--inbox > .inbox { overflow: visible; }
  .inbox__body { display: block; }
  .inbox__side { border-right: 0; }
  .inbox__list { overflow: visible; }
  .inbox.is-reading .inbox__side, .inbox:not(.is-reading) .inbox__detail { display: none; }
  .inbox__detail { overflow: visible; }
  .msg__back { display: inline-flex; }
  .msg__bar { position: static; justify-content: space-between; -webkit-backdrop-filter: none; backdrop-filter: none; background: #fff; }
}
@media (max-width: 600px) {
  .inbox__head { gap: .8rem; }
  .segmented { width: 100%; }
  .segmented__btn { flex: 1; justify-content: center; padding: 0 .5rem; }
  .inbox > .banner { margin: 0 1rem .8rem; }
  .banner--soft { flex-direction: column; gap: .5rem; }
  .inbox__status { padding: 0 1rem .7rem; }
  .inbox__search { margin: .75rem .75rem .4rem; font-size: 16px; }
  .inbox__list { padding: .2rem .35rem .6rem; }
  .msg { gap: 1.25rem; padding: 0 1rem 1.75rem; }
  .msg__bar { margin: 0 -1rem; padding: .7rem 1rem; }
  .msg__from { grid-template-columns: auto minmax(0, 1fr); }
  .msg__date { grid-column: 2; text-align: left; }
  .msg__piece { grid-template-columns: auto minmax(0, 1fr); }
  .msg__piece--text { grid-template-columns: minmax(0, 1fr); }
  .msg__piece-go { display: none; }
  .msg__facts div { grid-template-columns: 7rem minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .editor__piece .editor__wide, .editor__piece .editor__wide + small, .editor__flags { grid-column: auto; }
  .editor__flags { flex-direction: column; }
}
