:root {
  --white: #ffffff;
  --grey-50: #f9fafb;
  --grey-100: #f2f4f6;
  --grey-200: #e5e8eb;
  --grey-300: #d1d6db;
  --grey-500: #8b95a1;
  --grey-600: #6b7684;
  --grey-700: #4e5968;
  --grey-900: #191f28;
  --blue-50: #e8f3ff;
  --blue-100: #c9e2ff;
  --blue-500: #3182f6;
  --bg: var(--grey-50);
  --surface: var(--white);
  --surface-border: var(--grey-200);
  --text: var(--grey-900);
  --text-secondary: var(--grey-700);
  --text-muted: var(--grey-500);
  --accent: var(--blue-500);
  --shadow: 0 2px 12px rgba(2, 9, 19, 0.06), 0 1px 4px rgba(2, 9, 19, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --fs-ui: 15px;
  --fs-label: 14px;
  --fs-btn: 14px;
  --fs-caption: 13px;
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Pretendard Variable', 'Pretendard', 'Noto Sans KR', -apple-system, sans-serif;
  font-size: var(--fs-ui);
  color: var(--text);
  background: var(--bg);
  letter-spacing: -0.01em;
  line-height: 1.5;
  min-height: 100dvh;
  width: 100%;
  margin: 0;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

/* ── View switching (landing / form / complete) ── */
body.order-landing #orderShell {
  display: none !important;
}

body.order-landing #landingView {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

body.order-form-page {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

body.order-form-page #landingView {
  display: none !important;
}

body.order-form-page #orderShell {
  display: flex !important;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: var(--fs-btn);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  padding: 12px 20px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  text-decoration: none;
  touch-action: manipulation;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform 0.1s ease;
}

.btn:hover {
  border-color: var(--grey-300);
  background: var(--grey-100);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  color: var(--white);
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #1b6fe0;
  border-color: #1b6fe0;
}

.btn-primary:active {
  background: #1565d8;
  border-color: #1565d8;
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

/* ── Landing page ── */
.landing {
  width: 100%;
}

.landing__cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.landing__header {
  text-align: center;
  margin-bottom: 32px;
  width: 100%;
}

.landing__title {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.35;
}

.landing__subtitle {
  margin-top: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.6;
}

.choice-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.choice-card--primary {
  border-color: var(--blue-100);
  background: linear-gradient(180deg, var(--white) 0%, var(--blue-50) 100%);
}

.choice-card__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.choice-card__desc {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.6;
}

.choice-card__btn {
  width: 100%;
  min-height: 48px;
  font-size: 15px;
}

@media (min-width: 640px) {
  .landing__cards {
    flex-direction: row;
    align-items: stretch;
  }

  .choice-card {
    flex: 1;
    justify-content: space-between;
  }
}

/* ── Order form shell ── */
.order-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  background: var(--bg);
}

.order-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--surface-border);
  flex-shrink: 0;
}

.order-header__back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
  padding: 0;
  font: inherit;
}

.order-header__back:hover {
  background: var(--grey-100);
}

.order-header__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── Stepper ── */
.stepper {
  display: flex;
  gap: 0;
  padding: 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}

.stepper::-webkit-scrollbar {
  display: none;
}

.stepper__item {
  display: flex;
  align-items: flex-start;
  flex: 1 0 auto;
  min-width: 0;
  pointer-events: none;
  user-select: none;
}

.stepper__item:last-child .stepper__connector {
  display: none;
}

.stepper__node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 52px;
  padding: 0 4px;
}

.stepper__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--grey-100);
  border: 2px solid var(--grey-200);
  border-radius: 50%;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.stepper__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--transition);
}

.stepper__connector {
  flex: 1;
  height: 2px;
  min-width: 12px;
  margin: 13px 4px 0;
  background: var(--grey-200);
  transition: background var(--transition);
}

.stepper__item--active .stepper__num {
  color: var(--white);
  background: var(--accent);
  border-color: var(--accent);
}

.stepper__item--active .stepper__label {
  color: var(--accent);
  font-weight: 700;
}

.stepper__item--completed .stepper__num {
  color: var(--accent);
  background: var(--blue-50);
  border-color: var(--accent);
}

.stepper__item--completed .stepper__label {
  color: var(--text-secondary);
}

.stepper__item--completed .stepper__connector {
  background: var(--accent);
}

@media (min-width: 480px) {
  .stepper {
    padding: 20px 24px;
    justify-content: center;
  }

  .stepper__node {
    min-width: 64px;
  }

  .stepper__label {
    font-size: 12px;
  }
}

/* ── Step panels ── */
.order-main {
  flex: 1;
  min-height: 0;
  padding: 24px 20px;
  padding-bottom: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.order-form {
  display: flex;
  flex-direction: column;
}

.step-panel {
  animation: stepFadeIn 0.25s ease;
}

@keyframes stepFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-panel__question {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.step-panel__hint {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.step-panel__subtitle {
  margin-top: 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
}

.step-panel__subtitle--spaced {
  margin-top: 28px;
}

/* ── Modeling tier cards ── */
.tier-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.tier-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 16px;
  font-family: inherit;
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  touch-action: manipulation;
}

.tier-card__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.tier-card__desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.tier-card:hover {
  border-color: var(--grey-300);
  background: var(--grey-50);
}

.tier-card--active {
  border-color: var(--accent);
  background: var(--blue-50);
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.12);
}

.tier-card--active .tier-card__title {
  color: var(--accent);
}

.tier-result {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-sm);
}

.tier-result__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.tier-result__desc {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Shape grid ── */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

@media (min-width: 480px) {
  .shape-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 88px;
  padding: 12px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  touch-action: manipulation;
}

.shape-btn svg {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
}

.shape-btn:hover {
  border-color: var(--grey-300);
  background: var(--grey-50);
}

.shape-btn--active {
  color: var(--accent);
  background: var(--blue-50);
  border-color: var(--accent);
}

.shape-btn--active svg {
  color: var(--accent);
}

/* ── Dimension fields ── */
.dim-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 12px;
}

@media (min-width: 520px) {
  .dim-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dim-grid--three {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.dim-field__label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--text-secondary);
}

.dim-field__input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dim-field__input {
  flex: 1;
  text-align: right;
}

.dim-field__unit {
  flex: 0 0 28px;
  font-size: var(--fs-caption);
  font-weight: 500;
  color: var(--text-muted);
}

/* ── Estimate panel ── */
.estimate-panel {
  margin-top: 8px;
  padding: 20px;
  background: linear-gradient(180deg, var(--white) 0%, var(--blue-50) 100%);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
}

.estimate-panel__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.estimate-panel__note {
  font-weight: 500;
  color: var(--text-muted);
}

.estimate-panel__total {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.estimate-panel__rows {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.estimate-panel__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.estimate-panel__row span:last-child {
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}

.estimate-panel__disclaimer {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Form inputs ── */
.text-input {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-ui);
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.text-input::placeholder {
  color: var(--grey-300);
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--blue-50);
}

.text-input--error {
  border-color: #e53935;
}

.text-input--error:focus {
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.12);
}

.text-area {
  width: 100%;
  margin-top: 24px;
  font-family: inherit;
  font-size: var(--fs-ui);
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  outline: none;
  resize: vertical;
  min-height: 140px;
  line-height: 1.6;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.text-area::placeholder {
  color: var(--grey-300);
}

.text-area:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--blue-50);
}

/* ── Contact fields (Step 5) ── */
.contact-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.form-field__label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--text-secondary);
}

.field-error {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #e53935;
}

/* ── Footer nav ── */
.order-footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--surface-border);
  flex-shrink: 0;
}

.order-footer .btn {
  flex: 1;
  min-height: 48px;
  font-size: 15px;
}

.order-footer .btn-primary {
  flex: 2;
}

/* ── Image upload ── */
.image-upload {
  margin-top: 20px;
}

.image-upload__drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 140px;
  padding: 24px 16px;
  background: var(--surface);
  border: 2px dashed var(--grey-300);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  touch-action: manipulation;
}

.image-upload__drop:hover {
  border-color: var(--accent);
  background: var(--blue-50);
}

.image-upload__drop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  color: var(--accent);
  background: var(--blue-50);
  border-radius: 50%;
}

.image-upload__drop-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.image-upload__drop-hint {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.image-upload__list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

@media (min-width: 480px) {
  .image-upload__list {
    grid-template-columns: repeat(4, 1fr);
  }
}

.image-upload__item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--grey-100);
  border: 1px solid var(--surface-border);
}

.image-upload__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-upload__remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--white);
  background: rgba(0, 0, 0, 0.55);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.image-upload__remove:hover {
  background: rgba(0, 0, 0, 0.72);
}

/* ── Studio overlay ── */
.studio-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.studio-overlay__frame {
  width: 100%;
  flex: 1 1 auto;
  border: none;
  display: block;
}

/* ── Clay Studio 열기 버튼 (랜딩 · 주문 2단계 공통) ── */
a.btn-studio-open,
button.btn-studio-open {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(135deg, var(--blue-50) 0%, var(--white) 100%);
  border: 1.5px solid var(--blue-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform 0.1s ease;
}

.landing__cards .btn-studio-open--landing {
  margin-top: 0;
}

.step-panel .btn-studio-open--landing {
  margin-top: 16px;
}

a.btn-studio-open:hover,
button.btn-studio-open:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.1);
}

a.btn-studio-open:active,
button.btn-studio-open:active {
  transform: scale(0.99);
}

.btn-studio-open__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.btn-studio-open__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.btn-studio-open__label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.btn-studio-open__sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.btn-studio-open__arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

/* ── 구분선 ── */
.image-upload-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.image-upload-divider::before,
.image-upload-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--grey-200);
}

/* ── studio 완료 버튼 (style.css 쪽 hud 안) ── */
.btn-studio-done {
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
  background: var(--accent);
  border: none;
  cursor: pointer;
  width: 100%;
  min-height: 48px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
  transition: background 0.15s ease;
}

.btn-studio-done:active {
  background: #1b6fe0;
}

/* ── Mobile · 인앱 브라우저 (카카오톡·인스타) ── */
@media (max-width: 480px) {
  body.order-landing #landingView {
    justify-content: flex-start;
    padding-top: max(32px, env(safe-area-inset-top, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-bottom: max(32px, env(safe-area-inset-bottom, 0px));
  }

  .landing__header {
    margin-bottom: 24px;
  }

  .landing__title {
    font-size: 22px;
  }

  .landing__subtitle {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.55;
  }

  .landing__cards {
    gap: 12px;
  }

  .choice-card {
    gap: 16px;
    padding: 18px 16px;
  }

  .choice-card__title {
    font-size: 17px;
  }

  .choice-card__desc {
    font-size: 13px;
  }

  .order-header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .order-header__back {
    width: 40px;
    height: 40px;
  }

  .order-header__title {
    font-size: 16px;
  }

  .stepper {
    padding: 10px 8px;
  }

  .stepper__node {
    min-width: 48px;
    gap: 4px;
  }

  .stepper__num {
    width: 26px;
    height: 26px;
    font-size: 10px;
  }

  .stepper__label {
    font-size: 10px;
  }

  .order-main {
    padding: 16px;
    padding-bottom: 4px;
  }

  .step-panel__question {
    font-size: 18px;
    line-height: 1.45;
  }

  .step-panel__hint {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.55;
  }

  .step-panel__subtitle {
    margin-top: 16px;
  }

  .step-panel__subtitle--spaced {
    margin-top: 22px;
  }

  .tier-grid {
    margin-top: 16px;
    gap: 8px;
  }

  .tier-card {
    padding: 14px;
  }

  .shape-grid {
    gap: 8px;
  }

  .shape-btn {
    min-height: 80px;
    gap: 6px;
  }

  .dim-grid {
    gap: 12px;
  }

  .text-area {
    margin-top: 16px;
    min-height: 120px;
    padding: 12px 14px;
  }

  .contact-fields {
    gap: 12px;
    margin-top: 16px;
  }

  .text-input {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px;
  }

  .estimate-panel {
    padding: 16px;
  }

  .estimate-panel__total {
    font-size: 22px;
  }

  .image-upload {
    margin-top: 16px;
  }

  .image-upload__drop {
    min-height: 112px;
    padding: 18px 12px;
  }

  .image-upload__list {
    gap: 8px;
  }

  .order-footer {
    gap: 8px;
    padding: 12px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }

  .order-footer .btn {
    min-height: 50px;
  }
}

@media (max-width: 360px) {
  .stepper__label {
    font-size: 9px;
  }

  .stepper__node {
    min-width: 44px;
  }
}
