:root {
  color-scheme: light;
  --ink: #2c1821;
  --muted: #78616b;
  --line: #eadde2;
  --surface: rgba(255, 255, 255, 0.88);
  --accent: #c72c61;
  --accent-dark: #9d1f49;
  --shadow: 0 22px 60px rgba(88, 36, 56, 0.13);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, rgba(255, 198, 220, .48), transparent 28rem),
    radial-gradient(circle at 90% 10%, rgba(213, 199, 255, .42), transparent 30rem),
    linear-gradient(145deg, #fff9fb, #f8f4ff 62%, #fff8f0);
}

button, input { font: inherit; }
button { color: inherit; }

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

.hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 24px;
  color: white;
  font-size: 38px;
  background: linear-gradient(145deg, #ef477c, #a51e53);
  box-shadow: 0 14px 32px rgba(183, 37, 88, .28);
  transform: rotate(-4deg);
}

.eyebrow, .step {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2.15rem, 5vw, 4.25rem); line-height: .96; letter-spacing: -.055em; }
h2 { margin-bottom: 0; font-size: 1.12rem; letter-spacing: -.02em; }
.subtitle { max-width: 650px; margin-bottom: 0; color: var(--muted); font-size: 1.05rem; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .85fr);
  gap: 24px;
  align-items: start;
}

.panel {
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.controls { padding: 30px; }
.controls section + section { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); }
.preview-panel { position: sticky; top: 20px; padding: 30px; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.section-heading.compact { margin-bottom: 12px; }

.counter {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #ffe8f0;
  font-size: .78rem;
  font-weight: 800;
}

.color-grid { display: grid; grid-template-columns: repeat(6, minmax(44px, 1fr)); gap: 11px; }
.color-button {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 2px solid transparent;
  border-radius: 18px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line), 0 5px 13px rgba(70, 24, 43, .06);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.color-button:hover { transform: translateY(-2px); }
.color-button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(199,44,97,.12); }
.color-swatch { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.color-button[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.hint, .status { margin: 12px 0 0; color: var(--muted); font-size: .82rem; }

.style-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.style-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  text-align: left;
  border: 2px solid transparent;
  border-radius: 18px;
  background: white;
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}
.style-button[aria-checked="true"] { border-color: var(--accent); background: #fff7fa; }
.style-icon { width: 40px; height: 40px; border-radius: 13px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.style-label strong, .style-label small { display: block; }
.style-label small { margin-top: 3px; color: var(--muted); font-size: .75rem; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { margin-top: 3px; color: var(--muted); }
.toggle-row input { width: 46px; height: 26px; accent-color: var(--accent); cursor: pointer; }

.canvas-frame {
  position: relative;
  overflow: hidden;
  width: min(100%, 480px);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: inset 0 0 30px rgba(70, 30, 45, .05);
}
.checkerboard {
  position: absolute;
  inset: 0;
  opacity: .54;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eadfe4 25%, transparent 25%),
    linear-gradient(-45deg, #eadfe4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eadfe4 75%),
    linear-gradient(-45deg, transparent 75%, #eadfe4 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}
canvas { position: relative; display: block; width: 100%; height: 100%; }

.stripe-order-hint { margin: 16px 0 8px; color: var(--muted); font-size: .78rem; font-weight: 700; text-align: center; }
.selected-summary { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 34px; margin: 0 0 18px; }
.summary-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 7px 6px 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .78rem; }
.summary-index { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; color: var(--muted); background: #f6eef2; font-size: .68rem; font-weight: 800; }
.summary-order-controls { display: inline-flex; gap: 2px; margin-left: 2px; }
.summary-order-controls button { display: grid; place-items: center; width: 23px; height: 23px; padding: 0; border: 0; border-radius: 50%; color: var(--accent-dark); background: #f9edf2; cursor: pointer; font-size: .75rem; font-weight: 900; }
.summary-order-controls button:hover:not(:disabled) { background: #f4dce6; }
.summary-order-controls button:disabled { opacity: .3; cursor: default; }
.summary-dot { width: 13px; height: 13px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

.actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.primary-button, .secondary-button, .text-button { border: 0; cursor: pointer; font-weight: 800; }
.primary-button, .secondary-button { min-height: 52px; border-radius: 16px; padding: 0 18px; }
.primary-button { color: white; background: linear-gradient(135deg, #d9346d, #a91f52); box-shadow: 0 11px 24px rgba(174, 31, 82, .24); }
.primary-button:hover { filter: brightness(.97); transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--line); background: white; }
.text-button { padding: 8px 0; color: var(--accent); background: transparent; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px 8px 0; color: var(--muted); font-size: .82rem; }
footer a { color: var(--accent-dark); font-weight: 700; text-decoration: none; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 26px; }
  .hero { align-items: flex-start; }
  .brand-mark { width: 54px; height: 54px; border-radius: 18px; font-size: 28px; }
  .controls, .preview-panel { padding: 20px; border-radius: 22px; }
  .color-grid { grid-template-columns: repeat(4, 1fr); }
  .style-grid { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

.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; }
.subheading { margin: 18px 0 10px; font-size: .9rem; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-row button, .small-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  color: var(--accent-dark);
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}
.preset-row button:hover, .small-button:hover { background: #fff3f7; border-color: #e2bccb; }
.combine-flags { display: grid; gap: 9px; margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fffafd; }
.combine-flags label strong, .combine-flags label small { display: block; }
.combine-flags label small { margin-top: 3px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.append-preset-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.append-preset-controls select { min-width: 0; border: 1px solid var(--line); border-radius: 999px; padding: 8px 34px 8px 12px; color: var(--ink); background: #fff; font: inherit; font-size: .78rem; font-weight: 750; }
.pride-palette { display: grid; grid-template-columns: repeat(7, minmax(48px, 1fr)); gap: 8px; }
.palette-color { min-width: 0; padding: 6px 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.palette-color span { display: block; width: 25px; height: 25px; margin: 0 auto 4px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); }
.palette-color small { display: block; overflow: hidden; color: var(--muted); font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.palette-color:hover { transform: translateY(-1px); box-shadow: 0 5px 13px rgba(70,24,43,.07); }
.stripe-editor-heading { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-top: 18px; }
.stripe-editor-heading .subheading { margin: 0 0 3px; }
.stripe-editor-heading .hint { margin: 0; }
.stripe-editor { display: grid; gap: 8px; margin-top: 12px; max-height: 430px; overflow: auto; padding-right: 3px; }
.stripe-row { display: grid; grid-template-columns: 30px 44px minmax(92px, 1fr) auto; align-items: center; gap: 9px; padding: 8px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.stripe-number { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: #f7edf1; color: var(--muted); font-size: .72rem; font-weight: 800; }
.native-color { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.hex-field input { width: 100%; min-width: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.hex-field input:focus { outline: 2px solid rgba(199,44,97,.22); border-color: var(--accent); }
.stripe-actions { display: inline-flex; gap: 4px; }
.stripe-actions button { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 9px; color: var(--accent-dark); background: #f9edf2; cursor: pointer; font-weight: 900; }
.stripe-actions button:hover:not(:disabled) { background: #f2dbe5; }
.stripe-actions button:disabled { opacity: .28; cursor: default; }
.stripe-actions .remove-stripe { color: #9b243e; }

@media (max-width: 560px) {
  .pride-palette { grid-template-columns: repeat(4, 1fr); }
  .append-preset-controls { grid-template-columns: 1fr; }
  .stripe-editor-heading { align-items: flex-start; }
  .stripe-row { grid-template-columns: 28px 42px 1fr; }
  .stripe-actions { grid-column: 2 / -1; justify-content: flex-end; }
}

.orientation-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.orientation-button { display: flex; align-items: center; gap: 11px; padding: 12px; border: 2px solid transparent; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); text-align: left; cursor: pointer; }
.orientation-button[aria-checked="true"] { border-color: var(--accent); background: #fff7fa; box-shadow: 0 0 0 4px rgba(199,44,97,.09); }
.orientation-button strong, .orientation-button small { display: block; }
.orientation-button small { margin-top: 2px; color: var(--muted); font-size: .72rem; }
.orientation-icon { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); background-color: #fff; }
.vertical-icon { background-image: linear-gradient(90deg, #e40303 0 16.66%, #ff8c00 16.66% 33.33%, #ffed00 33.33% 50%, #008026 50% 66.66%, #004dff 66.66% 83.33%, #750787 83.33% 100%); }
.horizontal-icon { background-image: linear-gradient(180deg, #e40303 0 16.66%, #ff8c00 16.66% 33.33%, #ffed00 33.33% 50%, #008026 50% 66.66%, #004dff 66.66% 83.33%, #750787 83.33% 100%); }
@media (max-width: 430px) { .orientation-picker { grid-template-columns: 1fr; } }
