.custom-plate-app-root {
  --plate-color: #2F2E30;
  --frame-color: #F4EFEB;
  color-scheme: light;
  font-family: "IBM Plex Sans Thai", "Segoe UI", Tahoma, Arial, sans-serif;
  background: #f8fafc;
  color: #172033;
}

.custom-plate-app-root * {
  box-sizing: border-box;
}

.custom-plate-app-root {
  margin: 0;
  min-height: 100vh;
}

.custom-plate-app-root button,
.custom-plate-app-root input {
  font: inherit;
}

.custom-plate-app-root .app {
  height: 100vh;
  height: 100svh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(390px, 0.84fr) minmax(0, 1.16fr);
  align-items: start;
  overflow: hidden;
}

.custom-plate-app-root .preview {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(22px, 4vw, 56px);
  background: #f8fafc;
  border-left: 1px solid #d8dee8;
}

.custom-plate-app-root .product {
  width: min(92%, 980px);
  aspect-ratio: 2.92;
  display: grid;
  place-items: center;
}

.custom-plate-app-root #plateCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.custom-plate-app-root #plateCanvas.dragging {
  cursor: grabbing;
}

.custom-plate-app-root .panel {
  grid-column: 1;
  grid-row: 1;
  height: 100vh;
  height: 100svh;
  min-height: 100svh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(22px, 3.2vw, 52px);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 22px;
  background: #ffffff;
}

.custom-plate-app-root .eyebrow {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #64748b;
  font-weight: 700;
}

.custom-plate-app-root h1 {
  margin: 0;
  max-width: 680px;
  font-size: clamp(32px, 3.6vw, 58px);
  line-height: 1.08;
  letter-spacing: 0;
}

.custom-plate-app-root .intro {
  margin: 0;
  max-width: 560px;
  color: #475569;
  line-height: 1.7;
}

.custom-plate-app-root .tabs,
.custom-plate-app-root .style-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  background: #f1f5f9;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
}

.custom-plate-app-root .style-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.custom-plate-app-root .tab,
.custom-plate-app-root .style-tab {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  color: #334155;
  background: transparent;
  cursor: pointer;
}

.custom-plate-app-root .tab.active,
.custom-plate-app-root .style-tab.active {
  color: #ffffff;
  background: #172033;
}

.custom-plate-app-root .text-controls,
.custom-plate-app-root .icon-controls {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #ffffff;
}

.custom-plate-app-root .icon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.custom-plate-app-root .icon-header span {
  font-weight: 700;
}

.custom-plate-app-root .delete-icon {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #172033;
  background: #ffffff;
  cursor: pointer;
}

.custom-plate-app-root .icon-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: 174px;
  overflow: auto;
  padding-right: 2px;
}

.custom-plate-app-root .icon-option {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #334155;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.15;
}

.custom-plate-app-root .icon-option img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.custom-plate-app-root .icon-option span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-plate-app-root .icon-option:hover,
.custom-plate-app-root .icon-option.active {
  color: #ffffff;
  background: #172033;
}

.custom-plate-app-root .text-field {
  display: grid;
  gap: 8px;
}

.custom-plate-app-root .text-field span {
  font-weight: 700;
}

.custom-plate-app-root .text-field textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #172033;
  text-transform: uppercase;
  background: #ffffff;
  resize: vertical;
}

.custom-plate-app-root .move-tabs,
.custom-plate-app-root .line-size-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  background: #f1f5f9;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
}

.custom-plate-app-root .move-tab,
.custom-plate-app-root .line-size-tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: #334155;
  background: transparent;
  cursor: pointer;
}

.custom-plate-app-root .move-tab.active,
.custom-plate-app-root .line-size-tab.active {
  color: #ffffff;
  background: #172033;
}

.custom-plate-app-root .line-size-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
}

.custom-plate-app-root .line-size-controls > span {
  font-weight: 700;
}

.custom-plate-app-root .rotation-field {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) 44px;
  align-items: center;
  gap: 10px;
}

.custom-plate-app-root .rotation-field span {
  font-weight: 700;
}

.custom-plate-app-root .rotation-field input {
  width: 100%;
}

.custom-plate-app-root .rotation-field output {
  text-align: right;
  font-weight: 700;
  color: #475569;
}

.custom-plate-app-root .controls {
  display: grid;
  gap: 18px;
}

.custom-plate-app-root .picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
}

.custom-plate-app-root .picker span {
  font-weight: 700;
}

.custom-plate-app-root .picker input {
  width: 74px;
  height: 44px;
  padding: 2px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.custom-plate-app-root .swatches {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 10px;
}

.custom-plate-app-root .swatches button {
  position: relative;
  aspect-ratio: 1.62;
  min-height: 70px;
  padding: 8px;
  border-radius: 8px;
  border: 2px solid #ffffff;
  outline: 1px solid #cbd5e1;
  background: var(--swatch);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}

.custom-plate-app-root .swatches span {
  display: block;
  position: relative;
  font-size: 11px;
  line-height: 1.25;
  color: rgba(15, 23, 42, 0.62);
  font-weight: 700;
}

.custom-plate-app-root .swatch-name {
  max-width: 100%;
  margin-top: 14px;
  white-space: normal;
}

.custom-plate-app-root .swatch-ref {
  margin-top: 3px;
  font-size: 10px;
  opacity: 0.86;
}

.custom-plate-app-root .swatches button:nth-child(2) span,
.custom-plate-app-root .swatches button:nth-child(3) span,
.custom-plate-app-root .swatches button:nth-child(5) span,
.custom-plate-app-root .swatches button:nth-child(12) span,
.custom-plate-app-root .swatches button:nth-child(13) span,
.custom-plate-app-root .swatches button:nth-child(15) span,
.custom-plate-app-root .swatches button:nth-child(16) span {
  color: rgba(255, 255, 255, 0.72);
}

.custom-plate-app-root .swatches button:focus-visible,
.custom-plate-app-root .tab:focus-visible,
.custom-plate-app-root .style-tab:focus-visible,
.custom-plate-app-root .move-tab:focus-visible,
.custom-plate-app-root .line-size-tab:focus-visible,
.custom-plate-app-root .icon-option:focus-visible,
.custom-plate-app-root .delete-icon:focus-visible,
.custom-plate-app-root .text-field textarea:focus-visible,
.custom-plate-app-root .reset:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
}

.custom-plate-app-root .summary {
  display: grid;
  gap: 10px;
  padding-top: 8px;
}

.custom-plate-app-root .summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
}

.custom-plate-app-root .summary span {
  color: #475569;
}

.custom-plate-app-root .summary strong {
  font-size: 14px;
  text-transform: uppercase;
}

.custom-plate-app-root .reset {
  width: fit-content;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #172033;
  background: #ffffff;
  cursor: pointer;
}

.custom-plate-app-root .reset:hover {
  background: #f8fafc;
}

.custom-plate-app-root .order-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #f8fafc;
}

.custom-plate-app-root .order-panel h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.custom-plate-app-root .order-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.custom-plate-app-root .order-fields label {
  display: grid;
  gap: 6px;
}

.custom-plate-app-root .order-fields span {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}

.custom-plate-app-root .order-fields input,
.custom-plate-app-root .order-fields textarea,
.custom-plate-app-root .order-summary {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #172033;
  background: #ffffff;
}

.custom-plate-app-root .order-fields input {
  min-height: 40px;
  padding: 0 10px;
}

.custom-plate-app-root .order-fields textarea,
.custom-plate-app-root .order-summary {
  padding: 10px;
  resize: vertical;
}

.custom-plate-app-root .notes-field {
  grid-column: 1 / -1;
}

.custom-plate-app-root .summary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: #172033;
  cursor: pointer;
  font-weight: 700;
}

.custom-plate-app-root .confirmation-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #b7c7dc;
  border-radius: 8px;
  background: #ffffff;
}

.custom-plate-app-root .confirmation-card[hidden] {
  display: none;
}

.custom-plate-app-root .confirmation-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.custom-plate-app-root .confirmation-card span {
  color: #475569;
  font-weight: 700;
}

.custom-plate-app-root .confirmation-card strong {
  color: #172033;
  font-size: 18px;
}

.custom-plate-app-root .confirmation-card p {
  margin: 0;
  color: #475569;
  line-height: 1.5;
}

.custom-plate-app-root .confirmation-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.custom-plate-app-root .confirmation-actions button {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid #172033;
  border-radius: 8px;
  color: #ffffff;
  background: #172033;
  cursor: pointer;
  font-weight: 700;
  font-size: clamp(13px, 1.8vw, 15px);
  line-height: 1.15;
  white-space: nowrap;
}

.custom-plate-app-root .confirmation-actions button + button {
  color: #172033;
  background: #ffffff;
}

.custom-plate-app-root .order-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.custom-plate-app-root .order-actions button {
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #172033;
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
  font-size: clamp(12px, 1.8vw, 14px);
  line-height: 1.15;
  white-space: nowrap;
}

.custom-plate-app-root .order-actions button:hover {
  background: #f1f5f9;
}

.custom-plate-app-root .order-summary {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.custom-plate-app-root .summary-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #ffffff;
}

@media (max-width: 1024px) {
  .custom-plate-app-root .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch;
  }

  .custom-plate-app-root .preview {
    grid-column: 1;
    grid-row: 1;
    z-index: 5;
    min-height: 36svh;
    height: 36svh;
    padding: 12px 18px 30px;
    border-left: 0;
    border-bottom: 1px solid #d8dee8;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  }

  .custom-plate-app-root .panel {
    grid-column: 1;
    grid-row: 2;
    height: 64vh;
    height: 64svh;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-left: 0;
    justify-content: flex-start;
  }

  .custom-plate-app-root .product {
    width: min(90vw, 720px);
  }

  .custom-plate-app-root h1 {
    font-size: clamp(34px, 7vw, 56px);
  }
}

@media (max-width: 520px) {
  .custom-plate-app-root .preview {
    min-height: 34svh;
    height: 34svh;
    padding: 10px 12px 100px;
  }

  .custom-plate-app-root .product {
    width: min(86vw, 640px);
  }

  .custom-plate-app-root .panel {
    height: 66vh;
    height: 66svh;
    padding: 22px 16px 32px;
    gap: 18px;
  }

  .custom-plate-app-root h1 {
    font-size: clamp(32px, 10vw, 46px);
  }

  .custom-plate-app-root .tabs,
.custom-plate-app-root .style-tabs {
    grid-template-columns: 1fr;
  }

  .custom-plate-app-root .swatches {
    grid-template-columns: repeat(2, minmax(86px, 1fr));
  }

  .custom-plate-app-root .icon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-plate-app-root .rotation-field {
    grid-template-columns: 1fr 52px;
  }

  .custom-plate-app-root .rotation-field span {
    grid-column: 1 / -1;
  }

  .custom-plate-app-root .order-fields {
    grid-template-columns: 1fr;
  }

  .custom-plate-app-root .order-actions {
    grid-template-columns: 1fr;
  }

  .custom-plate-app-root .confirmation-actions {
    grid-template-columns: 1fr;
  }
}
