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

:root {
  --cream: #F7F4EF;
  --cream-dark: #EDE8E0;
  --ink: #1A1714;
  --ink-muted: #6B665F;
  --ink-faint: #B5AFA6;
  --accent: #C4622D;
  --accent-light: #F0DDD3;
  --white: #FFFFFF;
  --border: #DDD8D0;
  --radius: 4px;
  --radius-lg: 8px;
}

html, body { height: 100%; }

body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Loading ── */
#loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.loading-logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 32px;
  font-weight: 400;
  letter-spacing: 0.04em;
}
.loading-logo span { color: var(--accent); }
.loading-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Studio shell ── */
.studio {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.studio-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: 60px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.logo span { color: var(--accent); }
.header-product {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
}

/* ── Steps nav ── */
.steps-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: 52px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.step-item.active { color: var(--ink); }
.step-item.done   { color: var(--accent); cursor: pointer; }
.step-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}
.step-item.active .step-dot { background: var(--ink); color: var(--white); border-color: var(--ink); }
.step-item.done .step-dot   { background: var(--accent); color: var(--white); border-color: var(--accent); }
.step-line {
  width: 40px; height: 1px;
  background: var(--border);
  margin: 0 12px;
}
.progress-bar { height: 2px; background: var(--cream-dark); flex-shrink: 0; }
.progress-fill { height: 2px; background: var(--accent); transition: width 0.4s ease; }

/* ── Body layout ── */
.studio-body {
  display: grid;
  grid-template-columns: 380px 1fr;
  flex: 1;
  min-height: 0;
}

/* ── Left panel ── */
.panel {
  background: var(--white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.panel-inner {
  padding: 28px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.panel-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 26px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink);
}
.panel-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: -12px;
}

/* ── Upload zone ── */
.upload-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--cream);
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-zone.has-photo { padding: 0; border-style: solid; border-color: var(--border); }
.upload-thumb {
  width: 100%; height: 160px;
  object-fit: cover;
  display: block;
}
.upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.upload-icon { font-size: 24px; color: var(--ink-faint); }
.upload-label { font-size: 13px; font-weight: 500; color: var(--ink); }
.upload-hint { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.04em; text-transform: uppercase; }
.btn-text {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  margin-top: -12px;
  text-decoration: underline;
}
.btn-text:hover { color: var(--accent); }

/* ── Fields ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.required { color: var(--accent); }
.hint { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; }
.field input, .field textarea {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  resize: none;
}
.field input:focus, .field textarea:focus {
  border-color: var(--accent);
  background: var(--white);
}
.field textarea { min-height: 90px; line-height: 1.6; }
.char-count { font-size: 11px; color: var(--ink-faint); text-align: right; }

/* ── Style options ── */
.style-options { display: flex; gap: 8px; }
.style-opt {
  flex: 1;
  padding: 9px 8px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  transition: all 0.15s;
}
.style-opt:hover { border-color: var(--ink-muted); color: var(--ink); }
.style-opt.active { border-color: var(--accent); background: var(--accent-light); color: var(--ink); }

/* ── Format grid ── */
.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.format-opt {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  background: var(--cream);
  transition: all 0.15s;
}
.format-opt:hover { border-color: var(--ink-muted); }
.format-opt.active { border-color: var(--accent); background: var(--accent-light); }
.format-size { font-size: 14px; font-weight: 500; color: var(--ink); }
.format-price { font-size: 11px; color: var(--ink-muted); margin-top: 3px; }

/* ── Frame options ── */
.frame-options { display: flex; flex-direction: column; gap: 8px; }
.frame-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--cream);
  transition: all 0.15s;
}
.frame-opt:hover { border-color: var(--ink-muted); }
.frame-opt.active { border-color: var(--accent); background: var(--accent-light); }
.frame-swatch {
  width: 28px; height: 28px;
  border-radius: 3px;
  flex-shrink: 0;
}
.frame-swatch--black  { background: #1A1714; }
.frame-swatch--white  { background: #F0EDE8; border: 1px solid var(--border); }
.frame-swatch--oak    { background: linear-gradient(135deg,#8B6C42,#A8845A,#7A5C35); }
.frame-swatch--walnut { background: linear-gradient(135deg,#4A3728,#6B4E3D,#3D2E22); }
.frame-opt span:nth-child(2) { flex: 1; font-size: 13px; color: var(--ink); }
.frame-price { font-size: 12px; color: var(--ink-muted); }

/* ── Summary ── */
.summary-block {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.summary-row span { color: var(--ink-muted); }
.summary-row strong { color: var(--ink); font-weight: 500; }

/* ── Addons ── */
.addon-options { display: flex; flex-direction: column; gap: 8px; }
.addon-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--cream);
  transition: all 0.15s;
}
.addon-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-light); }
.addon-opt input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.addon-info { display: flex; flex: 1; justify-content: space-between; align-items: center; }
.addon-price { font-size: 12px; color: var(--ink-muted); }

/* ── Total ── */
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-size: 15px;
}
.total-row strong { font-size: 20px; font-weight: 500; }

/* ── Buttons ── */
.btn-row { display: flex; gap: 10px; }
.btn {
  flex: 1;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  white-space: nowrap;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-muted);
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:hover { background: #2D2A26; }
.btn-cart { background: var(--accent); color: var(--white); font-size: 14px; }
.btn-cart:hover { background: #A8501F; }
.btn-cart.loading { opacity: 0.7; cursor: not-allowed; display: flex; align-items: center; justify-content: center; gap: 8px; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Preview column ── */
.preview-col {
  display: flex;
  flex-direction: column;
  padding: 28px 32px;
  background: var(--cream);
  overflow-y: auto;
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.preview-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.preview-format {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 500;
}
.preview-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
#poster-canvas {
  display: block;
  box-shadow: 0 6px 40px rgba(26,23,20,0.13), 0 2px 8px rgba(26,23,20,0.07);
  border-radius: 2px;
  max-width: 100%;
}

/* ── Error screen ── */
.error-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  text-align: center;
}
.error-msg { color: var(--ink-muted); max-width: 400px; line-height: 1.7; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .studio-body { grid-template-columns: 1fr; }
  .preview-col { order: -1; padding: 16px; }
  .panel { border-right: none; border-top: 1px solid var(--border); }
  .steps-nav { padding: 0 16px; }
  .step-line { width: 20px; margin: 0 6px; }
  .studio-header { padding: 0 16px; }
}

/* ── Frame grid (stap 2) ── */
.frame-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.frame-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  background: var(--cream);
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.frame-card:hover { border-color: var(--ink-muted); }
.frame-card.active { border-color: var(--accent); background: var(--accent-light); }
.frame-card .frame-swatch { width: 32px; height: 32px; border-radius: 3px; }
.frame-card-label { font-size: 12px; font-weight: 500; color: var(--ink); }
.frame-card-price { font-size: 11px; color: var(--ink-muted); }
.frame-opt-none {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--cream);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  text-align: center;
  transition: all 0.15s;
}
.frame-opt-none:hover { border-color: var(--ink-muted); }
.frame-opt-none.active { border-color: var(--accent); background: var(--accent-light); }
