* { box-sizing: border-box; }

:root {
  --primary: #3330F9;
  --primary-dark: #0A06DF;
  --primary-bg: #E7E6FE; 
  --primary-subtle: #C3C2FD; 
  --text: #202124;
  --muted: #68707a;
  --border: #dedfe3;
  --background: #f7f7f8;
  --soft: #f0f0f2;
  --success: #18794e;
  --success-soft: #e8f5ef;
  --white: #ffffff;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button, input, select { font: inherit; }

.float-backhome {
  .back-link {
    padding: 0.5rem;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    vertical-align: middle;
    gap: 0.5rem;
    color: var(--primary);
    border-radius: 0.5rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    line-height: 1;
    span {
      font-size: 1rem;
    }
    &:hover {
      background-color: var(--primary-bg);
    }
  }
}

@media (min-width: 990px) {
  .float-backhome {
    position: fixed;
    top: 1rem;
  }
}

.site-header { text-align: center; padding: 34px 20px 28px; }
.site-header h1 { margin: 0 0 7px; font-size: clamp(29px, 4vw, 38px); line-height: 1.2; }
.site-header p { margin: 0; color: var(--muted); font-size: 16px; }

.container { width: min(900px, calc(100% - 32px)); margin: 0 auto 52px; }
.container-wide { width: min(1080px, calc(100% - 32px)); }

.tool-card { background: #fff; border-radius: 9px; padding: 24px; box-shadow: 0 1px 5px rgba(0, 0, 0, .04); }
.tool-card + .tool-card { margin-top: 20px; }

.tool-intro { margin-bottom: 20px; }
.tool-intro h2 { margin: 0 0 5px; font-size: 21px; }
.tool-intro p { margin: 0; color: var(--muted); }

/* ---------------- Generator layout ---------------- */

.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sub-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  background: #fbfbfc;
}

.sub-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

.sub-card-head .palette-format-tabs { margin-left: auto; }

.sub-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex: 0 0 7px; }

/* Color panel (base color input) */

.color-panel-body { margin-bottom: 16px; }

.format-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.format-tab {
  border: 0;
  background: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.format-tab.active { background: var(--primary); color: #fff; }

.color-input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.color-field-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: text;
}

.color-swatch {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-swatch::-moz-color-swatch { border: 0; border-radius: 6px; }

.color-text {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
}

.color-text:focus-visible { outline: none; }

.color-field-box:focus-within {
  outline: 3px solid rgba(91,91,240,.25);
  outline-offset: 2px;
}

.color-text.invalid { color: #c62839; }
.color-field-box:has(.color-text.invalid) { border-color: #c62839; background: #fbeaec; }

.random-color-box {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  text-align: center;
}

.random-color-box:hover { background: var(--soft); }

.dice-btn {
  flex: 0 0 auto;
  width: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 16px;
  cursor: pointer;
}

.dice-btn:hover { background: var(--primary-bg); }

.field label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 13.5px; }

.mono-field { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }

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

.mono-variation-label { margin-top: 14px !important; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  width: 100%;
}

.segmented-btn {
  flex: 1;
  border: 0;
  background: #fff;
  padding: 9px 8px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  border-right: 1px solid var(--border);
}

.segmented-btn:last-child { border-right: 0; }
.segmented-btn.active { background: var(--primary); color: #fff; }

.mono-hint {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
}

select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 3px solid rgba(91,91,240,.25);
  outline-offset: 2px;
}

/* Palette swatches */

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

.swatch {
  border: 0;
  padding: 0;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--border);
  text-align: left;
  position: relative;
  transition: transform .12s;
}

.swatch:hover { transform: translateY(-2px); }

.swatch-color { display: block; width: 100%; height: 84px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }

.swatch-hex {
  display: block;
  padding: 8px 9px;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: #fff;
}

.swatch-copied {
  position: absolute;
  top: 8px; right: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .15s, transform .15s;
  pointer-events: none;
}

.swatch-copied.show { opacity: 1; transform: translateY(0); }

.swatch-base-badge {
  position: absolute;
  top: 8px; left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,.72);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}

.swatch.is-base { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

/* Actions + export */

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.secondary-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}

.secondary-btn:hover { background: var(--soft); }
.secondary-btn[aria-expanded="true"] { background: var(--text); color: #fff; border-color: var(--text); }

.export-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfbfc;
}

.export-code {
  margin: 12px 0;
  padding: 14px;
  border-radius: 8px;
  background: #1e1e26;
  color: #e6e6f0;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}

/* Harmonies reference grid */

.harmonies-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.harmony-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.harmony-card:hover { border-color: var(--primary); }
.harmony-card.active { border-color: var(--primary); background: var(--primary-bg); }

.harmony-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.harmony-formula {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-weight: 700;
  font-size: 15px;
}

/* ---------------- Content / FAQ ---------------- */

.content-section { margin-top: 32px; padding: 0 4px; }
.content-section h2 { margin: 0 0 10px; font-size: 25px; }
.content-section h3 { margin: 26px 0 7px; font-size: 19px; }
.content-section p, .content-section li { color: #454a51; }
.content-section ol { padding-left: 23px; }

.site-footer { margin-top: auto; padding: 18px; text-align: center; background: #ededee; color: #30343a; }
.site-footer p { margin: 0; }

@media (max-width: 760px) {
  .tool-card { padding: 17px; }
  .generator-grid { grid-template-columns: 1fr; }
  .harmonies-grid { grid-template-columns: repeat(2, 1fr); }
  .actions-row { flex-direction: column; }
  .actions-row .secondary-btn { width: 100%; }
}

@media (max-width: 460px) {
  .harmonies-grid { grid-template-columns: 1fr; }
}
