*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.app-header {
  padding: 1.5rem 2rem;
  background: white;
  border-bottom: 1px solid #e5e5e5;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a1a;
}

.app-main {
  flex: 1;
  display: flex;
  gap: 0;
  min-height: calc(100vh - 80px);
  overflow: hidden;
  position: relative;
  align-items: stretch;
  height: calc(100vh - 80px);
  max-height: calc(100vh - 80px);
}

/* Sidebar */
.sidebar {
  width: 360px;
  background: white;
  border-right: 1px solid #e5e5e5;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  height: 100%;
  min-height: calc(100vh - 80px);
  max-height: calc(100vh - 80px);
  align-self: stretch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.sidebar-content {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem 1.5rem;
  min-height: 0; /* Allows flex child to shrink below content size */
  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #d1d5db #f5f5f5;
}

/* Custom scrollbar for sidebar - Chrome/Safari/Edge */
.sidebar-content::-webkit-scrollbar {
  width: 12px;
  -webkit-appearance: none;
}

.sidebar-content::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 6px;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 6px;
  border: 2px solid #f5f5f5;
  -webkit-box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.1);
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background-color: #9ca3af;
}

.sidebar-content::-webkit-scrollbar-thumb:active {
  background-color: #6b7280;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
  background: white;
  border-top: 1px solid #e5e5e5;
  position: relative;
  z-index: 11;
  isolation: isolate;
}

.sidebar-footer .secondary-btn {
  margin-top: 0;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 1.25rem 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.separator {
  height: 1px;
  background: #e5e5e5;
  margin: 2rem 0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

/* Reserve space for reset buttons to prevent layout shift */
#reset-top-pos[hidden],
#reset-bottom-pos[hidden] {
  display: block;
  visibility: hidden;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: none;
  pointer-events: none;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: relative;
}

.control-group label {
  font-weight: 600;
  font-size: 0.875rem;
  color: #1a1a1a;
  margin: 0;
}

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-left: auto;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  outline: none;
}

.help-btn:hover svg,
.help-btn:focus-visible svg {
  opacity: 0.7;
}

.help-btn:active svg {
  opacity: 0.5;
}

.help-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.help-content {
  position: absolute;
  font-size: 0.75rem;
  color: #4b5563;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  padding: 0.75rem;
  line-height: 1.5;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 100;
  max-width: 280px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  top: 0;
  right: 0;
  margin-top: 1.5rem;
  white-space: normal;
}

.help-content:not([hidden]) {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Position help content relative to the control group */
.control-group {
  position: relative;
}

/* Add arrow pointing to the button */
.help-content::before {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 12px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #e5e7eb;
}

.help-content::after {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 12px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid white;
  margin-bottom: -1px;
}

.control-group small.hint-text {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: -0.25rem;
}

input[type="file"],
input[type="text"],
textarea,
input[type="range"] {
  font: inherit;
}

input[type="text"],
textarea {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  background: white;
  color: #1a1a1a;
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
}

textarea {
  min-height: 3rem;
  line-height: 1.5;
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: #9ca3af;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: 2px solid #9333ea;
  outline-offset: 1px;
  border-color: transparent;
}

.select-input {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  background: white;
  color: #1a1a1a;
  font-size: 0.875rem;
  font-family: inherit;
  width: 100%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2 4L6 8L10 4' stroke='%231a1a1a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.select-input:hover {
  border-color: #9333ea;
}

.select-input:focus {
  outline: 2px solid #9333ea;
  outline-offset: 1px;
  border-color: transparent;
}

.text-input-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  position: relative;
}

.text-input-row input[type="text"],
.text-input-row textarea {
  flex: 1;
}

.icon-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  font-size: 1rem;
  line-height: 1;
  color: #6b7280;
}

.icon-btn:hover {
  color: #1a1a1a;
  background: #f3f4f6;
}

.secondary-btn {
  align-self: flex-start;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  background: white;
  color: #1a1a1a;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.secondary-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn-block {
  align-self: stretch;
  width: 100%;
  text-align: center;
}

.add-text-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  background: white;
  color: #1a1a1a;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.add-text-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.icon-plus {
  font-size: 1rem;
  font-weight: 600;
}

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 0.375rem;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.upload-btn-primary {
  background: #9333ea;
  color: white;
}

.upload-btn-primary:hover {
  background: #7e22ce;
}

.upload-btn-secondary {
  background: white;
  color: #1a1a1a;
  border: 1px solid #d1d5db;
}

.upload-btn-secondary:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.upload-icon {
  font-size: 1rem;
}

.extra-text-list {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.extra-text-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}

.extra-text-row .text-input-row {
  width: 100%;
}

.extra-text-row input[type="text"],
.extra-text-row textarea {
  flex: 1;
  min-width: 0;
}

.extra-text-row .button-group {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.25rem;
}

.extra-text-row .button-group .secondary-btn {
  flex: 1;
}

.extra-reset-btn,
.extra-remove-btn {
  flex: 1;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

.overlay-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.overlay-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #1a1a1a;
  padding: 0.5rem;
  background: #f9fafb;
  border-radius: 0.375rem;
  border: 1px solid #e5e5e5;
}

.overlay-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overlay-remove-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

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

input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #e5e5e5;
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #9333ea;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #9333ea;
  cursor: pointer;
  border: none;
}

#canvas-zoom-value {
  min-width: 3.5rem;
  text-align: right;
  font-size: 0.875rem;
  color: #1a1a1a;
}

.image-size-display {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #6b7280;
}

.dropdown-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 0.5rem;
  background: white;
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 400px;
  padding: 0.25rem 0;
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.dropdown-menu:not([hidden]) {
  display: block;
}

.dropdown-menu:not([hidden]) {
  display: block;
}

.dropdown-menu[hidden] {
  display: none !important;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
}

.dropdown-section {
  padding: 0.25rem 0;
}

.dropdown-section:not(:first-child) {
  border-top: 1px solid #e5e5e5;
  margin-top: 0.25rem;
  padding-top: 0.5rem;
}

.dropdown-section-title {
  padding: 0.5rem 1rem 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dropdown-item {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: white;
  color: #1a1a1a;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.15s ease;
  border-radius: 0;
}

.dropdown-item:hover {
  background: #f5f5f5;
}

.dropdown-item:active {
  background: #e5e7eb;
}

.dropdown-section:first-child .dropdown-item:first-child {
  border-radius: 0.5rem 0.5rem 0 0;
}

.dropdown-section:last-child .dropdown-item:last-child {
  border-radius: 0 0 0.5rem 0.5rem;
}

.dropdown-item-label {
  font-weight: 500;
}

.dropdown-item-value {
  color: #6b7280;
  font-size: 0.8125rem;
}

.split-button-group {
  position: relative;
  display: flex;
  width: 100%;
  margin-top: 0;
  margin-bottom: 0.75rem;
  border-radius: 0.5rem;
  overflow: visible;
  background: #9333ea;
}

.split-button-main {
  flex: 1;
  border-radius: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
}

.split-button-main svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.split-button-dropdown {
  width: auto;
  min-width: 3rem;
  padding: 0.75rem 0.75rem;
  border-radius: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  pointer-events: auto;
}

.split-button-dropdown:disabled {
  opacity: 0.5;
  cursor: pointer;
  pointer-events: auto;
}

.split-button-dropdown svg {
  margin: 0;
  width: 14px;
  height: 14px;
}

.primary-btn {
  padding: 0.625rem 1rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  background: #9333ea;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}

.primary-btn:not(.split-button-main):not(.split-button-dropdown) {
  width: 100%;
  margin-top: 0.5rem;
  align-items: center;
  justify-content: center;
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  background: #d1d5db;
}

.primary-btn:not(:disabled):hover {
  background: #7e22ce;
}

.split-button-main:not(:disabled):hover {
  background: #7e22ce;
}

.split-button-dropdown:not(:disabled):hover {
  background: #7e22ce;
}

/* Main Content Area */
.main-content {
  flex: 1;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: auto;
  min-width: 0;
  overflow-y: auto;
  height: 100%;
  flex-shrink: 0;
}

.canvas-wrapper {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.canvas-shell {
  position: relative;
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  transform-origin: center top;
  z-index: 1;
}

#meme-canvas {
  max-width: 100%;
  max-height: calc(100vh - 200px);
  width: 800px;
  height: 400px;
  aspect-ratio: 2 / 1;
  background: white;
  border-radius: 0.5rem;
  border: 1px solid #e5e5e5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 1;
}

.canvas-placeholder {
  pointer-events: auto;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: pointer;
}

.upload-box {
  width: 100%;
  max-width: 400px;
  background: white;
  border: 1px dashed #d1d5db;
  border-radius: 0.5rem;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  transition: border-color 0.15s ease;
}

.upload-box:hover {
  border-color: #9333ea;
}

.upload-icon-box {
  width: 48px;
  height: 48px;
  background: #f3f4f6;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.upload-icon-svg {
  width: 24px;
  height: 24px;
  color: #4b5563;
}

.upload-text {
  font-size: 0.875rem;
  color: #4b5563;
  line-height: 1.5;
}

.upload-link {
  color: #9333ea;
  font-weight: 500;
  cursor: pointer;
}

.upload-hint {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

#meme-canvas.grabbable {
  cursor: grab;
}

#meme-canvas.dragging {
  cursor: grabbing;
}

#meme-canvas.delete-hover {
  cursor: pointer;
}

#meme-canvas.resize-hover {
  cursor: nwse-resize;
}

#meme-canvas.resize-nwse {
  cursor: nwse-resize;
}

#meme-canvas.resize-nesw {
  cursor: nesw-resize;
}

#meme-canvas.resize-ns {
  cursor: ns-resize;
}

#meme-canvas.resize-ew {
  cursor: ew-resize;
}

#meme-canvas.rotate-hover {
  cursor: grab !important;
}

#meme-canvas.rotate-hover:active {
  cursor: grabbing !important;
}

#meme-canvas.text-hover {
  cursor: pointer;
}

#meme-canvas.drop-target {
  border-style: dashed;
  border-color: #9333ea;
  box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.2);
}

.canvas-hint {
  margin: 0;
  font-size: 0.875rem;
  color: #6b7280;
  text-align: center;
}

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

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
}

.modal-dialog {
  position: relative;
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
  background: white;
  border-radius: 0.5rem;
  border: 1px solid #e5e5e5;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
}

.modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 0.5rem;
  max-height: calc(80vh - 120px);
}

.template-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding-bottom: 1rem;
}

@media (max-width: 700px) {
  .template-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.template-btn {
  padding: 0;
  border-radius: 0.5rem;
  border: 1px solid #e5e5e5;
  background: white;
  color: #1a1a1a;
  font-size: 0.875rem;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  transition: all 0.15s ease;
}

.template-btn img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.template-btn span {
  display: block;
  padding: 0.5rem;
  font-weight: 500;
}

.template-btn:hover {
  border-color: #9333ea;
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.template-btn:active {
  transform: translateY(0);
}

/* Drag Overlay */
.drag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(59, 130, 246, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drag-overlay-content {
  text-align: center;
  color: white;
}

.drag-overlay-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.drag-overlay-text {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.drag-overlay-hint {
  font-size: 1rem;
  opacity: 0.9;
}

/* Text Options Toggle */
.text-options-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #d1d5db;
  background: white;
  color: #1a1a1a;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 0;
  position: relative;
}

.text-options-toggle:hover {
  background: #f9fafb;
  border-color: #9333ea;
}

.text-options-toggle.active {
  background: #9333ea;
  border-color: #9333ea;
  color: white;
}

.text-options-toggle.active:hover {
  background: #7e22ce;
  border-color: #7e22ce;
}

.text-options-toggle .dropdown-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  color: #6b7280;
  pointer-events: none;
  transition: transform 0.15s ease;
}

.text-options-toggle:hover .dropdown-indicator,
.text-options-toggle.active .dropdown-indicator {
  color: #9333ea;
}

.text-options-toggle.active .dropdown-indicator {
  color: white;
  transform: rotate(180deg);
}

.text-options-toggle svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Text Options Submenu */
.text-options-modal {
  position: fixed;
  z-index: 1000;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 280px;
  max-width: 320px;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  isolation: isolate;
  display: flex;
  flex-direction: column;
}

.text-options-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  z-index: 10;
  border-radius: 0.25rem;
  transition: all 0.15s ease;
}

.text-options-modal-close:hover {
  background: #f5f5f5;
  color: #1a1a1a;
}

.text-options-modal-close:active {
  background: #e5e5e5;
}

.text-options-modal-content {
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

.text-options-menu {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Custom scrollbar for text options modal */
.text-options-modal-content::-webkit-scrollbar {
  width: 8px;
}

.text-options-modal-content::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 4px;
}

.text-options-modal-content::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 4px;
}

.text-options-modal-content::-webkit-scrollbar-thumb:hover {
  background: #b0b0b0;
}

.text-options-modal-content {
  scrollbar-width: thin;
  scrollbar-color: #d0d0d0 #f5f5f5;
}

.text-option-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: visible;
}

.sync-text-style-group {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 0.5rem;
}

.sync-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: #1a1a1a;
  text-transform: none;
  letter-spacing: normal;
}

.sync-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #9333ea;
}

.text-option-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Segmented Control */
.segmented-control {
  display: flex;
  background: #f5f5f5;
  border-radius: 0.375rem;
  padding: 2px;
  gap: 2px;
}

.segmented-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  position: relative;
  z-index: 10;
}

.segmented-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.segmented-btn.active {
  background: white;
  color: #1a1a1a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.color-mode-switch .segmented-btn.active {
  background: #8B5CF6;
  color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.color-mode-switch .segmented-btn:not(.active) {
  background: #f5f5f5;
  color: #6b7280;
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: 1rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #1a1a1a;
}

.radio-option input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: #9333ea;
}

.radio-option span {
  user-select: none;
}

/* Fill Control */
.fill-control-full {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.fill-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}



.opacity-control {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: #f5f5f5;
  border-radius: 0.375rem;
  border: 1px solid #e5e5e5;
}

.opacity-input {
  border: none;
  background: transparent;
  font-size: 0.875rem;
  color: #1a1a1a;
  width: 40px;
  padding: 0;
  text-align: right;
}

.opacity-input:focus {
  outline: none;
}

.opacity-input::-webkit-inner-spin-button,
.opacity-input::-webkit-outer-spin-button {
  opacity: 1;
}

.opacity-control span {
  color: #6b7280;
  font-size: 0.875rem;
}

/* Color Picker */
.color-picker-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.color-mode-tabs {
  display: flex;
  gap: 0.25rem;
  background: #f5f5f5;
  padding: 0.25rem;
  border-radius: 0.375rem;
}

.color-tab {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-tab.active {
  background: white;
  color: #9333ea;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.color-picker-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.color-picker-canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 0.375rem;
  overflow: hidden;
  cursor: crosshair;
  border: 1px solid #e5e5e5;
}

.color-picker-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  pointer-events: auto;
}

.color-picker-selector {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  border-radius: 50%;
  background: #000;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.color-picker-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.eyedropper-tool-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #e5e5e5;
  background: white;
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.eyedropper-tool-btn:hover {
  background: #f5f5f5;
  border-color: #9333ea;
  color: #9333ea;
}

.eyedropper-tool-btn.active {
  background: #8B5CF6;
  color: white;
  border-color: #8B5CF6;
}

.color-slider-wrapper {
  position: relative;
  flex: 1;
  height: 20px;
  border-radius: 0.25rem;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid #e5e5e5;
}

.color-slider {
  width: 100%;
  height: 100%;
  display: block;
}

.color-slider-handle {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.color-picker-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-value-input {
  width: 80px;
  padding: 0.375rem 0.5rem;
  border: 1px solid #e5e5e5;
  background: white;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: #1a1a1a;
  font-family: monospace;
}

.opacity-value-input {
  width: 50px;
  padding: 0.375rem 0.5rem;
  border: 1px solid #e5e5e5;
  background: white;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: #1a1a1a;
  text-align: right;
}

.opacity-percent {
  font-size: 0.875rem;
  color: #6b7280;
}

.color-picker-swatches {
  border-top: 1px solid #e5e5e5;
  padding-top: 0.75rem;
}

.color-swatches-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.25rem;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  min-height: 20px;
  border-radius: 0.375rem;
  border: 1px solid #e5e5e5;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.1);
  border-color: #9333ea;
  z-index: 1;
}

.icon-btn-small {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.icon-btn-small:hover {
  background: #f5f5f5;
  color: #1a1a1a;
}

.icon-btn-small svg {
  width: 16px;
  height: 16px;
}

/* Responsive */
@media (max-width: 768px) {
  .app-main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e5e5e5;
  }

  .main-content {
    padding: 1rem;
  }
}
