:root {
  --canvas: #F4F3F8;
  --surface: #FFFFFF;
  --surface-muted: #F7F6FB;
  --border: #E5E3EE;
  --border-strong: #C9C5D8;
  --text-primary: #16151C;
  --text-secondary: #6E6B7B;
  --text-tertiary: #75728A;
  --text-inverse: #FFFFFF;
  --accent: #5B3DF5;
  --accent-hover: #4A2FE0;
  --accent-soft: #F1EDFF;
  --success: #17945F;
  --error: #D93B3B;

  --r-10: 10px;
  --r-12: 12px;
  --r-14: 14px;
  --r-16: 16px;
  --r-20: 20px;
  --r-24: 24px;
  --r-full: 999px;

  --shadow-card: 0 12px 32px rgba(22, 21, 28, 0.08);
  --shadow-pop: 0 12px 32px rgba(22, 21, 28, 0.14);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
  width: 20px;
  height: 20px;
  flex: none;
  display: block;
}

.page {
  min-height: 100vh;
  padding: 56px 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-24);
  padding: 32px;
  box-shadow: var(--shadow-card);
}

.head { margin-bottom: 24px; }

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 36px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.sub {
  margin: 0;
  font-size: 15px;
  line-height: 23px;
  color: var(--text-secondary);
}

form { display: flex; flex-direction: column; gap: 24px; }

/* ---------- position ---------- */
.positions { display: flex; flex-direction: column; gap: 12px; }

.position {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: var(--r-16);
  background: var(--surface-muted);
}

.position-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}

.position-title {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--text-secondary);
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--r-10);
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover { background: var(--surface); color: var(--text-primary); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: block; }
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-secondary);
}

/* ---------- select ---------- */
.dropdown { position: relative; }

.select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-12);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.select:hover { border-color: var(--border-strong); }
.select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.select[aria-expanded="true"] { border-color: var(--accent); }

.select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select .ic { color: var(--text-secondary); }
.select[aria-expanded="true"] .ic { color: var(--accent); }
.chev-up { display: none; }
.select[aria-expanded="true"] .chev-up { display: block; }
.select[aria-expanded="true"] .chev-down { display: none; }

.popup {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-14);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.popup[hidden] { display: none; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  margin-bottom: 4px;
  border-radius: var(--r-10);
  background: var(--surface-muted);
  color: var(--text-tertiary);
}

.search .ic { width: 16px; height: 16px; }

.search input {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}

.options {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 264px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-10);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-primary);
  cursor: pointer;
}

.option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option .ic { width: 16px; height: 16px; opacity: 0; color: var(--accent); }
.option[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.option[aria-selected="true"] .ic { opacity: 1; }
.option.is-active { background: var(--surface-muted); }
.option[aria-selected="true"].is-active { background: var(--accent-soft); }
.option-empty { padding: 12px; font-size: 13px; color: var(--text-tertiary); }

/* ---------- color chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  padding: 8px 14px 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.chip:hover { border-color: var(--border-strong); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.swatch {
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  box-shadow: inset 0 0 0 1px rgba(22, 21, 28, 0.18);
  flex: none;
}

/* ---------- stepper ---------- */
.stepper { display: flex; align-items: center; gap: 10px; }

.step-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-12);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.step-btn.plus { color: var(--accent); }
.step-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.step-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.step-btn:disabled { opacity: 0.45; cursor: not-allowed; border-color: var(--border); background: var(--surface); }

.step-value {
  min-width: 60px;
  height: 44px;
  border-radius: var(--r-12);
  background: var(--surface-muted);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 600;
}

/* ---------- buttons ---------- */
.btn {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-14);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

.btn-outline {
  min-height: 48px;
  font-size: 15px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  color: var(--accent);
}

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

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover { background: var(--surface-muted); }

.footnote {
  margin: 0;
  font-size: 12px;
  line-height: 17px;
  color: var(--text-secondary);
  text-align: center;
}

/* ---------- success ---------- */
.success { display: flex; flex-direction: column; gap: 20px; }
.success[hidden] { display: none; }

.success-mark {
  width: 56px;
  height: 56px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.ic-check { width: 28px; height: 28px; }

.num-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-radius: var(--r-14);
  background: var(--surface-muted);
}

.num-stack { display: flex; flex-direction: column; gap: 2px; }
.num-label { font-size: 12px; line-height: 17px; color: var(--text-secondary); }
.num-value { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.2px; }

.copy-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-10);
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.copy-btn:hover { background: var(--surface); color: var(--text-primary); }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-14);
  background: var(--surface);
}

.details-title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; }

.order-items { display: flex; flex-direction: column; gap: 12px; }

.order-item { display: flex; flex-direction: column; gap: 2px; }
.order-item strong { font-size: 14px; line-height: 20px; font-weight: 500; }
.order-item span { font-size: 12px; line-height: 17px; color: var(--text-secondary); }

.order-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 20px;
  color: var(--text-secondary);
}

.order-total strong { font-size: 14px; font-weight: 500; color: var(--text-primary); }

.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}

.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status-note { font-size: 13px; line-height: 20px; color: var(--text-secondary); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  padding: 12px 16px;
  border-radius: var(--r-12);
  background: var(--text-primary);
  color: var(--text-inverse);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .page { padding: 0; }

  .card {
    max-width: none;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 24px 16px 32px;
  }

  .head { margin-bottom: 20px; }

  h1 { font-size: 26px; line-height: 32px; }

  form { gap: 20px; }

  .chips { gap: 8px; }
}

@media (min-width: 641px) and (max-width: 900px) {
  .page { padding: 32px 20px; }
  .card { max-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
