/* Minimal extras (Tailwind handles most styling) */
body { color: #1f2937; }
body[data-active-tab="#tab-classic"] #clear-canvas-btn-top,
body[data-active-tab="#tab-wall"] #clear-canvas-btn-top {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#app-header {
  position: sticky;
  top: 0;
  z-index: 35;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: .75rem 0.5rem;
  border-radius: 1.25rem;
  box-shadow: 0 8px 24px rgba(15,23,42,0.08);
}

#balloon-canvas { touch-action: none; }

.balloon-canvas {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  border: 1px black solid;
  margin-top: 0.25rem;
}

/* Buttons */
.btn-dark,
.btn-blue,
.btn-green,
.btn-yellow,
.btn-danger,
.btn-indigo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  border: 0;
  font-size: 0.95rem;
}
.btn-dark:focus-visible,
.btn-blue:focus-visible,
.btn-green:focus-visible,
.btn-yellow:focus-visible,
.btn-danger:focus-visible,
.btn-indigo:focus-visible,
.tool-btn:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}
.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: .5rem .75rem;
  border: 1px solid #e2e8f0;
  border-radius: .75rem;
  background: #fff;
  color: #1e293b;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.tool-btn svg { width: 1.1em; height: 1.1em; fill: currentColor; }
.tool-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.tool-btn[aria-pressed="true"] { background:#3b82f6; color:#fff; border-color:#3b82f6; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* Base button style - Slate Gradient */
.btn-dark   { background: linear-gradient(135deg, #334155, #0f172a); color:#fff; padding:.6rem .8rem; border-radius:.75rem; transition: all 0.2s; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15); }
.btn-dark:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25); }

/* Primary Action - Vibrant Blue/Indigo Gradient */
.btn-blue   { background: linear-gradient(135deg, #6366f1, #3b82f6); color:#fff; padding:.6rem .8rem; border-radius:.75rem; transition: all 0.2s; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.btn-blue:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4); }

/* Success/Save - Emerald Gradient */
.btn-green  { background: linear-gradient(135deg, #10b981, #059669); color:#fff; padding:.6rem .8rem; border-radius:.75rem; transition: all 0.2s; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.btn-green:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4); }

/* Secondary Action - White Glass */
.btn-yellow { background: rgba(255,255,255,0.9); color:#334155; border: 1px solid #cbd5e1; padding:.55rem .75rem; border-radius:.75rem; transition: all 0.2s; }
.btn-yellow:hover { background:#fff; border-color:#94a3b8; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

/* Destructive - Red Gradient */
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color:#fff; padding:.6rem .8rem; border-radius:.75rem; transition: all 0.2s; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4); }

/* Accent - Indigo/Purple Gradient */
.btn-indigo { background: linear-gradient(135deg, #8b5cf6, #6366f1); color:#fff; padding:.6rem .8rem; border-radius:.75rem; transition: all 0.2s; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.btn-indigo:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4); }

.btn-dark.text-sm { padding:.35rem .55rem; }

.copy-message{ opacity:0; transition:opacity .3s; }
.copy-message.show{ opacity:1; }

.hint { font-size:.8rem; color:#64748b; }

/* Palette / Swatches */
.palette-box {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .5rem;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: .9rem;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
  touch-action: pan-y;
}

.swatch {
  appearance: none;
  padding: 0;
  position: relative;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  border: 2px solid rgba(0,0,0,.05);
  box-shadow: 0 2px 4px rgba(0,0,0,.05);
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.swatch:hover { transform: scale(1.1); z-index: 10; }
.swatch:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }
.swatch.active { outline: 2px solid #6366f1; outline-offset: 2px; }
.swatch.tiny { width: 1.4rem; height: 1.4rem; border-width: 1px; box-shadow: none; }

.current-color-chip {
  min-width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  border: 2px solid rgba(51,65,85,0.15);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 .6rem;
  background-size: cover;
  background-position: center;
  background-color: #fff;
}

.swatch-row { display:flex; flex-wrap:wrap; gap:.5rem; }
.family-title { font-weight:700; color:#334155; margin-top:.25rem; font-size:.9rem; letter-spacing: -0.01em; }
#wall-display { min-height: 60vh; }
#wall-display svg { width: 100%; height: 100%; display: block; }

.badge {
  position:absolute;
  right:-6px; top:-6px;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .25rem;
  background:#1e293b;
  color:#fff;
  border-radius: 9999px;
  font-size:.7rem;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Selects */
.select {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid #cbd5e1;
  border-radius: .5rem;
  background: #fff;
  color: #334155;
}

#classic-swatch-grid .sw { width: 24px; height: 24px; border-radius: 6px; border: 1px solid rgba(0,0,0,.1); cursor: pointer; }
#classic-swatch-grid .sw:focus { outline: 2px solid #2563eb; outline-offset: 2px; }
.slot-btn { position: relative; overflow: hidden; }
.slot-btn[aria-pressed="true"] { background:#3b82f6; color:#fff; }
.slot-btn.slot-active {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.95);
  outline: 3px solid #f97316;
  outline-offset: 3px;
  z-index: 1;
}
.slot-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slot-swatch {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  border: 3px solid #e5e7eb;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: border-color .2s, transform .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: rgba(0,0,0,0.4);
  background-size: cover;
  background-position: center;
  position: relative;
}

.slot-swatch:hover {
  border-color: #9ca3af;
}

.slot-swatch.active {
  border-color: #2563eb;
  transform: scale(1.1);
}
.slot-swatch.active::after { display: none; }

.replace-row {
  padding: 0.35rem;
  background: rgba(248,250,252,0.9);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: 12px;
}
.replace-chip {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 2px solid rgba(51,65,85,0.18);
  box-shadow: 0 3px 8px rgba(0,0,0,0.06);
  background-size: cover;
  background-position: center;
  background-color: #fff;
  cursor: pointer;
}

.wall-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.wall-toolbar .tool-btn {
  width: 100%;
  justify-content: center;
}

.topper-type-group {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.topper-type-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.topper-type-btn i { font-size: 1rem; }
.topper-number-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.topper-number-btn {
  padding: 0.4rem 0.5rem;
  font-weight: 800;
}
.number-tint-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 0.85rem;
}
.number-tint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.floating-nudge {
  position: fixed;
  right: 0.9rem;
  bottom: 4.6rem;
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(148,163,184,0.3);
  border-radius: 1rem;
  padding: 0.55rem;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  width: 180px;
  max-width: 85vw;
  z-index: 35;
  touch-action: none;
}
.floating-nudge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  margin-bottom: .25rem;
}
.floating-nudge-body.collapsed { display: none; }
.floating-nudge.collapsed .floating-nudge-body { display: none; }
.floating-nudge.collapsed #floating-nudge-toggle { opacity: 0.8; }
.floating-nudge.dragging { cursor: grabbing; }
.floating-nudge .panel-heading { font-size: 0.95rem; margin-bottom: 0; }
.floating-nudge .btn-dark { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
.floating-nudge-tab { display: none; }

@media (max-width: 1023px) {
  .floating-nudge { bottom: 6rem; left: auto; right: 0.9rem; }
}

.slot-label {
  font-weight: 600;
  color: #4b5563;
}

/* Panel styling */
.panel-heading {
  font-weight: 800;
  color: #334155;
  margin-bottom: .35rem;
  letter-spacing: -0.02em;
}
.panel-card {
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 12px 30px rgba(15,23,42,0.06);
}
.control-stack {
  display: flex;
  flex-direction: column;
}

/* ---------- Control sheet ---------- */
.control-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 3.8rem;
  max-height: 60vh;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 -4px 30px rgba(0,0,0,0.08);
  border-radius: 1.5rem 1.5rem 0 0;
  padding: 1.25rem 1rem;
  overflow-y: auto;
  z-index: 30;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.control-sheet.hidden { display: none; }
.control-sheet.minimized { transform: translateY(100%); }
.panel-title {
  font-weight: 900;
  font-size: 1.1rem;
  background: linear-gradient(to right, #4f46e5, #db2777);
  -webkit-background-clip: text;
  color: transparent;
  margin-bottom: .5rem;
}
.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .4rem;
}
.sheet-close-btn {
  padding: .45rem .75rem;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  font-weight: 700;
  color: #111827;
}

.control-stack {
  display: flex;
  flex-direction: column;
}

@media (max-width: 1023px) {
  body { padding-bottom: 0; overflow: auto; }
  html, body { height: auto; overflow: auto; }
  #current-color-chip-global { display: none; }
  #clear-canvas-btn-top { display: none !important; }
  /* Add breathing room under canvases so sheets/tabbar don’t cover content */
  #classic-display,
  #wall-display,
  #balloon-canvas {
    margin-bottom: 5rem;
  }

  /* Stack switching: show only the active mobile tab stack across panels */
  .control-sheet .control-stack { display: none; }
  body[data-mobile-tab="controls"] #controls-panel [data-mobile-tab="controls"],
  body[data-mobile-tab="colors"]   #controls-panel [data-mobile-tab="colors"],
  body[data-mobile-tab="save"]     #controls-panel [data-mobile-tab="save"],
  body[data-mobile-tab="controls"] #classic-controls-panel [data-mobile-tab="controls"],
  body[data-mobile-tab="colors"]   #classic-controls-panel [data-mobile-tab="colors"],
  body[data-mobile-tab="save"]     #classic-controls-panel [data-mobile-tab="save"],
  body[data-mobile-tab="controls"] #wall-controls-panel [data-mobile-tab="controls"],
  body[data-mobile-tab="colors"]   #wall-controls-panel [data-mobile-tab="colors"],
  body[data-mobile-tab="save"]     #wall-controls-panel [data-mobile-tab="save"] {
    display: block;
  }
  .control-sheet { bottom: 4.5rem; max-height: 55vh; }
  .control-sheet.minimized { transform: translateY(115%); }

  /* Larger tap targets and spacing */
  .tool-btn,
  .btn-dark,
  .btn-blue,
  .btn-green,
  .btn-yellow,
  .btn-danger,
  .btn-indigo {
    min-height: 44px;
    padding: 0.75rem 0.85rem;
    font-size: 1rem;
  }
  .swatch { width: 2.4rem; height: 2.4rem; }
  .swatch.tiny { width: 1.8rem; height: 1.8rem; }
  .select { min-height: 44px; }
  .panel-card { padding: 0.85rem; }
}

.mobile-action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 4.75rem;
  padding: 0.35rem 0.75rem 0.7rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.72) 0%, rgba(255,255,255,0.96) 100%);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(226,232,240,0.9);
  box-shadow: 0 -10px 30px rgba(15,23,42,0.08);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 20; /* below control sheets (30) and modals (60) */
}

.color-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.color-modal.hidden { display: none; }
.color-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.35);
  backdrop-filter: blur(4px);
}
.color-modal-card {
  position: relative;
  width: min(640px, 92vw);
  max-height: 80vh;
  background: #fff;
  border-radius: 1.25rem;
  padding: 1.1rem 1.1rem 1.25rem;
  box-shadow: 0 24px 60px rgba(15,23,42,0.2);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1;
}
.color-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.color-modal-title { font-size: 1.1rem; font-weight: 800; color: #0f172a; letter-spacing: -0.01em; }
.color-modal-subtitle { font-size: 0.9rem; color: #475569; }
.color-modal-close {
  background: #e2e8f0;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 1.4rem;
  color: #0f172a;
}
.color-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.75rem;
  overflow-y: auto;
  padding: 0.25rem;
}
.color-option {
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: 12px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #fff;
  box-shadow: 0 4px 12px rgba(15,23,42,0.05);
  transition: transform 0.1s ease;
}
.color-option:hover { transform: translateY(-1px); }
.color-option .swatch {
  width: 2.4rem;
  height: 2.4rem;
  border-width: 2px;
}
.color-option .label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
  line-height: 1.1;
}
.color-option .meta {
  font-size: 0.72rem;
  color: #475569;
  text-align: center;
}
.mobile-action-bar.hidden { display: none; }
.mobile-action-chip {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 2px solid rgba(51,65,85,0.18);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  background-size: cover;
  background-position: center;
  background-color: #fff;
}
.mobile-action-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
  width: 100%;
}
.mobile-action-btn {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: 14px;
  padding: 0.55rem 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
  box-shadow: 0 4px 14px rgba(15,23,42,0.08);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}
.mobile-action-btn i { font-size: 1rem; }
.mobile-action-btn.danger { color: #dc2626; border-color: rgba(248,113,113,0.35); }
.mobile-action-btn:active { transform: translateY(1px); }
.mobile-action-btn.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.18), 0 6px 16px rgba(37,99,235,0.2);
}

.mobile-tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: .6rem .9rem .9rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(224,242,254,0.92));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #0f172a;
  z-index: 40;
  gap: .4rem;
  box-shadow: 0 -6px 30px rgba(15, 23, 42, 0.12);
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}
.mobile-tabbar.hidden { display: none; }

@media (max-width: 1023px) {
  /* Tuck canvases above the tabbar */
  #classic-display,
  #wall-display,
  #balloon-canvas {
    margin-bottom: 5.5rem;
  }
}
.mobile-tabbar .mobile-tab-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  text-align: center;
  padding: .7rem .5rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255,255,255,0.8);
  color: #1d4ed8;
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: 0.01em;
  transition: all 0.2s ease;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.12);
}
.mobile-tabbar .mobile-tab-icon {
  font-size: 1.2rem;
  line-height: 1;
  display: block;
  flex-shrink: 0;
}
.mobile-tabbar .mobile-tab-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-color: rgba(37, 99, 235, 0.2);
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.3);
  transform: translateY(-2px);
}


@media (min-width: 1024px) {
  .control-sheet {
    left: 1rem;
    top: 7rem;
    bottom: auto;
    width: 340px;
    max-height: calc(100vh - 8rem);
    border-radius: 1.5rem;
    position: sticky;
    overflow-y: auto;
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.4);
  }
  body { padding-bottom: 0; overflow: auto; }
  .mobile-action-bar { display: none !important; }
}

/* Compact viewport fallback */
@media (max-height: 760px) {
  body { overflow: auto; }
  .control-sheet {
    position: static;
    max-height: none;
  }
  .floating-nudge {
    bottom: 1rem;
  }
}
