:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --soft: #eef2f6;
  --line: #d9e0ea;
  --brand: #377df6;
  --brand-dark: #1f5fd0;
  --brand-soft: #edf4ff;
  --accent: #377df6;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 18%, rgba(55, 125, 246, 0.16), transparent 31rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #111827;
  font-size: 0.96rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
}

.nav-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px clamp(16px, 3vw, 28px);
}

.nav-links a {
  color: #334155;
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

.ghost-button {
  margin-left: auto;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: clamp(22px, 4vw, 44px);
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(26px, 5vw, 52px) clamp(18px, 4vw, 32px) 44px;
}

.preview-panel,
.controls {
  min-width: 0;
}

.preview-panel {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 18px;
}

.hero-copy {
  display: grid;
  gap: 12px;
  max-width: 720px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.55;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 15ch;
  color: #020617;
  font-size: clamp(2.3rem, 4.4vw, 4rem);
  font-weight: 800;
  line-height: 1.02;
}

.hero-copy p:last-child {
  max-width: 42ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  line-height: 1.75;
}

h2 {
  color: #111827;
  font-size: 0.98rem;
  font-weight: 900;
}

.phone-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(70vh, 740px);
  padding: clamp(20px, 4vw, 42px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(55, 125, 246, 0.16), transparent 19rem),
    linear-gradient(180deg, #ffffff, #eef2f6);
  box-shadow: 0 24px 70px rgba(31, 95, 208, 0.14);
}

.layer-toolbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(6, auto);
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid rgba(216, 226, 240, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.14);
  backdrop-filter: blur(14px);
}

.layer-toolbar.is-empty {
  opacity: 0.68;
}

.layer-toolbar span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-toolbar button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--brand-dark);
  background: #fff;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.layer-toolbar button:focus,
.layer-toolbar button:focus-visible,
.layer-item:focus,
.layer-item:focus-visible {
  outline: none;
}

.layer-toolbar button:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.layer-toolbar button:disabled {
  color: #98a2b3;
  background: #f2f4f7;
  cursor: not-allowed;
}

.stage-header {
  display: none;
}

.client-preview,
.phone-stage,
.layer-toolbar {
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.stage-header strong {
  font-size: 0.94rem;
  text-transform: uppercase;
}

.stage-header span {
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 800;
}

canvas {
  width: min(100%, 420px);
  height: auto;
  max-height: 68vh;
  border-radius: 42px;
  cursor: move;
  filter: drop-shadow(0 28px 34px rgba(15, 23, 42, 0.20));
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

canvas:active {
  cursor: move;
}

.hint-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.94rem;
}

.controls {
  display: grid;
  gap: 14px;
  align-content: start;
}

.control-group,
.summary {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 35px rgba(31, 95, 208, 0.08);
}

.control-group:first-child {
  border-top: 4px solid var(--accent);
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid #cbd8ea;
  border-radius: 7px;
  background: #fff;
  font-weight: 700;
}

input[type="range"] {
  accent-color: var(--brand);
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-box {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  min-height: 112px;
  padding: 16px;
  border: 1px dashed #99afd0;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.upload-box span {
  max-width: 100%;
  color: var(--brand-dark);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.upload-box small {
  color: var(--muted);
  font-size: 0.82rem;
}

.layers-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.layer-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fff;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.layer-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-item.is-active {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-soft);
  box-shadow: inset 4px 0 0 var(--brand);
}

.layer-item button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #d92d20;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch,
.custom-swatch {
  width: 38px;
  height: 38px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px #bfd0e7;
  cursor: pointer;
}

.swatch.is-active,
.custom-swatch.is-active {
  box-shadow: 0 0 0 3px var(--accent);
}

.no-finish {
  position: relative;
  background:
    linear-gradient(45deg, transparent 46%, #d92d20 48%, #d92d20 52%, transparent 54%),
    linear-gradient(45deg, #f8fafc 25%, transparent 25%),
    linear-gradient(-45deg, #f8fafc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f8fafc 75%),
    linear-gradient(-45deg, transparent 75%, #f8fafc 75%),
    #d7dee9;
  background-position: 0 0, 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 100% 100%, 16px 16px, 16px 16px, 16px 16px, 16px 16px;
}

.custom-swatch {
  position: relative;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  background: conic-gradient(red, #ff0, #0f0, #0ff, #00f, #f0f, red);
}

.custom-swatch.has-custom-color {
  background: var(--swatch);
}

.custom-swatch::before,
.custom-swatch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.55);
  transform: translate(-50%, -50%);
}

.custom-swatch::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.custom-swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 7px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--brand-dark);
  color: #fff;
  background: var(--brand);
  box-shadow: 0 10px 22px rgba(55, 125, 246, 0.22);
}

.primary-button:disabled {
  border-color: #b8c4d5;
  color: #748197;
  background: #e8edf5;
  box-shadow: none;
  cursor: not-allowed;
}

.ghost-button {
  border: 1px solid var(--line);
  color: #27364d;
  background: #fff;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
  text-align: right;
  font-weight: 900;
}

.export-message {
  margin: -6px 0 0;
  color: #d92d20;
  font-size: 0.9rem;
  font-weight: 800;
}

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

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

  .summary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .nav-links {
    display: none;
  }

  .preview-panel {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: 12ch;
  }

  .hint-bar {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  .topbar,
  .hint-bar {
    align-items: stretch;
  }

  .workspace {
    padding-top: 28px;
  }

  h1 {
    font-size: 3rem;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .phone-stage {
    min-height: 58vh;
  }

  canvas {
    max-height: 60vh;
  }
}

.client-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 58px) clamp(18px, 4vw, 32px) 42px;
}

.client-hero {
  display: block;
  margin-bottom: clamp(24px, 4vw, 42px);
}

.client-editor {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 360px;
  gap: clamp(18px, 3vw, 28px);
  align-items: stretch;
}

.client-copy {
  display: grid;
  gap: 14px;
  align-content: start;
  max-width: 720px;
}

.client-copy h1 {
  max-width: 13ch;
  font-size: clamp(3rem, 6vw, 5.2rem);
}

.client-copy p:last-child {
  max-width: 42ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

.client-preview {
  display: grid;
  gap: 12px;
  align-content: stretch;
  min-height: 0;
}

.client-preview .phone-stage {
  min-height: 0;
  height: min(76vh, 760px);
}

.client-steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-height: min(76vh, 760px);
  margin-top: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.client-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 35px rgba(31, 95, 208, 0.08);
}

.client-step > div {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.step-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  font-weight: 900;
}

.client-summary {
  grid-column: auto;
}

@media (max-width: 1060px) {
  .client-editor {
    grid-template-columns: 1fr;
  }

  .client-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 660px) {
  .client-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .client-topbar .ghost-button {
    margin-left: 0;
  }

  .client-steps,
  .client-summary {
    grid-template-columns: 1fr;
  }

  .client-summary {
    grid-column: auto;
  }

  .layer-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layer-toolbar span {
    grid-column: 1 / -1;
  }

  .phone-stage {
    padding-bottom: clamp(20px, 4vw, 42px);
  }

  .client-preview .phone-stage {
    height: auto;
    min-height: 0;
  }
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  width: 100%;
  margin-top: 34px;
  padding: 28px clamp(24px, 18vw, 330px);
  border-top: 1px solid var(--line);
  color: #31527b;
  background: #ffffff;
  font-size: 0.86rem;
  font-weight: 500;
}

.site-footer strong {
  color: #020617;
  font-weight: 900;
}

.site-footer a {
  color: #1d4ed8;
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  color: #0f172a;
}

@media (max-width: 720px) {
  .site-footer {
    flex-direction: column;
    justify-content: center;
    padding-inline: 18px;
    text-align: center;
  }
}
