/* Clean dark-slate studio theme matching LaserDeck's ornament customiser,
   designed for effortless mobile & desktop customer use. */

:root {
  --bg: #11151d;
  --surface: #181d27;
  --surface-2: #1f2633;
  --surface-hover: #262f3f;
  --border: #2c3547;
  --border-focus: #ea6a28;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #ea6a28;
  --accent-hover: #f37a3b;
  --accent-soft: rgba(234, 106, 40, 0.16);
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top center, #1b2230 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 18px 48px;
}

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #c84b18);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(234, 106, 40, 0.32);
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.tagline {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.pill-maker {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.list-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

/* ---------------- Shape Selector ---------------- */
.shape-section {
  margin-bottom: 18px;
}

.section-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.shape-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
  font-family: inherit;
}

.shape-card:hover {
  background: var(--surface-2);
  border-color: #46546e;
}

.shape-card[aria-checked="true"] {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(234, 106, 40, 0.14), rgba(234, 106, 40, 0.05));
  box-shadow: 0 0 0 1px rgba(234, 106, 40, 0.35);
}

.shape-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: #cbd5e1;
  display: grid;
  place-items: center;
}

.shape-card[aria-checked="true"] .shape-icon {
  color: var(--accent);
}

.shape-icon svg {
  width: 36px;
  height: 36px;
  display: block;
}

.shape-info {
  min-width: 0;
}

.shape-name {
  font-weight: 650;
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shape-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ---------------- Studio Card ---------------- */
.studio-card, .list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px 24px;
  box-shadow: var(--shadow);
}

.studio-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.studio-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.step-hint {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.editing-banner {
  margin: 5px 0 0;
  font-size: 0.84rem;
  color: #fbbf24;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 26px;
  align-items: start;
}

/* ---------------- Form Controls ---------------- */
.controls-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.84rem;
  font-weight: 500;
  color: #cbd5e1;
}

.req {
  color: #f87171;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-lg {
  font-size: 1.05rem;
  padding: 11px 13px;
}

select.input {
  cursor: pointer;
}

textarea.input {
  resize: vertical;
  min-height: 68px;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.field-hint.warn {
  color: #fbbf24;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.custom-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px 14px;
}

.custom-panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #cbd5e1;
  margin-bottom: 10px;
}

/* Quantity Stepper */
.qty-stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}

.qty-btn {
  width: 40px;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  transition: background 0.15s;
}

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

.qty-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-size: 0.98rem;
  font-weight: 600;
  padding: 9px 4px;
  outline: none;
  -moz-appearance: textfield;
}

.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(234, 106, 40, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #46546e;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-2);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.83rem;
}

.btn-danger-ghost {
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.14);
}

.controls-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.controls-actions .btn-primary {
  flex: 1 1 190px;
}

.controls-actions .btn-secondary {
  flex: 1 1 165px;
}

.no-payment-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------------- Preview Column ---------------- */
.preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
}

.preview-stage {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 0.96;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.preview-stage svg {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-loading {
  color: #64748b;
  font-size: 0.9rem;
}

.preview-meta {
  text-align: center;
  font-size: 0.86rem;
}

.preview-meta .meta-dims {
  font-weight: 600;
  color: #e2e8f0;
}

.preview-meta .meta-style {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.laser-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.swatch-engrave {
  background: #111111;
  border: 1px solid #64748b;
}

.swatch-cut {
  background: #e5262b;
}

.maker-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  width: 100%;
}

/* ---------------- Order List Tray ---------------- */
.list-card {
  margin-top: 20px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.list-header h3 {
  margin: 0;
  font-size: 1.08rem;
}

.list-header .muted {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
}

.list-sub {
  margin: 3px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.list-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.order-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.order-item-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  align-items: center;
}

.order-item-card.is-editing {
  border-color: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.2);
}

.order-thumb {
  width: 78px;
  height: 78px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 10px;
  padding: 5px;
  display: grid;
  place-items: center;
}

.order-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.order-info {
  min-width: 0;
  flex: 1;
}

.order-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.order-item-name {
  font-weight: 700;
  font-size: 0.96rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qty-tag {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #fdba74;
  flex-shrink: 0;
}

.order-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.order-item-actions .btn-sm {
  padding: 5px 9px;
  font-size: 0.77rem;
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 15, 0.74);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal-dialog {
  width: 100%;
  max-width: 580px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.icon-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.icon-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-intro {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.modal-items-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
}

.summary-mini-thumb {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}

.summary-mini-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.summary-row-text {
  min-width: 0;
  flex: 1;
}

.summary-row-title {
  font-weight: 600;
}

.summary-row-sub {
  font-size: 0.77rem;
  color: var(--text-muted);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.alert {
  padding: 10px 13px;
  border-radius: 9px;
  font-size: 0.85rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.alert-info {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #bae6fd;
  text-align: left;
}

/* Success View */
.success-view {
  align-items: center;
  text-align: center;
  padding-top: 26px;
}

.success-icon {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  border: 2px solid var(--ok);
  color: var(--ok);
  display: grid;
  place-items: center;
  font-size: 1.65rem;
  font-weight: 700;
}

.success-view h3 {
  margin: 4px 0 0;
  font-size: 1.3rem;
}

.success-text {
  margin: 0;
  color: var(--text-muted);
  max-width: 440px;
}

.ref-box {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 24px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.ref-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.ref-code {
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  color: #fdba74;
}

.success-foot {
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  animation: toastIn 0.2s ease;
}

.toast.ok {
  border-color: rgba(34, 197, 94, 0.5);
}

.toast.err {
  border-color: rgba(239, 68, 68, 0.5);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Footer ---------------- */
.footer {
  margin-top: 28px;
  text-align: center;
  font-size: 0.79rem;
  color: var(--text-muted);
}

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .shape-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .studio-layout {
    grid-template-columns: 1fr;
  }
  .preview-col {
    order: -1;
  }
  .preview-stage {
    max-width: 340px;
  }
}

@media (max-width: 540px) {
  .app-shell {
    padding: 14px 12px 36px;
  }
  .studio-card, .list-card {
    padding: 16px 14px 18px;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .shape-card {
    padding: 10px;
    gap: 9px;
  }
  .shape-icon {
    width: 32px;
    height: 32px;
  }
  .shape-icon svg {
    width: 30px;
    height: 30px;
  }
  .shape-name {
    font-size: 0.86rem;
  }
  .shape-sub {
    display: none;
  }
  .studio-header {
    flex-direction: column;
    gap: 4px;
  }
}
