/* =========================================================
   Studio V2 Layout & Styles
   Matching exact proportions: Col 1: 52.5%, Col 2: 21.5%, Col 3: 26.0%
   Clean Pure White Theme with Category Sidebar, 4-Col/3-Col Grid,
   Middle Custom Controls (Purple Box), and Right Preview & Actions
   ========================================================= */

/* Body & Global Reset for V2 */
body.v2-page {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  background: #f8fafc;
  color: #0f172a;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Clean White / Light Theme Scrollbars */
body.v2-page * {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}
body.v2-page *::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
body.v2-page *::-webkit-scrollbar-track {
  background: #f8fafc;
}
body.v2-page *::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
body.v2-page *::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 3-Column Studio Grid Layout */
body.v2-page .v2-studio-layout {
  display: grid;
  grid-template-columns: 46% 28% 26%;
  height: calc(100vh - 64px);
  min-height: calc(100vh - 64px);
  width: 100vw;
  overflow: hidden;
  background: #f8fafc;
  box-sizing: border-box;
}

/* =========================================================
   COLUMN 1: STORE-STYLE ASSET LIBRARY (52.5% Width)
   ========================================================= */
.v2-col-library {
  width: 100%;
  height: 100%;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  z-index: 10;
}

/* Library Header */
.v2-lib-header {
  padding: 10px 14px 8px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* Top 3 Tab Switcher */
.v2-lib-top-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.v2-lib-tab-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.v2-lib-tab-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.v2-lib-tab-btn.active {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #6d28d9;
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.2);
}

.v2-lib-tab-btn .badge {
  font-size: 9px;
  font-weight: 800;
  background: #8b5cf6;
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 10px;
}

.v2-lib-tab-btn.active .badge {
  background: #6d28d9;
}

/* Search Bar */
.v2-lib-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v2-lib-search-bar input {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.v2-lib-search-bar input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
  background: #ffffff;
}

.v2-lib-badge {
  font-size: 11px;
  font-weight: 700;
  color: #6d28d9;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* Library Body: Left Sidebar + Right Grid */
.v2-lib-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Left Subcategory Sidebar */
.v2-lib-cat-sidebar {
  width: 145px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  padding: 6px 4px;
}

.v2-cat-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  margin-bottom: 2px;
  transition: all 0.12s;
  box-sizing: border-box;
  text-align: left;
}

.v2-cat-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.v2-cat-item.active {
  background: #ede9fe;
  color: #6d28d9;
  font-weight: 800;
  border-left: 2.5px solid #8b5cf6;
}

.v2-cat-item .v2-cat-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-cat-item .v2-cat-count {
  font-size: 9px;
  font-weight: 700;
  color: #8b5cf6;
  background: #f5f3ff;
  padding: 1px 5px;
  border-radius: 4px;
}

/* Right Cards Grid Wrap */
.v2-lib-grid-wrap {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px;
}

.v2-asset-grid {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.v2-asset-grid.grid-ornaments {
  grid-template-columns: repeat(4, 1fr);
}

.v2-asset-grid.grid-frames {
  grid-template-columns: repeat(3, 1fr); /* 3 columns for frames */
}

/* Clean Cards */
.v2-asset-card {
  min-width: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  position: relative;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.v2-asset-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.v2-asset-card.is-selected {
  border-color: #8b5cf6 !important;
  background: #fbfaff !important;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25), 0 4px 10px rgba(139, 92, 246, 0.15) !important;
}

.v2-card-thumb {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.v2-card-thumb img {
  max-width: 86%;
  max-height: 86%;
  object-fit: contain;
  filter: none !important;
}

.v2-card-thumb.frame-thumb {
  height: 68px;
  background: #f8fafc;
}

.v2-card-thumb.frame-thumb img {
  max-width: 92%;
  max-height: 92%;
}

.v2-card-thumb.theme-thumb {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid transparent;
  overflow: hidden;
  background: #f8fafc;
}

.v2-mini-theme-preview {
  width: min(320px, 100%);
  min-width: 0;
  transform: scale(0.48);
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
  display: flex;
  justify-content: center;
}

.v2-mini-theme-preview .message {
  width: 100% !important;
  margin: 0 !important;
  animation: none !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06) !important;
  box-sizing: border-box !important;
}

.v2-mini-theme-preview .message-content {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px !important;
  line-height: 1.4 !important;
}

.v2-equipped-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #7c3aed;
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.v2-kind-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #6366f1;
  color: #ffffff;
  font-size: 8.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.25);
  pointer-events: none;
}

.v2-btn-card-add {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.4);
  transition: transform 0.1s, background 0.1s;
}

.v2-btn-card-add:hover {
  background: #059669;
  transform: scale(1.1);
}

/* Custom Upload Card & Delete Button */
.v2-custom-upload-card {
  border: 2px dashed #c4b5fd !important;
  background: #fdfcff !important;
  cursor: pointer;
}

.v2-custom-upload-card:hover {
  border-color: #8b5cf6 !important;
  background: #f5f3ff !important;
  transform: translateY(-2px);
}

.v2-card-thumb.upload-thumb {
  background: #faf5ff;
  border-color: #ede9fe;
  flex-direction: column;
}

.v2-card-del-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.4);
  transition: transform 0.1s, background 0.1s;
  z-index: 5;
}

.v2-card-del-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.v2-separated-badge {
  display: inline-block;
  margin-left: 3px;
  padding: 1px 4px;
  border: 1px solid #34d399;
  border-radius: 4px;
  background: #ecfdf5;
  color: #059669;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.2px;
  vertical-align: 1px;
  white-space: nowrap;
}
.v2-card-title {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #1e293b;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   COLUMN 2: CUSTOM CONTROLS (21.5% Width - PURPLE BOX)
   ========================================================= */
.v2-controls {
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  z-index: 15;
}

.v2-custom-header {
  padding: 10px 12px 8px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.v2-custom-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.v2-custom-title-row h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
}

.v2-custom-sub {
  font-size: 10px;
  font-weight: 700;
  color: #8b5cf6;
}

/* Custom 5 Tabs */
.v2-custom-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
}

.v2-tab-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  padding: 6px 2px;
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
  white-space: nowrap;
}

.v2-tab-btn:hover {
  color: #0f172a;
}

.v2-tab-btn.active {
  background: #ffffff;
  color: #6d28d9;
  font-weight: 800;
  border: 1px solid #8b5cf6;
  box-shadow: 0 1px 4px rgba(139, 92, 246, 0.2);
}

.v2-custom-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px;
}

/* Custom-tool visual order */
.v2-order-rainbow { order: 10; }
.v2-order-frame-tone { order: 15; }
.v2-order-bubble-bg { order: 20; }
.v2-order-bubble-pattern { order: 30; }
.v2-order-bubble-border { order: 40; }
.v2-order-bubble-padding { order: 50; }
.v2-order-bubble-fine { order: 60; }

.v2-order-ornament-slots { order: 10; }
.v2-order-ornament-color,
.v2-order-ornament-empty { order: 20; }
.v2-order-ornament-size { order: 30; }
.v2-order-ornament-animation { order: 40; }
.v2-order-ornament-flip { order: 50; }
.v2-order-ornament-cutout { order: 60; }
.v2-order-ornament-quick-cut { order: 70; }

.v2-order-text-color { order: 10; }
.v2-order-text-stroke { order: 20; }
.v2-order-text-shadow { order: 30; }
.v2-order-text-font { order: 40; }

.v2-order-nickname-position { order: 10; }
.v2-order-nickname-design { order: 20; }
.v2-order-nickname-display { order: 30; }
.v2-order-nickname-location { order: 40; }
.v2-order-nickname-frame-slot { order: 50; }

.v2-order-preset-mood { order: 10; }
.v2-order-preset-motion { order: 20; }

.v2-color-mode-pills .v2-pill {
  flex: 1 1 0;
}

/* Control Groups */
.v2-ctrl-group {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.v2-ctrl-title {
  font-size: 11px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f1f5f9;
}

.v2-ctrl-row {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.v2-ctrl-row:last-child {
  margin-bottom: 0;
}

.v2-ctrl-row label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}

.v2-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.v2-slider-header label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}

.v2-slider-header b {
  cursor: text;
  font-size: 10px;
  font-weight: 700;
  color: #6d28d9;
}

.v2-ctrl-row input[type="range"] {
  width: 100%;
  accent-color: #8b5cf6;
  cursor: pointer;
  margin: 2px 0;
}

.v2-color-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.v2-color-row input[type="color"] {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  padding: 0;
  cursor: pointer;
  background: none;
}

.v2-hex-input {
  width: 70px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  font-family: monospace;
  text-align: center;
  color: #0f172a;
}

.v2-btn-mini {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
}

.v2-btn-mini:hover {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #6d28d9;
}

.v2-pills-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 4px;
}

/* Clean White Form Controls (Select Dropdowns & Checkboxes) */
body.v2-page select,
body.v2-page .v2-select {
  width: 100%;
  background-color: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-size: 11.5px !important;
  font-family: inherit !important;
  font-weight: 600 !important;
  outline: none !important;
  cursor: pointer !important;
  transition: border-color 0.15s, box-shadow 0.15s !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
  appearance: auto !important;
}

body.v2-page select:focus,
body.v2-page .v2-select:focus {
  border-color: #8b5cf6 !important;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2) !important;
}

body.v2-page select option,
body.v2-page .v2-select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
  padding: 6px 8px !important;
}

body.v2-page input[type="checkbox"] {
  accent-color: #8b5cf6;
  cursor: pointer;
}

.v2-pill {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 4px 2px;
  font-size: 9px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

.v2-pill:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.v2-pill.active {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #6d28d9;
}

.v2-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

/* Decoration Slots in Inspector */
.v2-deco-slots-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 8px;
}

.v2-deco-slots-heading .v2-ctrl-title {
  margin-bottom: 0;
}

.v2-deco-gap-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.v2-deco-gap-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #8b5cf6;
  cursor: pointer;
}

.v2-deco-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.v2-deco-slot-wrapper {
  position: relative;
  width: 100%;
}

.v2-deco-slot-btn {
  width: 100%;
  min-height: 60px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 4px 4px 4px;
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.v2-deco-slot-wrapper.active .v2-deco-slot-btn,
.v2-deco-slot-btn.active {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #6d28d9;
  box-shadow: 0 1px 4px rgba(139, 92, 246, 0.2);
}

.v2-deco-slot-wrapper.empty .v2-deco-slot-btn,
.v2-deco-slot-btn.empty {
  opacity: 0.6;
}

.v2-slot-icon-area {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 22px;
}

.v2-slot-thumb {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.v2-slot-emoji {
  font-size: 15px;
  line-height: 20px;
  display: block;
}

.v2-slot-num {
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.1;
}

.v2-deco-slot-btn small {
  font-size: 8px;
  color: #64748b;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.1;
}

/* X button on the top right of each equipped decoration slot */
.v2-deco-slot-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #f87171;
  color: #ef4444;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.25);
  transition: all 0.15s ease;
}

.v2-deco-slot-remove:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #dc2626;
  transform: scale(1.15);
  box-shadow: 0 2px 5px rgba(239, 68, 68, 0.4);
}

.v2-deco-slot-remove:active {
  transform: scale(0.95);
}

/* Per-slot position lock, kept opposite the remove button for quick access. */
.v2-deco-slot-lock,
.v2-deco-slot-reset {
  position: absolute;
  bottom: 4px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid #d8deea;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: #667085;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.v2-deco-slot-lock {
  right: 4px;
}

.v2-deco-slot-reset {
  right: 28px;
}

.v2-deco-slot-lock:hover,
.v2-deco-slot-reset:hover {
  transform: translateY(-1px);
  border-color: #8b5cf6;
  color: #6d28d9;
}

.v2-deco-slot-lock.is-locked {
  border-color: #7c3aed;
  background: #7c3aed;
  color: #ffffff;
}

.v2-deco-slot-lock:active,
.v2-deco-slot-reset:active {
  transform: scale(0.92);
}

.v2-deco-slot-wrapper.locked .v2-deco-slot-btn {
  border-color: #a78bfa;
  background: #faf7ff;
}

.v2-ctrl-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.v2-btn-cutout {
  background: #ede9fe;
  border: 1px solid #8b5cf6;
  color: #6d28d9;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s;
}

.v2-btn-cutout:hover {
  background: #ddd6fe;
}

/* Mirror Clone Button */
.v2-btn-mirror {
  width: 100%;
  margin: 4px 0 2px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #6d28d9;
  cursor: pointer;
  transition: all 0.12s;
}

.v2-btn-mirror:hover {
  background: #ede9fe;
  border-color: #8b5cf6;
}

/* Part buttons for quick cuts */
.v2-part-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.v2-part-grid .part-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 5px 2px;
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  text-align: center;
  transition: all 0.1s;
}

.v2-part-grid .part-btn:hover {
  background: #ede9fe;
  color: #6d28d9;
}

.v2-part-grid .part-btn.selected {
  background: #7c3aed;
  border-color: #6d28d9;
  color: #ffffff;
}

/* Crop Details */
.v2-crop-details {
  margin-top: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 8px;
}

.v2-crop-details summary {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

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

.v2-btn-danger {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.v2-btn-danger:hover {
  background: #fee2e2;
}

.v2-empty-notice {
  padding: 24px 12px;
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.5;
}

/* Preset Cards */
.v2-presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.v2-preset-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.v2-preset-card:hover {
  background: #f1f5f9;
}

.v2-preset-card.selected {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #6d28d9;
}

/* =========================================================
   COLUMN 3: LIVE PREVIEW & ACTIONS (26.0% Width)
   ========================================================= */
body.v2-page .workspace.v2-workspace {
  width: 100%;
  height: 100%;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Header & Live Preview Toolbar (Compact 1-row) */
.v2-preview-header {
  padding: 4px 0 6px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.v2-preview-tools-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.v2-tool-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.v2-tool-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Toolbar Controls Single Row: 2초 롤링 + 가로 닉네임 + 채팅 위쪽 + 투명 + 테스트 */
.v2-preview-tools-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin-top: 0;
  flex-wrap: nowrap;
}

.v2-rolling-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: #475569;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}

.v2-rolling-toggle-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.v2-rolling-toggle-btn.active {
  background: #ecfdf5;
  border-color: #10b981;
  color: #047857;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.25);
}

.v2-rolling-toggle-btn .check-box {
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
}

/* Nickname Toggle Group */
.v2-nick-toggle-group {
  display: flex;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  white-space: nowrap;
}

.v2-nick-btn {
  background: transparent;
  border: none;
  color: #64748b;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.v2-nick-btn:hover {
  color: #0f172a;
}

.v2-nick-btn.active {
  background: #ffffff;
  color: #6d28d9;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Stage & Preview Area - Checkerboard transparency grid */
body.v2-page .stage {
  flex: 1;
  min-height: 360px;
  max-height: 495px;
  background-color: #f8fafc;
  background-image: 
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin: 6px 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

body.v2-page .stage.opaque-preview {
  background-image: none !important;
  background-color: #0f172a !important;
}

body.v2-page .stage {
  padding: 42px 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

body.v2-page .stage .preview {
  width: 100%;
  max-width: 100%;
  transform-origin: center center;
  zoom: 0.68; /* Scaled down comfortably for editing screen; OBS export remains 100% standard scale */
  display: flex;
  align-items: center;
  justify-content: center;
}

.v2-icon-tool {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d9e1ec;
  border-radius: 9px;
  background: #ffffff;
  color: #64748b;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.v2-icon-tool svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.v2-icon-tool .v2-icon-fill {
  fill: currentColor;
  stroke: none;
  opacity: 0.18;
}

.v2-icon-tool:hover {
  transform: translateY(-1px);
  color: #6d4aff;
  border-color: #b9a9ff;
  background: #f7f5ff;
  box-shadow: 0 4px 10px rgba(109, 74, 255, 0.16);
}

.v2-icon-tool:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(109, 74, 255, 0.12);
}

.v2-icon-tool.is-active {
  color: #6d4aff;
  border-color: #c4b5fd;
  background: #f2efff;
}

.v2-icon-tool.is-reset:hover {
  color: #e05270;
  border-color: #f2a7b7;
  background: #fff4f6;
}

.v2-preview-zoom {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  margin-left: auto;
}

.v2-preview-zoom select {
  width: auto !important;
  min-width: 64px;
  padding: 4px 6px !important;
  font-size: 11px !important;
}

.v2-rainbow-list { display:flex; flex-direction:column; gap:6px; margin-top:8px; }
.v2-rainbow-row { display:flex; align-items:center; gap:6px; min-width:0; }
.v2-rainbow-row > b { width:16px; color:#64748b; font-size:11px; text-align:center; }
.v2-rainbow-row input[type="color"] { width:28px; height:24px; padding:0; border:0; background:transparent; cursor:pointer; }
.v2-rainbow-row code { flex:1; min-width:0; color:#475569; font:10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.v2-rainbow-row .v2-btn-mini { min-width:24px; padding:3px 5px; }

body.admin-page :is(.v2-frame-card, .v2-theme-card)[draggable="true"] {
  cursor: grab;
}

body.admin-page :is(.v2-frame-card, .v2-theme-card).frame-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

body.admin-page :is(.v2-frame-card, .v2-theme-card).frame-drag-over {
  border-color: #7c3aed !important;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.22) !important;
}

/* Remove card shadow & safe area label that created artificial boundary confusion */
body.v2-page .chat-wrap {
  box-shadow: none !important;
  /* The regular editor reserves a tall canvas.  In V2 that placed actual chats
     at the canvas top, so let the frame group use its content height instead. */
  min-height: 0 !important;
  padding: 8px 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

body.v2-page .chat-wrap .chat-list {
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

body.v2-page .chat-wrap .message {
  width: min(calc(100% - 16px), var(--width)) !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

body.v2-page .safe-area {
  display: none !important;
}

.chat-wrap.has-text-stroke .message-content span,
.chat-wrap.has-text-stroke .message-content strong,
.chat-wrap.has-text-stroke .nickname-text {
  -webkit-text-stroke: var(--text-stroke-width, 1.5px) var(--text-stroke-color, #000000);
  paint-order: stroke fill;
}

/* Layer order controller */
.v2-layer-box {
  margin: 6px 0 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.v2-layer-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.v2-layer-title {
  font-size: 11px;
  font-weight: 800;
  color: #b91c1c;
}

.v2-layer-hint {
  font-size: 9px;
  color: #64748b;
}

.v2-layer-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.v2-layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 3px 6px;
  gap: 4px;
}

.v2-layer-row.is-empty {
  opacity: 0.45;
  background: #f8fafc;
  border-color: #e2e8f0;
}

.v2-layer-name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #1e293b;
  min-width: 58px;
  white-space: nowrap;
}

.v2-layer-name .v2-deco-mini {
  font-size: 9px;
  color: #64748b;
  max-width: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-num-boxes {
  display: flex;
  align-items: center;
  gap: 2px;
}

.v2-num-box {
  width: 17px;
  height: 17px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  color: #475569;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.1s;
}

.v2-num-box:hover:not(:disabled) {
  border-color: #dc2626;
  color: #dc2626;
  background: #fff1f2;
}

.v2-num-box.active {
  background: #dc2626 !important;
  border-color: #b91c1c !important;
  color: #ffffff !important;
  font-weight: 900;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.35);
}

.v2-num-box:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: #e2e8f0;
  background: #f1f5f9;
}

/* Style shop bar */
.v2-styleshop-bar {
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
}

.v2-btn-styleshop {
  background: #0284c7;
  border: 1px solid #0369a1;
  color: #ffffff;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s;
  white-space: nowrap;
}

.v2-btn-styleshop:hover {
  background: #0369a1;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

/* =========================================================
   CYAN & YELLOW BOX: SAVE & OBS CSS BAR
   ========================================================= */
.v2-complete-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.v2-btn-temp-save {
  background: #ecfeff;
  border: 1.5px solid #06b6d4; /* Cyan button */
  color: #0e7490;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.v2-btn-temp-save:hover {
  background: #cffafe;
  color: #155e75;
}

.v2-btn-complete-obs {
  flex: 1;
  background: linear-gradient(135deg, #facc15 0%, #eab308 100%); /* Yellow button */
  border: 1.5px solid #ca8a04;
  color: #422006;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.35);
  transition: all 0.12s;
}

.v2-btn-complete-obs:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.5);
  background: linear-gradient(135deg, #fde047 0%, #facc15 100%);
}
