.theme-editor-shell {
  padding: 28px 24px 40px;
  --theme-editor-panel-bg: var(--color-surface-solid);
  --theme-editor-panel-bg-alt: var(--color-surface-solid-alt);
  --theme-editor-panel-bg-subtle: color-mix(in srgb, var(--theme-editor-panel-bg) 82%, var(--color-bg) 18%);
  --theme-editor-border: var(--color-border, rgba(148, 163, 184, 0.18));
  --theme-editor-border-strong: color-mix(in srgb, var(--accent-primary) 32%, var(--theme-editor-border));
  --theme-editor-text-strong: var(--color-text, #f8fafc);
  --theme-editor-text-muted: var(--color-text-muted, #94a3b8);
  --theme-editor-button-bg: var(--theme-editor-panel-bg-subtle);
  --theme-editor-button-bg-alt: var(--theme-editor-panel-bg-alt);
  --theme-editor-button-text: var(--theme-editor-text-strong);
}

.theme-editor-embedded {
  padding: 0;
}

.theme-editor-embedded .theme-editor-actions {
  justify-content: flex-start;
  margin-bottom: 14px;
}

.theme-editor-embedded .theme-preset-section {
  margin-bottom: 18px;
}

.theme-editor-embedded .theme-editor-layout {
  gap: 16px;
}

.theme-editor-embedded .theme-preview-card {
  height: 100%;
}

.theme-editor-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.theme-editor-kicker,
.theme-preview-kicker,
.theme-preview-workspace-kicker,
.theme-section-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-secondary);
}

.theme-editor-hero-copy h1 {
  margin: 8px 0 10px;
}

.theme-editor-hero-copy p {
  margin: 0;
  max-width: 760px;
  color: var(--theme-editor-text-muted);
}

.theme-editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-editor-link,
.theme-editor-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: var(--theme-radius-button);
  border: 1px solid var(--theme-editor-border-strong);
  background: var(--theme-editor-button-bg);
  color: var(--theme-editor-button-text);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--theme-transition-fast), border-color var(--theme-transition-fast), background var(--theme-transition-fast);
}

.theme-editor-btn.secondary {
  background: var(--theme-editor-button-bg-alt);
}

.theme-editor-btn.danger {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(67, 16, 27, 0.88);
  color: #fecaca;
}

.theme-editor-link:hover,
.theme-editor-btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent-primary) 48%, var(--theme-editor-border));
}

.theme-editor-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.theme-editor-status {
  min-height: 22px;
  margin-bottom: 18px;
  font-size: 0.84rem;
  color: var(--theme-editor-text-muted);
}

.theme-editor-status.is-success {
  color: var(--compliant);
}

.theme-editor-status.is-error {
  color: var(--non-compliant);
}

.theme-preset-section {
  margin-bottom: 20px;
  padding: 22px;
  border-radius: var(--theme-radius-card);
  border: 1px solid var(--theme-editor-border-strong);
  background: linear-gradient(180deg, var(--theme-editor-panel-bg), var(--theme-editor-panel-bg-subtle));
  box-shadow: var(--theme-shadow-card);
}

.theme-preset-head h2 {
  margin: 6px 0 8px;
}

.theme-preset-head p,
.theme-advanced-copy p {
  margin: 0;
  color: var(--theme-editor-text-muted);
}

.theme-preset-summary {
  margin: 16px 0 14px;
}

.theme-preset-summary-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: calc(var(--theme-radius-card) - 2px);
  border: 1px solid var(--theme-editor-border-strong);
  background: var(--theme-editor-panel-bg-subtle);
}

.theme-preset-summary-card.is-custom {
  border-color: var(--theme-editor-border);
}

.theme-preset-summary-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-secondary);
}

.theme-preset-summary-card strong {
  color: var(--theme-editor-text-strong);
  font-size: 1rem;
}

.theme-preset-summary-card span:last-child {
  color: var(--theme-editor-text-muted);
  font-size: 0.84rem;
}

.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.theme-preset-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: calc(var(--theme-radius-card) - 2px);
  border: 1px solid var(--theme-editor-border);
  background: var(--theme-editor-panel-bg-subtle);
  box-shadow: var(--theme-shadow-card);
  transition: transform var(--theme-transition-fast), border-color var(--theme-transition-fast), box-shadow var(--theme-transition-fast);
}

.theme-preset-card.is-applied {
  border-color: var(--theme-editor-border-strong);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-primary) 18%, transparent), var(--theme-shadow-card);
}

.theme-preset-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent-primary) 42%, var(--theme-editor-border));
}

.theme-preset-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.theme-preset-card-head h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.theme-preset-card-head p {
  margin: 0;
  color: var(--theme-editor-text-muted);
  font-size: 0.82rem;
}

.theme-preset-tone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 6px 10px;
  border-radius: var(--theme-radius-badge);
  border: 1px solid var(--theme-editor-border);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.theme-preset-tone.tone-light {
  background: color-mix(in srgb, white 58%, var(--theme-editor-panel-bg-subtle));
  color: color-mix(in srgb, var(--theme-editor-text-strong) 90%, var(--accent-primary));
}

.theme-preset-tone.tone-dark {
  background: color-mix(in srgb, #020617 26%, var(--theme-editor-panel-bg-alt));
  color: color-mix(in srgb, var(--accent-primary) 72%, var(--theme-editor-text-strong));
}

.theme-preset-swatches {
  display: flex;
  gap: 8px;
}

.theme-preset-swatch {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--theme-editor-border) 72%, rgba(255, 255, 255, 0.12));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.theme-preset-footer {
  display: grid;
  gap: 10px;
}

.theme-preset-note {
  color: var(--theme-editor-text-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.theme-editor-main {
  min-width: 0;
}

.theme-advanced-shell {
  border-radius: var(--theme-radius-card);
  border: 1px solid var(--theme-editor-border-strong);
  background: linear-gradient(180deg, var(--theme-editor-panel-bg), var(--theme-editor-panel-bg-subtle));
  box-shadow: var(--theme-shadow-card);
  overflow: hidden;
}

.theme-advanced-shell > summary {
  list-style: none;
}

.theme-advanced-shell > summary::-webkit-details-marker {
  display: none;
}

.theme-advanced-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  cursor: pointer;
}

.theme-advanced-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--theme-editor-text-strong);
}

.theme-advanced-summary-note {
  color: var(--theme-editor-text-muted);
  font-size: 0.84rem;
  text-align: right;
}

.theme-advanced-copy {
  padding: 0 22px 18px;
}

.theme-advanced-shell .theme-editor-sections {
  padding: 0 22px 22px;
}

.theme-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.theme-editor-sections {
  display: grid;
  gap: 16px;
}

.theme-section {
  padding: 22px;
  border-radius: var(--theme-radius-card);
  border: 1px solid var(--theme-editor-border-strong);
  background: linear-gradient(180deg, var(--theme-editor-panel-bg), var(--theme-editor-panel-bg-subtle));
  box-shadow: var(--theme-shadow-card);
}

.theme-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.theme-section-head h2 {
  margin: 6px 0 6px;
}

.theme-section-head p {
  margin: 0;
  color: var(--theme-editor-text-muted);
}

.theme-section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-section-actions button {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: var(--theme-radius-button);
}

.theme-section-grid {
  display: grid;
  gap: 12px;
}

.theme-field-row {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.theme-field-meta strong {
  display: block;
  color: var(--theme-editor-text-strong);
  font-size: 0.92rem;
}

.theme-field-meta span {
  display: block;
  margin-top: 4px;
  color: var(--theme-editor-text-muted);
  font-size: 0.78rem;
}

.theme-field-input,
.theme-field-range {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-field-input input[type="text"],
.theme-field-input input[type="number"],
.theme-field-input select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--theme-radius-input);
  border: 1px solid var(--theme-editor-border);
  background: var(--theme-editor-panel-bg-alt);
  color: var(--theme-editor-text-strong);
}

.theme-field-input input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--theme-editor-border);
  background: var(--theme-editor-panel-bg-alt);
}

.theme-color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--theme-editor-border);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.theme-field-range input[type="range"] {
  flex: 1;
}

.theme-range-value {
  min-width: 54px;
  text-align: right;
  color: var(--theme-editor-text-muted);
  font-size: 0.82rem;
}

.theme-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.theme-icon-card {
  padding: 14px;
  border-radius: var(--theme-radius-card);
  border: 1px solid var(--theme-editor-border);
  background: var(--theme-editor-panel-bg-alt);
}

.theme-icon-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.theme-icon-card-head strong {
  color: var(--theme-editor-text-strong);
}

.theme-icon-preview {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--theme-editor-border) 90%, var(--accent-primary));
  background: color-mix(in srgb, var(--theme-editor-panel-bg-alt) 92%, white 8%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.theme-icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.theme-icon-empty {
  color: var(--theme-editor-text-muted);
  font-size: 0.72rem;
  text-align: center;
}

.theme-icon-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.theme-icon-actions input[type="file"] {
  display: none;
}

.theme-editor-preview {
  position: sticky;
  top: 24px;
}

.theme-preview-card {
  padding: 22px;
  border-radius: var(--theme-radius-card);
  border: 1px solid var(--theme-editor-border-strong);
  background: linear-gradient(180deg, var(--theme-editor-panel-bg), var(--theme-editor-panel-bg-subtle));
  box-shadow: var(--theme-shadow-card);
}

.theme-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.theme-preview-head h2 {
  margin: 6px 0 0;
}

.theme-preview-badge,
.theme-preview-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: var(--theme-radius-badge);
  font-size: 0.76rem;
  font-weight: 700;
}

.theme-preview-badge {
  border: 1px solid var(--theme-editor-border-strong);
  background: color-mix(in srgb, var(--accent-primary) 14%, transparent);
  color: color-mix(in srgb, var(--accent-primary) 72%, var(--theme-editor-text-strong));
}

.theme-preview-grid {
  display: grid;
  gap: 12px;
}

.theme-preview-panel {
  padding: 14px;
  border-radius: var(--theme-radius-card);
  border: 1px solid var(--theme-editor-border);
  background: var(--theme-editor-panel-bg-alt);
}

.theme-preview-panel header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
}

.theme-preview-panel header strong {
  color: var(--theme-editor-text-strong);
}

.theme-preview-panel header span,
.theme-preview-workspace p {
  color: var(--theme-editor-text-muted);
  font-size: 0.8rem;
}

.theme-preview-button-row,
.theme-preview-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-preview-chip.risk-low { background: color-mix(in srgb, var(--risk-low) 18%, transparent); color: var(--risk-low); }
.theme-preview-chip.risk-moderate { background: color-mix(in srgb, var(--risk-moderate) 18%, transparent); color: var(--risk-moderate); }
.theme-preview-chip.risk-high { background: color-mix(in srgb, var(--risk-high) 18%, transparent); color: var(--risk-high); }
.theme-preview-chip.risk-critical { background: color-mix(in srgb, var(--risk-critical) 18%, transparent); color: var(--risk-critical); }
.theme-preview-chip.review-overdue { background: color-mix(in srgb, var(--review-overdue) 18%, transparent); color: var(--review-overdue); }
.theme-preview-chip.review-due-soon { background: color-mix(in srgb, var(--review-due-soon) 18%, transparent); color: var(--review-due-soon); }
.theme-preview-chip.review-scheduled { background: color-mix(in srgb, var(--review-scheduled) 18%, transparent); color: var(--review-scheduled); }
.theme-preview-chip.class-regulated { background: color-mix(in srgb, var(--classification-regulated) 18%, transparent); color: var(--classification-regulated); }
.theme-preview-chip.class-confidential { background: color-mix(in srgb, var(--classification-confidential) 18%, transparent); color: var(--classification-confidential); }
.theme-preview-chip.class-restricted { background: color-mix(in srgb, var(--classification-restricted) 18%, transparent); color: var(--classification-restricted); }
.theme-preview-chip.class-public { background: color-mix(in srgb, var(--classification-public) 18%, transparent); color: var(--classification-public); }

.theme-preview-workspace {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--theme-radius-card);
  border: 1px solid color-mix(in srgb, var(--workspace-gradient-start) 44%, var(--theme-editor-border));
  background:
    linear-gradient(color-mix(in srgb, var(--theme-editor-panel-bg) 54%, transparent), color-mix(in srgb, var(--theme-editor-panel-bg) 54%, transparent)),
    linear-gradient(var(--workspace-gradient-angle), var(--workspace-gradient-start), var(--workspace-gradient-end));
  box-shadow: var(--theme-shadow-card-hover);
}

.theme-preview-workspace-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.theme-preview-workspace-head h3 {
  margin: 6px 0 0;
  color: #f7fbff;
}

.theme-preview-score {
  font-size: 2rem;
  font-weight: 800;
  color: var(--compliant);
}

.theme-preview-workspace-bar {
  margin: 14px 0 12px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.theme-preview-workspace-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--section-tint-green), var(--section-tint-cyan));
}

@media (max-width: 1180px) {
  .theme-editor-layout {
    grid-template-columns: 1fr;
  }

  .theme-editor-preview {
    position: static;
  }
}

@media (max-width: 720px) {
  .theme-editor-shell {
    padding-inline: 14px;
  }

  .theme-editor-hero {
    flex-direction: column;
  }

  .theme-editor-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .theme-field-row {
    grid-template-columns: 1fr;
  }
}
