/* MakeThemes — app chrome (neutral, does not use theme variables) */

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

:root {
  --app-bg: #f4f4f5;
  --app-surface: #ffffff;
  --app-border: #e4e4e7;
  --app-text: #18181b;
  --app-muted: #71717a;
  --app-accent: #3f3f46;
  --app-radius: 8px;
  --app-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --app-mono: ui-monospace, "Cascadia Code", "SF Mono", monospace;
  --panel-width: 380px;
  --header-height: 3.75rem;
  --app-control-height: 2rem;
}

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--app-font);
  background: var(--app-bg);
  color: var(--app-text);
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */

.app-header {
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.app-header__inner {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.5rem 1rem;
  max-width: 1600px;
  margin: 0 auto;
  min-height: var(--header-height);
}

.app-header__brand {
  min-width: 0;
}

.app-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.app-tagline {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--app-muted);
}

.app-tagline a {
  color: var(--app-muted);
  text-decoration: none;
}

.app-tagline a:hover {
  color: var(--app-text);
  text-decoration: underline;
}

.app-tagline__sep {
  margin: 0 0.25rem;
  opacity: 0.45;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.export-menu__trigger {
  white-space: nowrap;
}

.btn--header {
  height: var(--app-control-height);
  padding: 0 0.85rem;
  font-size: 0.75rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Export menu */

.export-menu {
  position: relative;
}

.export-menu__panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 13.5rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  padding: 0.35rem;
  z-index: 50;
}

.export-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--app-text);
  cursor: pointer;
  white-space: nowrap;
}

.export-menu__item:hover {
  background: var(--app-bg);
}

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

/* Main layout */

.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

/* Control panel */

.control-panel {
  position: sticky;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  display: flex;
  flex-direction: column;
  background: var(--app-surface);
  border-right: 1px solid var(--app-border);
  z-index: 10;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 1.5rem;
}

.control-section {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--app-border);
}

.control-section:last-child,
.control-section--nested:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.control-section--nested {
  padding-bottom: 0.875rem;
  margin-bottom: 0.875rem;
  border-bottom: 1px solid var(--app-border);
}

.control-section__title {
  margin: 0 0 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-muted);
}

.control-section__mode {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.control-hint {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--app-muted);
  line-height: 1.45;
}

.control-hint code {
  font-family: var(--app-mono);
  font-size: 0.6875rem;
  background: var(--app-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.control-field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.control-field--inline input[type="checkbox"] {
  accent-color: var(--app-accent);
}

.btn--full { width: 100%; }

/* Collapsible sections */

.control-details {
  margin-top: 0.625rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-bg);
  overflow: hidden;
}

.control-details--section {
  margin-bottom: 0.625rem;
  background: var(--app-surface);
}

.control-details--nested {
  margin-top: 0.5rem;
  background: var(--app-bg);
}

.control-section--presets {
  border-bottom: none;
  margin-bottom: 0.75rem;
  padding-bottom: 0;
}

.control-section--presets .control-section__title {
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
}

.control-section--actions--inline {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0;
  border: none;
}

.control-section--actions--inline .btn { flex: 1; }



.control-field--file input[type="file"] {
  font-size: 0.75rem;
  width: 100%;
}

.control-details__summary {
  padding: 0.5rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--app-text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.control-details__summary::-webkit-details-marker { display: none; }

.control-details__summary::after {
  content: '';
  flex-shrink: 0;
  width: 0.4em;
  height: 0.4em;
  margin-left: auto;
  margin-right: 0.35rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.45;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.control-details[open] .control-details__summary::after {
  transform: rotate(-135deg);
  opacity: 0.65;
}

.control-details[open] .control-details__summary {
  border-bottom: 1px solid var(--app-border);
}

.control-details__body {
  padding: 0.75rem 0.625rem 0.25rem;
}

.control-details .control-field--code {
  padding: 0.625rem;
}

.contrast-summary-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

.contrast-summary-badge--pass {
  background: #dcfce7;
  color: #166534;
}

.contrast-summary-badge--warn {
  background: #fef9c3;
  color: #854d0e;
}

.contrast-summary-badge--fail {
  background: #fee2e2;
  color: #991b1b;
}

/* Contrast checks */

.contrast-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.625rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.contrast-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--app-surface);
}

.contrast-item__label { color: var(--app-muted); }

.contrast-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.contrast-badge--pass { background: #dcfce7; color: #166534; }
.contrast-badge--warn { background: #fef9c3; color: #854d0e; }
.contrast-badge--fail { background: #fee2e2; color: #991b1b; }

.control-grid {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.control-grid--colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.control-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--app-muted);
}

.control-field--color {
  --cp-size: 1.75rem;
}

.control-field--color input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  background: var(--app-surface);
  color: var(--app-text);
}

.control-field select,
.control-field textarea {
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  background: var(--app-surface);
  color: var(--app-text);
}

.control-field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.85rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2371717a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 0.7rem) center;
  background-size: 0.65rem;
}

.control-field textarea {
  font-family: var(--app-mono);
  font-size: 0.6875rem;
  line-height: 1.45;
  resize: vertical;
  width: 100%;
}

.control-field--range input[type="range"] {
  width: 100%;
  accent-color: var(--app-accent);
}

.control-field--code { gap: 0.5rem; }

/* Presets */

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.control-section--presets .preset-grid {
  gap: 0.625rem;
}

.control-section--presets .preset-card {
  padding: 0.5rem 0.625rem;
}

.preset-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-bg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--app-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.preset-card:hover {
  border-color: var(--app-accent);
}

.preset-card.is-active {
  border-color: var(--app-text);
  box-shadow: 0 0 0 1px var(--app-text);
}

.preset-card__name {
  flex: 1;
  min-width: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-card__swatches {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding-left: 2px;
}

.preset-card__swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--app-surface);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.preset-card__swatch + .preset-card__swatch {
  margin-left: -5px;
}

/* Mode toggle */

.mode-toggle {
  display: flex;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  overflow: hidden;
}

.mode-toggle--header {
  height: var(--app-control-height);
}

.mode-toggle--header .mode-btn {
  padding: 0 0.65rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  height: 100%;
}

.mode-toggle--compact .mode-btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.6875rem;
}

.mode-btn {
  padding: 0.4rem 0.65rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--app-muted);
}

.mode-btn.is-active {
  background: var(--app-text);
  color: var(--app-surface);
}

/* App buttons */

.btn {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }

.btn--primary {
  background: var(--app-text);
  color: var(--app-surface);
  border-color: var(--app-text);
}

.btn--secondary {
  background: var(--app-surface);
  color: var(--app-text);
  border-color: var(--app-border);
}

.btn--ghost {
  background: transparent;
  color: var(--app-muted);
  border-color: var(--app-border);
}

.btn--small {
  font-size: 0.75rem;
  padding: 0.35rem 0.6rem;
  align-self: flex-start;
}

.control-section--actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.25rem;
  border-bottom: none;
}

.control-section--actions .btn { flex: 1; }

.export-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Preview tabs (header) */

.preview-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.preview-tab {
  flex: 0 0 auto;
  padding: 0.45rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--app-muted);
  cursor: pointer;
  white-space: nowrap;
}

.preview-tab:hover { color: var(--app-text); }

.preview-tab.is-active {
  background: var(--app-text);
  color: var(--app-surface);
}

/* Preview area */

.preview-frame { display: none; }
.preview-frame.is-active { display: block; }

.preview-wrap {
  min-width: 0;
  padding: 0.75rem 1rem 1.5rem;
  position: sticky;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Mobile tabs */

.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--app-surface);
  border-top: 1px solid var(--app-border);
  z-index: 40;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}

.mobile-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--app-muted);
  border-top: 2px solid transparent;
}

.mobile-tab.is-active {
  color: var(--app-text);
  border-top-color: var(--app-text);
}

/* Toast */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--app-text);
  color: var(--app-surface);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 100;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Tablet / mobile */

@media (max-width: 1100px) {
  :root { --header-height: 5.5rem; }

  .app-header__inner {
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    grid-template-rows: auto auto;
  }

  .app-header__brand { grid-column: 1; grid-row: 1; }
  .app-header__actions { grid-column: 2; grid-row: 1; justify-self: end; }
  .preview-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
  }
}

@media (max-width: 900px) {
  .app-tagline { display: none; }
}

@media (max-width: 768px) {
  :root { --header-height: 5.25rem; }

  body { padding-bottom: 3.25rem; }

  .app-main {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    height: auto;
    min-height: calc(100dvh - var(--header-height) - 3.25rem);
    border-right: none;
  }

  .panel-scroll {
    max-height: none;
  }

  .preview-wrap {
    position: static;
    height: auto;
    min-height: calc(100dvh - var(--header-height) - 3.25rem);
    overflow-y: visible;
  }

  .app-main[data-mobile-view="edit"] .preview-wrap { display: none; }
  .app-main[data-mobile-view="preview"] .control-panel { display: none; }

  .mobile-tabs { display: flex; }

  .toast { bottom: 4.5rem; }

  .btn--header.hide-mobile { display: none; }

}

@media (max-width: 420px) {
  .app-header__actions {
    gap: 0.35rem;
  }

  .preview-tab {
    padding: 0.4rem 0.55rem;
    font-size: 0.75rem;
  }

  .control-grid--colors {
    grid-template-columns: 1fr;
  }
}