/* ==========================================================================
   Locket Gold Studio (/caption) — Warm Cream & Honey-Gold Design System
   Inspired by khunganh.nodns.vn · Responsive Split-Screen Studio
   ========================================================================== */

:root {
  /* Surfaces */
  --bg-page: #FFFDF5;
  --bg-hero: #FFF7E7;
  --bg-preview-stage: linear-gradient(180deg, #FFFCF0 0%, #FFF3D1 100%);
  --bg-card: #FFFFFF;
  --bg-subtle: #FFFAF0;
  --bg-input: #FFFCF6;
  --bg-pill-track: #F5EED9;
  --bg-hover: #FFF6DF;

  /* Borders & Elevation */
  --border-card: #ECE3D1;
  --border-strong: #DFCFAF;
  --border-input: #E5D9BF;
  --border-focus: #E5A400;
  --ring-focus: 0 0 0 3px #FFEFA8;
  --shadow-card: 0 2px 6px rgba(110, 82, 24, 0.04), 0 12px 28px -6px rgba(110, 82, 24, 0.07);
  --shadow-card-hover: 0 6px 16px rgba(110, 82, 24, 0.07), 0 16px 32px -6px rgba(110, 82, 24, 0.1);
  --shadow-widget: 0 18px 36px -10px rgba(120, 82, 20, 0.26), 0 0 0 6px #FFFFFF, 0 0 0 7px #E5D5B5;

  /* Typography Ink (WCAG AA+ contrast >= 4.5:1 across cream/white surfaces) */
  --ink-primary: #2D2416;
  --ink-secondary: #685536;
  --ink-muted: #7C6744;
  --ink-on-gold: #462E00;

  /* Brand Honey-Gold & Accents */
  --gold-top: #FFC837;
  --gold-bot: #FFB000;
  --gold-border: #E59E00;
  --gold-lip: #CC8B00;
  --gold-soft-bg: #FFF0BE;
  --gold-soft-border: #F2D67E;
  --gold-soft-ink: #7A5800;

  /* Rose Accent (Photobooth & Love badges) */
  --rose-top: #FF6B8B;
  --rose-bot: #F43F5E;
  --rose-lip: #BE123C;
  --rose-soft-bg: #FFF0F3;
  --rose-soft-border: #FECDD3;
  --rose-soft-ink: #9F1239;

  /* Semantic Status */
  --ok-bg: #EDF7ED;
  --ok-border: #C6E3C6;
  --ok-ink: #27592B;
  --err-bg: #FFF1EE;
  --err-border: #F5C6BC;
  --err-ink: #9E2F1E;
  --info-bg: #FFF8E3;
  --info-border: #F2DC9B;
  --info-ink: #6E5005;

  /* Radii */
  --r-card: 20px;
  --r-panel-inner: 14px;
  --r-control: 12px;
  --r-frame: 16px;
  --r-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   1. Base Reset, Browser Surfaces & Strict Overflow Protection
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: #FFE596;
  color: #2D2416;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-color: #DAC9A9 transparent;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-x: clip;
  background-color: var(--bg-page);
  background-image:
    radial-gradient(900px 420px at 50% -80px, rgba(255, 206, 84, 0.22), rgba(255, 253, 245, 0) 70%);
  color: var(--ink-primary);
  font-family: 'Plus Jakarta Sans', 'Be Vietnam Pro', ui-rounded, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   2. App Shell, Compact Header & Top Mode Switcher
   ========================================================================== */
.studio-shell {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 16px 24px 56px;
}

.studio-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 13px;
  background: linear-gradient(180deg, var(--gold-top) 0%, var(--gold-bot) 100%);
  border: 1px solid var(--gold-border);
  box-shadow: 0 3px 0 var(--gold-lip);
  color: var(--ink-on-gold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-copy p {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  padding: 5px 10px 5px 6px;
  border-radius: var(--r-pill);
  max-width: 240px;
  min-height: 40px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--gold-soft-bg);
  border: 1.5px solid var(--gold-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-soft-ink);
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.btn-header-connect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  background: var(--gold-soft-bg);
  border: 1px solid var(--gold-soft-border);
  color: var(--ink-on-gold);
  font-size: 12.5px;
  font-weight: 700;
  transition: background 0.18s var(--ease-out), transform 0.18s var(--ease-out);
  white-space: nowrap;
}

.btn-header-connect:hover {
  background: #FFE799;
}

.btn-logout {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s;
}

.btn-logout:hover {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err-ink);
}

/* Top Mode Switcher */
.mode-switch-wrap {
  background: var(--bg-pill-track);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 20px;
  width: 100%;
}

.mode-tab-btn {
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
  min-width: 0;
  text-align: center;
}

.mode-tab-btn:hover {
  color: var(--ink-primary);
  background: rgba(255, 255, 255, 0.55);
}

.mode-tab-btn.active {
  background: var(--bg-card);
  color: var(--ink-primary);
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(110, 82, 24, 0.08);
}

.mode-tab-btn svg {
  flex-shrink: 0;
}

.mode-tab-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-mini {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, var(--rose-top), var(--rose-bot));
  color: #FFFFFF;
  flex-shrink: 0;
}

/* ==========================================================================
   3. Split-Screen Studio Grid (Desktop Sticky Left Preview + Right Controls)
   ========================================================================== */
.mode-view {
  width: 100%;
  min-width: 0;
}

.studio-split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  width: 100%;
  min-width: 0;
}

.studio-preview-col,
.studio-controls-col {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.studio-controls-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 1024px) {
  .studio-split-layout {
    grid-template-columns: 392px minmax(0, 1fr);
    gap: 26px;
  }

  .studio-preview-col {
    position: sticky;
    top: 18px;
    z-index: 10;
  }
}

@media (min-width: 1280px) {
  .studio-split-layout {
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 30px;
  }
}

/* ==========================================================================
   4. Cards, Section Headers & Common Form Controls
   ========================================================================== */
.studio-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--r-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.step-pill {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--gold-soft-bg);
  border: 1px solid var(--gold-soft-border);
  color: var(--ink-on-gold);
  font-size: 12.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.step-pill.rose {
  background: var(--rose-soft-bg);
  border-color: var(--rose-soft-border);
  color: var(--rose-soft-ink);
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ink-primary);
  line-height: 1.3;
}

.card-subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--gold-soft-bg);
  border: 1px solid var(--gold-soft-border);
  color: var(--gold-soft-ink);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill.ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-ink);
}

.status-pill.rose {
  background: var(--rose-soft-bg);
  border-color: var(--rose-soft-border);
  color: var(--rose-soft-ink);
}

.form-group {
  margin-bottom: 14px;
  min-width: 0;
}

.form-group:last-child {
  margin-bottom: 0;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-primary);
}

.field-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.input-field,
.pb-input,
.select-field {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--r-control);
  color: var(--ink-primary);
  font-size: 15px;
  font-weight: 500;
  transition: border-color 0.18s, box-shadow 0.18s, background-color 0.18s;
  scroll-margin-top: 16px;
  scroll-margin-bottom: 120px;
}

.input-field::placeholder,
.pb-input::placeholder {
  color: var(--ink-muted);
  opacity: 0.85;
}

.input-field:hover,
.pb-input:hover,
.select-field:hover {
  border-color: var(--border-strong);
}

.input-field:focus,
.pb-input:focus,
.select-field:focus {
  outline: none;
  background: #FFFFFF;
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
}

.input-with-clear {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-clear .input-field {
  padding-right: 42px;
}

.btn-input-clear {
  position: absolute;
  right: 6px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-input-clear:hover {
  background: var(--bg-pill-track);
  color: var(--ink-primary);
}

/* ==========================================================================
   5. Tactile Honey-Gold & Studio Buttons
   ========================================================================== */
.btn-gold-3d {
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--gold-top) 0%, var(--gold-bot) 100%);
  border: 1px solid var(--gold-border);
  box-shadow: 0 4px 0 var(--gold-lip), 0 8px 18px rgba(204, 139, 0, 0.2);
  color: var(--ink-on-gold);
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 0.14s var(--ease-out), box-shadow 0.14s var(--ease-out), filter 0.14s;
  scroll-margin-bottom: 110px;
  text-align: center;
}

.btn-gold-3d:hover:not(:disabled) {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--gold-lip), 0 12px 22px rgba(204, 139, 0, 0.26);
}

.btn-gold-3d:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--gold-lip), 0 4px 10px rgba(204, 139, 0, 0.18);
}

.btn-gold-3d:disabled,
.btn-espresso:disabled,
.btn-soft:disabled,
.btn-rose-3d:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-espresso {
  width: 100%;
  min-height: 48px;
  padding: 11px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, #3B2F1E 0%, #261E12 100%);
  border: 1px solid #1E170D;
  box-shadow: 0 4px 0 #140F08, 0 8px 18px rgba(45, 36, 22, 0.16);
  color: #FFF9EB;
  font-size: 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 0.14s var(--ease-out), box-shadow 0.14s var(--ease-out), filter 0.14s;
  scroll-margin-bottom: 110px;
}

.btn-espresso:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-espresso:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #140F08;
}

.btn-rose-3d {
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--rose-top) 0%, var(--rose-bot) 100%);
  border: 1px solid #E11D48;
  box-shadow: 0 4px 0 var(--rose-lip), 0 8px 18px rgba(225, 29, 72, 0.22);
  color: #FFFFFF;
  font-size: 14.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 0.14s var(--ease-out), box-shadow 0.14s var(--ease-out);
  scroll-margin-bottom: 110px;
}

.btn-rose-3d:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.btn-rose-3d:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--rose-lip);
}

.btn-soft {
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-strong);
  color: var(--ink-primary);
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.16s, border-color 0.16s, transform 0.14s;
}

.btn-soft:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #D2BC91;
}

.btn-soft:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-soft.full {
  width: 100%;
}

.btn-soft.danger {
  color: var(--err-ink);
  border-color: var(--err-border);
  background: #FFF8F6;
}

.btn-soft.danger:hover:not(:disabled) {
  background: var(--err-bg);
}

.btn-xs {
  min-height: 36px;
  padding: 6px 11px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

/* ==========================================================================
   6. Left Sticky 1:1 Squircle Live Preview Card
   ========================================================================== */
.preview-studio-card {
  background: var(--bg-preview-stage);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.preview-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  min-width: 0;
}

.preview-card-heading {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-primary);
  letter-spacing: -0.01em;
}

/* Signature 1:1 iOS Home-Screen Squircle Widget Stage */
.squircle-stage-outer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0 12px;
}

.studio-squircle-stage {
  width: 300px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 22.5%;
  position: relative;
  overflow: hidden;
  background: #FFFDF5;
  box-shadow: var(--shadow-widget);
  transform: translateZ(0);
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}

@media (min-width: 1280px) {
  .studio-squircle-stage {
    width: 316px;
  }
}

.studio-squircle-stage canvas {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.studio-squircle-stage canvas:active,
.studio-squircle-stage canvas.is-dragging {
  cursor: grabbing;
}

.preview-particle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 6;
}

/* Interactive Transform Toolbar under Preview */
.preview-gesture-hint {
  margin: 2px 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  text-align: center;
}

.transform-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 11px 12px;
  margin-bottom: 12px;
}

.zoom-control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-zoom-step {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--ink-primary);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}

.btn-zoom-step:hover {
  background: var(--bg-hover);
}

.btn-zoom-step:active {
  transform: scale(0.94);
}

.zoom-val-badge {
  min-width: 48px;
  text-align: right;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--gold-soft-ink);
  font-variant-numeric: tabular-nums;
}

/* Custom Range Input */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #EADEC6;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid #EEA000;
  box-shadow: 0 2px 6px rgba(120, 82, 20, 0.25);
  transition: transform 0.14s var(--ease-out);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid #EEA000;
  box-shadow: 0 2px 6px rgba(120, 82, 20, 0.25);
}

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

.btn-tool-chip {
  min-height: 38px;
  padding: 6px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, border-color 0.15s;
}

.btn-tool-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-tool-chip.active {
  background: var(--gold-soft-bg);
  border-color: var(--gold-border);
  color: var(--ink-on-gold);
}

.stage-bg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 2px;
}

.stage-bg-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.stage-bg-swatches {
  display: flex;
  align-items: center;
  gap: 7px;
}

.stage-bg-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 0 1px #D5C5A5;
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stage-bg-dot.active {
  transform: scale(1.14);
  box-shadow: 0 0 0 2px var(--gold-border);
}

.stage-bg-dot.checker {
  background-color: #FFFFFF;
  background-image:
    linear-gradient(45deg, #E2D9C8 25%, transparent 25%),
    linear-gradient(-45deg, #E2D9C8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #E2D9C8 75%),
    linear-gradient(-45deg, transparent 75%, #E2D9C8 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}

.frame-info-mini {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.frame-info-mini-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   7. Account Connection Panel (Inline Non-Blocking Auth + Connected Bar)
   ========================================================================== */
.account-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #FFFAF0 100%);
  border: 1.5px solid var(--border-strong);
}

.account-segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  background: var(--bg-pill-track);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.seg-btn {
  min-height: 40px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.16s;
}

.seg-btn.active {
  background: var(--bg-card);
  color: var(--ink-primary);
  border-color: var(--border-strong);
  box-shadow: 0 1px 4px rgba(110, 82, 24, 0.08);
}

.auth-inline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.auth-pw-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.helper-note {
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 11px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-ink);
  font-size: 12px;
  line-height: 1.45;
}

.connected-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.connected-user-meta {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.connected-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--gold-border);
  background: var(--gold-soft-bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--ink-on-gold);
}

.connected-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.connected-name {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--ink-primary);
  line-height: 1.25;
}

.connected-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.connected-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   8. Photo Dropzone & Upload Controls
   ========================================================================== */
.photo-dropzone {
  border: 2px dashed #DFC99B;
  border-radius: 16px;
  background: var(--bg-subtle);
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
}

.photo-dropzone:hover,
.photo-dropzone.drag-over {
  background: var(--bg-hover);
  border-color: var(--gold-border);
}

.dropzone-icon-wrap {
  width: 44px;
  height: 44px;
  margin: 0 auto 8px;
  border-radius: 13px;
  background: var(--gold-soft-bg);
  border: 1px solid var(--gold-soft-border);
  color: var(--ink-on-gold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-primary);
}

.dropzone-sub {
  font-size: 12px;
  color: var(--ink-secondary);
  margin-top: 3px;
}

.photo-meta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok-ink);
  font-size: 12.5px;
  font-weight: 700;
  flex-wrap: wrap;
}

/* ==========================================================================
   9. Frame Picker Grid, Category Pills & Fine-Tuning Accordion
   ========================================================================== */
.active-frame-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 13px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-card);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.active-frame-desc {
  font-size: 12.5px;
  color: var(--ink-secondary);
  margin: 0;
  min-width: 0;
}

.frame-toolbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.category-pills {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
  margin-bottom: 12px;
  max-width: 100%;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

.category-pill {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.16s;
}

.category-pill:hover {
  background: var(--bg-hover);
  color: var(--ink-primary);
}

.category-pill.active {
  background: linear-gradient(180deg, var(--gold-top), var(--gold-bot));
  border-color: var(--gold-border);
  color: var(--ink-on-gold);
  box-shadow: 0 2px 0 var(--gold-lip);
}

.frames-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
  width: 100%;
  min-width: 0;
}

.frame-card {
  position: relative;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-card);
  border-radius: var(--r-frame);
  padding: 8px;
  cursor: pointer;
  transition: transform 0.16s var(--ease-out), border-color 0.16s, box-shadow 0.16s, background 0.16s;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.frame-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
  background: #FFFFFF;
}

.frame-card.active {
  background: #FFFBF0;
  border-color: var(--gold-border);
  box-shadow: 0 0 0 2px #FFE48F, 0 6px 16px rgba(204, 139, 0, 0.14);
}

.frame-card.is-current {
  border-color: #469B52;
}

.frame-thumb-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background-color: #F7EFE0;
  background-image:
    linear-gradient(45deg, #EFE5D1 25%, transparent 25%),
    linear-gradient(-45deg, #EFE5D1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #EFE5D1 75%),
    linear-gradient(-45deg, transparent 75%, #EFE5D1 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 7px;
}

.frame-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.frame-badge {
  position: absolute;
  left: 5px;
  bottom: 5px;
  max-width: calc(100% - 10px);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 800;
  background: rgba(45, 36, 22, 0.78);
  color: #FFFDF5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.frame-badge.exclusive {
  background: linear-gradient(180deg, var(--gold-top), var(--gold-bot));
  color: var(--ink-on-gold);
}

.frame-status-tag {
  position: absolute;
  top: 5px;
  left: 5px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 800;
  background: #237A34;
  color: #FFFFFF;
}

.frame-fav-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(223, 207, 175, 0.9);
  background: rgba(255, 255, 255, 0.92);
  color: #9A8460;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
  transition: transform 0.14s, color 0.14s, background 0.14s;
}

.frame-fav-btn:hover {
  transform: scale(1.08);
}

.frame-fav-btn.is-fav {
  color: #E11D48;
  border-color: #FDA4AF;
  background: #FFF1F2;
}

.frame-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.frame-sub-state {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-top: 2px;
}

.frame-card.active .frame-sub-state {
  color: var(--gold-soft-ink);
}

/* Collapsible Frame Fine-Tuning */
.tuning-details {
  margin-top: 14px;
  border: 1px solid var(--border-card);
  border-radius: 14px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.tuning-details summary {
  list-style: none;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  user-select: none;
}

.tuning-details summary::-webkit-details-marker {
  display: none;
}

.tuning-chevron {
  transition: transform 0.2s var(--ease-out);
  color: var(--ink-secondary);
}

.tuning-details[open] .tuning-chevron {
  transform: rotate(180deg);
}

.tuning-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border-card);
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-label-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.slider-val-pill {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-soft-ink);
  background: var(--gold-soft-bg);
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   10. Vietnamese Typography, Swatches, Color Chips & Emoji Grid
   ========================================================================== */
.quick-chips-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.quick-chip {
  min-height: 36px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.quick-chip:hover {
  background: var(--gold-soft-bg);
  border-color: var(--gold-border);
}

.font-pills-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin-top: 6px;
}

.font-pill-btn {
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 11px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  transition: all 0.15s;
}

.font-pill-btn:hover {
  border-color: var(--border-strong);
  background: #FFFFFF;
}

.font-pill-btn.active {
  background: #FFFBF0;
  border-color: var(--gold-border);
  box-shadow: 0 0 0 2px #FFE699;
}

.font-pill-sample {
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.font-pill-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-muted);
  font-family: 'Plus Jakarta Sans', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.typo-split-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.pos-segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  background: var(--bg-pill-track);
  padding: 4px;
  border-radius: 11px;
}

.pos-btn {
  min-height: 36px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 700;
}

.pos-btn.active {
  background: #FFFFFF;
  color: var(--ink-primary);
  border-color: var(--border-strong);
  box-shadow: 0 1px 3px rgba(110, 82, 24, 0.08);
}

/* 9-Swatch Gradient / Style Grid */
.color-swatches-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 640px) {
  .color-swatches-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.color-swatch-card {
  min-height: 44px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 0;
  transition: all 0.15s;
}

.color-swatch-card:hover {
  background: #FFFFFF;
  border-color: var(--border-strong);
}

.color-swatch-card.active {
  background: #FFFBF0;
  border-color: var(--gold-border);
  box-shadow: 0 0 0 2px #FFE699;
}

.swatch-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(45, 36, 22, 0.14);
}

.swatch-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-gradient-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.custom-gradient-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.color-picker-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.color-picker-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 700;
  min-height: 38px;
}

.color-picker-wrapper input[type="color"] {
  width: 24px;
  height: 24px;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}

.hex-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  color: var(--ink-secondary);
}

.text-color-chips {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.text-color-chip {
  min-height: 40px;
  padding: 6px 11px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--border-card);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.text-color-chip:hover {
  border-color: var(--border-strong);
  background: #FFFFFF;
}

.text-color-chip.active {
  background: #FFFBF0;
  border-color: var(--gold-border);
  box-shadow: 0 0 0 2px #FFE699;
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}

.emoji-btn {
  min-height: 42px;
  border-radius: 10px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-subtle);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.13s, border-color 0.13s, background 0.13s;
}

.emoji-btn:hover {
  transform: translateY(-1px);
  background: #FFFFFF;
  border-color: var(--border-strong);
}

.emoji-btn.active {
  background: var(--gold-soft-bg);
  border-color: var(--gold-border);
}

/* ==========================================================================
   11. Primary Action Panel & Inline Feedback Messages
   ========================================================================== */
.bake-toggle-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-card);
  margin-bottom: 14px;
  cursor: pointer;
}

.bake-toggle-box input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: #E59E00;
  flex-shrink: 0;
  cursor: pointer;
}

.bake-toggle-copy {
  font-size: 12.5px;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.bake-toggle-copy strong {
  color: var(--ink-primary);
  display: block;
}

.cta-stack {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.cta-dual-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.msg {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  display: none;
}

.msg.show {
  display: block;
}

.msg.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok-ink);
}

.msg.err {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-ink);
}

.msg.info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-ink);
}

/* ==========================================================================
   12. Mode 2: Camera Captions Manager & Presets Library
   ========================================================================== */
.preview-screen {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 18px 14px;
  background-color: #2A241C;
}

.preview-caption-pill {
  max-width: 90%;
  padding: 9px 16px;
  border-radius: 22px;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.34);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  word-break: break-word;
  z-index: 2;
}

.caption-reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: rgba(20, 20, 25, 0.78);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s;
}

.caption-reaction-badge:hover {
  transform: scale(1.06);
}

.caption-reaction-badge.burst {
  animation: badgePop 0.32s var(--ease-out);
}

@keyframes badgePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.floating-reaction-particle {
  position: absolute;
  font-size: 20px;
  pointer-events: none;
  z-index: 9;
  animation: floatReactionUp 1.25s ease-out forwards;
}

@keyframes floatReactionUp {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.85) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--offset-x, 0px), -120px) scale(1.35) rotate(var(--rot, 12deg));
  }
}

.caption-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

.caption-item {
  padding: 10px 12px;
  border-radius: 13px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all 0.15s;
}

.caption-item:hover {
  background: #FFFFFF;
  border-color: var(--border-strong);
}

.caption-item.active {
  background: #FFFBF0;
  border-color: var(--gold-border);
}

.cap-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 700;
  max-width: 100%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn-icon.del {
  min-width: 38px;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background: #FFFFFF;
  color: var(--err-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon.del:hover {
  background: var(--err-bg);
  border-color: var(--err-border);
}

.preset-category-block {
  margin-bottom: 18px;
}

.preset-category-block:last-child {
  margin-bottom: 0;
}

.preset-category-title {
  margin: 0 0 9px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink-primary);
}

.preset-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip {
  min-height: 40px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-chip:hover {
  background: var(--gold-soft-bg);
  border-color: var(--gold-border);
  transform: translateY(-1px);
}

/* ==========================================================================
   13. Mode 3: Photobooth 4-Cut Studio + Crop & Admin Modals
   ========================================================================== */
.pb-layouts-container {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.pb-layout-btn {
  min-height: 44px;
  padding: 8px 8px;
  border-radius: 12px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.15s;
}

.pb-layout-btn:hover {
  background: #FFFFFF;
  border-color: var(--border-strong);
}

.pb-layout-btn.active {
  background: var(--rose-soft-bg);
  border-color: #FB7185;
  color: var(--rose-soft-ink);
  box-shadow: 0 0 0 2px #FFE4E6;
}

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

.pb-theme-card {
  padding: 10px 8px;
  border-radius: 13px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-subtle);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 0;
}

.pb-theme-card:hover {
  background: #FFFFFF;
  border-color: var(--border-strong);
}

.pb-theme-card.active {
  background: var(--rose-soft-bg);
  border-color: #FB7185;
  box-shadow: 0 0 0 2px #FFE4E6;
}

.pb-theme-icon {
  font-size: 20px;
  margin-bottom: 3px;
}

.pb-theme-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-theme-sub {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-muted);
}

.pb-type-pill {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 700;
}

.pb-type-pill.active {
  background: var(--rose-soft-bg);
  border-color: #FB7185;
  color: var(--rose-soft-ink);
}

.pb-frames-scroll {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  max-height: 290px;
  overflow-y: auto;
  padding: 2px;
  margin-bottom: 8px;
}

.pb-frame-card {
  padding: 7px;
  border-radius: 13px;
  border: 1.5px solid var(--border-card);
  background: #FFFFFF;
  cursor: pointer;
  text-align: center;
  min-width: 0;
  transition: all 0.15s;
}

.pb-frame-card:hover {
  border-color: var(--border-strong);
}

.pb-frame-card.active {
  background: var(--rose-soft-bg);
  border-color: #FB7185;
  box-shadow: 0 0 0 2px #FFE4E6;
}

.pb-frame-thumb-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  overflow: hidden;
  background: #F6EFE0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
}

.pb-frame-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pb-frame-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-slots-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.pb-slot-item {
  position: relative;
  min-height: 120px;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  border: 2px dashed #DFC99B;
  background: var(--bg-subtle);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pb-slot-item:hover {
  border-color: #FB7185;
  background: #FFF9FA;
}

.pb-slot-item.has-img {
  border-style: solid;
  border-color: var(--border-strong);
  background: #1C1917;
}

.pb-slot-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pb-slot-label {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-primary);
  margin-top: 4px;
}

.pb-slot-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(25, 20, 15, 0.78);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.pb-slot-crop-btn {
  position: absolute;
  bottom: 6px;
  left: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(25, 20, 15, 0.8);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
}

.pb-slot-zoom-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(244, 63, 94, 0.9);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  z-index: 2;
}

/* Modals (Photobooth Crop & Admin) */
.pb-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 26, 15, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.pb-crop-modal-content,
.pb-admin-modal-content {
  width: 100%;
  max-width: 460px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 24px 56px rgba(34, 26, 15, 0.3);
  color: var(--ink-primary);
}

.pb-admin-modal-content {
  max-width: 580px;
}

.pb-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  font-size: 15px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#pbCropCanvas,
#pbPreviewCanvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ==========================================================================
   14. Spinner & Toast Notification
   ========================================================================== */
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid rgba(70, 46, 0, 0.25);
  border-top-color: currentColor;
  animation: studioSpin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes studioSpin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -130%);
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  max-width: min(440px, calc(100vw - 24px));
  padding: 11px 16px;
  border-radius: 14px;
  background: #2D2416;
  color: #FFFDF5;
  border: 1px solid #524229;
  box-shadow: 0 14px 32px rgba(34, 26, 15, 0.28);
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: transform 0.28s var(--ease-out), opacity 0.24s;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ==========================================================================
   15. Tablet (640px–1023px) & Mobile (< 640px) Ergonomic Overrides
   ========================================================================== */
@media (max-width: 1023px) {
  .studio-shell {
    max-width: 720px;
    padding: 14px 16px 48px;
  }

  .studio-preview-col {
    position: static;
  }

  .studio-squircle-stage {
    width: 268px;
  }
}

@media (max-width: 767px) {
  /* CRITICAL: Prevent iOS Safari forced viewport zoom on input focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  textarea,
  select,
  .input-field,
  .pb-input,
  .select-field {
    font-size: 16px !important;
  }
}

@media (max-width: 639px) {
  .studio-shell {
    padding: 10px 12px 44px;
  }

  .studio-topbar {
    padding: 10px 12px;
    border-radius: 16px;
    margin-bottom: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .brand-copy h1 {
    font-size: 15px;
  }

  .brand-copy p {
    display: none;
  }

  .user-name {
    max-width: 88px;
  }

  .mode-switch-wrap {
    padding: 4px;
    gap: 4px;
    margin-bottom: 14px;
    border-radius: 14px;
  }

  .mode-tab-btn {
    min-height: 44px;
    padding: 7px 6px;
    font-size: 12px;
    gap: 5px;
    border-radius: 10px;
  }

  .mode-tab-btn .badge-mini {
    display: none;
  }

  /* Compact Above-the-Fold 1:1 Preview on Mobile */
  .preview-studio-card {
    padding: 13px;
    border-radius: 20px;
  }

  .squircle-stage-outer {
    padding: 4px 0 10px;
  }

  .studio-squircle-stage {
    width: 236px;
    max-width: calc(100vw - 56px);
  }

  .btn-zoom-step {
    width: 44px;
    height: 44px;
  }

  .transform-quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .btn-tool-chip {
    min-height: 44px;
    font-size: 12.5px;
  }

  .studio-card {
    padding: 15px 14px;
    border-radius: 18px;
  }

  .auth-inline-grid,
  .auth-pw-grid,
  .typo-split-row,
  .cta-dual-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .frame-toolbar-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
  }

  .category-pill {
    min-height: 44px;
    padding: 8px 14px;
  }

  /* Touch-friendly 3-column frame grid on standard phones (380-639px) */
  .frames-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
  }

  .font-pills-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .color-swatches-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .emoji-picker-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
  }

  .emoji-btn {
    min-height: 44px;
  }

  .pb-layouts-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pb-theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pb-frames-scroll {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 374px) {
  .studio-squircle-stage {
    width: 216px;
  }

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

  .font-pills-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ==========================================================================
   MODE 4: CUSTOM LOCKET GOLD JOIN DATE STUDIO
   ========================================================================== */
.locket-date-preview-stage {
  background: radial-gradient(circle at top, #fffaf0 0%, #f6ecd7 100%);
  border: 1.5px solid #e7d8bc;
  border-radius: 18px;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.locket-date-card {
  width: 100%;
  max-width: 340px;
  background: linear-gradient(135deg, #171717 0%, #241c10 100%);
  border: 1.5px solid rgba(245, 166, 35, 0.52);
  border-radius: 18px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.24);
  color: #fff;
  text-align: left;
}

.locket-gold-heart-box {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(255, 224, 102, 0.22), rgba(245, 166, 35, 0.14));
  border: 1px solid rgba(255, 214, 92, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.locket-gold-banner-body {
  flex: 1;
  min-width: 0;
}

.locket-gold-banner-title {
  font-size: 14.5px;
  font-weight: 800;
  color: #FFE066;
  line-height: 1.25;
}

.locket-joined-sub {
  font-size: 12px;
  font-weight: 600;
  color: #e5e7eb;
  margin-top: 2px;
  line-height: 1.35;
  word-break: break-word;
}

.locket-gold-banner-arrow {
  color: rgba(255, 224, 102, 0.78);
  flex-shrink: 0;
}

.date-caption-preview-wrap {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.date-caption-preview-label {
  font-size: 11px;
  font-weight: 700;
  color: #8f754c;
}

.date-caption-preview-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FFF4D6, #FCD34D);
  color: #451A03;
  font-size: 12.5px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
  border: 1px solid rgba(217, 119, 6, 0.35);
  text-align: center;
}

.date-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.date-preset-chip {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1.5px solid #e7d8bc;
  background: #fffdf8;
  color: #4b3920;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.date-preset-chip:hover {
  border-color: #f59e0b;
  background: #fff8e6;
}

.date-preset-chip.sel {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #b45309;
  color: #fff;
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.28);
}
