/* Ornament editor (approved mock web/mock/tool.html). Full viewport, panels scroll inside.
   Acid only for what is selected and for the main action; everything else is quiet.
   Type 16 / 20, no monospace; spacing step 4/8. */
:root {
  --bg: #0c0c0c; --panel: #141414; --raise: #1d1d1d; --line: #2a2a2a; --line-2: #3d3d3d;
  --text: #f0ede8; --mute: #9b978f; --faint: #6d6a64; --acid: #e8e80c; --paper: #ffffff;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px;
  --t: 16px; --t-h: 20px;
  --bar: 56px; --lib: 340px; --side: 380px;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: var(--t)/1.4 var(--font); overflow: hidden; }
[hidden], .app [hidden] { display: none; }   /* class rules like display:grid must not beat the hidden attribute */
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.35; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.app {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: var(--lib) minmax(0, 1fr) var(--side);
  grid-template-rows: var(--bar) auto minmax(0, 1fr);
  grid-template-areas: "bar bar bar" "lib canvas order" "lib canvas set";
}

/* bar */
.bar { grid-area: bar; display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s4); border-bottom: 1px solid var(--line); }
.bar__home { color: var(--mute); text-decoration: none; }
.bar__home:hover { color: var(--text); }
.bar__name { color: var(--text); }
.bar__hist { display: flex; gap: var(--s1); padding-left: var(--s3); border-left: 1px solid var(--line); }
.bar__photos { display: flex; align-items: center; gap: var(--s2); padding-left: var(--s3); border-left: 1px solid var(--line); }
.ph { width: 40px; height: 40px; border: 1px solid var(--line-2); overflow: hidden; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph.is-on { border-color: var(--acid); }
.phw { position: relative; display: block; }
.ph__x { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; line-height: 18px; background: var(--bg); color: var(--mute); border: 1px solid var(--line-2); opacity: 0; }
.phw:hover .ph__x, .ph__x:focus-visible { opacity: 1; }
.ph__x:hover { color: var(--text); }
.ph--add { color: var(--mute); }
.bar__out { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.btn { min-height: 40px; padding: 0 var(--s4); border: 1px solid var(--line-2); color: var(--text); }
.btn:hover { border-color: var(--mute); }
.btn--main { background: var(--acid); border-color: var(--acid); color: var(--bg); }
.ibtn { width: 40px; height: 40px; display: grid; place-items: center; color: var(--mute); }
.ibtn:hover { color: var(--text); background: var(--raise); }
.ibtn--txt { width: auto; padding: 0 var(--s2); }
.link { color: var(--mute); min-height: 40px; }
.link:hover { color: var(--text); text-decoration: underline; }

/* panels */
.lib, .order, .set { background: var(--panel); }
.lib { grid-area: lib; border-right: 1px solid var(--line); padding: var(--s3); overflow-y: auto; }
.order { grid-area: order; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: var(--s3); max-height: 50dvh; overflow-y: auto; }
.set { grid-area: set; border-left: 1px solid var(--line); padding: var(--s4); overflow-y: auto; }
.h { font-size: var(--t); font-weight: 400; color: var(--mute); margin-bottom: var(--s3); }
.set .h { font-size: var(--t-h); color: var(--text); margin-bottom: var(--s2); }

/* library */
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: var(--s3); border-bottom: 1px solid var(--line); }
.tabs button { min-height: 44px; color: var(--mute); }
.tabs button[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--acid); }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-2); margin-bottom: var(--s3); }
.seg button { min-height: 40px; color: var(--mute); }
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--text); }
.grp { color: var(--mute); margin: var(--s4) 0 var(--s2); }
.grp:first-child { margin-top: var(--s1); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.card { position: relative; display: grid; align-content: start; gap: var(--s1); padding: var(--s2); text-align: left; border: 1px solid var(--line); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--paper); margin-bottom: var(--s1); }
.card__d { color: var(--mute); line-height: 1.3; }
.card:hover { background: var(--raise); border-color: var(--line-2); }
.card__add { position: absolute; top: var(--s3); left: var(--s3); right: var(--s3); padding: var(--s1); text-align: center; background: var(--bg); color: var(--text); opacity: 0; }
.card:hover .card__add, .card:focus-visible .card__add { opacity: 1; }
.card--save { place-content: center; text-align: center; min-height: 160px; color: var(--mute); border-style: dashed; }
.card img:not([src]) { background: var(--raise); }
.card__x { position: absolute; top: var(--s3); right: var(--s3); width: 32px; height: 32px; background: var(--bg); color: var(--mute); opacity: 0; }
.card:hover .card__x, .card:focus-within .card__x { opacity: 1; }
.card__x:hover { color: var(--text); }
.namer { display: grid; gap: var(--s2); padding: var(--s2); border: 1px solid var(--acid); grid-column: 1 / -1; }
.namer input { font: inherit; padding: var(--s2); background: var(--bg); color: var(--text); border: 1px solid var(--line-2); }
.namer div { display: flex; gap: var(--s2); }
.sync { margin-top: var(--s4); color: var(--faint); }
.card--save:hover { color: var(--text); }

/* canvas */
.canvas { grid-area: canvas; grid-row: 2 / span 2; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #0f0f0f; min-width: 0; }
.canvas__tools { display: flex; align-items: center; gap: var(--s1); padding: var(--s2) var(--s3); }
.canvas__where { color: var(--mute); margin-left: var(--s3); }
.canvas__where button { color: var(--text); text-decoration: underline; min-height: 40px; }
.canvas__busy { margin-left: auto; color: var(--mute); }
.canvas__busy::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: var(--s2); border-radius: 50%; background: var(--acid); opacity: 0; }
.canvas__busy.is-on::before { opacity: 1; animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.2; } }
.canvas__stage { position: relative; min-height: 0; overflow: hidden; }
.canvas__scroll { position: absolute; inset: var(--s4); display: grid; grid-template: 100% / 100%; place-items: center; }
.canvas__scroll img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; background: var(--paper); }
.canvas__scroll img:not([src]) { display: none; }
.canvas__stage.is-full .canvas__scroll { overflow: auto; grid-template: auto / auto; place-content: start center; }
.canvas__stage.is-full .canvas__scroll img { max-width: none; max-height: none; }
.canvas__msg { position: absolute; left: var(--s4); right: var(--s4); bottom: var(--s4); padding: var(--s2) var(--s3); background: #3a1414; color: #ffd9d9; }
.canvas__msg:empty { display: none; }
.crop { position: absolute; inset: 0; }
.crop__box { position: absolute; left: var(--l, 10%); top: var(--t, 10%); width: var(--w, 80%); height: var(--h, 80%); border: 2px dashed var(--acid); box-shadow: 0 0 0 9999px rgba(12, 12, 12, 0.6); cursor: move; touch-action: none; }
.crop__box i { position: absolute; width: 18px; height: 18px; background: var(--acid); }
.crop__box i[data-h="nw"] { left: -10px; top: -10px; cursor: nwse-resize; }
.crop__box i[data-h="ne"] { right: -10px; top: -10px; cursor: nesw-resize; }
.crop__box i[data-h="sw"] { left: -10px; bottom: -10px; cursor: nesw-resize; }
.crop__box i[data-h="se"] { right: -10px; bottom: -10px; cursor: nwse-resize; }
.grid-all { position: absolute; inset: var(--s4); overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s3); align-content: start; }
.all__head { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: var(--s2); }
.grid-all .all__item { display: grid; gap: var(--s1); text-align: left; border: 1px solid var(--line); padding: var(--s2); }
.grid-all .all__item:hover { border-color: var(--mute); }
.grid-all img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: var(--paper); }
.grid-all span { color: var(--mute); }
.snaps { display: flex; gap: var(--s2); padding: var(--s2) var(--s3) var(--s3); border-top: 1px solid var(--line); overflow-x: auto; }
.snap { flex: 0 0 64px; height: 64px; border: 1px solid var(--line-2); }
.snap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.snap.is-on { border-color: var(--acid); }
.snap--add { flex: 0 0 auto; padding: 0 var(--s4); color: var(--mute); border-style: dashed; }
.snap { position: relative; }
.snap__x { position: absolute; top: 0; right: 0; width: 24px; height: 24px; background: var(--bg); color: var(--mute); opacity: 0; }
.snap:hover .snap__x, .snap:focus-within .snap__x { opacity: 1; }
.snap--add:hover { color: var(--text); }

/* empty state: the whole centre is the drop zone */
.drop { display: none; }
.app[data-state="empty"] .drop { position: absolute; inset: var(--s6); display: grid; place-content: center; gap: var(--s2); text-align: center; border: 2px dashed var(--line-2); cursor: pointer; }
.app[data-state="empty"] .drop:hover, .app[data-state="empty"] .drop:focus-visible, .drop.is-over { border-color: var(--acid); outline: none; }
.drop__big { font-size: var(--t-h); }
.drop__small { color: var(--mute); }
.app[data-state="empty"] { grid-template-columns: var(--lib) minmax(0, 1fr); grid-template-areas: "bar bar" "lib canvas" "lib canvas"; }
.app[data-state="empty"] .order, .app[data-state="empty"] .set { display: none; }
.app[data-state="empty"] .snaps, .app[data-state="empty"] .canvas__tools,
.app[data-state="empty"] .bar__hist, .app[data-state="empty"] .bar__out { visibility: hidden; }
.app.is-dropping .drop { display: grid; position: absolute; inset: var(--s4); place-content: center; background: rgba(12, 12, 12, 0.85); border: 2px dashed var(--acid); z-index: 5; }

/* order */
.end { width: 100%; display: flex; align-items: baseline; gap: var(--s2); min-height: 36px; padding: 0 var(--s2); text-align: left; color: var(--mute); }
.end span { color: var(--faint); }
.end:hover { color: var(--text); }
.end.is-sel { color: var(--text); box-shadow: inset 2px 0 0 var(--acid); }
.flow { list-style: none; display: grid; gap: var(--s1); margin: var(--s1) 0 var(--s1) var(--s2); padding-left: var(--s2); border-left: 1px solid var(--line-2); }
.row { display: flex; align-items: center; gap: var(--s2); padding: var(--s1); min-height: 52px; border: 1px solid transparent; cursor: pointer; }
.row img { width: 40px; height: 40px; object-fit: cover; background: var(--paper); flex: 0 0 auto; }
.row__grip { color: var(--faint); letter-spacing: -0.2em; cursor: grab; padding: 0 var(--s1); }
.row__n { flex: 1; min-width: 0; min-height: 40px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__n svg { width: 16px; height: 16px; vertical-align: -2px; }
.row__i { color: var(--mute); margin-right: var(--s2); font-variant-numeric: tabular-nums; }
.row .ibtn { width: 32px; height: 32px; flex: 0 0 auto; }
.row .ibtn svg { width: 18px; height: 18px; }
.row__hov { opacity: 0; }
.row:hover .row__hov, .row:focus-within .row__hov { opacity: 1; }
.row:hover { background: var(--raise); }
.row.is-sel { border-color: var(--acid); background: var(--raise); }
.row.is-off img, .row.is-off .row__n { opacity: 0.35; }
.row img:not([src]) { background: var(--raise); }
.row.is-drag { opacity: 0.35; }
.row.drop-above { box-shadow: 0 -2px 0 var(--acid); }
.row.drop-below { box-shadow: 0 2px 0 var(--acid); }
.flow.is-target { outline: 1px dashed var(--acid); outline-offset: 2px; }
.row__warn { color: #e0a24a; }
.flow__empty { color: var(--faint); padding: var(--s2) var(--s3); }
.flow__empty[hidden] { display: none; }

/* settings */
.set__d { color: var(--mute); margin-bottom: var(--s6); }
.rng { display: grid; gap: var(--s1); margin-bottom: var(--s6); }
.rng__top { display: flex; justify-content: space-between; }
.rng output { color: var(--text); font-variant-numeric: tabular-nums; }
.rng input { width: 100%; accent-color: var(--acid); height: 24px; }
.rng__ends { display: flex; justify-content: space-between; color: var(--faint); }
.set__hint { color: var(--faint); margin-bottom: var(--s3); }
.set__warn { color: #e0a24a; margin-bottom: var(--s4); }
.set__thumb { display: block; width: 100%; max-height: 160px; object-fit: contain; background: var(--paper); margin-bottom: var(--s4); }
.set__thumb:not([src]) { display: none; }
.chk { display: flex; align-items: center; gap: var(--s2); min-height: 44px; margin-bottom: var(--s3); cursor: pointer; }
.chk input { accent-color: var(--acid); width: 18px; height: 18px; }
.radio.is-off { opacity: 0.4; cursor: default; }
.swatch input { width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; -webkit-appearance: none; appearance: none; }
.swatch input::-webkit-color-swatch-wrapper { padding: 0; }
.swatch input::-webkit-color-swatch { border: 0; }
.swatch input::-moz-color-swatch { border: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-bottom: var(--s3); }
.radio { display: flex; align-items: center; gap: var(--s2); min-height: 44px; cursor: pointer; }
.radio input { accent-color: var(--acid); width: 18px; height: 18px; }
.swatch { width: 32px; height: 32px; border: 1px solid var(--line-2); margin-left: auto; overflow: hidden; }

/* toast */
.toast { position: fixed; left: 50%; bottom: var(--s6); transform: translate(-50%, 8px); padding: var(--s2) var(--s4); background: var(--text); color: var(--bg); opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; z-index: 60; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.has-act.is-on { pointer-events: auto; }
.toast__act { margin-left: var(--s2); text-decoration: underline; min-height: 32px; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
  .canvas__busy.is-on::before { animation: none; }
}

/* phone and narrow tablet: picture on top (sticks while you scroll), then order, settings, library */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "bar" "canvas" "order" "set" "lib"; }
  .app[data-state="empty"] { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "canvas" "lib"; }
  .bar { flex-wrap: wrap; gap: var(--s2); padding: var(--s2) var(--s3); }
  .bar__photos { order: 3; flex-basis: 100%; margin: 0; padding: 0; border: 0; overflow-x: auto; }
  .bar__photos .link { white-space: nowrap; }
  .bar__hist { padding-left: var(--s2); }
  .bar__out .btn { padding: 0 var(--s3); }
  .canvas { grid-row: auto; position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--line); }
  .canvas__stage { height: 42dvh; }
  .app[data-state="empty"] .canvas__stage { height: 60dvh; }
  .order { max-height: none; border-left: 0; }
  .set { border-left: 0; }
  .lib { border-right: 0; border-top: 1px solid var(--line); }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card__d { display: none; }
}
@media (max-width: 480px) {
  .bar__home { display: none; }
  .bar__out .btn { min-height: 40px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
