@font-face {
  font-family: Catalog Heading;
  src: url("/catalog-heading.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #10191f;
  --page-text: #f2f7f7;
  --page-muted: #c3d1d6;
  --page-line: #60737c;
  --text: #1b2b3c;
  --muted: #4b5e70;
  --surface: #fcfdfe;
  --field: #fff;
  --line: #d3dee6;
  --navy: #182f4b;
  --blue: #244f77;
  --green: #205e54;
  --accent-ui: var(--green);
  --ink: #1a2e3e;
  --light-text: #f4fbff;
  --header-line: #88a6bf;
  --header-focus: #a9dfca;
}

body { background: var(--page); color: var(--page-text); isolation: isolate; margin: 0; min-height: 100dvh; }
body[data-channel="primalform"] { --cover-radius: 50%; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(110deg, #0d171bcc, #152126a8), var(--catalog-art, none) center / cover no-repeat;
}
.masthead { color: var(--light-text); background: #112027dc; border-bottom: 1px solid var(--page-line); }
.mast-inner {
  max-width: 1180px; margin: auto; padding: 13px clamp(14px, 4vw, 36px);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 340px) auto;
  align-items: center; gap: 12px 24px;
}
#brand {
  color: inherit; margin: 0; font: 600 clamp(28px, 3.6vw, 43px)/.95 Catalog Heading, Georgia, serif;
  letter-spacing: -.025em; overflow-wrap: anywhere;
}
.masthead .catalog-search {
  display: flex; justify-content: flex-start; gap: 9px; min-width: 0;
  padding-inline: 12px; border: 1px solid var(--header-line); background: #f4fbff0b;
}
.masthead .catalog-search:focus-within { outline: 2px solid var(--header-focus); outline-offset: 2px; }
.masthead .catalog-search svg { flex: 0 0 17px; }
.masthead .catalog-search #q {
  width: 100%; color: inherit; background: transparent; padding: 4px 0;
  border: 0; border-radius: 0; min-height: 40px; outline: 0; font: inherit;
}
.masthead #q::placeholder { color: #d7e8f4; opacity: 1; }
.staff-controls { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.staff-controls:has(> [hidden]:first-child + [hidden]) { display: none; }
.staff-controls > * {
  font: inherit; font-size: .79rem; padding: 5px 8px; min-height: 40px;
  border: 1px solid var(--header-line); border-radius: 2px; color: inherit; background: var(--navy);
}
.staff-controls button:hover, .staff-controls button[aria-pressed=true] { background: #d9eee8; color: var(--navy); }

main { max-width: 1180px; padding: 24px clamp(14px, 4vw, 36px) 40px; }
#storeCatalog {
  display: grid; grid-template-columns: minmax(128px, 17.5%) minmax(0, 1fr);
  gap: clamp(18px, 3.75vw, 46px); align-items: start;
}
#storeCatalog:has(> #sectionRail[hidden]) { grid-template-columns: minmax(0, 1fr); }
#sectionRail { position: sticky; top: 16px; }
#nav {
  display: grid; gap: 2px; margin: 0; padding: 7px 0 0;
  border: 0;
  max-height: calc(100dvh - 40px); overflow: auto;
}
#nav button {
  background: transparent; min-height: 44px; border-radius: 0; color: var(--page-muted);
  text-align: left; padding: 5px 10px; white-space: normal; overflow-wrap: anywhere; border: 0;
}
#nav button:hover { color: #b4e9d8; }
#nav button.active { background: #214841; color: #d7f4e8; box-shadow: inset 2px 0 #83cfb9; font-weight: 700; }
.catalog-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-bottom: 7px; border-bottom: 1px solid var(--page-line); }
#sectionTitle { margin: 0; font: 600 clamp(28px, 5vw, 45px)/1 Catalog Heading, Georgia, serif; }
#count { margin: 0; font-size: .79rem; text-align: end; color: var(--page-muted); }
.catalog-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 9px 0 13px; }
#stock { gap: 5px; flex: 0 1 auto; min-width: 0; margin: 0; overflow-x: auto; flex-wrap: nowrap; padding: 3px; }
#stock:empty { display: none; }
#stock button, #sub button, #loadMore, .editor-toolbar button, #missingOnly {
  background: #202f36; color: var(--page-text); border: 1px solid var(--page-line); border-radius: 4px;
}
#stock button { white-space: nowrap; min-height: 36px; font-size: .75rem; }
#stock [aria-pressed=true], #sub button.active, #missingOnly[aria-pressed=true] {
  color: var(--light-text); background: var(--green); border-color: #7bc2ab;
}
#missingOnly { min-height: 36px; font-size: .75rem; }

#grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 2.45vw, 31px) clamp(6px, 1.65vw, 19px); }
#grid article { min-width: 0; border: 0; background: transparent; overflow: visible; }
#grid article button { width: 100%; align-items: center; height: auto; color: var(--page-text); border-radius: 10px; text-align: center; }
#grid article:focus-within { outline: 2px solid #99dfca; }
#grid .photo, #grid .missing-cover {
  width: min(100%, 220px); aspect-ratio: 1; border-radius: var(--cover-radius, 0); overflow: visible;
  background: #27383f; color: var(--page-muted); margin: 0 0 8px;
}
#grid .photo[data-tone]::after { border-width: 2px; }
#grid .photo img { border-radius: inherit; object-fit: cover; }
#grid .photo img:not([src]) { visibility: hidden; }
#grid .unavailable-photo::before { content: "Фото недоступно"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .72rem; }
#grid .photo .badge {
  inset: auto auto 0 50%; transform: translate(-50%, 25%); padding: 2px 6px;
  font-size: clamp(.58rem, 1.2vw, .73rem); border-radius: 20px; z-index: 1;
  max-width: 100%; width: max-content; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#grid strong { color: var(--page-text); font-size: clamp(.72rem, 1.7vw, .98rem); padding: 2px 3px 1px; text-align: center; }
#grid article:hover strong { color: #b4e9d8; }
#grid .lot-price { color: #a7e6d2; font-size: clamp(.71rem, 1.7vw, .98rem); padding: 3px 3px 0; text-align: center; }
#grid small { padding: 2px 3px 3px; color: var(--page-muted); text-align: center; }
#grid del { color: var(--page-muted); }
#detailPrice del { color: var(--muted); }
#loadMore { display: block; min-height: 42px; margin: 18px auto 0; padding-inline: 18px; }
#loadMore:hover, .editor-toolbar button:hover { border-color: #99dfca; }

#editorTools { margin: 0 0 16px; padding: 0 0 10px; border-bottom: 1px solid var(--page-line); }
#editorTools .editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.editor-toolbar button { min-height: 39px; padding-inline: 12px; }
.editor-toolbar #newLot { color: var(--light-text); background: var(--green); border-color: #7bc2ab; }
#channel { color: var(--page-muted); }
dialog { color: var(--text); background: var(--surface); border-color: var(--line); }
dialog button, dialog input, dialog select, dialog textarea, #mobileSub {
  color: var(--text); background: var(--field); border-color: var(--line);
}
dialog a { color: var(--blue); }
dialog .edit-group, dialog .edit-primary, dialog #actions { background: var(--surface); border-color: var(--line); }
.management-dialog#theme {
  color-scheme: dark; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 70px #11284040;
}
.management-dialog#theme {
  width: min(590px, calc(100vw - 20px)); max-height: 90dvh; padding: clamp(14px, 4vw, 26px);
}
.management-dialog::backdrop, #detail::backdrop { background: #142a40a6; }
.management-dialog .management-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px;
}
.management-dialog .management-head h2, #theme .management-head h2 {
  color: var(--text); margin: 0; font: 600 31px/1.1 Catalog Heading, Georgia, serif;
}
.management-dialog button, .management-dialog input { min-height: 40px; border-radius: 5px; }
.management-dialog input[type=text], #folderName, .folder-row form input { font-size: 16px; }
.management-dialog input::placeholder { color: var(--muted); opacity: 1; }
.management-dialog .quiet-action { border-color: transparent; background: transparent; color: var(--blue); }
.management-dialog .primary-action, #theme .folder-row button[type=submit], #themeForm button.primary-action, #detail #actions button {
  color: #fff; background: var(--green); border-color: var(--green);
}
.management-dialog button:hover { border-color: var(--green); }
#theme #folderCreate { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; margin: 0 0 13px; }
#theme #folderCreate input { min-height: 44px; }
#folderFeedback, #themeError { color: var(--accent-ui); font-size: .88rem; margin: 8px 0; }
#themeError:empty { display: none; }
#themeError { color: #ffb6c0; margin-right: auto; }
.folder-list { border-block: 1px solid var(--line); }
.folder-list > p { margin: 0; padding: 9px 2px; color: var(--muted); font-size: .85rem; }
.folder-list .folder-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  gap: 8px; padding: 8px 2px; margin: 0; border: 0; border-radius: 0; background: transparent;
}
.folder-list .folder-row + .folder-row { border-top: 1px solid var(--line); }
.folder-info strong { color: var(--text); font-weight: 650; }
.folder-info .folder-link {
  display: block; min-height: 0; max-width: 100%; padding: 2px 0;
  border: 0; background: transparent; text-align: left; overflow-wrap: anywhere;
}
.folder-info .folder-link:hover { text-decoration: underline; text-underline-offset: .15em; }
.folder-info small, .folder-info p { color: var(--muted); margin: 0; }
.folder-info p { font-size: .8rem; }
.folder-row > form { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.folder-row .folder-actions { margin: 0; justify-content: flex-end; gap: 3px; }
.folder-row .folder-actions button { min-height: 40px; background: var(--surface); color: var(--blue); font-size: .79rem; }
.folder-row .folder-actions .folder-danger { color: #ffb6c0; }
.section-hint { color: var(--muted); font-size: .85rem; margin: 0 0 10px; }
#theme .folder-actions .check { margin: 0 4px; min-height: 44px; font-size: .8rem; white-space: nowrap; }
#themeForm { padding: 9px 0 0; align-items: center; gap: 8px; }
#theme .settings-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--field);
  border-radius: 7px; margin-bottom: 14px;
}
#theme .settings-tabs button { color: var(--text); min-height: 40px; }
#theme .settings-tabs button[aria-pressed=true] { color: #fff; background: var(--green); }
.background-field { margin-top: 15px; }
.background-field h3 { margin: 0 0 5px; font-size: .87rem; font-weight: 600; }
.background-preview {
  display: flex; align-items: center; min-height: 70px; padding: 12px 14px; border-radius: 6px;
  background: linear-gradient(#182f4b9c,#182f4b9c), var(--background-preview) center/cover, var(--navy);
  color: var(--light-text); font: 600 25px/1.1 Catalog Heading, Georgia, serif; overflow-wrap: anywhere;
}
.background-actions { display: flex; gap: 6px; margin-top: 6px; }
#theme .check input { min-height: 0; accent-color: var(--green); }
#theme .status-row, #theme .status-row.muted {
  background: transparent; border: 0; border-radius: 0; margin: 0; padding: 7px 2px; border-bottom: 1px solid var(--line);
}
#theme .status-row label { color: var(--muted); }
#theme .status-row .status-preview {
  color: var(--text); background: var(--field); border: 0; font-weight: 650;
}
.management-footer {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; margin-top: 16px;
  padding-top: 9px; border-top: 1px solid var(--line); background: var(--surface);
}
#themeForm .management-footer button { flex: 0 1 auto; padding-inline: 16px; }
#mobileMenu label { color: var(--page-muted); }
#mobileMenu select { color: var(--text); }
dialog .form-message, dialog .edit-group button.danger { color: #912d43; }
#detail, #theme {
  --surface: #17252c;
  --field: #21323a;
  --text: var(--page-text);
  --muted: var(--page-muted);
  --line: #50636d;
  --accent-ui: #a7e6d2;
  color-scheme: dark;
  color: var(--text);
  border-radius: 14px;
  box-shadow: 0 20px 70px #080f1390;
}
#theme { --blue: #a4d5ef; --ink: #fff; }
#theme button:focus-visible, #theme input:focus-visible { outline-color: var(--header-focus); }
#detail h2 {
  color: var(--text);
  font: 600 31px/1.1 Catalog Heading, Georgia, serif;
  overflow-wrap: anywhere;
}
#detail a, #detailPrice { color: var(--accent-ui); }
#gallery { display: block; margin-top: 10px; }
#galleryTrack {
  display: flex; width: 100%; aspect-ratio: 4 / 3; max-height: 48dvh;
  overflow: auto hidden; scroll-snap-type: x mandatory; scrollbar-width: none;
  background: #10191f; border-radius: 9px;
}
#galleryTrack .photo { flex: 0 0 100%; height: 100%; scroll-snap-align: start; border-radius: 0; }
#galleryTrack .photo img { width: 100%; height: 100%; max-height: none; object-fit: contain; }
#galleryTrack img:not([src]) { visibility: hidden; }
#galleryTrack .unavailable-photo::before {
  content: "Фото недоступно"; position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted);
}
#galleryControls { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px; }
#galleryControls button { min-width: 44px; min-height: 40px; }
#galleryControls button:disabled { opacity: .5; cursor: default; }
#galleryPosition { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
#detail #edit .edit-primary { background: var(--field); }
#detail ::placeholder { color: var(--muted); opacity: 1; }
#detail .edit-group button.danger, #detail .form-message { color: #ffb6c0; }
#detail button:focus-visible, #detail select:focus-visible, #detail textarea:focus-visible, #detail a:focus-visible {
  outline-color: var(--header-focus);
}
button:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline-color: var(--blue); }
.masthead button:focus-visible, .masthead select:focus-visible { outline-color: var(--header-focus); }
#storeCatalog button:focus-visible, #storeCatalog select:focus-visible { outline-color: var(--header-focus); }

@media (max-width: 720px) {
  .mast-inner { padding: 12px 12px 10px; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .mast-inner .catalog-search { grid-column: 1 / -1; grid-row: 2; }
  #brand { font-size: clamp(24px, 6vw, 30px); }
  .masthead .catalog-search #q { font-size: 16px; }
  main { padding: 7px 10px 24px; }
  #storeCatalog { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #sectionRail { position: static; min-width: 0; }
  #nav { display: flex; overflow: auto; border-width: 0 0 1px; padding: 2px; }
  #nav button { flex-shrink: 0; white-space: nowrap; }
  #nav button.active { box-shadow: inset 0 -2px #83cfb9; }
}
@media (max-width: 390px) {
  .folder-list .folder-row:has(.folder-danger) { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .folder-list .folder-row:has(.folder-danger) .folder-actions { justify-content: flex-start; }
  .folder-row > form { grid-template-columns: minmax(0, 1fr); }
  .folder-row .folder-actions { flex-wrap: nowrap; }
  .folder-row .folder-actions button { padding-inline: 5px; }
}
