/* ——————————————————————————————— customer order flow */
.operator-link {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf7;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}
.operator-link:hover {
  border-color: var(--ink);
  background: var(--acid);
  color: var(--ink);
}
.operator-link:active {
  transform: translateY(1px);
}
.operator-link svg {
  width: 15px;
  height: 15px;
}
.operator-arrow {
  font-size: 12px;
  color: var(--muted);
  margin-left: 1px;
}
.operator-link:hover .operator-arrow {
  color: var(--ink);
}

/* Text colors are deliberately limited to the three approved customer options. */
.text-color-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}
.color-option {
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.42);
  text-align: left;
  position: relative;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.15s ease;
}
.color-option:hover {
  border-color: var(--line-strong);
  background: #fffdf8;
  transform: translateY(-1px);
}
.color-option.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--dot);
  border: 1px solid rgba(0, 0, 0, 0.13);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14);
}
.color-option > span:nth-child(2) {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.color-option b {
  font-size: 8.5px;
  font-weight: 500;
  white-space: nowrap;
}
.color-option small {
  font-size: 7px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.color-option.active small {
  color: rgba(255, 255, 255, 0.52);
}
.color-check {
  display: none;
  position: absolute;
  right: 8px;
  top: 8px;
  width: 12px;
  height: 12px;
  color: var(--acid);
}
.color-option.active .color-check {
  display: block;
}
.generate-btn {
  width: 100%;
}
.generate-btn:disabled {
  opacity: 0.45;
}

/* ——————————————————————————————— order modal */
.order-modal {
  width: min(500px, 100%);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 120px rgba(20, 18, 12, 0.28);
  padding: 28px;
  position: relative;
  animation: modalIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.order-close {
  position: absolute;
  right: 18px;
  top: 18px;
  background: var(--surface-2);
  z-index: 2;
}
.order-modal h2 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.045em;
  font-weight: 600;
}
.order-modal h2 em {
  font-style: normal;
  position: relative;
  z-index: 0;
  display: inline-block;
}
.order-modal h2 em::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: -2%;
  right: -2%;
  bottom: 4%;
  height: 22%;
  background: var(--acid);
  transform: rotate(-1.3deg);
  border-radius: 2px;
}
.order-intro {
  margin: 0 0 17px;
  max-width: 390px;
  font-size: 9.5px;
  line-height: 1.65;
  color: var(--muted);
}
.order-model-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 8.5px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.order-model-summary .oms-swatch {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--oms-color, var(--acid));
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex: 0 0 auto;
}
.order-model-summary .oms-strong {
  font-weight: 500;
  color: var(--ink);
}
.order-model-summary .oms-sep {
  height: 16px;
  width: 1px;
  background: var(--line-strong);
}
.order-modal .field {
  gap: 6px;
  margin-bottom: 13px;
}
.order-modal .field > span {
  font-size: 9px;
}
.order-modal .field input {
  height: 44px;
  font-size: 12px;
}
.order-confirm {
  width: 100%;
  margin-top: 6px;
}
.order-error {
  margin: 2px 0 10px;
  padding: 8px 10px;
  border: 1px solid rgba(207, 63, 37, 0.2);
  background: rgba(207, 63, 37, 0.05);
  border-radius: 7px;
  color: var(--danger);
  font-size: 8.5px;
  line-height: 1.5;
}
.product-code {
  margin: 18px 0 12px;
  font-family: var(--font-display);
  font-size: clamp(48px, 10vw, 68px);
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-align: center;
  padding: 18px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(circle at 10% 10%, rgba(220, 255, 79, 0.18), transparent 38%),
    var(--surface-2);
  user-select: all;
}
.copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf8;
  font-size: 8.5px;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.copy-code-btn:hover {
  border-color: var(--ink);
}
.copy-code-btn svg {
  width: 14px;
  height: 14px;
}
.order-file-name {
  font-size: 8px;
  color: var(--muted);
  word-break: break-all;
  margin: 2px 0 12px;
}
.order-preview-image {
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin: 4px 0 15px;
}
.restart-btn {
  width: 100%;
}
#orderSuccessView[hidden] {
  display: none !important;
}
@media (max-width: 980px) {
  .operator-link span:not(.operator-arrow) {
    display: none;
  }
  .operator-link {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }
  .operator-arrow {
    display: none;
  }
}
@media (max-width: 540px) {
  .order-modal {
    padding: 22px 18px;
    border-radius: 18px;
  }
  .order-modal h2 {
    font-size: 24px;
  }
  .text-color-options {
    grid-template-columns: 1fr;
  }
  .color-option {
    min-height: 52px;
    flex-direction: row;
    align-items: center;
  }
  .color-option > span:nth-child(2) {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
  }
  .product-code {
    font-size: 44px;
  }
}

/* ——————————————————————————————— collapsible control sections */
/* Avoid a flash of the optional sections before JS wraps their bodies. */
.control-section.optional-section:not(.collapsible) > :not(.section-heading) {
  display: none;
}
.control-section.collapsible .section-heading {
  cursor: pointer;
  user-select: none;
}
.control-section.collapsed > .section-body {
  display: none;
}
.control-section.collapsed .section-heading {
  margin-bottom: 0;
}
.control-section.collapsed {
  padding-bottom: 17px;
}
.section-toggle {
  width: 23px;
  height: 23px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  margin-left: 2px;
  color: var(--muted);
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.section-toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: #fffdf8;
}
.section-toggle svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}
.control-section.collapsed .section-toggle svg {
  transform: rotate(-90deg);
}
.section-heading:hover .section-toggle {
  border-color: var(--line-dark);
  color: var(--ink);
}


/* ——————————————————————————————— tablet / touch layout */
/* Coarse pointers are tablets/phones: make every customer control finger-sized. */
@media (pointer: coarse) {
  button,
  input,
  select,
  .range {
    touch-action: manipulation;
  }
  .section-heading h3 {
    font-size: 15px;
  }
  .section-num {
    width: 26px;
    height: 20px;
    font-size: 9px;
  }
  .section-meta {
    font-size: 10px;
  }
  .section-toggle {
    width: 30px;
    height: 30px;
  }
  .control-row {
    margin: 17px 0 10px;
  }
  .control-row label {
    font-size: 12px;
  }
  .control-row output {
    font-size: 11px;
    padding: 4px 9px;
  }
  .sub-label {
    font-size: 11px;
  }
  .font-card {
    min-height: 98px;
    padding: 13px 14px 12px;
  }
  .fontAa {
    font-size: 34px;
    height: 32px;
    margin-bottom: 10px;
  }
  .font-name {
    font-size: 10px;
  }
  .font-note {
    font-size: 9px;
  }
  .range {
    height: 34px;
  }
  .range::-webkit-slider-runnable-track {
    height: 6px;
  }
  .range::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
    margin-top: -8px;
    border-width: 2px;
  }
  .range::-moz-range-track {
    height: 6px;
  }
  .range::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }
  .range-scale {
    font-size: 9.5px;
  }
  .example-row button {
    height: 36px;
    padding: 0 12px;
    font-size: 10px;
  }
  .text-btn {
    min-height: 40px;
    font-size: 11px;
  }
  .color-option {
    min-height: 88px;
    padding: 12px;
  }
  .color-option b {
    font-size: 10px;
  }
  .color-option small {
    font-size: 8px;
  }
  .btn {
    height: 58px;
    font-size: 12px;
  }
  .btn svg {
    width: 18px;
    height: 18px;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
  .topbar {
    min-height: 72px;
  }
}

/* Xiaomi Pad landscape: give the customization panel a little more room. */
@media (pointer: coarse) and (min-width: 1181px) {
  :root {
    --panel-w: 470px;
  }
  .panel-head {
    padding: 26px 30px 20px;
  }
  .panel-scroll {
    padding: 0 30px 30px;
  }
  .panel-actions {
    padding: 16px 30px 20px;
  }
  .stage-copy {
    left: 44px;
    top: 44px;
  }
}

/* Respect notch / gesture areas in installed standalone mode. */
@supports (padding: env(safe-area-inset-bottom)) {
  .panel-actions {
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  .topbar {
    padding-left: max(22px, env(safe-area-inset-left));
    padding-right: max(26px, env(safe-area-inset-right));
  }
}

/* ——————————————————————————————— product context / future product picker */
.product-context {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 26px 13px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 9px;
  color: var(--ink-soft);
}
.product-context-label {
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.product-context strong {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
}
.product-context-version {
  font-size: 7.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
}
.product-context-note {
  margin-left: auto;
  font-size: 7.5px;
  color: var(--muted);
}
.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 0 26px 14px;
}
.product-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.4);
  padding: 10px;
  text-align: left;
  font-size: 9px;
  color: var(--ink-soft);
}
.product-card.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.product-card b {
  display: block;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 3px;
}
.product-card small {
  display: block;
  font-size: 7.5px;
  color: var(--muted);
}
.product-card.active small {
  color: rgba(255, 255, 255, 0.55);
}
@media (max-width: 1180px) {
  .product-context {
    margin: 0 20px 13px;
  }
  .product-grid {
    padding: 0 20px 14px;
  }
}
@media (pointer: coarse) {
  .product-context {
    min-height: 42px;
    font-size: 10px;
  }
  .product-context strong {
    font-size: 12px;
  }
  .product-grid {
    gap: 9px;
  }
  .product-card {
    min-height: 58px;
    padding: 12px;
    font-size: 10px;
  }
  .product-card b {
    font-size: 12px;
  }
}
