.design-page {
  padding: 0 env(safe-area-inset-right) calc(1.5rem + env(safe-area-inset-bottom))
    env(safe-area-inset-left);
}

.design-main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.design-main h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
}

.design-lead {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  color: #333;
  line-height: 1.55;
  max-width: 40rem;
}

.design-form {
  margin: 0;
}

.design-layout {
  display: grid;
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 900px) {
  .design-layout {
    grid-template-columns: 1fr min(22rem, 34vw);
  }
}

.design-fieldset {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid rgba(0, 51, 102, 0.18);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0, 51, 102, 0.04);
}

.design-fieldset legend {
  padding: 0 0.35rem;
  font-family: "Palanquin Dark", Arial, sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #003366;
}

.design-fieldset--art {
  padding-bottom: 1rem;
}

.design-fieldset--preview {
  margin-bottom: 0;
}

.design-fieldset--upload {
  border-style: dashed;
  background: rgba(245, 248, 250, 0.9);
}

.design-empty {
  margin: 0;
  color: #555;
  font-size: 0.95rem;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.category-tab {
  border: 2px solid rgba(0, 51, 102, 0.2);
  background: #f5f8fa;
  color: #003366;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
}

.category-tab:hover {
  border-color: rgba(21, 245, 186, 0.65);
}

.category-tab[aria-selected="true"] {
  border-color: #15f5ba;
  background: rgba(21, 245, 186, 0.18);
  color: #002147;
}

.category-panel[hidden] {
  display: none !important;
}

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.75rem, 1fr));
  gap: 0.55rem;
}

.clip-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.45rem 0.35rem 0.5rem;
  border: 2px solid rgba(0, 51, 102, 0.12);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.clip-card:hover {
  border-color: rgba(0, 51, 102, 0.35);
}

.clip-card:focus-visible {
  outline: 3px solid #15f5ba;
  outline-offset: 2px;
}

.clip-card--selected {
  border-color: #003366;
  box-shadow: 0 0 0 2px rgba(21, 245, 186, 0.35);
}

.clip-card__thumb {
  display: flex;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 10px;
  overflow: hidden;
  background: #eef4f8;
}

.clip-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.clip-card__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #003366;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.design-preview-note {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: #555;
  line-height: 1.45;
}

.design-preview-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 100 / 55;
  border: 1px solid rgba(0, 51, 102, 0.15);
  background: linear-gradient(180deg, #faf6ef 0%, #f0e6d8 100%);
  overflow: hidden;
  /* Shallow arch on top (same idea as SVG sleeve outline). */
  clip-path: polygon(0% 1.4%, 50% 0%, 100% 1.4%, 100% 100%, 0% 100%);
}

.design-preview-library {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.design-preview-library[hidden] {
  display: none !important;
}

.design-preview-upload {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.45rem 0.45rem;
  box-sizing: border-box;
}

.design-preview-upload[hidden] {
  display: none !important;
}

.design-preview-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #cfa772;
  overflow: hidden;
}

/* Same proportions as sleeve viewBox 100×55 (app/sleeve_export.py ART_SLOT, TEXT_ZONE, BRANDING_ZONE). */
.design-preview-slot {
  position: absolute;
  box-sizing: border-box;
  border-radius: 4px;
}

.design-preview-slot--art {
  left: 5%;
  top: 9.09090909090909%;
  width: 48%;
  height: 85.45454545454545%;
  display: flex;
  flex-direction: column;
  padding: 0.2rem 0.25rem 0.3rem;
  border: 2px dashed #b8860b;
  background: rgba(255, 224, 102, 0.35);
}

.design-preview-slot--text {
  left: 56%;
  top: 9.09090909090909%;
  width: 42%;
  height: 40%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0.2rem 0.35rem 0.35rem;
  border: 2px dashed #0369a1;
  background: rgba(125, 211, 252, 0.45);
  overflow: hidden;
}

.design-preview-slot--brand {
  left: 56%;
  top: 50.90909090909091%;
  width: 42%;
  height: 49.09090909090909%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0.35rem 0.3rem 0.25rem;
  border: 2px dashed rgba(68, 64, 60, 0.45);
  background: rgba(120, 113, 108, 0.08);
  pointer-events: none;
}

/* Physical sleeve lockup: M/T/M + OMENTS / HAT / ATTER, rule above OMENTS. */
.design-preview-brand-mtm {
  display: grid;
  grid-template-columns: min-content 1fr;
  column-gap: 0.1rem;
  row-gap: 0.03rem;
  align-items: baseline;
  width: 100%;
  max-width: 100%;
  font-family: Arial, Helvetica, sans-serif;
  color: #1a1a1a;
}

.design-preview-brand-spacer {
  grid-column: 1;
  grid-row: 1;
}

.design-preview-brand-rule {
  grid-column: 2;
  grid-row: 1;
  border-top: 1px solid #1a1a1a;
  margin-bottom: 0.06rem;
  width: 100%;
  max-width: 4.2em;
}

.design-preview-brand-cap {
  font-weight: 800;
  font-size: clamp(0.48rem, 1.75vw, 0.78rem);
  line-height: 1;
}

.design-preview-brand-rest {
  font-weight: 700;
  font-size: clamp(0.22rem, 0.82vw, 0.38rem);
  letter-spacing: 0.1em;
  line-height: 1;
}

.design-preview-slot-label {
  flex-shrink: 0;
  font-size: 0.55rem;
  font-weight: 800;
  color: #003366;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.1;
  margin-bottom: 0.1rem;
}

.design-preview-slot-imgwrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.design-preview-slot-imgwrap img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Block, not flex: text in a flex item often stays one line and clips (wide mono glyphs). */
.design-preview-upload-name {
  flex: 1;
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  min-width: 0;
  padding: 0.1rem 0.15rem;
  box-sizing: border-box;
  text-align: center;
  font-weight: 700;
  line-height: 1.2;
  color: #002147;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  overflow: hidden;
}

.design-text-size-sm {
  font-size: clamp(0.36rem, 1.28vw, 0.68rem);
}

.design-text-size-md {
  font-size: clamp(0.45rem, 1.65vw, 0.82rem);
}

.design-text-size-lg {
  font-size: clamp(0.52rem, 1.92vw, 0.96rem);
}

.design-font-sans {
  font-family: Arial, Helvetica, sans-serif;
}

.design-font-serif {
  font-family: Georgia, "Times New Roman", Times, serif;
}

.design-font-script {
  font-family: "Segoe Script", "Brush Script MT", cursive;
}

.design-font-mono {
  font-family: Consolas, "Courier New", monospace;
}

.design-preview-upload-caption {
  flex-shrink: 0;
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: #444;
  text-align: center;
  line-height: 1.35;
}

.design-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  font-size: 0.88rem;
  color: #555;
  line-height: 1.45;
}

.design-preview-placeholder[hidden] {
  display: none !important;
}

.design-field {
  margin-bottom: 1rem;
}

.design-field:last-child {
  margin-bottom: 0;
}

.design-field label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  color: #003366;
  margin-bottom: 0.35rem;
}

.design-field .optional {
  font-weight: 500;
  color: #666;
}

.design-required {
  color: #9a3412;
  font-weight: 800;
  margin-left: 0.15em;
  white-space: nowrap;
}

.design-checkbox .design-required {
  margin-left: 0.1em;
}

.design-field input[type="text"],
.design-field input[type="tel"],
.design-field input[type="email"],
.design-field select {
  width: 100%;
  max-width: 100%;
  font-size: 16px;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(0, 51, 102, 0.25);
  border-radius: 10px;
  background: #fff;
  min-height: 48px;
  box-sizing: border-box;
}

.design-field input[type="file"] {
  width: 100%;
  font-size: 0.9rem;
  min-height: 48px;
}

.design-upload-help {
  margin: 0 0 0.75rem;
  font-size: 0.86rem;
  color: #444;
  line-height: 1.45;
}

.design-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.9rem;
  line-height: 1.45;
  cursor: pointer;
  margin-top: 0.25rem;
}

.design-checkbox input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: #003366;
}

.design-submit {
  width: 100%;
  margin-top: 0.25rem;
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: "Palanquin Dark", Arial, sans-serif;
  color: #fff;
  background: #003366;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.design-submit:hover {
  background: #004488;
}

.design-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.design-msg {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.design-msg:not(:empty) {
  padding: 0.75rem 1rem;
  border-radius: 10px;
}

.design-msg--ok {
  background: rgba(21, 245, 186, 0.2);
  border: 1px solid rgba(21, 245, 186, 0.45);
  color: #003333;
}

.design-msg--err {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.35);
  color: #721c24;
}

.design-thank-you-ref {
  margin: 1.25rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(21, 245, 186, 0.15);
  border: 1px solid rgba(21, 245, 186, 0.4);
  font-size: 0.95rem;
  color: #003333;
}

.design-thank-you .landing-cta {
  margin-top: 2rem;
}
