/* ── Page-specific styles for index.html ──────────────────────────────
   Extracted from inline <style> block. All colors use design tokens.  */

/* ── Header ───────────────────────────────────────────────────────── */
header {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 1px solid var(--color-border);
}
.header-left {
  flex-shrink: 0;
}
.header-search-wrap {
  position: relative;
  flex: 1;
  max-width: 400px;
  margin: 0 var(--space-md);
}
.header-search-box {
  display: flex;
  align-items: stretch;
  height: 36px;
  width: 100%;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}
.header-search-box:focus-within {
  border-color: var(--color-accent);
}
.header-search-box .search-category-btn {
  font-size: var(--font-size-xs);
  padding: 0 0.5rem;
}
.header-search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: var(--font-size-sm);
  padding: 0 0.6rem;
  border: none;
  background: transparent;
  color: var(--color-text);
  outline: none;
}
.header-search-box .search-submit-btn {
  padding: 0 0.7rem;
}
.header-search-wrap .search-dropdown {
  z-index: 1000;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.header-left h1 { margin: 0 0 0.25rem 0; font-size: 1.75rem; font-weight: var(--font-weight-bold); letter-spacing: -0.02em; }
.header-left h1 a.header-logo { color: inherit; text-decoration: none; }
.header-left h1 a.header-logo:hover { color: var(--color-accent); }
.tagline { color: var(--color-text-muted); font-size: 0.95rem; margin: 0; }
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.header-right a, .header-right button {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-decoration: none;
  background: none;
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
}
.header-right .header-user-name {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-right: 0.5rem;
}
.header-right .header-user-name.is-admin {
  color: var(--color-danger);
}
.header-right a:hover, .header-right button:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.header-right button.is-active {
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.header-right button.header-delete-btn:hover {
  color: var(--color-error);
  border-color: var(--color-error);
}

/* ── Admin bar ────────────────────────────────────────────────────── */
.admin-bar {
  margin-top: 0.75rem;
  margin-bottom: 0;
  display: flex;
  justify-content: flex-end;
}
.admin-bar button {
  font-size: 0.9rem;
  color: var(--color-danger);
  background: none;
  border: 1px solid var(--color-danger);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
}
.admin-bar button:hover {
  color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}
.admin-bar button.is-active {
  color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

/* ── Categories grid & title ──────────────────────────────────────── */
.categories-title {
  font-size: 0.8rem;
  font-weight: var(--font-weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}
.categories-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* ── Category card ────────────────────────────────────────────────── */
.category-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  transition: background 0.15s, border-color 0.15s;
}
.category-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-lg);
  transition: background 0.15s;
}
a.card-header:hover {
  background: var(--color-surface-hover);
  color: var(--color-accent-hover);
}
.category-card .card-content {
  flex: 1;
  min-width: 0;
}

/* ── Sub-chips ────────────────────────────────────────────────────── */
.card-subcategories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.1rem 0.65rem;
}
.card-sub-chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.82rem;
  font-weight: var(--font-weight-normal);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.card-sub-chip:hover {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border-color: var(--color-accent);
}

/* ── Category card actions ────────────────────────────────────────── */
.category-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-shrink: 0;
}
.category-card-actions button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.category-card-actions button:hover {
  background: var(--color-surface-hover);
  color: var(--color-accent);
}
.category-card-actions button.delete:hover { color: var(--color-error); }
.category-card-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: grab;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: none;
  background: transparent;
}
.category-card-drag-handle:active { cursor: grabbing; }
.category-card-drag-handle:hover { color: var(--color-accent); background: var(--color-surface-hover); }
.category-card.dragging { opacity: 0.6; }
.loading { color: var(--color-text-muted); padding: 2rem 0; }
.error { color: var(--color-error); padding: 1rem 0; }

/* ── View system ──────────────────────────────────────────────────── */
.view-category {
  display: none;
  background: var(--color-bg);
}
.view-category.show { display: block; }
.view-home.hide { display: none; }

/* ── Home tabs ────────────────────────────────────────────────────── */
.view-home .home-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0;
}
.view-home .home-tabs button {
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.85rem;
  margin-bottom: -1px;
  cursor: pointer;
}
.view-home .home-tabs button:hover { color: var(--color-accent); }
.view-home .home-tabs button.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: var(--font-weight-semi);
}
.view-home .home-tabs button[data-tab="system"] {
  margin-left: auto;
}
.view-home .home-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.view-home .home-tab-header .categories-title { margin: 0; }
.view-home .home-tab-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.view-home .home-tab-actions button {
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--color-danger);
  background: none;
  border: 1px solid var(--color-danger);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.view-home .home-tab-actions button:hover {
  color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}
.view-home .home-tab-actions button.is-active {
  color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}
.view-home .home-tab-panel { display: none; }
.view-home .home-tab-panel.is-active { display: block; }

/* ── System settings ──────────────────────────────────────────────── */
.view-home .system-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 0.5rem;
}
.view-home .system-settings-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  transition: background 0.15s, border-color 0.15s;
}
.view-home .system-settings-card[role="button"],
.view-home .system-settings-card[data-system-href] {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.view-home .system-settings-card[role="button"]:hover,
.view-home .system-settings-card[data-system-href]:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-accent);
}
.view-home .system-settings-card-title {
  font-size: 1.1rem;
  font-weight: var(--font-weight-semi);
  margin: 0 0 0.5rem 0;
  color: var(--color-text);
}
.view-home .system-settings-card-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0 0 0.75rem 0;
  line-height: 1.4;
}
.view-home .home-list { list-style: none; padding: 0; margin: 0; }
.view-home .home-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--color-border); color: var(--color-text); }

/* ── Manufacturers list ───────────────────────────────────────────── */
.view-home .home-list-manufacturer-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.view-home .home-list-manufacturer-name {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
  text-decoration: none;
}
.view-home .home-list-manufacturer-name:hover { color: var(--color-accent); }
.view-home .home-list-manufacturer-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.view-home .home-list-manufacturer-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--color-text-muted);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
}
.view-home .home-list-manufacturer-action-icon:hover { color: var(--color-accent); border-color: var(--color-accent); }
.view-home .home-list-manufacturer-action-icon.header-delete-btn:hover { color: var(--color-error); border-color: var(--color-error); }

/* ── Home subtabs ─────────────────────────────────────────────────── */
.view-home .home-subtabs,
.view-category .home-subtabs,
.view-component .home-subtabs,
.view-manufacturer .home-subtabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--color-border);
}
.view-home .header-subtabs,
.view-category .header-subtabs,
.view-component .header-subtabs,
.view-manufacturer .header-subtabs {
  margin-top: 0;
}
.view-home .header-subtabs .home-tab-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}
.view-home .home-subtabs .home-subtab,
.view-category .home-subtabs .home-subtab,
.view-component .home-subtabs .home-subtab,
.view-manufacturer .home-subtabs .home-subtab {
  font-size: var(--font-size-lg);
  font-family: inherit;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.75rem;
  margin-bottom: -1px;
  cursor: pointer;
}
.view-home .home-subtabs .home-subtab:hover,
.view-category .home-subtabs .home-subtab:hover,
.view-component .home-subtabs .home-subtab:hover,
.view-manufacturer .home-subtabs .home-subtab:hover { color: var(--color-accent); }
.view-home .home-subtabs .home-subtab.is-active,
.view-category .home-subtabs .home-subtab.is-active,
.view-component .home-subtabs .home-subtab.is-active,
.view-manufacturer .home-subtabs .home-subtab.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: var(--font-weight-semi);
}
.view-home .home-subtab-panel { display: none; }
.view-home .home-subtab-panel.is-active { display: block; }

/* ── Global search hero ──────────────────────────────────────────── */
.search-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: var(--space-xl);
}
.search-hero-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-normal);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-xl);
  letter-spacing: 0.01em;
}
.search-hero-box {
  display: flex;
  align-items: stretch;
  height: 44px;
  width: 66%;
  margin: 0 auto;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}
.search-hero-box:focus-within {
  border-color: var(--color-accent);
}
.search-hero-box-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;
}
.search-category-btn {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 0.4rem;
  font-family: inherit;
  font-size: var(--font-size-sm);
  padding: 0 0.75rem;
  border: none;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast);
}
.search-category-btn:hover {
  background: var(--color-surface-hover);
}
.search-category-btn svg {
  flex-shrink: 0;
  opacity: 0.5;
}
.search-hero-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: var(--font-size-md);
  padding: 0 1rem;
  border: none;
  background: transparent;
  color: var(--color-text);
  outline: none;
}
.search-submit-btn {
  display: flex;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  font-family: inherit;
  padding: 0 1.1rem;
  border: none;
  background: var(--color-accent);
  color: var(--color-text-inverse);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.search-submit-btn:hover {
  background: var(--color-accent-hover);
}

/* Category filter dropdown */
.search-category-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  padding: var(--space-sm) var(--space-md);
  max-height: 50vh;
  overflow-y: auto;
}
.search-category-dropdown.is-visible { display: block; }
.search-category-dropdown-header {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semi);
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}
.search-category-dropdown-list {
  column-count: 3;
  column-gap: var(--space-md);
}
@media (max-width: 640px) {
  .search-category-dropdown-list { column-count: 2; }
}
.search-category-option {
  display: block;
  padding: 0.15rem 0;
  font-size: var(--font-size-xs);
  line-height: 1.4;
  color: var(--color-text);
  cursor: pointer;
  break-inside: avoid;
  transition: color var(--transition-fast);
}
.search-category-option:hover {
  color: var(--color-accent);
}
.search-category-option.is-selected {
  font-weight: var(--font-weight-semi);
  color: var(--color-accent);
}
.search-subcategory-section { }
.search-subcategory-back { display: inline-block; font-size: var(--font-size-xs); color: var(--color-accent); cursor: pointer; margin-bottom: 0.4rem; padding: 0.15rem 0; transition: opacity var(--transition-fast); }
.search-subcategory-back:hover { opacity: 0.7; }
.search-subcategory-header { margin-bottom: 0.25rem; }
.search-subcategory-list { column-count: 3; column-gap: var(--space-md); }
@media (max-width: 640px) { .search-subcategory-list { column-count: 2; } }

/* Autocomplete dropdown */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 10;
  display: none;
}
.search-dropdown.is-visible { display: block; }
.search-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  cursor: pointer;
}
.search-dropdown-item:hover {
  background: var(--color-surface-hover);
}
.sdi-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow: hidden;
}
.sdi-name {
  font-weight: var(--font-weight-semi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sdi-mpn {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}
.sdi-cat {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  white-space: nowrap;
  flex-shrink: 0;
}
.search-dropdown-empty {
  padding: 0.75rem 1rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-align: center;
}
.search-results {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-lg) 0;
}
.search-results-count {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-md);
}
.search-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.search-results-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--color-border);
  font-weight: var(--font-weight-semi);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.search-results-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}
.search-results-table tbody tr:hover {
  background: var(--color-surface-hover);
}
.search-results-table a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: var(--font-weight-semi);
}
.search-results-table a:hover {
  text-decoration: underline;
}

/* ── Subpage tabs (category / component views) ────────────────────── */
.view-category .subpage-tabs,
.view-component .subpage-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: -0.25rem;
  margin-bottom: 0;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0;
}
.view-category .subpage-tabs button,
.view-component .subpage-tabs button {
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.85rem;
  margin-bottom: -1px;
  cursor: pointer;
}
.view-category .subpage-tabs button:hover,
.view-component .subpage-tabs button:hover { color: var(--color-accent); }
.view-category .subpage-tabs button[data-tab="system"],
.view-component .subpage-tabs button[data-tab="system"] { margin-left: auto; }
.view-category .subpage-tabs button.is-active,
.view-component .subpage-tabs button.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: var(--font-weight-semi);
}

/* ── Category view header & breadcrumb (NavTrail Bar) ────────────── */
.view-category header { margin-bottom: 0; padding-bottom: 0; }
.category-breadcrumb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.category-breadcrumb-bar .breadcrumb-bar-trail {
  flex: 1;
  min-width: 0;
}
.category-breadcrumb-bar .category-view-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.category-breadcrumb-bar .category-view-actions button {
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--color-danger);
  background: none;
  border: 1px solid var(--color-danger);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.category-breadcrumb-bar .category-view-actions button:hover {
  color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}
.category-breadcrumb-bar .category-view-actions button.is-active {
  color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}
.view-category .category-view-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* ── Subcategories grid ───────────────────────────────────────────── */
.view-category .subcategories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

/* ── Parameters section ───────────────────────────────────────────── */
.view-category .parameters-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}
.view-category .parameters-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0;
}
.view-category .parameters-section-header .categories-title { margin: 0; }
.view-category .parameters-section-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.view-category .parameters-section-actions button {
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--color-danger);
  background: none;
  border: 1px solid var(--color-danger);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.view-category .parameters-section-actions button:hover {
  color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

/* ── Parameter pills ──────────────────────────────────────────────── */
.view-category .parameters-section-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0 0.25rem 0;
  -webkit-overflow-scrolling: touch;
  min-height: 2.5rem;
  border-bottom: 1px solid var(--color-border);
}
.view-category .parameter-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  color: var(--color-text);
  white-space: nowrap;
}
.view-category .parameter-pill .parameter-pill-text { flex: 0 1 auto; min-width: 0; }
.view-category .parameter-pill .param-unit { color: var(--color-text-muted); margin-left: 0.25rem; }
.view-category .parameter-pill.parameter-pill-inherited { opacity: 0.85; border-style: dashed; }
.view-category .parameter-pill .parameter-pill-actions {
  display: none;
  flex-shrink: 0;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.25rem;
}
.view-category .parameters-section-list.edit-mode .parameter-pill .parameter-pill-actions { display: flex; }
.view-category .parameter-pill .parameter-pill-actions button {
  padding: 0.2rem;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  line-height: 0;
}
.view-category .parameter-pill .parameter-pill-actions button:hover { color: var(--color-accent); background: var(--color-surface-hover); }
.view-category .parameter-pill .parameter-pill-actions button.delete:hover { color: var(--color-error); }
.view-category .parameters-section-list.edit-mode .parameter-pill[data-own='1'] { cursor: grab; }
.view-category .parameters-section-list.edit-mode .parameter-pill[data-own='1']:active { cursor: grabbing; }
.view-category .parameter-pill.parameter-pill-dragging { opacity: 0.6; }

/* ── Components section ───────────────────────────────────────────── */
.view-category .components-section {
  margin-top: var(--space-md);
}
.view-category .components-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0;
}
.view-category .components-section-header .categories-title { margin: 0; }
.view-category .components-section-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.view-category .components-section-actions button {
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--color-danger);
  background: none;
  border: 1px solid var(--color-danger);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.view-category .components-section-actions button:hover {
  color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

/* ── Components table ─────────────────────────────────────────────── */
/* .components-table-wrap uses .table-card from components.css for border, radius, overflow, thead, padding, fonts.
   Only app-specific overrides below. */
.view-category .components-table .components-table-param-header,
.view-manufacturer .components-table .components-table-param-header { }
.view-category .components-table .components-table-message,
.view-manufacturer .components-table .components-table-message { color: var(--color-text-muted); white-space: normal; }
.view-category .components-table .components-table-message.error,
.view-manufacturer .components-table .components-table-message.error { color: var(--color-error); }
.view-category .component-row .component-info-link,
.view-manufacturer .component-row .component-info-link { color: var(--color-accent); text-decoration: none; font-weight: var(--font-weight-medium); }
.view-category .component-row .component-info-link:hover,
.view-manufacturer .component-row .component-info-link:hover { text-decoration: underline; }
.view-category .component-row .component-subcategory { color: var(--color-text-muted); }
.view-category .component-row .component-subcategory a { color: var(--color-text-muted); text-decoration: none; }
.view-category .component-row .component-subcategory a:hover { color: var(--color-accent); }
.view-category .component-row .component-manufacturer,
.view-manufacturer .component-row .component-manufacturer { color: var(--color-text-muted); }
.view-category .component-row .component-mpn,
.view-manufacturer .component-row .component-mpn { color: var(--color-text); }
.view-category .component-row .component-param-cell,
.view-manufacturer .component-row .component-param-cell { color: var(--color-text-muted); }
.view-category .component-row .component-row-actions,
.view-manufacturer .component-row .component-row-actions { width: 1%; }

/* ── Filters ──────────────────────────────────────────────────────── */
.view-category .filter-bar-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.view-category .applied-filters-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }
.view-category .applied-filters-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-right: 0.25rem; white-space: nowrap; }
.view-category .filter-pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.5rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-pill); font-size: 0.85rem; }
.view-category .filter-pill .pill-remove { background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: 0 0.15rem; font-size: 1rem; line-height: 1; }
.view-category .filter-pill .pill-remove:hover { color: var(--color-error); }
.view-category .filter-actions-wrap { display: flex; gap: 0.5rem; flex-shrink: 0; }
.view-category .btn-filter-reset, .view-category .btn-filter-apply { padding: 0.4rem 0.75rem; border-radius: var(--radius-md); font-size: 0.9rem; font-family: inherit; cursor: pointer; }
.view-category .btn-filter-reset { background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text-muted); }
.view-category .btn-filter-reset:hover { border-color: var(--color-accent); color: var(--color-accent); }
.view-category .btn-filter-apply { background: none; border: 1px solid var(--color-border); color: var(--color-text); }
.view-category .btn-filter-apply:hover { border-color: var(--color-accent); color: var(--color-accent); }
.view-category .components-table { table-layout: fixed; }
.components-table .col-resize { position: absolute; right: 0; top: 0; bottom: 0; width: 8px; cursor: col-resize; }
.components-table .col-resize:hover { background: var(--color-accent); opacity: 0.2; }
.components-table .col-resize::after { content: ''; position: absolute; right: 3px; top: 0; bottom: 0; width: 2px; background: var(--color-border); }
.components-table .col-sort { display: flex; flex-direction: column; align-items: center; gap: 0; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); line-height: 1; }
.components-table .sort-btn { display: flex; align-items: center; justify-content: center; background: none; border: none; padding: 2px 4px; margin: 0; cursor: pointer; border-radius: var(--radius-sm); transition: background 0.15s, opacity 0.15s; }
.components-table .sort-btn svg { color: var(--color-text-muted); opacity: 0.3; transition: opacity 0.15s, color 0.15s; }
.components-table .sort-btn:hover { background: var(--color-surface-alt, rgba(128,128,128,0.15)); }
.components-table .sort-btn:hover svg { opacity: 0.8; }
.components-table .col-sort.sort-asc .sort-btn-up svg { opacity: 1; color: var(--color-accent); }
.components-table .col-sort.sort-asc .sort-btn-down svg { opacity: 0.15; }
.components-table .col-sort.sort-desc .sort-btn-down svg { opacity: 1; color: var(--color-accent); }
.components-table .col-sort.sort-desc .sort-btn-up svg { opacity: 0.15; }
.view-category #categoryComponentsFilterRow td { background: var(--color-surface); padding: 0.3rem 0.5rem; vertical-align: top; white-space: nowrap; }
.view-category .filter-cell-input { width: 100%; min-width: 0; padding: 0.25rem 0.4rem; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text); font-size: var(--font-size-xs); }
.view-category .filter-cell-select { width: 100%; min-width: 0; padding: 0.25rem 0.4rem; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text); font-size: var(--font-size-xs); }
.view-category .filter-cell-list { max-height: 120px; overflow-y: auto; font-size: var(--font-size-xs); }
.view-category .filter-cell-list label { display: block; padding: 0.2rem 0; cursor: pointer; white-space: nowrap; }
.view-category .filter-cell-list input[type="checkbox"] { margin-right: 0.4rem; }
.view-category .filter-cell-list label:hover { color: var(--color-accent); }
.view-category .filter-range-inputs { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.3rem; }
.view-category .filter-range-input { width: 50%; min-width: 0; padding: 0.2rem 0.35rem; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text); font-size: var(--font-size-xs); }
.view-category .filter-range-input::placeholder { color: var(--color-text-muted); opacity: 0.7; }
.view-category .filter-range-sep { color: var(--color-text-muted); font-size: var(--font-size-xs); flex-shrink: 0; }

/* ── Subpage layout ─── now in layout.css (UI Kit) ─────────────────
   .subpage-wrap, .subpage-fixed-header, .subpage-scroll-content
   are defined in the shared layout.css.
   Page-specific overrides below.
   ──────────────────────────────────────────────────────────────────── */

/* ── Component view ───────────────────────────────────────────────── */
.view-component {
  display: none;
  background: var(--color-bg);
}
.view-component.show { display: block; }
.view-component header { margin-bottom: 0; padding-bottom: 0; }
.view-component .subpage-scroll-content {
  max-width: var(--content-max-width, 1120px);
  margin: 0 auto;
  padding-top: var(--space-lg);
}
.view-component .category-view-title {
  font-size: 1.75rem;
  font-weight: var(--font-weight-bold);
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}
.view-component .category-view-back,
.view-component .category-view-breadcrumb-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: var(--font-weight-normal);
  line-height: 1;
  padding: 0.2rem 0;
  border-radius: var(--radius-sm);
}
.view-component .category-view-back:hover,
.view-component .category-view-breadcrumb-link:hover { color: var(--color-accent); }
.view-component .category-view-breadcrumb-sep {
  color: var(--color-text-muted);
  font-size: 1.25rem;
  font-weight: var(--font-weight-normal);
  user-select: none;
}
.view-component .category-view-breadcrumb-current {
  font-size: 1.75rem;
  font-weight: var(--font-weight-bold);
}
.view-component .component-detail-body {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  margin-top: 0;
}
.view-component .component-detail-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  min-width: 0;
  max-width: 560px;
}
.view-component .component-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0;
}
.view-component .component-detail-actions a,
.view-component .component-detail-actions button {
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.view-component .component-detail-actions .component-detail-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}
.view-component .component-detail-actions a:hover,
.view-component .component-detail-actions button:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.view-component .component-detail-actions button.header-delete-btn:hover {
  color: var(--color-error);
  border-color: var(--color-error);
}
@media (max-width: 720px) {
  .view-component .component-detail-body {
    flex-direction: column;
    gap: 1.5rem;
  }
  .view-component .component-detail-list { max-width: none; }
  .view-component .component-detail-actions {
    flex-direction: row;
    align-self: flex-end;
  }
}
.view-component .component-detail-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--color-border); display: flex; gap: 1rem; }
.view-component .component-detail-list li:last-child { border-bottom: none; }
.view-component .component-detail-list .detail-label { font-weight: var(--font-weight-medium); color: var(--color-text-muted); min-width: 10rem; flex-shrink: 0; }
.view-component .component-detail-list .detail-value { word-break: break-word; }
.view-component .component-detail-list .detail-value a { color: var(--color-accent); }

/* ── Manufacturer categories ──────────────────────────────────────── */
.manufacturer-categories-section { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--color-border); }
.manufacturer-categories-title { font-size: 1rem; font-weight: var(--font-weight-semi); text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin: 0 0 1rem 0; }
.manufacturer-category-block { margin-bottom: 1.5rem; }
.manufacturer-category-path { font-size: 0.9rem; color: var(--color-text-muted); margin-bottom: 0.35rem; }
.manufacturer-category-path a { color: var(--color-accent); text-decoration: none; }
.manufacturer-category-path a:hover { text-decoration: underline; }
.manufacturer-category-components { list-style: none; padding: 0; margin: 0; }
.manufacturer-category-components li { padding: 0.35rem 0; border-bottom: 1px solid var(--color-border); }
.manufacturer-category-components li:last-child { border-bottom: none; }
.manufacturer-category-components a { color: var(--color-text); text-decoration: none; }
.manufacturer-category-components a:hover { color: var(--color-accent); }

/* ── Component edit view ──────────────────────────────────────────── */
.view-component-edit { display: none; }
.view-component-edit.show { display: block; }
.view-component-edit .subpage-scroll-content {
  max-width: var(--content-max-width, 1120px);
  margin: 0 auto;
  padding-top: var(--space-lg);
}
.view-component-edit .component-edit-actions { display: flex; gap: 0.5rem; margin-top: var(--space-xl); }
.view-component-edit .btn-secondary,
.view-component-edit .btn-primary {
  font-size: var(--font-size-md); font-family: inherit; padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); cursor: pointer;
  text-decoration: none; border: 1px solid var(--color-border); color: var(--color-text-muted); background: transparent;
}
.view-component-edit .btn-secondary:hover { color: var(--color-accent); border-color: var(--color-accent); }
.view-component-edit .btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.view-component-edit .btn-primary:hover { color: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.view-component-edit .form-error { color: var(--color-error); margin-bottom: var(--space-sm); }
.view-component-edit .detail-row input,
.view-component-edit .detail-row textarea,
.view-component-edit .detail-row select {
  width: 100%; padding: 0.35rem 0.5rem; font-family: inherit; font-size: var(--font-size-sm);
  color: var(--color-text); background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); margin: 0;
}
.view-component-edit .detail-row textarea { min-height: 48px; resize: vertical; }
.view-component-edit .detail-row input:focus,
.view-component-edit .detail-row textarea:focus,
.view-component-edit .detail-row select:focus { outline: none; border-color: var(--color-accent); }
.view-component-edit .checkbox-inline { display: flex; align-items: center; gap: 0.5rem; font-weight: normal; color: var(--color-text); cursor: pointer; }
.view-component-edit .checkbox-inline input { width: auto; margin: 0; }
.view-component-edit .edit-param-row { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-lg); border-bottom: 1px solid var(--color-border); }
.view-component-edit .edit-param-row:last-child { border-bottom: none; }
.view-component-edit .edit-param-label { width: 220px; font-weight: var(--font-weight-semi); color: var(--color-text-muted); font-size: var(--font-size-sm); flex-shrink: 0; }
.view-component-edit .edit-param-value { flex: 1; min-width: 0; }
.view-component-edit .edit-param-value input,
.view-component-edit .edit-param-value select {
  width: 100%; padding: 0.3rem 0.5rem; font-family: inherit; font-size: var(--font-size-sm);
  color: var(--color-text); background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); margin: 0;
}
.view-component-edit .edit-param-value input:focus,
.view-component-edit .edit-param-value select:focus { outline: none; border-color: var(--color-accent); }
.view-component-edit .param-input-group--inline { display: flex; gap: var(--space-xs); align-items: center; }
.view-component-edit .param-input-group--inline input { flex: 1; }
.view-component-edit .param-input-group--inline select { width: auto; min-width: 60px; }

/* ── Modals ────────────────────────────────────────────────────────── */
.modal { z-index: 1000; }
.modal.show { display: flex !important; }
.modal-inner-wide { max-width: 520px; }
#modalForm .modal-inner { max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal .required { color: var(--color-error); }
.modal .checkbox-label { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.modal .checkbox-label input { width: auto; margin: 0; }
.categories-sub {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-left: 1.25rem;
  margin-bottom: 1rem;
}
.category-card.subcategory .name { font-size: 0.95rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.modal .form-error { color: var(--color-error); font-size: 0.9rem; margin-bottom: 0.5rem; }

/* ── Component modal ──────────────────────────────────────────────── */
#modalComponentForm .modal-inner {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  max-height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
#modalComponentForm .modal-component-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem 1.5rem 1.5rem 1.5rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#modalComponentForm .modal-component-scroll::-webkit-scrollbar {
  display: none;
}
#modalComponentForm .scroll-arrow {
  position: absolute;
  left: 0;
  right: 0;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#modalComponentForm .scroll-arrow.visible {
  opacity: 1;
}
#modalComponentForm .scroll-arrow-top {
  top: 0;
  background: linear-gradient(to bottom, var(--color-surface) 0%, var(--color-surface) 60%, transparent 100%);
}
#modalComponentForm .scroll-arrow-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--color-surface) 0%, var(--color-surface) 60%, transparent 100%);
}
#modalComponentForm .scroll-arrow-triangle {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}
#modalComponentForm .scroll-arrow-top .scroll-arrow-triangle {
  border-bottom: 8px solid var(--color-text-muted);
}
#modalComponentForm .scroll-arrow-bottom .scroll-arrow-triangle {
  border-top: 8px solid var(--color-text-muted);
}
#modalComponentForm h2 {
  font-size: 1.75rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin: 0 0 1rem 0;
  letter-spacing: -0.02em;
}
#modalComponentForm label {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}
#modalComponentForm input,
#modalComponentForm textarea,
#modalComponentForm select {
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.75rem;
}
#modalComponentForm input::placeholder,
#modalComponentForm textarea::placeholder { color: var(--color-text-muted); }
#modalComponentForm input:focus,
#modalComponentForm textarea:focus,
#modalComponentForm select:focus {
  outline: none;
  border-color: var(--color-accent);
}
#modalComponentForm .form-error { color: var(--color-error); }
#modalComponentForm .checkbox-label { color: var(--color-text); }

/* ── Component parameters block ───────────────────────────────────── */
.component-params-block { margin-top: 1rem; margin-bottom: 0.5rem; }
.component-params-block .component-params-title { font-size: 0.9rem; color: var(--color-text-muted); margin: 0 0 0.5rem 0; }
.component-params-block label { display: block; margin-bottom: 0.25rem; }
.component-params-block input[data-param-name] { margin-bottom: 0.75rem; }
.component-params-block .param-input-group { display: flex; gap: 0; margin-bottom: 0.75rem; }
.component-params-block .param-input-group input[data-param-name] { flex: 1; margin-bottom: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.component-params-block .param-input-group select.param-prefix-select { width: auto; min-width: 3.5rem; border-left: none; border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0.4rem 0.3rem; font-size: 0.85rem; color: var(--color-text-muted); background: var(--color-surface); cursor: pointer; }
.component-params-block .edit-param-row { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; }
.component-params-block .edit-param-row .detail-label { font-weight: var(--font-weight-medium); color: var(--color-text-muted); min-width: 10rem; flex-shrink: 0; }
.component-params-block .edit-param-row .detail-value { flex: 1; min-width: 0; }

/* ── JS-generated element classes (modal param rows, etc.) ────────── */
.modal-param-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--color-border);
}
.modal-param-row .modal-param-name {
  flex: 1;
}
.modal-param-row .modal-param-badge {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-style: italic;
}
.modal-param-row .modal-param-drag-handle {
  color: var(--color-text-secondary);
  padding: 2px;
  display: inline-flex;
  align-items: center;
}
.modal-param-row .modal-param-edit-btn,
.modal-param-row .modal-param-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
}
.modal-param-row .modal-param-edit-btn {
  color: var(--color-text-secondary);
}
.modal-param-row .modal-param-delete-btn {
  color: var(--color-error);
}
.modal-param-row.inherited { opacity: 0.7; }
.modal-param-inherited-label {
  flex: none;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-style: italic;
  white-space: nowrap;
}
.modal-param-row.dragging { opacity: 0.4; }
.modal-param-row.drag-over { border-top: 2px solid var(--color-accent); }

/* ── Modal form layout helpers ────────────────────────────────────── */
.modal-name-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.modal-name-row input { flex: 1; }
.modal-name-row .btn { white-space: nowrap; }

.modal-param-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}
.modal-param-section-header label { margin: 0; }

.modal-param-edit-toggle {
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
}

.modal-param-list-wrap {
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}

/* ── Layout overrides for JS-created elements ─────────────────────── */
.card-subcategories-flush { padding: 0; }
.param-input-group--inline { margin-bottom: 0; }

/* ── Modal cat param section (JS toggle + layout) ─────────────────── */
#modalCatParamSection {
  margin-top: 0.75rem;
}
#btnAddParamFromModal {
  width: 100%;
}

/* ── Appearance modal (CDB-specific overrides) ───────────────────── */
/* Base theme-selector styles are in components.css (UI Kit).
   Below are CDB-only extensions: editor-open state + edit/delete buttons. */
.modal-inner-appearance { transition: max-width .2s; }
.modal-inner-appearance.editor-open { max-width: 95vw; width: 95vw; }
.theme-card-info-actions { display: flex; align-items: center; gap: var(--space-xs); }
.theme-card-edit-btn, .theme-card-delete-btn {
  width: 26px; height: 26px; border: 1px solid var(--color-border); background: transparent;
  color: var(--color-text-muted); border-radius: var(--radius-sm); cursor: pointer;
  font-size: 0.9rem; display: flex; align-items: center; justify-content: center;
}
.theme-card-edit-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.theme-card-delete-btn:hover { border-color: var(--color-error); color: var(--color-error); }

/* ── Theme editor ────────────────────────────────────────────────── */
.theme-editor-toolbar {
  display: flex; align-items: flex-end; gap: var(--space-md);
  margin-bottom: var(--space-lg); padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}
.theme-editor-name-wrap { flex: 1; }
.theme-editor-name-wrap label {
  display: block; font-size: var(--font-size-xs); color: var(--color-text-muted);
  margin-bottom: var(--space-2xs);
}
.theme-editor-name-input {
  width: 100%; padding: var(--space-xs) var(--space-sm);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); color: var(--color-text);
  font-family: inherit; font-size: var(--font-size-base);
}
.theme-editor-name-input:focus { border-color: var(--color-accent); outline: none; }
.theme-editor-base-wrap { min-width: 140px; }
.theme-editor-base-wrap label {
  display: block; font-size: var(--font-size-xs); color: var(--color-text-muted);
  margin-bottom: var(--space-2xs);
}
.theme-editor-base-select {
  width: 100%; padding: var(--space-xs) var(--space-sm);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); color: var(--color-text);
  font-family: inherit; font-size: var(--font-size-base); cursor: pointer;
}
.theme-editor-base-select:focus { border-color: var(--color-accent); outline: none; }
.theme-editor-group { margin-bottom: var(--space-lg); }
.theme-editor-group-title {
  font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-muted); margin: 0 0 var(--space-sm) 0;
  font-weight: var(--font-weight-semi);
}
.theme-editor-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm);
}
.theme-editor-field {
  padding: 3px 4px; border-radius: var(--radius-sm);
  transition: background .15s;
}
.theme-editor-field.highlight {
  background: rgba(59,130,246,.1);
}
.theme-editor-field label {
  font-size: var(--font-size-xs); color: var(--color-text-muted);
  margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.theme-editor-color-wrap { display: flex; gap: var(--space-xs); }
.theme-editor-color-picker {
  width: 32px; height: 28px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 0; cursor: pointer;
  flex-shrink: 0;
}
.theme-editor-color-picker:hover { border-color: var(--color-accent); }

/* ── Custom color picker popup ─────────────────────────────────── */
.color-picker-popup {
  z-index: 10001; width: 230px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 12px; font-size: 12px; color: var(--color-text);
}
.cp-preview-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.cp-swatch {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); flex-shrink: 0;
}
.cp-hex-input {
  flex: 1; min-width: 0; padding: 4px 6px; font-family: var(--font-mono);
  font-size: 12px; background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); color: var(--color-text); margin-bottom: 0;
}
.cp-hex-input:focus { border-color: var(--color-accent); outline: none; }
.cp-slider-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.cp-label {
  width: 12px; font-weight: 600; color: var(--color-text-muted); text-align: center;
}
.cp-slider {
  flex: 1; height: 6px; -webkit-appearance: none; appearance: none;
  border-radius: 3px; outline: none; cursor: pointer;
  margin-bottom: 0; padding: 0; border: none; width: auto;
}
.cp-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; border: 2px solid var(--color-border);
  cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.cp-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--color-border); cursor: pointer;
}
.cp-slider-h {
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.cp-slider-s {
  background: linear-gradient(to right, #888, var(--color-accent));
}
.cp-slider-l {
  background: linear-gradient(to right, #000, #888, #fff);
}
.cp-val {
  width: 28px; text-align: right; font-family: var(--font-mono);
  font-size: 11px; color: var(--color-text-muted);
}
.cp-buttons {
  display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px;
}
.cp-buttons .btn-sm { padding: 3px 10px; font-size: 11px; }
.theme-editor-text-input {
  flex: 1; min-width: 0; padding: var(--space-2xs) var(--space-xs);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); color: var(--color-text);
  font-family: var(--font-mono); font-size: var(--font-size-xs);
}
.theme-editor-text-input:focus { border-color: var(--color-accent); outline: none; }
.theme-editor-text-full { width: 100%; }
.theme-editor-actions {
  display: flex; gap: var(--space-sm); justify-content: flex-end;
  margin-top: var(--space-lg); padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

/* ── Theme editor: side-by-side layout ───────────────────────────── */
.theme-editor-body {
  display: flex;
  min-height: 0;
}
.theme-ref-panel {
  flex: 0 0 auto; width: 62%;
  min-width: 200px; max-width: 80%;
  position: sticky; top: 0; align-self: flex-start;
  overflow: hidden;
}
.theme-editor-resize-handle {
  flex: 0 0 6px;
  cursor: col-resize;
  background: var(--color-border);
  border-radius: 3px;
  margin: 0 2px;
  transition: background .15s;
  position: relative;
}
.theme-editor-resize-handle:hover,
.theme-editor-resize-handle.dragging {
  background: var(--color-accent);
}
.theme-editor-controls {
  flex: 1; min-width: 180px;
  max-height: 60vh; overflow-y: auto;
  padding-right: var(--space-xs);
  padding-left: var(--space-sm);
}

/* ── Live mockup ────────────────────────────────────────────────── */
.theme-ref-mockup {
  position: relative;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 11px; line-height: 1.4;
  font-family: var(--font-family, sans-serif);
  color: var(--color-text);
}
.ref-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--color-surface); padding: 8px 12px;
}
.ref-logo { font-weight: 700; font-size: 14px; }
.ref-header-right { display: flex; align-items: center; gap: 8px; }
.ref-admin { color: var(--color-danger); font-weight: 600; font-size: 10px; }
.ref-logout {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 2px 8px; font-size: 10px; color: var(--color-text);
}
.ref-tabs {
  display: flex; gap: 0; background: var(--color-surface);
  border-bottom: 1px solid var(--color-border); padding: 0 12px;
}
.ref-tab {
  padding: 6px 10px; font-size: 10px; color: var(--color-text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.ref-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.ref-breadcrumbs {
  padding: 8px 12px; display: flex; align-items: center; gap: 4px;
  font-size: 10px;
}
.ref-crumb { color: var(--color-text-muted); }
.ref-sep { color: var(--color-text-muted); }
.ref-current { color: var(--color-text); font-size: 12px; }
.ref-main { display: flex; gap: 10px; padding: 8px 12px; }
.ref-cards-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ref-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 8px 10px;
}
.ref-card:hover { background: var(--color-surface-hover); border-color: var(--color-accent); }
.ref-card-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 6px; }
.ref-card-head strong { font-size: 12px; }
.ref-count { color: var(--color-text-muted); font-size: 10px; }
.ref-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ref-chip {
  background: var(--color-accent); color: var(--color-text-inverse, #fff);
  padding: 2px 8px; border-radius: var(--radius-pill); font-size: 9px; font-weight: 600;
}
.ref-right-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ref-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.ref-pill {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-pill); padding: 2px 8px; font-size: 9px;
}
.ref-pill.dashed { border-style: dashed; }
.ref-modal-box {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 10px;
  box-shadow: var(--shadow-md);
}
.ref-input {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); height: 22px; margin-bottom: 6px;
}
.ref-input.focused { border-color: var(--color-accent); }
.ref-modal-btns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.ref-btn-cancel {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 2px 10px; font-size: 10px; color: var(--color-text-muted);
}
.ref-btn-primary {
  background: var(--color-accent); border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm); padding: 2px 10px; font-size: 10px;
  color: var(--color-bg); font-weight: 600;
}
.ref-bottom {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 8px 12px; gap: 10px;
}
.ref-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.ref-badge {
  padding: 2px 8px; border-radius: var(--radius-sm); font-size: 9px; font-weight: 600;
}
.ref-badge.success { background: var(--color-badge-success-bg); color: var(--color-badge-success-text); }
.ref-badge.info { background: var(--color-badge-info-bg); color: var(--color-badge-info-text); }
.ref-badge.warning { background: var(--color-badge-warning-bg); color: var(--color-badge-warning-text); }
.ref-badge.error { background: var(--color-badge-error-bg); color: var(--color-badge-error-text); }
.ref-swatches { display: flex; gap: 3px; }
.ref-sw {
  width: 18px; height: 18px; border-radius: 3px;
  border: 1px solid rgba(128,128,128,.3);
}
.theme-ref-hotspots { position: absolute; inset: 0; }
.theme-ref-hotspot {
  position: absolute;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: crosshair;
  transition: border-color .15s, background .15s;
}
.theme-ref-hotspot:hover,
.theme-ref-hotspot.highlight {
  border-color: var(--color-accent);
  background: rgba(59,130,246,.12);
}
.theme-ref-hotspot.highlight {
  animation: hotspot-pulse .6s ease-in-out infinite alternate;
}
@keyframes hotspot-pulse {
  from { background: rgba(59,130,246,.08); }
  to   { background: rgba(59,130,246,.22); }
}
.theme-ref-tip {
  display: none;
  position: absolute;
  z-index: 20;
  left: 50%; bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-width: 180px; max-width: 280px;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  font-size: 12px; line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  color: var(--color-text);
}
.theme-ref-hotspot:hover .theme-ref-tip { display: block; }
.theme-ref-tip strong { display: block; margin-bottom: 4px; color: var(--color-accent); }
.theme-ref-row {
  display: flex; align-items: center; gap: 6px; padding: 2px 0;
}
.theme-ref-swatch {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 3px; border: 1px solid rgba(255,255,255,.2);
  flex-shrink: 0;
}
.theme-ref-row code {
  font-family: var(--font-mono, monospace);
  font-size: 11px; color: var(--color-text);
}
.theme-ref-val {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 11px;
}
.theme-ref-hotspot[data-tip-below] .theme-ref-tip {
  bottom: auto; top: calc(100% + 6px);
}
.theme-ref-hotspot[data-tip-left] .theme-ref-tip {
  left: auto; right: 0; transform: none;
}

/* Narrow viewport: stack vertically */
@media (max-width: 768px) {
  .theme-editor-body { flex-direction: column; }
  .theme-ref-panel { flex: none; width: 100% !important; max-width: 100%; position: static; }
  .theme-editor-resize-handle { display: none; }
  .theme-editor-controls { max-height: none; padding-left: 0; }
  .modal-inner-appearance.editor-open { max-width: 95vw; }
}

/* ── Error fallback (JS) ──────────────────────────────────────────── */
.js-error-fallback {
  padding: 2rem;
  color: var(--color-error);
}
