:root {
  --bg: #020617;
  --panel: #0f172a;
  --panel-soft: #111827;
  --border: #233044;
  --text: #e5eefb;
  --muted: #9fb0c7;
  --accent: #14b8a6;
  --accent-strong: #2dd4bf;
  --danger: #fb7185;
  --success: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(
      circle at top left,
      rgba(20, 184, 166, 0.22),
      transparent 34rem
    ),
    linear-gradient(135deg, #020617 0%, #07111f 56%, #0f172a 100%);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.tool-panel {
  display: grid;
  gap: 24px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
}

.lede,
.section-heading p,
.status-card p,
.palette-button small,
.suggestion small {
  color: var(--muted);
}

.lede {
  max-width: 680px;
  margin-bottom: 0;
  line-height: 1.7;
}

.meters-cluster {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.ratio-meter {
  min-width: 170px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
}

.meter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meter-header small {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  color: var(--muted);
}

.meter-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meter-badge.pass {
  color: #052e16;
  background: var(--success);
}

.meter-badge.warn {
  color: #451a03;
  background: #facc15;
}

.meter-badge.fail {
  color: #4c0519;
  background: var(--danger);
}

.ratio-meter span {
  display: block;
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1.1;
  margin: 4px 0;
}

.ratio-meter small.meter-sub {
  color: var(--muted);
  font-size: 0.78rem;
}

.apca-meter {
  border-color: rgba(20, 184, 166, 0.35);
  background: rgba(15, 23, 42, 0.88);
}

.workspace {
  display: grid;
  grid-template-columns: 0.86fr 1.14fr;
  gap: 22px;
}

.controls,
.results,
.palettes {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.84);
  box-shadow: 0 18px 50px rgba(2, 6, 23, 0.32);
}

.controls,
.palettes {
  padding: 22px;
}

.results {
  padding: 20px;
}

.field-group {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

label {
  color: #cbd5e1;
  font-weight: 800;
}

.color-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
}

input[type="color"] {
  width: 58px;
  height: 48px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #020617;
  cursor: pointer;
}

input[type="text"] {
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: #020617;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
}

/* ═══ CVD Simulation Controls ═══ */
.cvd-section {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.cvd-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cvd-indicator {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cvd-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cvd-tab {
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cvd-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.cvd-tab.active {
  background: rgba(20, 184, 166, 0.2);
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ═══ Live Typography & Button Preview ═══ */
.sample-preview {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 16px 0;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  min-height: 220px;
  transition:
    filter 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.preview-typography {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-headline {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1.2;
}

.preview-subheading {
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.3;
  opacity: 0.95;
}

.preview-body {
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  opacity: 0.9;
}

.preview-caption {
  font-size: 0.78rem;
  opacity: 0.78;
  font-weight: 500;
}

.preview-components {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.preview-components-heading {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
}

.preview-buttons-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-btn-solid {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: default;
  transition: all 0.15s;
}

.preview-btn-outline {
  padding: 7px 15px;
  border-radius: 6px;
  border: 2px solid currentColor;
  background: transparent;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: default;
  transition: all 0.15s;
}

.preview-pill-badge {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: default;
}

.cvd-info-bar {
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(20, 184, 166, 0.12);
  border: 1px solid rgba(20, 184, 166, 0.25);
  font-size: 0.8rem;
  color: var(--text);
}

.cvd-info-bar code {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--accent-strong);
}

.validation-message {
  display: none;
  margin-bottom: 14px;
  color: var(--danger);
  font-weight: 700;
}

.validation-message.visible {
  display: block;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: #042f2e;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  font-weight: 900;
  cursor: pointer;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.apca-section {
  margin-top: 24px;
}

.apca-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.status-card.apca-card {
  border-color: rgba(20, 184, 166, 0.2);
}

/* ═══ CVD Matrix Section ═══ */
.cvd-matrix-section {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.84);
  box-shadow: 0 18px 50px rgba(2, 6, 23, 0.32);
}

.cvd-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.cvd-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cvd-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.cvd-card.active-cvd-card {
  border-color: var(--accent-strong);
  box-shadow: 0 0 12px rgba(20, 184, 166, 0.3);
}

.cvd-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.cvd-card-header h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.cvd-card-header small {
  color: var(--muted);
  font-size: 0.74rem;
  display: block;
}

.cvd-badge {
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  flex-shrink: 0;
}

.cvd-badge.pass {
  background: var(--success);
  color: #052e16;
}

.cvd-badge.fail {
  background: var(--danger);
  color: #4c0519;
}

.cvd-card-preview {
  padding: 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.cvd-preview-sample {
  font-size: 0.92rem;
  font-weight: 800;
}

.cvd-preview-btn {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 800;
}

.cvd-card-metrics {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.metric-label {
  color: var(--muted);
  margin-right: 4px;
}

.cvd-card-colors {
  font-size: 0.72rem;
  color: var(--muted);
}

.cvd-card-colors code {
  color: var(--text);
}

.status-card {
  min-height: 130px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

.status-card span {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
}

.status-card.pass span {
  color: #052e16;
  background: var(--success);
}

.status-card.fail span {
  color: #4c0519;
  background: var(--danger);
}

.status-card h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.status-card p {
  margin-bottom: 0;
}

.suggestions {
  margin-top: 20px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2 {
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.section-heading p {
  margin-bottom: 0;
}

.suggestion-list,
.palette-list {
  display: grid;
  gap: 10px;
}

.suggestion,
.palette-button,
.empty-state {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: #020617;
  text-align: left;
}

.suggestion,
.palette-button {
  cursor: pointer;
}

.suggestion:hover,
.palette-button:hover {
  border-color: var(--accent);
}

.swatch,
.palette-preview {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-weight: 900;
}

.suggestion strong,
.palette-button strong {
  display: block;
}

.empty-state {
  color: var(--muted);
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 24px, 680px);
    padding: 28px 0;
  }

  .hero,
  .workspace {
    grid-template-columns: 1fr;
    display: grid;
  }

  .meters-cluster {
    width: 100%;
    flex-direction: column;
  }

  .ratio-meter {
    width: 100%;
  }

  .status-grid,
  .apca-grid {
    grid-template-columns: 1fr;
  }
}
