/* Ornament 3D. Tokens, bar, buttons, .seg, .rng, .modes, .menu, .dlg come from editor.css;
   only the layout and the controls this page adds live here. The object is the hero: the
   chrome around it stays quiet, acid only for what is selected and the main action.
   Desktop: rail | sheet | stage | sheet | rail (shell.js). Phone: stage on top, a tab row, one sheet below. */
:root { --v3-light: #ece9e2; --v3-shade: rgba(12, 12, 12, 0.72); }
.v3 [hidden] { display: none; }   /* .rng, .seg and .menu set display; the hidden attribute must win */
body:has(.v3) { overflow: hidden; }

.v3 {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: var(--rail) var(--col-l) minmax(0, 1fr) var(--col-r) var(--rail);
  grid-template-rows: var(--bar) minmax(0, 1fr) auto;
  grid-template-areas: "bar bar bar bar bar" "rl lib stage set rr" "tl tl tl tl tl";
  column-gap: 0;
}

/* ---------- bar ---------- */
.v3__bar { grid-area: bar; gap: var(--s3); }
.v3__bar .bar__hist { padding-left: var(--s3); }

/* ---------- left: picture + library (a sheet; the rail picks which part shows) ---------- */
.v3__lib { grid-area: lib; }
.v3__libbody { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s4); }
.pics__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
.pics__h { margin: 0; color: var(--text); }
.pics__own { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.pics__own:focus-within { outline: 2px solid var(--acid); outline-offset: 2px; }
.pics__tools { display: flex; align-items: baseline; gap: var(--s2); }
.pics__cam { border: 0; background: none; color: inherit; font: inherit; }
.pics__cam:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
.pic__mark { position: absolute; top: var(--s1); left: var(--s1); padding: 0 var(--s2); border-radius: var(--s1); background: var(--bg); color: var(--text); font-size: 11px; line-height: 18px; pointer-events: none; }
.pics__row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.pic { position: relative; min-width: 0; display: grid; gap: var(--s1); padding: var(--s1); text-align: left; border: 1px solid var(--line); }
.pic__sub { display: block; color: var(--mute); }
.pic img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--bg); }
.pic__n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mute); padding: 0 var(--s1) var(--s1); line-height: 1.25; }
.pic:hover { border-color: var(--line-2); }
.pic:hover .pic__n { color: var(--text); }
.pic[aria-pressed="true"] { border-color: var(--acid); }
.pic[aria-pressed="true"] .pic__n { color: var(--text); }
.pics__note { margin-top: var(--s3); color: var(--mute); line-height: 1.35; }

.v3__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.v3__card { gap: var(--s2); padding: var(--s1); }
.v3__card img { height: auto; aspect-ratio: 4 / 3; margin: 0; background: var(--bg); }   /* height attr would beat aspect-ratio */
.v3__card img:not([src]) {   /* the preview is still being drawn */
  background: linear-gradient(100deg, var(--bg) 30%, var(--raise) 50%, var(--bg) 70%) 0 0 / 300% 100%;
  animation: v3-wait 1.4s linear infinite;
}
@keyframes v3-wait { to { background-position: -150% 0; } }
.v3__cardtext { display: grid; gap: 2px; padding: 0 var(--s1) var(--s1); }
.v3__card .card__n { line-height: 1.25; hyphens: auto; overflow-wrap: anywhere; }
.v3__cardsub { color: var(--mute); line-height: 1.25; }
.v3__card[aria-pressed="true"] { border-color: var(--acid); background: var(--raise); }

/* ---------- stage ---------- */
.v3__stage { --strip-h: 44px; grid-area: stage; position: relative; min-height: 0; min-width: 0; overflow: hidden; background: var(--bg); touch-action: none; }
.v3__stage:focus-visible { outline: 2px solid var(--acid); outline-offset: -2px; }
.v3__stage--light { background: var(--v3-light); }
.v3__stage--clear {   /* a checkerboard says "this background will be transparent" */
  background: repeating-conic-gradient(var(--raise) 0 25%, var(--bg) 0 50%) 0 0 / 24px 24px;
}
.v3__gl { display: block; width: 100%; height: 100%; cursor: grab; }
.v3__gl:active { cursor: grabbing; }

.v3__load {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s4); background: var(--v3-shade); color: var(--text); border: 1px solid var(--line-2);
  pointer-events: none;
}
.v3__spin { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--acid); border-radius: 50%; animation: v3-spin 0.8s linear infinite; }
@keyframes v3-spin { to { transform: rotate(360deg); } }

.v3__msg {
  position: absolute; left: var(--s4); bottom: calc(var(--s4) + var(--strip-h) + var(--s3)); right: var(--s4); max-width: 560px;
  display: grid; gap: var(--s3); padding: var(--s3) var(--s4);
  background: var(--panel); border: 1px solid var(--line-2); border-left: 2px solid var(--acid);
}
.v3__msg--error { border-left-color: #e0a24a; }
.v3__msgact { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.v3__msgact .btn { min-height: 44px; }
.v3__msgx { margin-left: auto; width: 44px; height: 44px; font-size: var(--t-h); }

.v3__hint {
  position: absolute; left: 50%; top: var(--s4); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 2 * var(--s4)); padding: var(--s1) var(--s3); background: var(--v3-shade); color: var(--mute); pointer-events: none; text-align: center;
}

/* the strip at the foot of the stage: skin.css (the material), shell.js (the behaviour) */
.v3__strip { position: absolute; left: 0; right: 0; bottom: var(--s4); width: max-content; max-width: calc(100% - 2 * var(--s4)); margin-inline: auto; display: flex; align-items: center; }

.v3__rec {
  position: absolute; left: 50%; top: var(--s4); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s3); padding: var(--s1) var(--s2) var(--s1) var(--s4);
  background: var(--panel); border: 1px solid var(--line-2); white-space: nowrap;
}
.v3__recdot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d; animation: pulse 1s ease-in-out infinite; }
.v3__recbar { width: 96px; height: 2px; background: var(--line-2); overflow: hidden; }
.v3__recbar i { --w: 0; display: block; height: 100%; background: var(--text); transform: scaleX(var(--w)); transform-origin: left; transition: transform 0.2s linear; }
.v3__rec .link { min-height: 44px; padding: 0 var(--s2); }

.v3__drop {
  position: absolute; inset: var(--s4); z-index: 5; display: grid; place-items: center;
  background: var(--v3-shade); border: 2px dashed var(--acid); color: var(--text); font-size: var(--t-h); text-align: center; padding: var(--s6);
  pointer-events: none;
}

/* ---------- right: sheets. Settings is one of them; Эффект, Свет and Глубина fill theirs elsewhere ---------- */
.v3__set, .v3__rs { grid-area: set; }
.set3__act { display: inline-flex; gap: var(--s1); }
.set3__h { margin-right: auto; font-size: var(--t-h); font-weight: 400; }
.set3__lead { color: var(--mute); line-height: 1.4; margin-bottom: var(--s2); }
.grp3 { padding-top: var(--s4); margin-top: var(--s4); border-top: 1px solid var(--line); }
.grp3__h { font-size: var(--t); font-weight: 400; color: var(--mute); margin-bottom: var(--s3); }
.v3__rng { margin-bottom: var(--s4); }
.v3__rng:last-child { margin-bottom: 0; }
.v3__seg { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
.v3__seg button { min-height: 44px; padding: 0 var(--s1); }
.v3__row { display: flex; align-items: center; gap: var(--s3); min-height: 44px; cursor: pointer; }
.v3__check { width: 20px; height: 20px; accent-color: var(--acid); flex: 0 0 auto; }

.tints { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 0; margin: calc(-1 * var(--s1)) 0 var(--s3); }
.tint { position: relative; height: 44px; display: grid; place-items: center; cursor: pointer; }
.tint::before { content: ""; width: 26px; height: 26px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.tint[aria-pressed="true"]::before, .tint--own.is-on::before { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.tint--own::before { background: conic-gradient(#e5484d, #e8e80c, #7be0b8, #7cc4ff, #b48cff, #e5484d); }
.tint--own.is-on::before { background: var(--c); }
.tint:focus-within::before, .tint:focus-visible::before { outline: 2px solid var(--acid); outline-offset: 4px; }
.tint:focus-visible { outline: none; }

/* ---------- phone tabs (hidden on wide screens: the rails do this there) ---------- */
.v3__tabs { display: none; }

/* ---------- phone and narrow tablet: stage on top, a tab strip, one section below ---------- */
@media (max-width: 899px) {
  .v3 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto minmax(0, 40%);
    grid-template-areas: "bar" "stage" "tl" "tabs" "panel";
  }
  .v3__bar { min-height: 52px; padding: 0 var(--s2) 0 0; gap: var(--s2); }
  .v3__bar .bar__hist { display: none; }
  .v3__bar .bar__out { gap: var(--s1); }
  .v3__bar .dl__btn { padding: 0 var(--s3); }
  .modes__a { padding: 0 var(--s3); }
  .menu { position: fixed; left: var(--s2); right: var(--s2); top: 56px; width: auto; }

  .rail { display: none; }
  .v3__tabs {
    grid-area: tabs; display: flex; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  }
  .v3__tabs::-webkit-scrollbar { display: none; }
  .v3__tabs button { flex: 0 0 auto; min-height: 48px; padding: 0 var(--s4); color: var(--mute); white-space: nowrap; }
  .v3__tabs button[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--acid); }

  .v3__lib, .v3__set, .v3__rs { grid-area: panel; }
  .v3__libbody { padding: var(--s3); gap: var(--s3); }
  .v3__strip { bottom: var(--s2); }
  .v3__stage { --strip-h: 52px; }
  .pics__row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .v3__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .v3__msg { left: var(--s2); right: var(--s2); bottom: calc(var(--s2) + var(--strip-h) + var(--s2)); max-width: none; padding: var(--s2) var(--s3); }
  .v3__hint { top: var(--s2); }
}
@media (min-width: 600px) and (max-width: 899px) {
  .v3__grid, .pics__row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .v3__bar .bar__hist { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  .v3__card img:not([src]) { animation: none; }
  .v3__spin { animation-duration: 2.4s; }
  .v3__recdot { animation: none; }
  .v3__recbar i { transition: none; }
}

/* settings: this effect first, then what is the same for every effect */
.grp3--fx .grp3__h { color: var(--text); font-size: var(--t-h); }
.set3__common { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line-2); color: var(--mute); }
.set3__common + .grp3 { border-top: 0; margin-top: var(--s2); padding-top: 0; }
