html[data-theme="dark"] {
  color-scheme: dark;
  --purple: #9b82ff;
  --orange: #ff9a2e;
  --ink: #f4f6fb;
  --text: #b7c0ce;
  --line: #313748;
  --soft: #171a22;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --bg: #101218;
  --surface: #1b1e27;
  --header: rgba(16, 18, 24, 0.92);
  --hover: #2a243d;
}

html[data-theme="dark"] body {
  background: var(--bg);
  color: var(--ink);
}

html[data-theme="dark"] .btn {
  box-shadow: 0 6px 14px rgba(255, 145, 20, 0.18);
}

html[data-theme="dark"] .btn-sm {
  box-shadow: 0 4px 10px rgba(255, 145, 20, 0.14);
}

html[data-theme="dark"] .sphere-btn > span {
  box-shadow: 0 6px 12px rgba(111, 70, 245, 0.16);
}

html[data-theme="dark"] ::selection { background: #3a2d66; }

html[data-theme="dark"] .header,
html[data-theme="dark"] .tabbar,
html[data-theme="dark"] .admin-top {
  background: var(--header);
}

.logo img.logo-dark { display: none; }

html[data-theme="dark"] .logo img.logo-light { display: none; }
html[data-theme="dark"] .logo img.logo-dark { display: block; }

html[data-theme="dark"] .nav a,
html[data-theme="dark"] .tab-btn,
html[data-theme="dark"] .sphere-btn { color: #d5dbe6; }

html[data-theme="dark"] .tab-btn[aria-selected="true"] { color: var(--purple); }

html[data-theme="dark"] .search input,
html[data-theme="dark"] .search-panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .request-panel,
html[data-theme="dark"] .contacts-panel,
html[data-theme="dark"] .contact-card,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .product-dialog,
html[data-theme="dark"] .success-dialog,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .product-row,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .editor,
html[data-theme="dark"] .detail-editor,
html[data-theme="dark"] .format-bar button,
html[data-theme="dark"] .format-font select,
html[data-theme="dark"] .shape-choice button,
html[data-theme="dark"] dialog {
  background: var(--surface);
  color: var(--ink);
}

html[data-theme="dark"] .search input,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .detail-editor,
html[data-theme="dark"] .format-bar button,
html[data-theme="dark"] .format-font select,
html[data-theme="dark"] .shape-choice button,
html[data-theme="dark"] .card,
html[data-theme="dark"] .product-row,
html[data-theme="dark"] .contact-card,
html[data-theme="dark"] .filter-btn,
html[data-theme="dark"] .captcha-refresh,
html[data-theme="dark"] .login-card .field input {
  border-color: #4a5162;
  background: #14171f;
  color: var(--ink);
}

html[data-theme="dark"] .field input::placeholder,
html[data-theme="dark"] .field textarea::placeholder,
html[data-theme="dark"] .search input::placeholder { color: #8d96a8; }

html[data-theme="dark"] .search-option:hover,
html[data-theme="dark"] .search-option.is-active,
html[data-theme="dark"] .tab-btn[aria-selected="true"],
html[data-theme="dark"] .btn-quiet:hover { background: var(--hover); }

@media (max-width: 860px) {
  html[data-theme="dark"] .nav:not(.nav-static) { background: var(--surface); }
}

html[data-theme="dark"] .band,
html[data-theme="dark"] body.admin { background: var(--soft); }

html[data-theme="dark"] .band {
  background: linear-gradient(180deg, var(--bg) 0%, #161922 12%, #161922 88%, var(--bg) 100%);
}

html[data-theme="dark"] .sphere-btn[aria-pressed="true"] > span {
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--orange);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .product-row,
html[data-theme="dark"] .filter-btn,
html[data-theme="dark"] .category-manage li,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .contact-card {
  border-color: #3a4154;
}

html[data-theme="dark"] .filter-btn {
  background: #14171f;
  color: #d5dbe6;
}

html[data-theme="dark"] .filter-btn[aria-pressed="true"],
html[data-theme="dark"] .editor-mode[aria-selected="true"],
html[data-theme="dark"] .shape-choice button[aria-pressed="true"] {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

html[data-theme="dark"] .card.is-hit {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--orange);
}

html[data-theme="dark"] .cover-scan { background: linear-gradient(160deg, #2a2440, #1d2838); }
html[data-theme="dark"] .cover-gate { background: linear-gradient(160deg, #163028, #241f38); }
html[data-theme="dark"] .cover-kiosk { background: linear-gradient(160deg, #3a2a1c, #321c2a); }
html[data-theme="dark"] .cover-print { background: linear-gradient(160deg, #1c2c40, #241f38); }
html[data-theme="dark"] .cover-soft { background: linear-gradient(160deg, #2a2440, #1c2c40); }
html[data-theme="dark"] .cover-more { background: linear-gradient(160deg, #3a2a1c, #241f38); }

html[data-theme="dark"] .request-panel,
html[data-theme="dark"] .contacts-panel {
  background: linear-gradient(180deg, #221f33 0%, var(--surface) 42%);
  border-color: #3a3454;
}

html[data-theme="dark"] .field span,
html[data-theme="dark"] .price-choice legend,
html[data-theme="dark"] .consent { color: #d5dbe6; }

html[data-theme="dark"] .captcha-image { background: #241f38; }

html[data-theme="dark"] .form-note { background: #2a2448; color: #ddd4ff; }
html[data-theme="dark"] .form-note.is-error,
html[data-theme="dark"] .panel-status { background: #3a2618; color: #ffc9a3; }

html[data-theme="dark"] .product-dialog,
html[data-theme="dark"] .success-dialog,
html[data-theme="dark"] .editor,
html[data-theme="dark"] #window-dialog,
html[data-theme="dark"] #categories-dialog {
  border-color: var(--line);
}

html[data-theme="dark"] dialog::backdrop,
html[data-theme="dark"] .editor::backdrop { background: rgba(0, 0, 0, 0.62); }

html[data-theme="dark"] .product-dialog::backdrop,
html[data-theme="dark"] .success-dialog::backdrop { background: transparent; }

html[data-theme="dark"] .product-dialog[open]::backdrop,
html[data-theme="dark"] .success-dialog[open]::backdrop { background: rgba(0, 0, 0, 0.62); }

@starting-style {
  html[data-theme="dark"] .product-dialog[open]::backdrop,
  html[data-theme="dark"] .success-dialog[open]::backdrop { background: transparent; }
}

html[data-theme="dark"] .product-close,
html[data-theme="dark"] .product-nav,
html[data-theme="dark"] .share-toggle {
  background: #2a2e3a;
  color: var(--ink);
}

html[data-theme="dark"] .share-toggle[aria-expanded="true"] {
  background: var(--purple);
  color: #fff;
}

html[data-theme="dark"] .share-menu {
  background: var(--surface);
}

html[data-theme="dark"] .share-menu button,
html[data-theme="dark"] .share-menu a { color: var(--ink); }

html[data-theme="dark"] .share-menu button:hover,
html[data-theme="dark"] .share-menu a:hover { background: var(--hover); }

html[data-theme="dark"] .product-gallery,
html[data-theme="dark"] .product-gallery.is-empty { background: #14171f; }

html[data-theme="dark"] .product-detail b { color: var(--ink); }

html[data-theme="dark"] .product-detail td,
html[data-theme="dark"] .product-detail th,
html[data-theme="dark"] .detail-editor td,
html[data-theme="dark"] .detail-editor th { border-color: #3a4152; }

html[data-theme="dark"] .product-detail td,
html[data-theme="dark"] .detail-editor td { color: var(--col-dark, var(--col-light, inherit)); }

html[data-theme="dark"] .product-detail th,
html[data-theme="dark"] .detail-editor th { color: var(--col-dark, var(--col-light, var(--ink))); }

html[data-theme="dark"] .detail-editor td:has(> br:only-child)::before { color: #8d96a8; }

html[data-theme="dark"] .contact-card b { color: #9aa3b4; }
html[data-theme="dark"] .contact-card > span:last-child { color: #7ec8ff; }

html[data-theme="dark"] .footer { border-top-color: var(--line); }

html[data-theme="dark"] .tab { color: #9aa3b4; }

@media (max-width: 860px) {
  html[data-theme="dark"] .nav { background: var(--surface); }
}
html[data-theme="dark"] .tab-current { color: var(--purple); }

html[data-theme="dark"] .thumb { background: #2a2448; }
html[data-theme="dark"] .category-manage li { background: #14171f; border-color: #4a5162; }
html[data-theme="dark"] .status {
  color-scheme: dark;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.2 6 6.2 11 1.2' fill='none' stroke='%23d5dbe6' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .status option,
html[data-theme="dark"] .status option:checked {
  background-color: #14171f;
  color: #f2f4f8;
}
html[data-theme="dark"] .status-new { background-color: #2a2448; color: #ddd4ff; }
html[data-theme="dark"] .status-progress { background-color: #3a2a16; color: #ffd7a8; }
html[data-theme="dark"] .status-closed { background-color: #163226; color: #b6f0cf; }
html[data-theme="dark"] .editor-mode { background: #14171f; color: var(--purple); }
html[data-theme="dark"] .editor-mode[aria-selected="true"],
html[data-theme="dark"] .shape-choice button[aria-pressed="true"] {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}
html[data-theme="dark"] .window-preview,
html[data-theme="dark"] .window-preview-frame,
html[data-theme="dark"] .gallery-item,
html[data-theme="dark"] .photo-frame,
html[data-theme="dark"] .mock { background: #14171f; }
html[data-theme="dark"] th,
html[data-theme="dark"] td { border-color: var(--line); }
html[data-theme="dark"] .btn-quiet { background: transparent; }

html[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
html[data-theme="light"] .theme-toggle .theme-sun,
html:not([data-theme="dark"]) .theme-toggle .theme-sun { display: none; }

.login-card { grid-template-columns: 1fr auto; }
.login-card > :not(.logo):not(.theme-toggle) { grid-column: 1 / -1; }
.login-card .logo { align-self: center; }
.login-card .theme-toggle { position: static; margin: 0; }

.theme-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
}

.theme-toggle svg { width: 20px; height: 20px; }

html[data-theme="dark"] .theme-toggle {
  background: #232734;
  color: #f4f6fb;
}

html[data-theme="dark"] .search-toggle {
  background: #232734;
  color: #f4f6fb;
  border-color: var(--line);
}

html[data-theme="dark"] .search.is-open .search-toggle {
  background: transparent;
  border-color: transparent;
}
