:root {
  --teal-deep: #0d5b6f;
  --teal-mid: #157a8e;
  --blue-light: #7fc7e8;
  --blue-pale: #c8e3ee;
  --blue-mist: #e6f2f7;
  --bg: #f6fbfd;
  --surface: #ffffff;
  --ink: #0d3a47;
  --ink-soft: #547682;
  --border: #d6e6ee;
  --shadow: 0 4px 20px rgba(13, 91, 111, 0.08);
  --radius: 14px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Lora', Georgia, serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.header-btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: all 0.15s var(--ease);
}
.header-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s var(--ease);
}
.header-btn:hover {
  background: var(--blue-mist);
  border-color: var(--blue-light);
  color: var(--teal-deep);
}
.header-btn:hover svg {
  opacity: 1;
}
.header-btn:active {
  transform: translateY(1px);
}

/* Hide labels on narrow screens — icons only */
@media (max-width: 640px) {
  .header-btn { padding: 0; width: 40px; justify-content: center; }
  .header-btn span { display: none; }
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.brand-name {
  font-family: 'Great Vibes', cursive;
  font-size: 44px;
  color: var(--teal-deep);
  line-height: 1;
}

.brand-tag {
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ===== Stepper ===== */
.stepper {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
}

.stepper ol {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  gap: 4px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  transition: background 0.4s var(--ease);
}

.step.completed:not(:last-child)::after { background: var(--teal-deep); }

.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 14px;
  transition: all 0.3s var(--ease);
}

.step.active .step-num {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
  color: white;
  box-shadow: 0 0 0 4px rgba(13, 91, 111, 0.12);
}
.step.completed .step-num {
  background: var(--blue-light);
  border-color: var(--blue-light);
  color: var(--teal-deep);
}

.step-label {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: color 0.3s var(--ease);
}
.step.active .step-label { color: var(--teal-deep); font-weight: 600; }
.step.completed .step-label { color: var(--ink); }

@media (max-width: 800px) {
  .step-label { display: none; }
}

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  padding: 18px;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ===== Step content ===== */
.step-panel { min-height: 500px; display: flex; flex-direction: column; }

.step-content {
  display: none;
  animation: fadeSlide 0.35s var(--ease);
}
.step-content.active { display: block; }

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

.step-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--teal-deep);
  margin: 0 0 6px;
}

.step-desc {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 16px;
  line-height: 1.5;
}

.step-nav {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.step-indicator {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ===== Form controls ===== */
.size-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.size-btn,
.shape-btn,
.btn,
.bead-size-btn {
  font-family: inherit;
  font-size: 14px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.size-btn:hover,
.shape-btn:hover:not(.disabled),
.bead-size-btn:hover { border-color: var(--blue-light); background: var(--blue-mist); }

.size-btn.active,
.shape-btn.active,
.bead-size-btn.active {
  background: var(--teal-deep);
  color: white;
  border-color: var(--teal-deep);
}

.shape-row { display: flex; gap: 8px; }

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.type-card {
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s var(--ease);
  text-align: center;
  touch-action: none; /* enable pointer-drag without browser scroll interference */
  user-select: none;
}
.type-card.dragging { opacity: 0.4; cursor: grabbing; }

/* Floating "ghost" bead that follows the cursor during type-card drag */
.type-drag-ghost {
  position: fixed;
  width: 56px;
  height: 56px;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  opacity: 0.9;
  filter: drop-shadow(0 6px 14px rgba(13, 58, 71, 0.35));
}
.type-drag-ghost .type-card-thumb {
  width: 100%;
  height: 100%;
}

/* Drop-target highlight on the bracelet during a type-card drag */
.bead.drop-hover {
  stroke: #f6c945;
  stroke-width: 4;
  filter: drop-shadow(0 0 8px rgba(246, 201, 69, 0.7));
}
.gap-marker.drop-hover { opacity: 1 !important; }
.gap-marker.drop-hover .gap-marker-bg { r: 16; fill: #f6c945; }

/* During a type drag, surface the gap markers so the user can see all
 * the places they can insert a bead. */
body.type-dragging .gap-marker { opacity: 0.55 !important; }
body.type-dragging .canvas-wrap { cursor: copy; }
.type-card:hover { border-color: var(--blue-light); background: var(--blue-mist); transform: translateY(-2px); }
.type-card.active {
  border-color: var(--teal-deep);
  box-shadow: 0 0 0 2px rgba(13, 91, 111, 0.15);
}
.type-card-thumb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: inset 0 -3px 8px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Transparent thumb for frame/ring types (star, circle ring, twisted ring) —
 * keeps the see-through shape visible on the card background. */
.type-card-thumb--frame {
  background-color: transparent !important;
  background-size: contain;
  border-radius: 0;
  box-shadow: none;
}

/* When the thumb holds a tiny inner dot (spacer), suppress the container's
 * own inset shadow so it doesn't sit behind the dot like a halo. */
.type-card-thumb--has-tiny-dot {
  background-color: transparent;
  box-shadow: none;
}

/* Tiny thumb dot for very small fixed-size beads (e.g. spacer 2mm) — shows
 * the bead at a representative scale rather than filling the whole circle. */
.type-card-tiny-dot {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow:
    inset 0 -1px 2px rgba(0, 0, 0, 0.35),
    inset 0 1px 1px rgba(255, 255, 255, 0.6),
    0 1px 2px rgba(0, 0, 0, 0.15);
}
.type-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.type-card-meta {
  font-size: 11px;
  color: var(--ink-soft);
}

.variant-picker {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--blue-mist);
  animation: fadeSlide 0.25s var(--ease);
}

.variant-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--teal-deep);
  margin-right: 4px;
}

.variant-tile {
  font-family: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s var(--ease);
}
.variant-tile:hover { border-color: var(--blue-light); }
.variant-tile.active {
  background: var(--teal-deep);
  color: white;
  border-color: var(--teal-deep);
}
.variant-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(0,0,0,0.1);
}
.shape-btn { display: inline-flex; align-items: center; gap: 8px; flex: 1; justify-content: center; }
.shape-btn.disabled { opacity: 0.5; cursor: not-allowed; }

.shape-icon { width: 18px; height: 18px; display: inline-block; }
.shape-round {
  border-radius: 50%;
  background: linear-gradient(135deg, #fff, var(--blue-light));
  border: 1px solid var(--blue-light);
}
.shape-soon {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; background: var(--blue-pale); color: var(--teal-deep);
  font-weight: 700; font-size: 14px;
}

.bead-size-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.bead-size-btn {
  font-size: 12px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center; justify-content: flex-end;
  gap: 8px;
  min-height: 70px;
}
.bead-size-dot {
  display: inline-block;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, var(--blue-light) 60%, #4a9bbf 100%);
  border: 1px solid rgba(0,0,0,0.05);
  transition: transform 0.2s var(--ease);
}
.bead-size-btn:hover .bead-size-dot { transform: scale(1.1); }

.color-palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px solid white;
  outline: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s var(--ease);
  padding: 0;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.selected { outline: 2px solid var(--teal-deep); outline-offset: 2px; }

.custom-color {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-soft);
}
.custom-color input[type="color"] {
  width: 36px; height: 36px; border: none; background: none; cursor: pointer; padding: 0;
}

.action-row { display: flex; flex-wrap: wrap; gap: 8px; }

.btn-primary {
  background: var(--teal-deep);
  color: white;
  border-color: var(--teal-deep);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--teal-mid); border-color: var(--teal-mid); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background: var(--blue-mist);
  border-color: var(--blue-pale);
  color: var(--teal-deep);
}
.btn-secondary:hover { background: var(--blue-pale); }

.btn-ghost {
  background: transparent;
  color: var(--teal-deep);
}
.btn-ghost:hover:not(:disabled) { background: var(--blue-mist); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Canvas ===== */
.canvas-panel {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 18px;
}

/* "Locked" mode: bracelet is read-only on the Render step */
.canvas-panel.locked #bracelet { pointer-events: none; }
.canvas-panel.locked .bead { cursor: default; }
.canvas-panel.locked .gap-marker-layer { display: none; }

/* ===== Render step: full-width 50/50 layout ===== */
.layout-render { grid-template-columns: 1fr; }
.layout-render .canvas-panel { display: none; }
.layout-render .step-panel { min-height: 0; position: static; }

.render-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 900px) {
  .render-split { grid-template-columns: 1fr; }
}

.render-col,
.ai-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.render-col-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.render-col-head .step-title { margin-bottom: 4px; }
.render-col-head .step-desc { margin: 0; }
.render-col-head .action-row { flex-shrink: 0; }

.canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 12px;
}

.canvas-title { font-size: 16px; font-weight: 600; color: var(--teal-deep); margin: 0 0 4px; }
.canvas-sub { margin: 0; color: var(--ink-soft); font-size: 13px; transition: opacity 0.2s; }

.canvas-wrap, .render-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: radial-gradient(circle at center, #ffffff 0%, var(--blue-mist) 100%);
  border-radius: 12px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

/* Contextual menu */
.ctx-menu {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(13, 91, 111, 0.15);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: ctxSlideUp 0.25s var(--ease);
  z-index: 5;
}
.ctx-menu[hidden] { display: none; }

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

.ctx-header {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.ctx-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--teal-deep);
  letter-spacing: 0.02em;
}
.ctx-close {
  width: 26px; height: 26px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 16px;
  border-radius: 6px;
  line-height: 1;
}
.ctx-close:hover { background: var(--blue-mist); color: var(--teal-deep); }

.ctx-section {
  display: flex; align-items: center; gap: 10px;
}
.ctx-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  width: 50px;
  flex-shrink: 0;
}
.ctx-row {
  display: flex; flex-wrap: wrap; gap: 6px; flex: 1;
}
.ctx-pill {
  font-family: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ctx-pill:hover { border-color: var(--blue-light); background: var(--blue-mist); }
.ctx-pill.active {
  background: var(--teal-deep);
  color: white;
  border-color: var(--teal-deep);
}
.ctx-pill-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(0,0,0,0.1);
}
.ctx-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid white;
  outline: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s var(--ease);
}
.ctx-swatch:hover { transform: scale(1.15); }
.ctx-swatch.selected { outline: 2px solid var(--teal-deep); }
.ctx-color-input {
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none; cursor: pointer; padding: 0;
}

#bracelet, #renderSvg {
  width: 100%; height: 100%; display: block;
  touch-action: none;
}

.foot {
  text-align: center;
  padding: 24px;
  color: var(--ink-soft);
  font-size: 13px;
}

/* ===== AI try-on ===== */
.ai-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.ai-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--teal-deep);
  margin: 0 0 6px;
}
.ai-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 12px 0;
}
.ai-style-label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: 1;
}
.ai-style-label select {
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.ai-style-label select:hover { border-color: var(--blue-light); }

.ai-result {
  width: 100%;
  aspect-ratio: 1 / 1;
  background:
    repeating-linear-gradient(
      45deg,
      var(--blue-mist) 0px,
      var(--blue-mist) 10px,
      #ffffff 10px,
      #ffffff 20px
    );
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  position: relative;
  margin-top: 12px;
}
.ai-result img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ai-result.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  animation: aiShimmer 1.6s linear infinite;
}
@keyframes aiShimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}
.ai-placeholder {
  text-align: center;
  padding: 16px 24px;
  line-height: 1.5;
}

.ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.ai-actions[hidden] { display: none; }

.ai-ref-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 8px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.ai-ref-toggle input { cursor: pointer; }

.ai-prompt-details {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-soft);
}
.ai-prompt-details summary {
  cursor: pointer;
  padding: 4px 0;
}
.ai-prompt-text {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: var(--blue-mist);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  color: var(--ink);
  line-height: 1.5;
}

.ai-token-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
}
.ai-token-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: var(--blue-mist);
  padding: 1px 5px;
  border-radius: 4px;
}

.ai-active-provider {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-soft);
}
.ai-active-provider strong { color: var(--teal-deep); font-weight: 600; }

/* ===== Settings modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 58, 71, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: modalFade 0.2s var(--ease);
}
.modal-backdrop[hidden] { display: none; }

@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalSlideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(13, 91, 111, 0.25);
  animation: modalSlideUp 0.25s var(--ease);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--teal-deep);
}
.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 18px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--blue-mist); color: var(--teal-deep); }

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg);
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-section h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--teal-deep);
  letter-spacing: 0.02em;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--ink);
}
.settings-field > span {
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.settings-field select,
.settings-field input[type="password"],
.settings-field input[type="text"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.settings-field input[type="password"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.settings-field select:focus,
.settings-field input:focus {
  outline: none;
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(127, 199, 232, 0.25);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--blue-mist);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.settings-group[hidden] { display: none; }

/* ===== Designs library ===== */
.design-save-row {
  display: flex;
  gap: 8px;
}
.design-save-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
}
.design-save-row input:focus {
  outline: none;
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(127, 199, 232, 0.25);
}

.designs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.design-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.15s var(--ease);
}
.design-card:hover { border-color: var(--blue-light); }

.design-card-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue-mist);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.design-card-thumb svg {
  width: 100%;
  height: 100%;
}

.design-card-body {
  flex: 1;
  min-width: 0;
}
.design-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--teal-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.design-card-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.design-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.design-card-actions button {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: all 0.15s var(--ease);
}
.design-card-actions button:hover {
  background: var(--blue-mist);
  border-color: var(--blue-light);
  color: var(--teal-deep);
}
.design-card-actions button.danger:hover {
  background: #fce4e4;
  border-color: #e88aa1;
  color: #c34977;
}

.designs-empty {
  padding: 16px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  background: var(--blue-mist);
  border-radius: 10px;
  border: 1px dashed var(--border);
}

/* ===== Bead visuals + animations ===== */

/* Smooth beads are wrapped in a <g> that handles translate + optional
 * rotation/scaling (needed for elongated types like the cylinder spacer). */
.bead-group {
  cursor: grab;
  transition: transform 0.5s var(--ease), opacity 0.3s ease;
}
.bead-group.entering { opacity: 0; }
.bead-group.dragging { cursor: grabbing; }

.bead {
  cursor: grab;
  transition:
    cx 0.5s var(--ease),
    cy 0.5s var(--ease),
    r 0.45s var(--ease),
    fill 0.3s ease,
    stroke 0.15s ease,
    opacity 0.3s ease;
}
.bead.dragging { cursor: grabbing; transition: none; }
.bead.selected { stroke: var(--teal-deep); stroke-width: 3; }
.bead.entering { opacity: 0; }

.bead-highlight {
  pointer-events: none;
  transition:
    cx 0.5s var(--ease),
    cy 0.5s var(--ease),
    r 0.45s var(--ease),
    opacity 0.3s ease;
}

/* Image-type beads — the wrapper <g> handles positioning so the position
 * transitions via CSS transform, which is reliably interpolated by the browser. */
.bead-image-wrapper {
  pointer-events: none;
  transition: transform 0.5s var(--ease);
}
.bead-image-wrapper.entering { opacity: 0; }

.bead-image {
  pointer-events: none;
  transition:
    width 0.5s var(--ease),
    height 0.5s var(--ease),
    x 0.5s var(--ease),
    y 0.5s var(--ease),
    opacity 0.3s ease;
}

/* Coloured ellipse rendered behind the bead photo so beads are always
 * visible — even before the image file loads (or if it's missing). */
.bead-image-fallback {
  pointer-events: none;
  transition:
    rx 0.5s var(--ease),
    ry 0.5s var(--ease),
    fill 0.3s ease;
}

/* Inner bead rendered inside container frames (e.g. star). */
.bead-inner {
  pointer-events: none;
  transition:
    r 0.4s var(--ease),
    fill 0.3s ease;
}

/* The clipPath shape inside <defs> animates too so the clip follows the bead */
clipPath > circle,
clipPath > ellipse {
  transition:
    cx 0.5s var(--ease),
    cy 0.5s var(--ease),
    r 0.5s var(--ease),
    rx 0.5s var(--ease),
    ry 0.5s var(--ease);
}

.bracelet-string {
  fill: none;
  stroke: #b8c6cc;
  stroke-width: 2;
  stroke-dasharray: 3 3;
  opacity: 0.7;
  transition: r 0.6s var(--ease);
}

/* Hover-to-add gap markers between beads */
.gap-marker {
  cursor: pointer;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 0.2s var(--ease), transform 0.5s var(--ease);
}
.canvas-wrap:hover .gap-marker { opacity: 0.35; }
.gap-marker:hover { opacity: 1; }

.gap-marker-bg {
  transition: r 0.15s var(--ease);
}
.gap-marker:hover .gap-marker-bg { r: 14; }
