*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --shirt-color: #2d2d2d;
  --shirt-stroke: #444;
  --collar-shadow: rgba(0,0,0,0.15);

  --bg: #f8f8f8;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #e5e5e5;
  --border-focus: #1a1a1a;
  --accent: #1a1a1a;
  --accent-text: #ffffff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ─── Header ─── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo__icon {
  color: var(--accent);
}

.logo__text {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.header__tag {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Main Product Layout ─── */
.main {
  flex: 1;
  padding: 40px 0;
}

.product {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

/* ─── Preview Section ─── */
.preview {
  position: sticky;
  top: 80px;
}

/* ─── Side Tabs ─── */
.side-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  width: fit-content;
}

.side-tab {
  padding: 6px 20px;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.side-tab--active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.side-tab:hover:not(.side-tab--active) {
  color: var(--text-primary);
}

/* ─── 3D Scene ─── */
.preview__scene {
  perspective: 1200px;
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
}

.preview__flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.preview__flipper.flipped {
  transform: rotateY(180deg);
}

.preview__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  transform-style: preserve-3d;
  overflow: hidden;
}

.preview__face--front {
  z-index: 1;
  transform: rotateY(0deg);
}

.preview__face--back {
  transform: rotateY(180deg);
}

.preview__stage {
  background: linear-gradient(135deg, #e8e8e8 0%, #f2f2f2 100%);
  border-radius: var(--radius);
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* ─── Preview Bar ─── */
.preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.flip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text-primary);
  transition: all var(--transition);
}

.flip-btn:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

/* ─── Side Indicator ─── */
.side-indicator {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  width: fit-content;
}

.tshirt-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
  transition: filter var(--transition);
}

.tshirt-body,
.tshirt-collar {
  transition: fill 0.4s ease;
}

.preview__text-layer {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 45%;
  min-width: 120px;
  min-height: 56px;
  padding: 10px 12px;
  text-align: center;
  cursor: grab;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.preview__text-layer.dragging {
  cursor: grabbing;
}

.preview__custom-text {
  color: #ffffff;
  font-size: 24px;
  font-family: var(--font);
  font-weight: 600;
  word-break: break-word;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: font-family 0.3s ease, font-size 0.2s ease, color 0.2s ease;
  line-height: 1.3;
  pointer-events: none;
}

.preview__hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Controls Section ─── */
.controls {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.controls__title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.controls__subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.controls__divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ─── Control Groups ─── */
.control-group {
  margin-bottom: 20px;
}

.control-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.control-input,
.control-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.control-input:focus,
.control-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
}

.control-input::placeholder {
  color: var(--text-muted);
}

.control-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.control-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ─── Control Row ─── */
.control-row {
  display: flex;
  gap: 16px;
}

.control-group--half {
  flex: 1;
}

/* ─── Color Input ─── */
.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--transition);
}

.color-input-wrapper:focus-within {
  border-color: var(--border-focus);
}

.control-color {
  width: 32px;
  height: 32px;
  border: none;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  background: none;
}

.control-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.control-color::-webkit-color-swatch {
  border-radius: 50%;
  border: 2px solid var(--border);
}

.control-color::-moz-color-swatch {
  border-radius: 50%;
  border: 2px solid var(--border);
}

.color-value {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: monospace;
}

/* ─── Range Slider ─── */
.control-range {
  width: 100%;
  height: 6px;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  margin-top: 4px;
}

.control-range::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform var(--transition);
}

.control-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.control-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ─── Color Swatches ─── */
.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  outline: none;
  position: relative;
}

.swatch:hover {
  transform: scale(1.1);
}

.swatch:focus-visible {
  box-shadow: 0 0 0 3px rgba(26,26,26,0.2);
}

.swatch--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

/* ─── Quantity Picker ─── */
.quantity-picker {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
  background: var(--surface);
}

.qty-btn {
  width: 38px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
}

.qty-btn:hover {
  background: var(--bg);
}

.qty-btn:active {
  background: var(--border);
}

.qty-input {
  width: 44px;
  min-width: 44px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 0.95rem;
  font-family: var(--font);
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* ─── Price ─── */
.price-display {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.price-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.price-amount {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ─── Buttons ─── */
.controls__actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(26,26,26,0.2);
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn--primary:hover {
  background: #333;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn--primary:active {
  transform: translateY(0);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn--secondary:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--accent);
  color: var(--accent-text);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  z-index: 1000;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ─── Footer ─── */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  margin-top: auto;
}

.footer__inner {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .product {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .preview {
    position: static;
  }

  .preview__scene {
    aspect-ratio: auto;
    height: 420px;
  }

  .preview__stage {
    padding: 32px;
  }

  .tshirt-svg {
    max-width: 260px;
  }

  .controls {
    padding: 28px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .main {
    padding: 20px 0;
  }

  .header__tag {
    display: none;
  }

  .controls__title {
    font-size: 1.3rem;
  }

  .preview__scene {
    height: 360px;
  }

  .preview__stage {
    padding: 24px;
  }

  .tshirt-svg {
    max-width: 200px;
  }

  .control-row {
    flex-direction: column;
    gap: 12px;
  }

  .controls__actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .preview__text-layer {
    width: 56%;
    min-width: 140px;
    min-height: 64px;
  }

  .price-amount {
    font-size: 1.3rem;
  }
}

@media (max-width: 360px) {
  .preview__scene {
    height: 300px;
  }

  .preview__stage {
    padding: 16px;
  }

  .tshirt-svg {
    max-width: 170px;
  }
}

/* ─── Animations ─── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.preview {
  animation: fadeInUp 0.6s ease both;
}

.controls {
  animation: fadeInUp 0.6s ease 0.15s both;
}
