:root {
  --bg: #0f1115;
  --panel-bg: #171a21;
  --panel-border: #262b35;
  --text: #e8e9ec;
  --text-dim: #9198a6;
  --accent: #ff5c39;
  --accent-hover: #ff7959;
  --whatsapp: #25d366;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--panel-border);
}

.help-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.help-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.help-btn svg {
  flex-shrink: 0;
}

.brand {
  font-family: "SharpGrotesk-Bold", "Arial Black", Helvetica, sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand span {
  color: var(--accent);
  font-weight: 500;
}

.tagline {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  height: calc(100vh - 74px);
}

@media (max-width: 900px) {
  /* Mobile: the shirt viewer stays put; only the design panel below it
     scrolls (like a bottom sheet), so you can keep an eye on the shirt
     while uploading/resizing. Achieved with body-as-flex-column so the
     layout's real height is "whatever's left after header+footer",
     without hardcoding their pixel heights. */
  html, body {
    height: 100vh;
    height: 100dvh;
  }

  body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .topbar,
  .site-footer {
    flex-shrink: 0;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
  }

  .viewer {
    flex-shrink: 0;
    overflow: hidden;
    padding: 10px;
    gap: 8px;
  }

  #mockup-canvas {
    max-height: 26vh;
  }

  .panel {
    min-height: 0;
    overflow-y: auto;
  }
}

.viewer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: radial-gradient(circle at 50% 40%, #4a4d54, #35373c 70%);
  padding: 20px;
}

.view-toggle {
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 999px;
}

.view-btn {
  padding: 8px 20px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.view-btn.active {
  background: var(--accent);
  color: #fff;
}

#viewer-canvas {
  max-width: 100%;
  max-height: calc(100% - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#mockup-canvas {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  /* Without this, touch browsers treat a drag on the canvas as a page-scroll
     gesture instead of feeding pointermove events to reposition the design. */
  touch-action: none;
}

.panel {
  border-left: 1px solid var(--panel-border);
  background: var(--panel-bg);
  overflow-y: auto;
  padding: 20px;
}

.panel-section {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-section:last-child {
  border-bottom: none;
}

.panel-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 12px;
}

.field {
  display: block;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.field span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
}

.field select,
.field input[type="text"],
.field input[type="tel"],
.field input[type="number"],
.field textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
}

.field textarea {
  resize: vertical;
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.field input[type="range"]:disabled {
  opacity: 0.4;
}

.size-value {
  float: right;
  color: var(--text);
  font-weight: 600;
}

.file-field input[type="file"] {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.field-label {
  display: block;
  margin: 14px 0 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

#design-gallery {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.gallery-category {
  margin: 14px 0 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.gallery-category:first-child {
  margin-top: 0;
}

.gallery-grid {
  display: grid;
  /* minmax(0, 1fr), not plain 1fr: without the explicit 0 minimum, a grid
     track's minimum width defaults to its content's natural size, so one
     long unbroken caption can force that whole column wider than the
     sidebar — pushing images out of the panel and misaligning other cells. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.gallery-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

.gallery-item:hover {
  border-color: var(--accent);
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background:
    linear-gradient(45deg, #2a2e38 25%, transparent 25%),
    linear-gradient(-45deg, #2a2e38 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2e38 75%),
    linear-gradient(-45deg, transparent 75%, #2a2e38 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  border-radius: 4px;
}

.gallery-item span {
  width: 100%;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.2;
  overflow-wrap: break-word;
}

.ink-colors {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.inline-field span {
  margin-bottom: 0;
}

.inline-field input[type="color"] {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--bg);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-field input {
  margin: 0;
}

.checkbox-field span {
  margin-bottom: 0;
  color: var(--text);
}

.hint-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin: 6px 0 12px;
  line-height: 1.4;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn-row .btn {
  margin-top: 0;
}

#mockup-canvas {
  cursor: grab;
}

#mockup-canvas.dragging {
  cursor: grabbing;
}

.design-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.design-preview span {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.resolution-status {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 1.2em;
}

.resolution-status.res-bad {
  color: #ff5c5c;
}

.resolution-status.res-warn {
  color: #f2c811;
}

.resolution-status.res-ok {
  color: #7ec8e3;
}

.resolution-status.res-good {
  color: #4fd18a;
}

.design-preview canvas {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #2a2e38 25%, transparent 25%),
    linear-gradient(-45deg, #2a2e38 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2e38 75%),
    linear-gradient(-45deg, transparent 75%, #2a2e38 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  margin-top: 6px;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-whatsapp {
  background: var(--whatsapp);
  color: #fff;
  margin-top: 12px;
}

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

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.swatch.active {
  border-color: var(--accent);
}

.size-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.size-btn {
  flex: 1 1 60px;
  padding: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
}

.size-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

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

.order-summary {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.order-summary h3 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.order-summary dl {
  margin: 0;
  font-size: 0.85rem;
}

.order-summary dt {
  color: var(--text-dim);
  float: left;
  clear: left;
  margin-right: 6px;
}

.order-summary dd {
  margin: 0 0 6px;
}

.hidden {
  display: none;
}

/* --- First-run tutorial dialog --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
}

/* Both rules have equal specificity (one class each); without this, whichever
   is declared later in the file wins, which broke closing the dialog — the
   "hidden" class was being added by JS but "display: flex" above kept winning. */
.modal-overlay.hidden {
  display: none;
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 28px 24px 24px;
}

.modal-box h2 {
  margin: 0 0 18px;
  padding-right: 24px;
  font-size: 1.2rem;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.tutorial-steps {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tutorial-steps li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.tutorial-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: rgba(255, 92, 57, 0.12);
  border-radius: 10px;
}

.tutorial-icon svg {
  width: 22px;
  height: 22px;
}

.tutorial-steps strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.tutorial-steps p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
}

@media (max-width: 600px) {
  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .brand {
    font-size: 1.3rem;
  }

  .tagline {
    font-size: 0.78rem;
  }

  .help-btn {
    font-size: 0.78rem;
    padding: 6px 12px;
  }

  .viewer {
    padding: 8px;
    gap: 6px;
  }

  .view-toggle {
    padding: 3px;
  }

  .view-btn {
    padding: 5px 14px;
    font-size: 0.75rem;
  }

  #mockup-canvas {
    max-height: 20vh;
  }

  .panel {
    padding: 16px;
  }

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

  .modal-box {
    padding: 22px 18px 18px;
  }

  .btn {
    padding: 12px 14px;
  }
}

.intro-splash {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  transition: opacity 0.4s ease;
}

.intro-splash.hidden {
  opacity: 0;
  pointer-events: none;
}

.intro-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.intro-skip {
  position: absolute;
  bottom: 24px;
  right: 24px;
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.intro-skip:hover {
  background: rgba(0, 0, 0, 0.6);
}

.site-footer {
  padding: 10px 24px;
  text-align: center;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
}

.site-footer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.site-footer a {
  color: var(--text-dim);
  text-decoration: underline;
}
