/* Cenvistone Catalogue — design system.
   ---------------------------------------------------------------------------
   The brand colours come from /theme.css (--color-primary, --color-accent and
   their automatic contrast colours).  Everything else is derived here so that
   an admin can change the brand without touching a line of markup.

   Rules of the house:
   - no inline styles and no inline scripts (strict CSP),
   - every colour is a token, every spacing a step of the scale,
   - the layout works from 320 px up to 1600 px.
   */

/* --- 1. Tokens ----------------------------------------------------------- */

:root {
  /* brand (overridden by /theme.css) */
  --color-primary: #1f6feb;
  --color-accent: #f59e0b;
  --on-primary: #ffffff;
  --on-accent: #1b1f24;

  --brand: var(--color-primary);
  --brand-ink: var(--on-primary);
  --accent: var(--color-accent);
  --accent-ink: var(--on-accent);

  /* brand tints */
  --brand-soft: #eaf1fd;
  --brand-soft: color-mix(in srgb, var(--brand) 9%, #ffffff);
  --brand-soft-strong: #d8e6fb;
  --brand-soft-strong: color-mix(in srgb, var(--brand) 16%, #ffffff);
  --brand-line: #c3d8f6;
  --brand-line: color-mix(in srgb, var(--brand) 30%, #ffffff);
  --brand-deep: #1a5dc0;
  --brand-deep: color-mix(in srgb, var(--brand) 78%, #000000);
  --brand-ring: rgba(31, 111, 235, 0.22);
  --brand-ring: color-mix(in srgb, var(--brand) 22%, transparent);

  /* neutrals */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f4;
  --border: #e4e8ec;
  --border-strong: #cfd6dd;
  --text: #16191d;
  --text-2: #4d5763;
  --text-3: #78838f;

  /* semantic */
  --danger: #c0392b;
  --danger-soft: #fdf0ee;
  --success: #157347;
  --success-soft: #ecf7f0;
  --warning-bg: #fff8e8;
  --warning-border: #f0d9a4;

  /* shape */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 999px;

  /* spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-2: 0 2px 6px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, 0.14);

  /* layout */
  --content-width: 1280px;
  --header-height: 58px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* icons (inline SVG data URIs, painted with currentColor through the mask) */
  --icon-external: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M6.5 2.5H3.2A1.2 1.2 0 0 0 2 3.7v9.1A1.2 1.2 0 0 0 3.2 14h9.1a1.2 1.2 0 0 0 1.2-1.2V9.5M9.5 2.5H13.5V6.5M13.5 2.5 7.8 8.2'/%3E%3C/svg%3E");
}

/* --- 2. Reset and base --------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--s-2);
  line-height: 1.25;
  letter-spacing: -0.011em;
  color: var(--text);
}

h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.0625rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 650; }

p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--brand-deep);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img { max-width: 100%; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--s-5) 0;
}

::selection {
  background: var(--brand-soft-strong);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--brand);
  color: var(--brand-ink);
  padding: var(--s-2) var(--s-4);
  border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; }

/* --- 3. Layout ----------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-top: 3px solid var(--brand);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}

.topbar-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--s-5);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--s-4);
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}
.brand:hover { text-decoration: none; }
.brand img {
  display: block;
  height: 32px;
  width: auto;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.nav a {
  display: inline-block;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-full);
  color: var(--text-2);
  font-weight: 550;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav a:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}
.nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.user-name {
  font-size: 0.875rem;
  color: var(--text-2);
  white-space: nowrap;
}

.lang-form select {
  height: 32px;
  padding: 0 var(--s-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-9);
}

.footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--s-5);
  text-align: center;
  color: var(--text-3);
  font-size: 0.8125rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.page-head h1 { margin: 0; }
.page-head p { margin: var(--s-1) 0 0; color: var(--text-2); }
.page-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
}

/* --- 4. Buttons ---------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 38px;
  padding: 0 var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease;
}
.button:hover {
  background: var(--surface-2);
  border-color: var(--brand-line);
  color: var(--brand-deep);
  text-decoration: none;
}
.button:active { transform: translateY(1px); }

.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--shadow-1);
}
.button.primary:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  color: var(--brand-ink);
}

.button.danger {
  color: var(--danger);
  border-color: #e6c4c0;
  background: var(--surface);
}
.button.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.button.small {
  min-height: 30px;
  padding: 0 var(--s-3);
  font-size: 0.8125rem;
  border-radius: var(--r-xs);
}

.button.block { display: flex; width: 100%; }

.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.875rem;
  color: var(--brand-deep);
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--danger); }

/* --- 5. Forms ------------------------------------------------------------ */

.field { margin-bottom: var(--s-4); }
.field:last-child { margin-bottom: 0; }
.field.grow { flex: 1 1 220px; min-width: 0; }

.field label,
.field > label {
  display: block;
  margin-bottom: var(--s-1);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
}
.field.checkbox label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 0;
  cursor: pointer;
}

/* A label that looks like a button (the file choosers) keeps the button size. */
label.button {
  display: inline-flex;
  width: auto;
  margin-bottom: 0;
  font-weight: 550;
  font-size: 0.9375rem;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  min-height: 38px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2378838f' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  padding-right: var(--s-7);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

input[readonly] {
  background: var(--surface-2);
  color: var(--text-3);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

fieldset.field {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin: 0 0 var(--s-4);
  background: var(--surface-2);
}
legend {
  font-weight: 650;
  font-size: 0.9rem;
  padding: 0 var(--s-2);
  color: var(--text);
}

.form-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}

.filter-form {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-form .field { margin-bottom: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 var(--s-4);
}

.hint,
.field-hint,
small {
  display: block;
  margin-top: var(--s-1);
  color: var(--text-3);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* --- 6. Messages --------------------------------------------------------- */

.messages {
  list-style: none;
  margin: 0 0 var(--s-4);
  padding: 0;
  display: grid;
  gap: var(--s-2);
}

.message {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.message.success { border-color: #bfe3cd; background: var(--success-soft); color: var(--success); }
.message.error { border-color: #e6c4c0; background: var(--danger-soft); color: var(--danger); }
.message.warning { border-color: var(--warning-border); background: var(--warning-bg); }

.notice {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: #6b4e12;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
}

.error { color: var(--danger); }
.error-list { color: var(--danger); padding-left: var(--s-5); }
.empty {
  color: var(--text-3);
  font-style: normal;
  text-align: center;
  padding: var(--s-6) var(--s-4);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}

/* --- 7. Panels ----------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-5);
  box-shadow: var(--shadow-1);
}
.panel:last-child { margin-bottom: 0; }
.panel > h2:first-child { margin-top: 0; }
.panel.narrow {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* --- 8. Tables ----------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  -webkit-overflow-scrolling: touch;
}

/* The table keeps its columns readable and scrolls sideways on a small screen. */
.table-wrap .table {
  min-width: 720px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.9rem;
}
.table th,
.table td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.table th {
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  white-space: nowrap;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table td small { margin-top: 2px; }

.thumb-cell {
  width: 88px;
}
.thumb-cell img {
  width: 56px;
  height: 56px;
  max-width: none;
  object-fit: cover;
  border-radius: var(--r-sm);
  display: block;
  background: var(--surface-3);
}

/* --- 9. Catalogue grid and cards ----------------------------------------- */

.toolbar {
  display: flex;
  gap: var(--s-4);
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}

.filter-panel {
  flex: 1 1 520px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}

.filter-search {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  margin-bottom: var(--s-4);
}
.filter-search .field { flex: 1 1 auto; margin-bottom: 0; min-width: 0; }
.filter-search input[type="search"] {
  height: 42px;
  font-size: 1rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2378838f' stroke-width='1.6' d='M11.3 11.3 15 15M7 12.5a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left var(--s-3) center;
  padding-left: var(--s-8);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s-3);
  align-items: end;
}
.filter-grid .field { margin-bottom: 0; }
.filter-grid select[multiple] {
  min-height: 38px;
  max-height: 116px;
  padding: var(--s-1);
}
.filter-grid select[multiple] option {
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-xs);
}

.filter-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
}

.filter-more {
  border: none;
  padding: 0;
  margin: var(--s-4) 0 0;
}
.filter-more summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) 0;
  cursor: pointer;
  list-style: none;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
}
.filter-more summary::-webkit-details-marker { display: none; }
.filter-more summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}
.filter-more[open] summary::before { transform: rotate(90deg); }
.filter-more summary:hover { color: var(--text); }
.filter-more-count {
  background: var(--brand-soft-strong);
  color: var(--brand-deep);
  border-radius: var(--r-full);
  padding: 0 var(--s-2);
  font-size: 0.75rem;
  font-weight: 700;
}
.filter-more .chip-group { padding-bottom: var(--s-2); }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 5px var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  background: var(--surface);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand);
}
.chip:hover {
  border-color: var(--brand-line);
  background: var(--surface-2);
  color: var(--text);
}
.chip.is-on,
.chip:has(input:checked) {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand-deep);
  font-weight: 600;
}
.chip:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.filter-foot {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}
.switch input { width: 16px; height: 16px; accent-color: var(--brand); }

.nowrap { white-space: nowrap; }

.result-count {
  color: var(--text-2);
  font-size: 0.875rem;
  margin: 0 0 var(--s-3);
}
.result-count strong { color: var(--text); font-weight: 650; }

.grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: var(--s-6);
}
.grid[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid[data-cols="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid[data-cols="7"] { grid-template-columns: repeat(7, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.card:hover {
  box-shadow: var(--shadow-2);
  border-color: var(--brand-line);
  transform: translateY(-2px);
}

.card-media {
  display: block;
  position: relative;
  background: var(--surface-3);
  overflow: hidden;
}
.card-media img,
.card video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.card:hover .card-media img { transform: scale(1.04); }

.card-body {
  padding: var(--s-3) var(--s-4) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  flex: 1 1 auto;
}
.card-body h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}
.card-body h2 a { color: var(--text); }
.card-body h2 a:hover { color: var(--brand-deep); text-decoration: none; }

/* Links that open the product page in a new browser tab. */
.link-newtab {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
}
.link-newtab::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  align-self: center;
  background-color: currentColor;
  -webkit-mask: var(--icon-external) center / contain no-repeat;
  mask: var(--icon-external) center / contain no-repeat;
  opacity: 0.65;
}
.link-newtab:hover::after { opacity: 1; }
.card-name {
  color: var(--text-2);
  margin: 0;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-tags {
  margin: var(--s-2) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  align-items: center;
}
.no-media {
  display: block;
  padding: 2.5rem var(--s-3);
  text-align: center;
  color: var(--text-3);
  font-size: 0.8125rem;
  aspect-ratio: 4 / 3;
}

.tag {
  display: inline-block;
  background: var(--surface-3);
  color: var(--text-2);
  border-radius: var(--r-full);
  padding: 2px var(--s-2);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
}

.badge {
  display: inline-block;
  border-radius: var(--r-xs);
  padding: 2px var(--s-2);
  font-size: 0.6875rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--accent);
  color: var(--accent-ink);
}
.badge.official {
  background: var(--brand-soft-strong);
  color: var(--brand-deep);
  vertical-align: middle;
}
.badge.video {
  position: absolute;
  right: var(--s-2);
  bottom: var(--s-2);
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
}

/* --- 10. Product page ---------------------------------------------------- */

.product-header {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--s-5);
}
.product-header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.product-name {
  font-size: 1.0625rem;
  color: var(--text-2);
  margin: var(--s-1) 0 0;
}
.product-updated {
  color: var(--text-3);
  font-size: 0.8125rem;
  margin: var(--s-1) 0 0;
}
.product-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
}
.product-actions form { margin: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  grid-template-areas:
    "gallery side"
    "tabs   side";
  gap: var(--s-5);
  align-items: start;
}
.detail-gallery { grid-area: gallery; margin-bottom: 0; }
.detail-side { grid-area: side; }
.detail-tabs { grid-area: tabs; }
.detail-side {
  display: grid;
  gap: var(--s-4);
  align-content: start;
}
.detail-side .panel { margin-bottom: 0; }

.description {
  white-space: pre-wrap;
  color: var(--text-2);
  margin: 0;
}

.share-box {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s-2);
}
.share-box label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.share-box input {
  width: 260px;
  font-size: 0.8125rem;
  font-family: var(--font-mono);
}
.inline-form {
  display: inline-flex;
  gap: var(--s-2);
  align-items: center;
  margin: 0;
}

.gallery-main {
  background: #101418;
  border-radius: var(--r-md);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gallery-main img,
.gallery-main video {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}
.gallery-item[hidden] { display: none; }
.placeholder {
  color: #fff;
  text-align: center;
  padding: var(--s-5);
}
.gallery-nav {
  display: flex;
  gap: var(--s-2);
  margin: var(--s-3) 0;
  justify-content: center;
}
.thumbs {
  list-style: none;
  display: flex;
  gap: var(--s-2);
  padding: var(--s-1);
  margin: 0;
  overflow-x: auto;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.thumb-button {
  border: 2px solid transparent;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: var(--r-sm);
  display: block;
  line-height: 0;
}
.thumb-button img {
  width: 76px;
  height: 76px;
  max-width: none;
  object-fit: cover;
  border-radius: var(--r-xs);
  display: block;
}
.thumb-button.active {
  border-color: var(--brand);
}

.attachments {
  list-style: none;
  padding: 0;
  margin: 0;
}
.attachments li {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  align-items: center;
}
.attachments li:last-child { border-bottom: none; }
.attachment-description { color: var(--text-2); font-size: 0.875rem; }
.file-size {
  color: var(--text-3);
  font-size: 0.8125rem;
  margin-left: auto;
  white-space: nowrap;
}

.tabs { margin-top: 0; }
.tab-bar {
  display: flex;
  gap: var(--s-5);
  margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--border);
}
.tab-button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--s-2) var(--s-1) var(--s-3);
  margin-bottom: -1px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--text-3);
}
.tab-button:hover { color: var(--text); }
.tab-button.active {
  color: var(--brand-deep);
  border-bottom-color: var(--brand);
}
[data-tab-panel][hidden] { display: none; }

.comments {
  list-style: none;
  padding: 0;
  margin: 0;
}
.comment {
  border-left: 2px solid var(--border);
  padding: var(--s-2) 0 var(--s-3) var(--s-4);
  margin-bottom: var(--s-2);
}
.comment.depth-1 { margin-left: var(--s-4); }
.comment.depth-2 { margin-left: var(--s-6); }
.comment.depth-3 { margin-left: var(--s-7); }
.comments.nested { margin-top: var(--s-2); }
.comment-head {
  display: flex;
  gap: var(--s-2);
  align-items: baseline;
  font-size: 0.8125rem;
  color: var(--text-3);
  flex-wrap: wrap;
}
.comment-author { font-weight: 650; color: var(--text); }
.comment-edited { font-style: italic; }
.comment-body p { margin: var(--s-1) 0; color: var(--text-2); }
.comment-actions {
  display: flex;
  gap: var(--s-4);
  font-size: 0.875rem;
  margin-top: var(--s-1);
}
.comment-actions form { margin: 0; }
.deleted { color: var(--text-3); font-style: italic; }

.history {
  list-style: none;
  padding: 0;
  margin: 0;
}
.history > li {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}
.history > li:last-child { border-bottom: none; }
.history-head {
  display: flex;
  gap: var(--s-3);
  font-size: 0.8125rem;
  color: var(--text-3);
  flex-wrap: wrap;
}
.history-action { font-weight: 650; color: var(--text); }
.changes {
  margin: var(--s-2) 0 0 var(--s-4);
  font-size: 0.8125rem;
  list-style: none;
  padding: 0;
}
.change-field { font-weight: 650; color: var(--text-2); }
.change-old {
  color: var(--text-3);
  text-decoration: line-through;
  margin-right: var(--s-1);
}
.change-new { color: var(--success); }
.change-note { color: var(--text-3); margin-right: var(--s-1); }

/* --- 11. Product form ---------------------------------------------------- */

.upload-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}
.upload-item {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2);
  background: var(--surface);
  width: 152px;
  box-shadow: var(--shadow-1);
}
.upload-item img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  border-radius: var(--r-xs);
  display: block;
}
.upload-item .upload-name {
  font-size: 0.75rem;
  word-break: break-all;
  margin-top: var(--s-1);
  color: var(--text-2);
}
.upload-item .upload-actions {
  display: flex;
  gap: var(--s-1);
  align-items: center;
  margin-top: var(--s-2);
}
.upload-item input[type="text"] { font-size: 0.75rem; min-height: 28px; }

.suggestions {
  list-style: none;
  padding: 0;
  margin: var(--s-2) 0 0;
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.suggestions button {
  background: var(--surface-3);
  border: none;
  border-radius: var(--r-full);
  padding: var(--s-1) var(--s-3);
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text-2);
}
.suggestions button:hover { background: var(--brand-soft-strong); color: var(--brand-deep); }

/* --- 12. Administration -------------------------------------------------- */

.manage {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: var(--s-6);
  align-items: start;
}

.manage-nav {
  position: sticky;
  top: calc(var(--header-height) + var(--s-4));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  box-shadow: var(--shadow-1);
  display: grid;
  gap: var(--s-4);
}

.manage-group {
  display: grid;
  gap: 2px;
}

.manage-group-title {
  margin: 0 0 var(--s-1);
  padding: 0 var(--s-3);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.manage-nav a {
  display: block;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
}
.manage-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.manage-nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 650;
}

.manage-content { min-width: 0; }
.manage-content > h1 { margin-bottom: var(--s-4); }

.stats {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: var(--s-3);
}
.stats li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}
.stats a {
  display: block;
  color: inherit;
}
.stats a:hover { text-decoration: none; }
.stats a:hover .stat-value { color: var(--brand-deep); }
.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat-label {
  display: block;
  color: var(--text-3);
  font-size: 0.8125rem;
  margin-top: var(--s-1);
}

.test-result { list-style: none; padding: 0; margin: 0; }
.test-result li { padding: var(--s-2) 0; border-bottom: 1px solid var(--border); }
.test-result li:last-child { border-bottom: none; }
.test-result .ok { color: var(--success); }
.test-result .error { color: var(--danger); }
.failed-row { background: var(--danger-soft); }
.job-error { color: var(--danger); font-size: 0.8125rem; }
.preview-logo { max-width: 240px; }
.theme-preview {
  background: var(--surface-2);
  padding: var(--s-3);
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-size: 0.75rem;
  margin: var(--s-3) 0 0;
}
.roles-form select { width: auto; min-width: 160px; }

.tag-create-form .field { max-width: 320px; margin-bottom: 0; }
.tag-create-form .form-actions {
  border-top: none;
  margin-top: var(--s-3);
  padding-top: 0;
}

.pagination {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  justify-content: center;
  margin: var(--s-6) 0 0;
}
.page-info { color: var(--text-2); font-size: 0.875rem; }

/* --- 13. Plain pages (login, status, share) ----------------------------- */

.plain-body { background: var(--bg); }
.plain-main {
  max-width: 440px;
  margin: 8vh auto;
  padding: 0 var(--s-4);
}
.login-panel {
  text-align: center;
  padding: var(--s-7) var(--s-6);
}
.login-panel h1 { margin-bottom: var(--s-5); }
.login-logo {
  max-width: 220px;
  height: auto;
  margin-bottom: var(--s-4);
}
.login-panel .field { text-align: left; }
.login-panel .notice { text-align: left; }

.shared-product {
  max-width: 960px;
  margin: 0 auto;
}
.shared-product header { margin-bottom: var(--s-5); }
.shared-product .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* --- 14. Responsive ------------------------------------------------------ */

@media (max-width: 1199px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "gallery"
      "side"
      "tabs";
  }
  .manage { grid-template-columns: 208px minmax(0, 1fr); gap: var(--s-5); }
}

@media (max-width: 1023px) {
  .manage {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-4);
  }
  .manage-nav {
    position: static;
    display: flex;
    gap: var(--s-2);
    overflow-x: auto;
    padding: var(--s-2);
    scrollbar-width: thin;
    -webkit-mask-image: linear-gradient(to right, #000 90%, transparent 100%);
    mask-image: linear-gradient(to right, #000 90%, transparent 100%);
  }
  .manage-group {
    display: flex;
    gap: var(--s-1);
  }
  .manage-group-title { display: none; }
  .manage-nav a { white-space: nowrap; }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .grid,
  .grid[data-cols="3"],
  .grid[data-cols="5"],
  .grid[data-cols="7"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .shared-product .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 899px) {
  /* The number of columns is forced by the screen width below 900 px (VIEW-4). */
  .filter-cols { display: none; }
  .grid,
  .grid[data-cols="3"],
  .grid[data-cols="5"],
  .grid[data-cols="7"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .shared-product .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .topbar-inner {
    flex-wrap: wrap;
    padding: var(--s-2) var(--s-4);
    gap: var(--s-2);
    row-gap: var(--s-2);
  }
  .brand { order: 1; }
  .topbar-right { order: 2; }
  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .content { padding: var(--s-5) var(--s-4) var(--s-8); }
  .user-name { display: none; }
}

@media (max-width: 599px) {
  .grid,
  .grid[data-cols="3"],
  .grid[data-cols="5"],
  .grid[data-cols="7"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shared-product .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: var(--s-4) var(--s-3) var(--s-7); }
  .filter-search { flex-wrap: wrap; }
  .filter-search .field { flex: 1 1 100%; min-width: 100%; }
  .filter-search .filter-actions { width: 100%; }
  .filter-search .filter-actions .button { width: 100%; }
  .panel { padding: var(--s-4); border-radius: var(--r-md); }
  .product-header { flex-direction: column; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions .button { flex: 1 1 auto; }
  .button { min-height: 40px; }
  .tab-bar { gap: var(--s-4); }
  .comment.depth-2 { margin-left: var(--s-5); }
  .comment.depth-3 { margin-left: var(--s-6); }
  .share-box input { width: 100%; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

@media (max-width: 419px) {
  .grid,
  .grid[data-cols="3"],
  .grid[data-cols="5"],
  .grid[data-cols="7"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-grid { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
  .topbar-right { gap: var(--s-1); }
}

/* --- 15. Motion and print ------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover { transform: none; }
  .card:hover .card-media img { transform: none; }
}

@media print {
  .topbar,
  .footer,
  .product-actions,
  .gallery-nav,
  .thumbs,
  .pagination { display: none; }
  body { background: #fff; }
  .panel { box-shadow: none; border-color: #ccc; }
}
