/* Priglantix Studio — professional canvas editor */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body.studio-editor {
  margin: 0;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  background: #e8eaed;
  color: #111827;
  -webkit-font-smoothing: antialiased;
}

.studio {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* Header */
.studio-header {
  position: relative;
  z-index: 30;
  flex-shrink: 0;
  height: 56px;
  overflow: visible;
}

.studio-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.studio-header__left,
.studio-header__center,
.studio-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.studio-header__center {
  flex: 1;
  justify-content: center;
  position: relative;
  min-width: 0;
}

.studio-header__right {
  flex-shrink: 0;
}

.studio-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #6b7280;
  transition: background 0.15s, color 0.15s;
}

.studio-templates-toggle {
  display: none;
  border: none;
  background: transparent;
  padding: 0;
}

.studio-templates-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.studio-templates-backdrop {
  display: none;
}

.mobile-text-sheet {
  display: none;
}

.studio-back:hover {
  background: #f3f4f6;
  color: #111827;
}

.studio-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.studio-brand__name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
}

.studio-brand__tpl {
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
}

.studio-zoom {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
}

#zoom-label {
  min-width: 44px;
  text-align: center;
}

.studio-btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  color: #374151;
  transition: background 0.15s;
}

.studio-btn-icon:hover,
.studio-btn-icon.active {
  background: #fff;
  color: #111827;
}

.studio-btn-ghost {
  padding: 6px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
  font-family: inherit;
}

.studio-btn-ghost:hover {
  background: #fff;
}

.studio-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}

.studio-btn-primary:hover {
  background: #1f2937;
}

.studio-export {
  position: relative;
  z-index: 30;
}

.studio-export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  padding: 6px;
  display: none;
  z-index: 50;
}

.studio-export-menu.open {
  display: block;
}

.studio-export-menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  text-align: left;
  font-family: inherit;
  font-size: 0.875rem;
  border-radius: 6px;
  cursor: pointer;
  color: #374151;
}

.studio-export-menu button:hover {
  background: #f3f4f6;
  color: #111827;
}

/* Body layout */
.studio-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1;
  min-height: 0;
}

.studio-panel {
  background: #fff;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  padding: 16px;
}

.studio-panel--props {
  border-right: none;
  border-left: 1px solid #e5e7eb;
}

.studio-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.studio-panel h2 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin: 0;
}

.studio-panel__filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.studio-filter-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
}

.studio-panel__filters .studio-select {
  width: 100%;
}

.studio-thumb-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.studio-thumb {
  position: relative;
  aspect-ratio: 3/4;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #f9fafb;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.studio-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.studio-thumb.active {
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.15);
}

.studio-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #ece7df;
}

.studio-select {
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  background: #fff;
  color: #374151;
}

/* Canvas zone */
.studio-canvas-zone {
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #e8eaed;
}

.studio-tools-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

/* Unified toolbar — Morphicon-style icons */
.studio-toolbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 12px 16px;
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
  border-bottom: 1px solid #e8eaed;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.studio-toolbar__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.studio-toolbar__add {
  flex-shrink: 0;
}

.studio-toolbar__format {
  flex: 1;
  min-width: 280px;
}

.studio-toolbar__format[hidden] {
  display: none !important;
}

.studio-toolbar__title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9ca3af;
  padding-left: 2px;
}

.studio-toolbar__grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.studio-toolbar__divider {
  width: 1px;
  margin: 4px 16px;
  background: linear-gradient(180deg, transparent, #e5e7eb 15%, #e5e7eb 85%, transparent);
  flex-shrink: 0;
}

.studio-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 72px;
  padding: 10px 12px;
  border: 1px solid #eef0f3;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  color: #374151;
  transition:
    transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1),
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.studio-tool-btn:hover {
  border-color: #d1d5db;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  transform: translateY(-2px);
}

.studio-tool-btn:active {
  transform: translateY(0) scale(0.97);
}

.studio-tool-btn--accent {
  border-color: #fce7f3;
  background: linear-gradient(145deg, #fff5f8, #fff);
}

.studio-tool-btn--accent:hover {
  border-color: #f9a8d4;
  box-shadow: 0 6px 20px rgba(219, 39, 119, 0.12);
}

.studio-tool-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f3f4f6;
  color: #1f2937;
  transition: background 0.2s, color 0.2s;
}

.studio-tool-btn:hover .studio-tool-icon {
  background: #111827;
  color: #fff;
}

.studio-tool-btn--accent .studio-tool-icon {
  background: #fce7f3;
  color: #be185d;
}

.studio-tool-btn--accent:hover .studio-tool-icon {
  background: #db2777;
  color: #fff;
}

.studio-tool-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.studio-tool-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.studio-format-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.studio-select--font {
  min-width: 160px;
  max-width: 220px;
  flex: 1;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.studio-size-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: #f3f4f6;
  border-radius: 10px;
}

.studio-chip-group {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: #f3f4f6;
  border-radius: 10px;
}

.studio-chip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.studio-chip-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.studio-chip-btn:hover {
  background: #fff;
  color: #111827;
}

.studio-chip-btn.active {
  background: #111827;
  color: #fff;
}

.studio-chip-btn--danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.studio-color-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #f3f4f6;
  cursor: pointer;
  overflow: hidden;
}

.studio-color-wrap input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

.studio-color-ring {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d1d5db;
  background: var(--studio-pick-color, #1f2937);
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.studio-color-wrap:hover .studio-color-ring {
  transform: scale(1.08);
}

.studio-tools-sep {
  width: 1px;
  height: 24px;
  background: #e5e7eb;
  margin: 0 4px;
}

.studio-tools-hint {
  font-size: 0.8rem;
  color: #9ca3af;
}

.studio-fatal {
  margin: 40px auto;
  max-width: 480px;
  padding: 32px;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 12px;
  text-align: center;
  color: #991b1b;
}

.studio-fatal strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.studio-object-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.studio-object-bar[hidden] {
  display: none !important;
}

.studio-input-num {
  width: 48px;
  padding: 6px 4px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  color: #111827;
}

.studio-input-num:focus {
  outline: none;
  background: #fff;
}

.studio-align-group {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: #f3f4f6;
  border-radius: 8px;
}

.studio-canvas-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-image:
    linear-gradient(#d1d5db 1px, transparent 1px),
    linear-gradient(90deg, #d1d5db 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: center center;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.studio-canvas-stage {
  flex-shrink: 0;
  margin: auto;
}

/* GI-style zoom — bottom-right-controls */
.bottom-right-controls {
  position: absolute;
  right: 20px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 12;
  pointer-events: none;
}

.zoom-controls-wrapper {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 220px;
  padding: 4px;
  background: #fff;
  border: 1px solid #e9e9ea;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #202830;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.zoom-btn:hover {
  background: #f3f4f6;
}

.zoom-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.zoom-slider {
  flex: 1;
  min-width: 0;
  height: 4px;
  margin: 0 4px;
  accent-color: #111827;
  cursor: pointer;
}

.zoom-percent {
  pointer-events: auto;
  min-width: 44px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  background: #fff;
  border: 1px solid #e9e9ea;
  border-radius: 999px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.studio-canvas-frame {
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.06),
    0 20px 50px rgba(0, 0, 0, 0.15);
  border-radius: 2px;
  background: #fff;
  line-height: 0;
}

#invite-canvas {
  display: block;
}

/* Properties panel */
.studio-hint {
  font-size: 0.8rem;
  color: #9ca3af;
  line-height: 1.45;
  margin: 0 0 16px;
}

.studio-fields label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 4px;
}

.studio-fields input,
.studio-fields textarea {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.studio-fields input:focus,
.studio-fields textarea:focus {
  outline: none;
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

/* Fabric.js selection styling override */
.canvas-container {
  margin: 0 !important;
}

@media (max-width: 1024px) {
  .studio-body {
    grid-template-columns: 200px 1fr;
  }
}

@media (max-width: 768px) {
  .studio-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .studio-header__bar {
    padding: 0 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    gap: 8px;
  }
  .studio-brand__name {
    display: none;
  }
  .studio-brand__tpl {
    font-size: 0.8rem;
    max-width: 28vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .studio-templates-toggle {
    display: flex;
  }
  .studio-export-label {
    display: none;
  }
  .studio-btn-primary {
    padding: 8px 10px;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
  }
  .studio-panel--templates {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 46;
    width: min(300px, 86vw);
    max-height: none;
    height: 100%;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    border-bottom: none;
    overflow-y: auto;
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
  }
  .studio.templates-open .studio-panel--templates {
    display: block;
  }
  .studio-templates-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(15, 23, 42, 0.4);
  }
  .studio.templates-open .studio-templates-backdrop {
    display: block;
  }
  .studio-thumb-list {
    grid-template-columns: repeat(2, 1fr);
  }
  .studio-header__center .gi-dock-label {
    display: block;
    font-size: 0.65rem;
  }
  .studio-header__center {
    position: static;
    flex: 0;
  }
  .gi-side-dock {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 38;
    justify-content: space-around;
    padding: 6px 8px;
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
  }
  body.studio-keyboard-open .gi-side-dock {
    display: none;
  }
  .gi-side-dock .gi-dock-btn {
    padding: 4px 8px;
    min-height: 52px;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    justify-content: center;
  }
  .gi-dock-icon {
    width: 40px;
    height: 40px;
  }
  .gi-sticker-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    bottom: calc(72px + env(safe-area-inset-bottom));
    transform: none;
    width: auto;
    max-height: min(58vh, 480px);
    z-index: 48;
  }
  .gi-sticker-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .bottom-right-controls {
    right: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    gap: 6px;
  }
  body.studio-editing-text .bottom-right-controls {
    bottom: calc(210px + env(safe-area-inset-bottom) + var(--keyboard-inset, 0px));
  }
  .zoom-controls-wrapper {
    width: 132px;
  }
  .zoom-percent {
    min-width: 38px;
    padding: 4px 8px;
    font-size: 0.72rem;
  }
  .studio-canvas-scroll {
    padding: 12px 12px 88px;
    touch-action: pan-x pan-y;
  }
  .canvas-container,
  .canvas-container .upper-canvas,
  .upper-canvas {
    touch-action: none !important;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  .studio-toolbar {
    flex-direction: column;
    gap: 12px;
  }
  .studio-toolbar__divider {
    width: 100%;
    height: 1px;
    margin: 0;
  }
  .studio-toolbar__format {
    min-width: 0;
  }
}

/* GI text toolbar — overlay on header */
.gi-text-toolbar-float {
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  z-index: 40;
  width: max-content;
  max-width: min(920px, calc(100vw - 32px));
  margin-inline: auto;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.gi-text-toolbar-float.is-open {
  opacity: 1;
  pointer-events: auto;
}

.gi-text-toolbar-float[hidden] {
  display: block !important;
  visibility: hidden;
}

.gi-text-toolbar-float.is-open[hidden] {
  visibility: visible;
}

.gi-text-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding: 6px 10px;
  min-height: 44px;
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
}

.gi-text-toolbar[hidden] {
  display: none !important;
}

.font-picker { position: relative; }

.font-picker__btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 140px;
  max-width: 200px;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  color: #374151;
}

.font-picker__btn:hover { border-color: #d1d5db; }

.font-picker__value {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.font-picker__chev svg { width: 16px; height: 16px; stroke: #9ca3af; }

.font-picker__menu {
  position: fixed;
  z-index: 5000;
  min-width: 240px;
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
}

.font-picker__item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1.25;
  text-align: left;
  color: #111827;
}

.font-picker__menu[hidden] { display: none !important; }

.font-picker__group { padding: 4px 0; }

.font-picker__group-title {
  display: none;
}

.font-picker__item:hover,
.font-picker__item.active { background: #f3f4f6; }

.gi-size-control {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 2px;
  background: #fff;
}

.gi-size-input {
  width: 42px;
  border: none;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  background: transparent;
  -moz-appearance: textfield;
}

.gi-size-input::-webkit-outer-spin-button,
.gi-size-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.gi-color-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}

.gi-color-btn input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.gi-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1f2937;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d1d5db;
}

.gi-chip-group {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.gi-chip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  color: #4b5563;
  transition: background 0.15s, color 0.15s;
}

.gi-chip-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.gi-chip-btn:hover { background: #f3f4f6; }
.gi-chip-btn.active { background: #111827; color: #fff; }
.gi-chip-btn--danger:hover { background: #fef2f2; color: #dc2626; }

.gi-slider-field {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 108px;
  padding: 4px 6px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.gi-slider-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  overflow: hidden;
}

.gi-slider-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.gi-slider-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  width: 52px;
  min-width: 0;
  max-width: 64px;
  height: 4px;
  margin: 0;
  background: #e5e7eb;
  border-radius: 999px;
  accent-color: #111827;
  cursor: pointer;
}

.gi-slider-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #111827;
  border: 0;
  cursor: pointer;
}

.gi-slider-field input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #111827;
  border: 0;
  cursor: pointer;
}

.gi-side-dock {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #fff;
  border-radius: 999px;
  border: 1px solid #eef0f3;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

.gi-dock-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: #374151;
  transition: background 0.15s;
}

.gi-dock-btn:hover {
  background: #f3f4f6;
}

.gi-dock-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid #eef0f3;
  flex-shrink: 0;
}

.gi-dock-icon svg {
  width: 20px;
  height: 20px;
  stroke: #374151;
  stroke-width: 2;
  fill: none;
}

.gi-dock-label {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  color: #4b5563;
  white-space: nowrap;
}

.gi-sticker-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: 360px;
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
  border: 1px solid #eef0f3;
}

.gi-sticker-panel[hidden] { display: none !important; }

.gi-sticker-cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px 0;
  flex-shrink: 0;
}

.gi-sticker-cat {
  flex-shrink: 0;
  padding: 6px 10px;
  border: none;
  border-radius: 999px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
}

.gi-sticker-cat.active {
  background: #111827;
  color: #fff;
}

.gi-sticker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 12px;
  overflow-y: auto;
}

.gi-sticker-item {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  height: auto;
  border: 1px solid #f3f4f6;
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  padding: 4px;
}

.gi-sticker-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.gi-sticker-empty {
  grid-column: 1 / -1;
  margin: 8px 0;
  color: #9ca3af;
  font-size: 0.8rem;
  text-align: center;
}

.gi-sticker-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #f3f4f6;
}

.gi-sticker-panel__head h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #111827;
}

.gi-sticker-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
}

.gi-sticker-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.gi-sticker-item:hover {
  background: #f3f4f6;
  transform: scale(1.06);
}

@media (max-width: 768px) {
  .gi-text-toolbar-float {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    bottom: calc(196px + env(safe-area-inset-bottom) + var(--keyboard-inset, 0px));
    width: auto;
    max-width: none;
    margin-inline: 0;
    z-index: 39;
  }
  body.studio-keyboard-open .gi-text-toolbar-float {
    bottom: calc(118px + var(--keyboard-inset, 0px));
  }
  .gi-text-toolbar { padding: 6px 8px; gap: 4px; }
  .font-picker__btn { min-width: 100px; }
  .gi-chip-btn,
  .gi-size-control,
  .gi-color-btn {
    min-height: 40px;
  }
  .gi-chip-btn {
    width: 40px;
    height: 40px;
  }
  .gi-slider-field {
    max-width: 96px;
    padding: 4px;
  }
  .gi-slider-field input[type="range"] {
    width: 44px;
    max-width: 48px;
  }
  .gi-sticker-panel { width: auto; }
  .mobile-text-sheet:not([hidden]) {
    display: block;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(70px + env(safe-area-inset-bottom) + var(--keyboard-inset, 0px));
    z-index: 40;
    padding: 10px 12px 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.16);
  }
  body.studio-keyboard-open .mobile-text-sheet:not([hidden]) {
    bottom: calc(8px + var(--keyboard-inset, 0px));
  }
  .mobile-text-sheet label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9ca3af;
  }
  .mobile-text-sheet textarea {
    display: block;
    width: 100%;
    min-height: 72px;
    max-height: 28vh;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    resize: vertical;
    color: #111827;
    background: #f9fafb;
  }
  .mobile-text-sheet textarea:focus {
    outline: none;
    border-color: #111827;
    background: #fff;
  }
}
