/* Экран «Кадр» по Human Interface Guidelines: системный шрифт, группы списков,
   цели от 44px, светлая и тёмная тема. На странице заказа картинка и кнопки стоят
   друг под другом. В ленте имя, лайк и текст лежат поверх плитки.
   Зависимость: index.html, app.js, gallery.html, gallery.js. */

:root {
  color-scheme: light;
  --bg: #e8e2d6;
  --card: #f4f0e8;
  --label: #1c1814;
  --secondary: rgba(48, 38, 28, 0.62);
  --tertiary: rgba(48, 38, 28, 0.34);
  --sep: rgba(48, 38, 28, 0.14);
  --fill: rgba(48, 38, 28, 0.06);
  --blue: #b8431f;
  --blue-press: #8c3014;
  --red: #a33b32;
  --green: #2f6b45;
  --selected: rgba(184, 67, 31, 0.12);
  --stage: #ddd4c6;
  --shadow: none;
  --wash: rgba(184, 67, 31, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #12100e;
    --card: #1c1916;
    --label: #f3eee6;
    --secondary: rgba(243, 238, 230, 0.62);
    --tertiary: rgba(243, 238, 230, 0.32);
    --sep: rgba(243, 238, 230, 0.12);
    --fill: rgba(243, 238, 230, 0.06);
    --blue: #e37a45;
    --blue-press: #f0a07a;
    --red: #e06a62;
    --green: #7dba8a;
    --selected: rgba(227, 122, 69, 0.16);
    --stage: #241f1b;
    --shadow: none;
    --wash: rgba(227, 122, 69, 0.2);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 520px at 100% 0%, var(--wash), transparent 60%),
    var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.3;
}

body {
  padding: 20px 16px max(24px, env(safe-area-inset-bottom));
}

.app {
  width: min(1080px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.machine, .form-note, .empty, .viewer-line {
  margin: 0;
  color: var(--secondary);
  font-size: 15px;
  line-height: 1.35;
}

.form-note { color: var(--red); min-height: 1.2em; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.viewer, .orders, .composer {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.viewer {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer .empty {
  margin: auto;
  padding: 32px 20px;
  text-align: center;
}

.frame {
  background: var(--stage);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(68vh, 760px);
  object-fit: contain;
}

.viewer-copy, .viewer-status {
  padding: 14px 16px 4px;
}

.viewer-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.viewer-line { margin-top: 4px; }

.viewer-status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 28px 20px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 16px;
}

.toolbar a, .toolbar button, .dl, .pair a, .send, .pick, .styles button {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0 14px;
}

.toolbar a, .dl, .pair a {
  background: var(--blue);
  color: #fff;
}

.toolbar button {
  background: var(--fill);
  color: var(--blue);
}

.toolbar button[aria-pressed="true"] {
  background: var(--blue);
  color: #fff;
}

.toolbar button.danger, .toolbar a.danger { color: var(--red); background: var(--fill); }

.orders {
  padding: 8px 0 12px;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.orders:empty { display: none; }

.group { margin: 0; padding: 0; }

.group h2 {
  margin: 12px 16px 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--secondary);
}

.group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.group li + li { box-shadow: inset 0 1px 0 var(--sep); }

.group li:has(button[aria-current="true"]) { background: var(--selected); }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 72px;
}

.open {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 72px;
  padding: 8px 8px 8px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--fill);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.thumb img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  display: block;
}

.copy { min-width: 0; }

.title {
  display: block;
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  display: block;
  margin-top: 2px;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.3;
}

.meta.now { color: var(--blue); }
.meta.done { color: var(--green); }
.meta.stop { color: var(--red); }

.downloads {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-right: 12px;
}

.downloads:empty { display: none; }

.dl { flex: 0 0 auto; }

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
}

.styles, .refs, .form-note, .tune { grid-column: 1 / -1; }

.tune-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
  font-weight: 600;
}

.tune output { color: var(--blue); font-variant-numeric: tabular-nums; }

.hint {
  margin: 0;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.35;
}

.size-k4 {
  color: var(--label);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: var(--blue);
}

.ratios, .sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ratios button, .sizes button {
  flex: 0 0 auto;
  width: auto;
  min-height: 44px;
  padding: 0 2px;
  margin-right: 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 transparent;
}

.ratios button[aria-checked="true"], .sizes button[aria-checked="true"] {
  background: transparent;
  color: var(--label);
  box-shadow: inset 0 -2px 0 var(--blue);
}

/* Ячейка соотношения: серый квадрат и внутри фигура кадра.
   Зависимость: paintRatios в app.js. */
.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}

.ratio-block, .styles, .refs, .form-note, .tune { grid-column: 1 / -1; }

.sizes {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.ratios {
  gap: 10px;
  padding-bottom: 2px;
}

.ratios button.ratio {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 52px;
  min-height: 76px;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}

.ratios button.ratio[aria-checked="true"] {
  background: transparent;
  color: var(--label);
  box-shadow: none;
}

.ratio-well {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--label) 10%, var(--card));
  border: 2px solid transparent;
  display: grid;
  place-items: center;
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), border-color 180ms;
}

.ratio-mark {
  display: block;
  border-radius: 4px;
  background: color-mix(in srgb, var(--label) 46%, transparent);
}

.ratios button.ratio[aria-checked="true"] .ratio-well {
  border-color: var(--label);
  transform: scale(0.92);
}

.ratios button.ratio:active .ratio-well { transform: scale(0.86); }

.share-pick { display: flex; gap: 8px; }

.share-pick button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 2px;
  margin-right: 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 -1px 0 transparent;
}

.share-pick button[aria-checked="true"] {
  background: transparent;
  color: var(--label);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.share-box { padding: 0 16px 16px; }

.share-url {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  background: var(--stage);
}

.pair:has(figure:only-child) { grid-template-columns: 1fr; }

.pair figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.pair img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(62vh, 720px);
  object-fit: contain;
  background: var(--stage);
}

.pair figcaption { text-align: center; }

.styles, .refs, .previews {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.styles button, .pick {
  flex: 0 0 auto;
  background: transparent;
  color: var(--secondary);
  font-weight: 600;
  border-radius: 0;
  padding: 0 2px;
  margin-right: 14px;
  box-shadow: inset 0 -1px 0 transparent;
}

.styles button[aria-checked="true"] {
  background: transparent;
  color: var(--label);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.pick {
  border-radius: 0;
  color: var(--label);
  box-shadow: inset 0 -1px 0 var(--sep);
}

.pick {
  position: relative;
  overflow: hidden;
}

.pick input {
  position: absolute;
  inset: 0;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}

.previews button {
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}

.library {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lib-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 76px;
}

.lib {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 76px;
  min-height: 96px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.lib img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  background: var(--stage);
  display: block;
}

.lib[aria-pressed="true"] img { outline: 2px solid var(--label); outline-offset: -2px; }

.lib[data-verdict="no"] { opacity: 0.45; }

.lib:disabled { cursor: default; }

.lib-drop {
  min-height: 28px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.previews img {
  width: 44px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

textarea {
  width: 100%;
  min-width: 0;
  resize: vertical;
  min-height: 92px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  padding: 0;
}

.send {
  background: var(--blue);
  color: #fff;
  min-width: 132px;
  border-radius: 10px;
}

.send:active, .toolbar a:active, .dl:active {
  background: var(--blue-press);
  transform: scale(0.97);
}
.send:disabled { opacity: 0.4; cursor: default; }

textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.spin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--tertiary);
  border-top-color: var(--blue);
  animation: turn 0.8s linear infinite;
}

.viewer-status .spin { width: 28px; height: 28px; }
.viewer-status .toolbar { padding: 4px 0 0; }

@media (max-width: 800px) {
  body { padding: 12px 12px max(16px, env(safe-area-inset-bottom)); }
  h1 { font-size: 28px; }
  .workspace { grid-template-columns: 1fr; }
  .orders { max-height: none; }
  .pair { grid-template-columns: 1fr; }
  .frame img, .pair img { max-height: 58vh; }
}

@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; border-color: var(--blue); }
}

@keyframes turn { to { transform: rotate(360deg); } }

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.top a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.comment-form input {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  color: var(--label);
  font: inherit;
  font-size: 17px;
  padding: 10px 12px;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Лента как плитка: картинки разной высоты, текст заказа на тени при наведении.
   Зависимость: gallery.js, функция tile. Открытая карточка /g/ эти классы не использует. */
.gallery-page { width: min(1280px, 100%); }

.gallery-page .styles { margin: 0 0 8px; }

.masonry {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 8px;
  gap: 10px;
  align-items: start;
}

.tile {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: var(--stage);
}

.tile-link {
  display: block;
  color: #fff;
  text-decoration: none;
}

.tile img {
  width: 100%;
  height: auto;
  display: block;
}

/* Пачка сравнения: плитка на две колонки, слева реф Shedevrum, справа наш кадр.
   Зависимость: gallery.js, класс tile-compare и поле ref. */
.tile-compare { grid-column: span 2; }

.compare {
  display: flex;
  gap: 3px;
  background: #111;
}

.compare-shot {
  position: relative;
  flex: 1;
  min-width: 0;
  background: #111;
}

.compare-shot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
}

.compare-tag {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
}


.tile-shade {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28%;
  display: flex;
  align-items: flex-end;
  padding: 12px 14px 52px;
  border-radius: 0 0 16px 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, #000 100%);
  opacity: 0.12;
  pointer-events: none;
  transition: opacity 0.2s ease, height 0.25s ease;
}

.tile-prompt {
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  overflow: hidden;
  transition: opacity 0.25s ease;
}

.tile:hover .tile-shade,
.tile:focus-within .tile-shade {
  opacity: 1;
  height: 58%;
}

.tile:hover .tile-prompt,
.tile:focus-within .tile-prompt { opacity: 1; }

.tile-like {
  position: absolute;
  z-index: 3;
  left: 6px;
  bottom: 4px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.tile-like[aria-pressed="true"] { color: #ff453a; }

@media (min-width: 900px) {
  .masonry { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
  .masonry { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .tile-shade, .tile-prompt { transition: none; }
}

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-copy { padding: 14px 16px 0; }

.card-copy h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.comment-form button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  color: var(--blue);
  padding: 0 12px;
  cursor: pointer;
}

.comment-form {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}

.comment-form input { flex: 1; }

/* Световой стол. Зависимость: front.html, index.html, gallery.html.
   Одна бумага, один акцент на действие, выбранный пункт — черта, не плашка.
   Шапка на всю ширину, стекло поверх бумаги. */

body:has(.front),
body:has(.studio),
body:has(.gallery-page) {
  padding: 0 0 max(24px, env(safe-area-inset-bottom));
}

.rail {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  margin: 0;
  padding: 6px 28px;
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--sep);
}

.mark {
  color: var(--label);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.brandline {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-width: 0;
  flex-wrap: wrap;
}

.brandline h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--secondary);
}

.brandline .machine { font-size: 13px; }

.top-links, .rail nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.top-links a, .rail nav a {
  color: var(--label);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Переключатель языка. Зависимость: data-set-lang в i18n.js. */
.lang {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lang button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 0 2px;
}

.lang button[aria-pressed="true"] {
  color: var(--label);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.studio, .gallery-page {
  width: min(1440px, calc(100% - 36px));
  margin: 18px auto 0;
}

.gallery-page { width: min(1320px, calc(100% - 48px)); }

.studio {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  grid-template-areas:
    "menu desk"
    "menu view"
    "menu wall";
  gap: 18px 28px;
  align-items: start;
}

/* Боковое меню кабинета. Библиотека — страница /library, не окно поверх заказа.
   Зависимость: nav.side в index.html и library.html. */
.side {
  grid-area: menu;
  position: sticky;
  top: 62px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding-top: 8px;
}

.side a,
.side button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  padding: 0 2px;
  cursor: pointer;
}

.side [aria-current="page"] {
  box-shadow: inset 0 -2px 0 var(--blue);
}

.studio .workspace { display: contents; }

/* Карточка открытого кадра. Зависимость: show() в app.js, классы .pair и .result-foot.
   Та же ширина и скругление, что у формы. Кнопки внутри, не на фоне страницы. */
.studio .viewer {
  grid-area: view;
  width: min(960px, 100%);
  background: var(--card);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--label) 8%, transparent);
  border-radius: 20px;
  min-height: 0;
  padding: 8px;
}

.studio .pair {
  margin: 0;
  padding: 0;
  gap: 6px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
}

.studio .pair figure { gap: 0; background: var(--bg); }

.studio .pair img {
  max-height: min(46vh, 520px);
  background: var(--bg);
}

.studio .pair figcaption {
  padding: 8px 12px 10px;
  text-align: left;
}

.studio .pair figcaption a {
  background: transparent;
  color: var(--secondary);
  min-height: 28px;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
  font-weight: 600;
  width: fit-content;
}

.studio .pair figcaption a:active {
  background: transparent;
  color: var(--label);
  transform: none;
}

/* Выбор скачивания. Зависимость: saveBox в app.js, savePanel в gallery.js, save_box в server.py. */
.save {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding-top: 4px;
}

.studio .save,
.post-page .save { align-items: flex-start; }

.save-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 100%;
}

.save-row button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: var(--bg);
  color: var(--secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  width: auto;
}

.save-row button[aria-checked="true"] {
  background: var(--card);
  color: var(--label);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--label) 18%, transparent);
}

.save-go,
.save-open {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--bg);
  color: var(--label);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  width: auto;
}

/* Окно выбора под «Скачать». display только у [open]: иначе диалог виден
   сразу и close() его не прячет. Зависимость: dialog.save-pop в saveBox. */
.save-pop {
  position: fixed;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  width: min(320px, calc(100vw - 32px));
  margin: auto;
  padding: 42px 16px 16px;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--label);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.save-pop[open] {
  display: flex;
}

.save-pop::backdrop {
  background: color-mix(in srgb, #000 46%, transparent);
}

.save-x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--secondary);
  font-size: 22px;
  line-height: 1;
}

.save-pop .save-get {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin-top: 0;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--label);
  color: var(--bg);
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
  width: fit-content;
}

.save .hint {
  margin: 0;
  max-width: 36rem;
}

.studio .result-foot { padding: 14px 8px 6px; }

.studio .viewer-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.studio .viewer .toolbar {
  gap: 6px;
  padding: 12px 0 8px;
}

.studio .viewer .toolbar button,
.studio .viewer .toolbar a {
  background: var(--bg);
  color: var(--label);
  border-radius: 10px;
  min-height: 36px;
  font-size: 14px;
}

.studio .viewer .toolbar button[aria-pressed="true"] {
  background: var(--label);
  color: var(--bg);
}

.studio .viewer .toolbar button.danger {
  background: transparent;
  color: var(--red);
}

.studio .viewer .toolbar button:active,
.studio .viewer .toolbar a:active {
  background: var(--bg);
  color: var(--label);
  transform: none;
}

.studio .viewer .toolbar button[aria-pressed="true"]:active {
  background: var(--label);
  color: var(--bg);
}

/* Иконки под кадром: нравится, не то, править, удалить, поделиться. «Как референс» остаётся словом.
   Зависимость: .result-acts и actIcon в app.js. */
.studio .viewer .result-acts .icon {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.studio .viewer .result-acts .icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.studio .viewer .result-acts .icon[data-vote="like"][aria-pressed="true"] svg,
.studio .viewer .result-acts .icon[data-vote="dislike"][aria-pressed="true"] svg {
  fill: currentColor;
}

.studio .share-box { padding: 0 0 8px; }

.studio .share-url {
  margin: 0 0 4px;
  color: var(--secondary);
  font-size: 13px;
}

.studio .copy-note { margin: 0 0 6px; }

/* display:flex у панели сильнее атрибута hidden, поэтому закрытую панель прячем сами.
   Зависимость: .share-warn и data-act=share-ask в app.js. */
.studio .share-box [hidden] { display: none; }

/* Предупреждение перед публикацией закрытого кадра. Зависимость: .share-warn в app.js. */
.studio .share-warn {
  margin-top: 8px;
  padding: 12px 14px 10px;
  border-radius: 12px;
  background: var(--bg);
  scroll-margin: 88px 0 28px;
}

.studio .share-warn p {
  margin: 0 0 10px;
  color: var(--label);
  font-size: 14px;
  line-height: 1.4;
}

.studio .share-warn .toolbar { margin: 0; }

/* Пустая рамка не стоит над историей: форма уже наверху. Открытый кадр по-прежнему в .viewer. */
.studio .viewer:has(> .empty) { display: none; }

.studio .pair img { max-height: 38vh; }

.studio .viewer .empty {
  margin: 0;
  width: min(100%, 280px);
  aspect-ratio: 3 / 4;
  max-height: 38vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  background:
    linear-gradient(var(--label), var(--label)) 16px 16px / 18px 1px no-repeat,
    linear-gradient(var(--label), var(--label)) 16px 16px / 1px 18px no-repeat,
    linear-gradient(var(--label), var(--label)) calc(100% - 16px) 16px / 18px 1px no-repeat,
    linear-gradient(var(--label), var(--label)) calc(100% - 16px) 16px / 1px 18px no-repeat,
    linear-gradient(var(--label), var(--label)) 16px calc(100% - 16px) / 18px 1px no-repeat,
    linear-gradient(var(--label), var(--label)) 16px calc(100% - 16px) / 1px 18px no-repeat,
    linear-gradient(var(--label), var(--label)) calc(100% - 16px) calc(100% - 16px) / 18px 1px no-repeat,
    linear-gradient(var(--label), var(--label)) calc(100% - 16px) calc(100% - 16px) / 1px 18px no-repeat,
    var(--stage);
}

.studio .orders {
  grid-area: wall;
  background: transparent;
  box-shadow: none;
  border: 0;
  padding: 0;
  max-height: none;
}

.day h2 {
  margin: 4px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
}

.day + .day { margin-top: 18px; }

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 3px;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--stage);
  overflow: hidden;
  cursor: pointer;
  min-height: 0;
}

.cell img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cell .spin { margin: auto; }

/* Отказ модерации на месте снимка. Зависимость: censorCell в app.js. */
.cell.censor-cell { background: var(--fill); color: var(--secondary); }
.cell .censor {
  width: 46%;
  height: 46%;
  display: grid;
}
.cell .censor svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Обёртка миниатюры. Глаз снаружи кнопки: внутри кнопки браузер не показывает подсказку.
   Зависимость: .shot в wallCell, .cell-feed::after. */
.shot {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
}

.shot > .cell {
  width: 100%;
  height: 100%;
}

.shot:hover { z-index: 4; }

/* Глаз в углу миниатюры: этот кадр стоит в общей ленте. Второй файл пары без знака.
   Зависимость: .cell-feed и feedMark в app.js. */
.cell-feed {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(8, 6, 4, 0.72);
  color: #fff;
  pointer-events: auto;
}

.cell-feed::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(8, 6, 4, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}

.cell-feed:hover::after { opacity: 1; }

.cell-feed svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cell[aria-current="true"] { outline: 2px solid var(--label); outline-offset: -2px; }

/* Полный кадр раскрывается строкой под нажатой ячейкой, а не над стеной.
   Зависимость: .wall-detail и mountDetail в app.js. */
.wall-detail {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 8px 0;
  scroll-margin-top: 72px;
  overflow-anchor: none;
}

/* После анимации сетка 1fr больше не держит высоту: новое предупреждение не обрезается.
   Зависимость: класс fit в mountDetail и у «Опубликовать в ленте». */
.wall-detail.fit .wall-detail-clip { display: block; }
.wall-detail.fit .wall-detail-body { overflow: visible; }

.group .wall-detail { grid-column: auto; }

.wall-detail-clip {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s ease;
}

/* Класс shown, не open: open уже задаёт строке списка колонку 56px. */
.wall-detail.shown .wall-detail-clip { grid-template-rows: 1fr; }

.wall-detail-body {
  overflow: hidden;
  min-height: 0;
}

/* Класс viewer тянет grid-area: view. Здесь родитель — строка анимации, не сетка кабинета.
   Иначе кадр садится в чужую строку и окно раскрывается пустым. */
.wall-detail-body.viewer {
  grid-area: auto;
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .wall-detail-clip { transition: none; }
}

.cell:active { transform: scale(0.98); }

/* Пластина заказа. Зависимость: index.html, классы .plate-ask и .composer.
   Кнопка, навык и видимость живут внутри неё, а не на фоне страницы. */
.studio .composer {
  grid-area: desk;
  width: min(960px, 100%);
  background: var(--card);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--label) 8%, transparent);
  border-top: 0;
  border-radius: 20px;
  padding: 8px;
  gap: 0;
  align-items: stretch;
  scroll-margin-top: 72px;
}

.studio .plate-ask {
  position: relative;
  grid-column: 1 / -1;
  padding: 14px 14px 58px;
  border-radius: 14px;
  background: var(--bg);
}

/* Высоту ставит bindPromptCount по числу строк. Потолок 220px обрезал длинный промпт из «Править». */
.studio .plate-ask textarea,
.ask textarea {
  max-height: none;
  overflow: hidden;
  resize: none;
}

/* Нижняя полоса пластины: счётчик слева, «Добавить реф» тише, «Нарисовать» главная.
   Меню рефа падает вниз от своей кнопки и не раздвигает форму. Зависимость: .ask-actions в index.html. */
.studio .plate-ask .ask-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Маленькие кадры референса в той же полосе, что «Добавить реф». Пустой список не виден.
   Зависимость: #previews внутри .ask-actions, paintRefs в app.js. */
.studio .plate-ask .previews {
  flex-wrap: nowrap;
  gap: 6px;
  width: auto;
  max-width: 168px;
  overflow-x: auto;
}

.studio .plate-ask .previews .chip,
.studio .plate-ask .previews .chip img {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
}

.studio .plate-ask .previews .chip {
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
}

.studio .plate-ask .previews .chip img {
  border-radius: 8px;
  object-fit: cover;
}

.studio .plate-ask .add-ref .pick {
  min-height: 44px;
  padding: 0 12px;
  background: transparent;
  color: var(--label);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--label) 22%, transparent);
}

.studio .plate-ask .add-ref .pick[aria-expanded="true"] {
  background: var(--card);
  box-shadow: none;
}

.studio .plate-ask .add-menu {
  right: 0;
  left: auto;
}

.studio .plate-ask .send {
  position: static;
  background: var(--label);
  color: var(--bg);
}

@media (max-width: 640px) {
  .studio .plate-ask { padding-bottom: 104px; }
  .studio .plate-ask .ask-count { bottom: 64px; }
  .studio .plate-ask .ask-actions {
    left: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    row-gap: 8px;
  }
  /* На узком экране иконки встают своей строкой над кнопками, иначе ряд не влезает. */
  .studio .plate-ask:has(.previews:not(:empty)) { padding-bottom: 148px; }
  .studio .plate-ask:has(.previews:not(:empty)) .ask-count { bottom: 108px; }
  .studio .plate-ask:has(.previews:not(:empty)) .previews {
    flex: 1 0 100%;
    max-width: none;
    justify-content: flex-end;
  }
  .studio .plate-ask .send { min-width: 0; }
  /* Меню шире кнопки. На узком экране оно на всю полосу, иначе уезжает за левый край. */
  .studio .plate-ask .add-ref { position: static; }
  .studio .plate-ask .add-menu {
    left: 0;
    right: 0;
    width: auto;
  }
}

.studio .plate-ask .send:active {
  background: var(--label);
  transform: scale(0.97);
}

.studio .composer > .form-note:empty {
  display: none;
}

.studio .composer > .form-note,
.studio .composer > .ratio-block,
.studio .composer > .style-block,
.studio .composer > .tune {
  grid-column: 1 / -1;
  margin: 0 8px;
  padding: 14px 0;
  border-top: 1px solid var(--sep);
}

.studio .ratio-well {
  background: var(--bg);
}

.studio .composer .styles {
  gap: 4px;
}

.studio .composer .styles button {
  margin: 0;
  border-radius: 9px;
  box-shadow: none;
  min-height: 36px;
  padding: 0 12px;
}

.studio .style-block .styles {
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 4px;
  border-top: 0;
  border-radius: 12px;
  background: var(--bg);
  flex-wrap: wrap;
  overflow: visible;
}

.studio .composer .styles button[aria-checked="true"] {
  background: var(--card);
  color: var(--label);
  box-shadow: none;
}

.studio .share-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: min(520px, 100%);
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.studio .share-pick button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin: 0;
  min-height: 0;
  padding: 10px 12px 12px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--label);
  box-shadow: none;
  text-align: left;
}

.studio .share-pick button[aria-checked="true"] {
  background: var(--card);
  color: var(--label);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--label) 18%, transparent);
}

.share-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.share-note {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--secondary);
}

.studio .pick {
  margin: 0;
  border-radius: 10px;
  background: var(--bg);
  color: var(--label);
  box-shadow: none;
  padding: 0 14px;
}

.file-hide {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.add-ref { position: relative; }

.add-menu {
  position: absolute;
  z-index: 6;
  left: 0;
  top: calc(100% + 8px);
  width: min(320px, 78vw);
  padding: 12px;
  border-radius: 14px;
  background: var(--card);
  box-shadow:
    0 10px 28px rgba(28, 24, 20, 0.16),
    0 0 0 1px color-mix(in srgb, var(--label) 12%, transparent);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.add-menu[hidden] { display: none; }

.add-menu button {
  min-height: 44px;
  margin: 0;
  border: 0;
  border-radius: 10px;
  background: var(--bg);
  color: var(--label);
  font: inherit;
  font-weight: 600;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
  box-shadow: none;
}

.add-menu .hint { margin: 0 2px 8px; }

/* Короткий выбор уже лежащих фото, не уходя со страницы заказа.
   Зависимость: #lib-pick в index.html, paintPick в app.js. */
.lib-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.lib-pick[hidden] { display: none; }

.add-menu .lib-pick button {
  width: 64px;
  height: 64px;
  min-height: 64px;
  padding: 0;
  overflow: hidden;
  text-align: center;
}

.add-menu .lib-pick button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px var(--blue);
}

.add-menu .lib-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.studio .previews {
  flex-wrap: wrap;
  overflow: visible;
  width: 100%;
}

.studio .previews:empty { display: none; }

.studio .previews .chip {
  width: 84px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}

.studio .previews .chip img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 10px;
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

/* Согласие перед «Доступен всем». Зависимость: #share-dialog в index.html, closeShareAsk в app.js. */
#share-dialog {
  width: min(440px, calc(100vw - 32px));
  margin: auto;
  border: 0;
  border-radius: 20px;
  padding: 18px 18px 16px;
  background: var(--card);
  color: var(--label);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--label) 10%, transparent);
}

#share-dialog::backdrop { background: rgba(8, 6, 4, 0.72); }

#share-dialog h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 650;
}

#share-dialog p {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
}

#share-dialog .share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

#share-dialog .share-actions button {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  cursor: pointer;
}

#share-yes {
  background: var(--blue);
  color: #fff;
}

#share-no {
  background: var(--fill);
  color: var(--label);
}

/* Страница библиотеки занимает колонку заказа. Зависимость: library.html, .studio. */
.library-page {
  grid-area: desk;
  grid-row: 1 / span 3;
  min-width: 0;
}


.lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lib-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

#library-close {
  appearance: none;
  flex: 0 0 auto;
  min-height: 44px;
  margin: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#library-close:focus,
#library-close:focus-visible {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--label);
}

.library-page .lib-upload { margin-top: 8px; }

.library-page .library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 12px;
  width: 100%;
  max-height: 52vh;
  margin-top: 14px;
  overflow: auto;
}

.library-page .lib-card { width: auto; }

.library-page .lib-open {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--stage);
  cursor: pointer;
}

.library-page .lib-open img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.library-page .lib-open:disabled {
  display: grid;
  place-items: center;
  height: 120px;
  cursor: default;
  color: var(--secondary);
  background: var(--fill);
}

.library-page .lib-censor {
  width: 42px;
  height: 42px;
  display: grid;
}

.library-page .lib-censor svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.library-page .lib {
  width: 100%;
  min-height: 28px;
  padding: 4px 0 0;
}

.library-page .lib-open-word {
  min-height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.lib-look {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.lib-look[hidden] { display: none; }

.lib-look img {
  width: 100%;
  max-height: min(68vh, 720px);
  object-fit: contain;
  background: var(--stage);
  border-radius: 12px;
}

#lib-look-back {
  appearance: none;
  min-height: 44px;
  margin: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.library-page:has(.lib-look:not([hidden])) .lib-lead,
.library-page:has(.lib-look:not([hidden])) .lib-upload,
.library-page:has(.lib-look:not([hidden])) .library,
.library-page:has(.lib-look:not([hidden])) #library-note {
  display: none;
}

.lib-on {
  color: var(--blue);
  font-weight: 700;
}

.studio .field { order: 1; }
.studio .form-note { order: 3; }
.studio .ratio-block { order: 4; }
.studio .style-block { order: 5; }
.studio .styles { order: 5; }
.studio .tune { order: 6; }

.studio .tune {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
}

.studio .tune-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.studio .tune-top { max-width: 280px; }

/* Подпись и значок подсказки в одной группе, число остаётся справа.
   Зависимость: .tune-name в index.html. */
.studio .tune-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Тот же приём, что у глаза на миниатюре ленты: кружок и текст снизу при наведении.
   Зависимость: .cell-feed::after, creativity.help. */
.tip-mark {
  position: relative;
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(8, 6, 4, 0.72);
  color: #fff;
  flex: 0 0 auto;
  cursor: help;
  outline: none;
}

.tip-mark svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tip-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 6;
  width: max-content;
  max-width: 240px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(8, 6, 4, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
}

.tip-mark:hover .tip-pop,
.tip-mark:focus .tip-pop { opacity: 1; }
.studio .tune-item input[type="range"] { width: min(280px, 100%); height: 32px; }
.studio .tune-item .hint { margin: 0; }

textarea::placeholder { color: var(--tertiary); }

.front {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto;
}

.front-gallery {
  width: min(1280px, calc(100% - 56px));
  margin: 8px auto 28px;
}

.front-gallery h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
}

.sheet.front-make {
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  width: min(920px, calc(100% - 56px));
  max-width: 100%;
  min-width: 0;
  gap: 28px;
}

.poster-tight h1 { max-width: 16ch; }

/* Пластина заказа на главной. Та же сборка, что .studio .composer:
   поле внутри, секции через черту, стили плашкой. Зависимость: front.html #front-form.
   min-width: 0 не даёт ряду стилей раздвинуть страницу шире экрана. */
.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--card);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--label) 8%, transparent);
  border-radius: 20px;
  padding: 8px;
}

.desk .form-note,
.desk .ratio-block,
.desk .style-block,
.desk .styles { grid-column: 1 / -1; }

.desk > .form-note,
.desk > .ratio-block,
.desk > .style-block {
  margin: 0 8px;
  padding: 14px 0;
  border-top: 1px solid var(--sep);
}

.desk > .form-note:empty { display: none; }

.desk .style-block .field-label { margin-bottom: 8px; }

.desk .style-block .styles {
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 4px;
  border-top: 0;
  border-radius: 12px;
  background: var(--bg);
  flex-wrap: wrap;
  overflow: visible;
}

.desk .styles button {
  margin: 0;
  border-radius: 9px;
  box-shadow: none;
  min-height: 36px;
  padding: 0 12px;
}

.desk .styles button[aria-checked="true"] {
  background: var(--card);
  color: var(--label);
  box-shadow: none;
}

.desk .ratio-well { background: var(--bg); }

.desk textarea {
  width: 100%;
  min-width: 0;
  min-height: 92px;
  font-size: 26px;
}

.desk .field,
.desk .ask { min-width: 0; max-width: 100%; }

.desk .create {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--label);
  color: var(--bg);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.desk .create:active { transform: scale(0.97); }
.desk .create:disabled { opacity: 0.4; cursor: default; }

.sheet {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 380px);
  gap: 40px 56px;
  align-items: start;
  width: min(1180px, calc(100% - 56px));
  margin: 0 auto;
  padding: 28px 0 20px;
}

.kicker {
  margin: 0 0 18px;
  color: var(--secondary);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.poster { min-width: 0; }

.poster h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.7rem, 5.4vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: -0.045em;
  font-weight: 700;
}

.poster h1 span { display: block; }

.poster h1 .rest {
  color: var(--secondary);
  font-weight: 500;
}

.poster-tight h1 {
  max-width: 14ch;
  font-size: clamp(2.15rem, 4.2vw, 3.4rem);
}

.ask {
  position: relative;
  grid-column: 1 / -1;
  min-width: 0;
  padding: 14px 14px 58px;
  border-radius: 14px;
  background: var(--bg);
}

.ask textarea {
  min-height: 92px;
  background: transparent;
}

.ask .create {
  position: absolute;
  right: 12px;
  bottom: 12px;
}

/* Счётчик запроса. Тот же предел, что maxlength и проверка «длиннее 1500».
   Стоит в нижней полосе пластины, слева от кнопки. Зависимость: bindPromptCount. */
.ask-count {
  position: absolute;
  left: 16px;
  bottom: 26px;
  color: var(--tertiary);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1;
  pointer-events: none;
}

.ask-count.near { color: var(--blue); }
.ask-count.full { color: var(--red); }

.aside {
  max-width: 34rem;
  margin: 22px 0 0;
  color: var(--secondary);
  font-size: 1.05rem;
  line-height: 1.4;
}

.go {
  margin-top: 26px;
  min-height: 48px;
  padding: 0 18px;
  background: var(--label);
  color: var(--bg);
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.go:active { transform: scale(0.97); }

.plate { margin: 0; }

.mat {
  position: relative;
  padding: 18px 18px 14px;
  background: var(--card);
  border: 1px solid var(--sep);
  box-shadow: 0 18px 50px rgba(28, 24, 20, 0.18);
}

.print {
  position: relative;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #c98562;
}

.glow {
  position: absolute;
  inset: -10% 10% auto auto;
  width: 70%;
  height: 46%;
  background: radial-gradient(circle, rgba(255, 226, 186, 0.95), transparent 68%);
}

.window {
  position: absolute;
  top: 9%;
  left: 14%;
  width: 46%;
  height: 38%;
  background: linear-gradient(#d7e4ea, #f3d7b0);
  box-shadow: inset 0 0 0 8px #2a211c;
}

.sill {
  position: absolute;
  left: 0;
  right: 0;
  top: 52%;
  bottom: 0;
  background: linear-gradient(#6d4a38, #2a1c16 70%);
}

.cup {
  position: absolute;
  left: 22%;
  bottom: 16%;
  width: 18%;
  height: 14%;
  border-radius: 0 0 40% 40%;
  background: #f4efe6;
  box-shadow: inset 0 8px 0 #e7d3c0;
}

.mat figcaption {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--secondary);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.plate-line {
  margin: 12px 0 0;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.35;
}

.crafts {
  display: flex;
  flex-wrap: wrap;
  width: min(1180px, calc(100% - 56px));
  margin: 0 auto;
  padding: 8px 0 28px;
  border-top: 1px solid var(--sep);
}

.crafts a {
  color: var(--secondary);
  text-decoration: none;
  min-height: 44px;
  padding-right: 16px;
  margin-right: 16px;
  border-right: 1px solid var(--sep);
  display: inline-flex;
  align-items: center;
  font-size: 14px;
}

.crafts a:last-child { border-right: 0; margin-right: 0; }

.crafts a.here { color: var(--label); }

.sheet { animation: settle 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }

@keyframes settle {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 860px) {
  .rail { padding: 6px 14px; flex-wrap: wrap; gap: 4px 12px; }
  .rail nav { flex-wrap: wrap; gap: 4px 14px; }
  body:has(.studio) .rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    row-gap: 0;
    flex-wrap: nowrap;
  }
  body:has(.studio) .brandline { display: contents; }
  body:has(.studio) .mark { grid-column: 1; grid-row: 1; }
  body:has(.studio) .rail nav { grid-column: 2; grid-row: 1; justify-self: end; }
  body:has(.studio) .machine {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .library-page { grid-row: auto; }
  .library-page .library { max-height: none; }
  .lib-look img { max-height: calc(100dvh - 160px); }
  .sheet, .crafts, .front-gallery { width: calc(100% - 24px); }
  .sheet.front-make { width: calc(100% - 24px); }
  .sheet { grid-template-columns: 1fr; gap: 22px; padding-top: 18px; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .poster-tight h1 { font-size: clamp(2rem, 9vw, 2.8rem); }
  .plate { max-width: 230px; }
  .poster h1 { font-size: clamp(2.6rem, 12vw, 3.6rem); }
  .studio, .gallery-page { width: calc(100% - 28px); }
  .studio { grid-template-columns: 1fr; grid-template-areas: "menu" "desk" "view" "wall"; }
  .side {
    position: static;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0 18px;
    padding-top: 0;
    overflow-x: auto;
  }
  .side a,
  .side button {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
  }
  .studio .share-pick { grid-template-columns: 1fr; }
  .wall { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .studio .orders { border-left: 0; border-top: 1px solid var(--sep); padding: 12px 0 0; max-height: none; }
  .studio .viewer .empty { width: 100%; max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .go:active, .send:active, .desk .create:active, .cell:active, .ratios button.ratio:active .ratio-well,
  .ratios button.ratio[aria-checked="true"] .ratio-well { transform: none; }
  .ratio-well { transition: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .rail { background: var(--bg); backdrop-filter: none; }
}

/* Одна открытая карточка ленты. Зависимость: gallery.js, класс post-page на /g/<секрет>.
   Та же пластина, что у результата в кабинете: кадр, подпись, действия, комментарий. */
.post-page {
  width: min(840px, calc(100% - 36px));
}

.post-page .card {
  padding: 8px;
  border-radius: 20px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--label) 8%, transparent);
}

.post-page .pair {
  margin: 0;
  padding: 0;
  gap: 6px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
}

.post-page .pair figure { gap: 0; background: var(--bg); }

.post-page .pair img {
  max-height: min(78vh, 880px);
  background: var(--bg);
}

.post-page .pair figcaption {
  padding: 8px 12px 10px;
  text-align: left;
}

.post-page .pair figcaption a {
  background: transparent;
  color: var(--secondary);
  min-height: 28px;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
  width: fit-content;
}

.post-page .pair figcaption a:active {
  background: transparent;
  color: var(--label);
  transform: none;
}

.post-page .card-copy { padding: 14px 8px 0; }

.post-page .card-copy h2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.post-page .card .toolbar {
  gap: 6px;
  padding: 12px 8px 8px;
}

.post-page .card .toolbar button,
.post-page .card .toolbar a {
  background: var(--bg);
  color: var(--label);
  border-radius: 10px;
  min-height: 36px;
  font-size: 14px;
}

.post-page .card .toolbar button[aria-pressed="true"] {
  background: var(--label);
  color: var(--bg);
}

.post-page .card .toolbar button:active,
.post-page .card .toolbar a:active {
  background: var(--bg);
  color: var(--label);
  transform: none;
}

.post-page .card .toolbar button[aria-pressed="true"]:active {
  background: var(--label);
  color: var(--bg);
}

/* На открытом кадре лайк — сердце и число, поделиться — значок. Слово «Лайк 2» не пишем.
   Зависимость: .post-acts и mark в gallery.js. */
.post-page .card .toolbar.post-acts .icon {
  width: 40px;
  min-width: 40px;
  padding: 0;
  gap: 4px;
  background: transparent;
  color: var(--secondary);
}

.post-page .card .toolbar.post-acts .icon[data-like] {
  width: auto;
  padding: 0 8px;
}

.post-page .card .toolbar.post-acts .icon svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.post-page .card .toolbar.post-acts .like-n {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.post-page .card .toolbar.post-acts .icon[aria-pressed="true"] {
  background: transparent;
  color: #ff453a;
}

.post-page .card .toolbar.post-acts .icon[aria-pressed="true"] svg {
  fill: currentColor;
}

.post-page .card .toolbar.post-acts .icon:active,
.post-page .card .toolbar.post-acts .icon[aria-pressed="true"]:active {
  background: transparent;
  transform: none;
}

/* Страница правил. Зависимость: rules.html, блоки [data-lang] переключает i18n.js. */
.rules-page {
  width: min(720px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.rules h1 {
  margin: 0 0 12px;
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.rules .lead {
  margin: 0 0 8px;
  color: var(--secondary);
  font-size: 17px;
  line-height: 1.45;
}

.rules h2 {
  margin: 28px 0 8px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.rules p,
.rules li {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.45;
}

.rules ul {
  margin: 0 0 8px;
  padding-left: 1.2em;
}

.rules a { color: var(--label); }

/* Профиль кабинета. Та же карточка, что у кадра: фон, скругление, поля 44px.
   Зависимость: profile.html, profile.js. На главной этой формы нет. */
.profile-page {
  grid-area: desk;
  grid-row: 1 / span 3;
  width: min(440px, 100%);
  min-width: 0;
}

.reset-page {
  width: min(440px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.profile-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--label) 8%, transparent);
  padding: 22px 22px 18px;
}

.profile-card h1 {
  margin: 0 0 18px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.profile-card .field { margin: 0 0 14px; }

.profile-card input[type="text"],
.profile-card input[type="password"],
.profile-card input[type="email"] {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  color: var(--label);
  font: inherit;
  font-size: 16px;
}

.profile-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 4px 0 16px;
  color: var(--label);
  font-size: 15px;
  line-height: 1.35;
}

.profile-check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex: none;
}

.profile-check a { color: var(--label); }

.profile-card .send {
  width: 100%;
  min-height: 44px;
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.profile-switch {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.profile-who {
  margin: 0 0 8px;
  font-size: 17px;
}

.profile-who span { color: var(--secondary); }

