:root {
  --orange: #E85D04;
  --orange-dark: #C64A00;
  --bg: #111318;
  --surface: #1B1E26;
  --surface-2: #242833;
  --text: #F4F4F6;
  --muted: #9AA1AE;
  --border: #2E323D;
  --danger: #FF5A5F;
  --success: #2FBF71;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title {
  flex: 1;
  font-weight: 600;
  font-size: 17px;
  text-align: center;
}
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { background: var(--surface-2); }

main#screens {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.screen { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.screen[hidden] { display: none; }

.brand { text-align: center; margin: 10vh 0 8px; }
.brand-badge {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--orange);
  color: #fff; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.brand h1 { margin: 0; font-size: 22px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

.step-title { margin: 4px 0 0; font-size: 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.24), 0 1px 3px rgba(0,0,0,.16);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  font-size: 20px;
  line-height: 1;
  user-select: none;
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-label-icon { font-size: 16px; color: var(--orange); }
.field-label-text { font-size: 13px; color: var(--muted); }
.required-mark { color: var(--danger); font-weight: 700; }
.optional-mark {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}

.tooltip-btn {
  margin-left: auto;
  background: none;
  border: none;
  padding: 2px;
  display: flex;
  color: var(--muted);
  position: relative;
  cursor: pointer;
}
.tooltip-btn .material-symbols-outlined { font-size: 17px; }
.tooltip-bubble {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 10px;
  width: 220px;
  max-width: 60vw;
  text-align: left;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}
.field input, .field select,
.input-icon-wrap input, .input-icon-wrap select {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px 13px 40px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input-icon-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'><path fill='%239AA1AE' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.field input:focus, .field select:focus,
.input-icon-wrap input:focus, .input-icon-wrap select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232,93,4,.18);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: box-shadow .15s, transform .05s, background .15s;
}
.btn-primary {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px rgba(232,93,4,.35);
}
.btn-primary:active { background: var(--orange-dark); transform: translateY(1px); box-shadow: 0 1px 1px rgba(0,0,0,.3); }
.btn-primary:disabled { opacity: .5; box-shadow: none; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--orange);
  color: var(--orange);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}
.choice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.24), 0 1px 3px rgba(0,0,0,.16);
  transition: box-shadow .15s, transform .05s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-align: center;
}
.choice-card:active { border-color: var(--orange); transform: translateY(1px); box-shadow: 0 1px 1px rgba(0,0,0,.2); }
.choice-card svg { color: var(--orange); }
.choice-card span { font-weight: 600; font-size: 14px; }
.choice-card small { color: var(--muted); font-size: 12px; }

.order-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.order-result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.order-result-item b { font-size: 15px; }
.order-result-item span { color: var(--muted); font-size: 13px; }

.order-card { align-items: center; text-align: center; padding: 24px 16px; }
.order-card-name { font-size: 22px; font-weight: 700; color: var(--orange); }
.order-card-partner { font-size: 15px; }
.order-card-state {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.order-card-state.is-sale { color: var(--success); border-color: var(--success); }
.order-card-state.is-cancel { color: var(--danger); border-color: var(--danger); }
.order-card-meta {
  display: flex;
  width: 100%;
  gap: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.order-card-meta-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.order-card-meta-item small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.order-card-meta-item span { font-size: 14px; font-weight: 600; }

.order-card-address, .order-card-products {
  width: 100%;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.order-card-address small, .order-card-products small {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.order-card-address span { font-size: 14px; }
.order-card-products ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.order-card-products li {
  font-size: 13px;
  display: flex;
  gap: 8px;
}
.order-card-products li b {
  color: var(--orange);
  flex-shrink: 0;
}

.photo-box {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  aspect-ratio: 3 / 4;
  max-height: 46vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface);
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.photo-placeholder svg { color: var(--muted); }

.photo-actions { display: flex; gap: 10px; }
.photo-actions .btn { flex: 1; }

.compress-info { color: var(--muted); font-size: 12px; text-align: center; margin: 0; }

.summary-card { gap: 8px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.summary-row:last-child { border-bottom: none; }
.summary-row span:first-child { color: var(--muted); }
.summary-thumb {
  width: 100%;
  border-radius: 10px;
  max-height: 220px;
  object-fit: cover;
}

.success-box {
  text-align: center;
  margin: 8vh 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.success-icon {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: rgba(47,191,113,.15);
  color: var(--success);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 50;
  max-width: 90vw;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 60;
  color: #fff;
  font-size: 14px;
}
.spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: var(--orange);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.swal-processing {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.35) !important;
  font-family: inherit !important;
}
.swal-processing .swal2-title { font-size: 16px !important; }
.swal-processing .swal2-loader {
  border-color: var(--orange) transparent var(--orange) transparent !important;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F5F6F8;
    --surface: #FFFFFF;
    --surface-2: #F0F1F4;
    --text: #16181D;
    --muted: #6B7280;
    --border: #E3E5EA;
    color-scheme: light;
  }
}
