:root {
  --accent: #005CB9;
  --accent-dark: #004a94;
  --accent-2: #40B4E5;
  --ink: #16283c;
  --ink-soft: #52657a;
  --bg: #f4f7fa;
  --line: #dee6ee;
  --danger: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}
.hidden { display: none !important; }

/* App fills whatever square it's embedded in */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.bar { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: nowrap; }

/* Big simple buttons */
.big-btn {
  flex: 1;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.big-btn:active { transform: scale(.98); }
.big-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.big-btn.primary:hover { background: var(--accent-dark); }
.big-btn.small { flex: 0 0 auto; padding: 10px 16px; font-size: 14px; }

/* Text row */
.text-row { display: flex; gap: 6px; align-items: center; }
.text-row input[type=text] {
  flex: 1; min-width: 60px; border: 2px solid var(--line); border-radius: 10px;
  padding: 10px; font-size: 15px; font-family: inherit;
}
.text-row input[type=text]:focus, .text-row select:focus { outline: none; border-color: var(--accent); }
.text-row select {
  border: 2px solid var(--line); border-radius: 10px; padding: 10px 6px; font-size: 14px;
  font-family: inherit; max-width: 110px;
}
.swatch-row { display: flex; gap: 5px; flex: 0 0 auto; }
.swatch-row .swatch { width: 22px; height: 22px; }

/* Stage */
.stage-area {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas-wrap { position: relative; }
#shirtSvg { position: absolute; inset: 0; pointer-events: none; }
#shirtSvg svg, #shirtSvg img { display: block; width: 100%; height: 100%; filter: drop-shadow(0 8px 18px rgba(15,23,42,.16)); }
.canvas-wrap canvas { position: relative; z-index: 2; }
.canvas-container { z-index: 2; }
#printArea {
  position: absolute; border: 1.5px dashed rgba(0,92,185,.55); border-radius: 4px; pointer-events: none; z-index: 3;
}
#stage3d canvas { display: block; border-radius: 12px; }
.stage3d-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: 15px; font-weight: 700; pointer-events: none;
}

/* Floating object toolbar */
.obj-toolbar {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; background: var(--ink); border-radius: 12px; padding: 6px; z-index: 6;
}
.obj-toolbar button {
  background: none; border: none; color: #e2e8f0; font-size: 18px; font-weight: 700;
  width: 40px; height: 36px; border-radius: 8px; cursor: pointer;
}
.obj-toolbar button:hover { background: rgba(255,255,255,.14); }
.obj-toolbar button.danger { color: #fca5a5; }

/* Pills */
.pills { display: flex; gap: 4px; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 3px; }
.pill {
  border: none; background: none; padding: 9px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 800; color: var(--ink-soft); cursor: pointer;
  font-family: inherit; display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.pill.active { background: var(--accent); color: #fff; }
.view-toggle .pill.active { background: var(--accent-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; display: inline-block; }

.chip {
  border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 16px;
  font-size: 14px; font-weight: 800; color: var(--ink-soft); cursor: pointer; font-family: inherit;
}
.chip.active { border-color: var(--accent); color: var(--accent); background: #eaf3fb; }

/* Garment + color picker row */
.picker-bar { justify-content: flex-start; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.prods { display: flex; gap: 6px; flex: 0 0 auto; }
.prod-btn {
  width: 54px; height: 50px; border: 2px solid var(--line); background: #fff; border-radius: 12px;
  cursor: pointer; font-family: inherit; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; flex: 0 0 auto;
}
.prod-btn .p-ico { font-size: 20px; line-height: 1; }
.prod-btn .p-lbl { font-size: 9px; font-weight: 800; color: var(--ink-soft); }
.prod-btn.selected { border-color: var(--accent); background: #eaf3fb; }
.prod-btn.selected .p-lbl { color: var(--accent); }

.colors { display: flex; gap: 6px; flex: 0 0 auto; margin-left: 10px; align-items: center; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15);
  cursor: pointer; flex: 0 0 auto; padding: 0;
}
.swatch.selected { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Toast */
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 700; z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 90%; text-align: center;
}

/* Very small squares: shrink paddings */
@media (max-width: 460px), (max-height: 560px) {
  .app { gap: 6px; padding: 8px; }
  .big-btn { font-size: 14px; padding: 10px 8px; }
  .pill { font-size: 12px; padding: 8px 10px; }
  .chip { font-size: 12px; padding: 8px 12px; }
  .prod-btn { width: 46px; height: 44px; }
  .swatch { width: 22px; height: 22px; }
}
