* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000000;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #ffffff;
}

/* Fullscreen Media Editor Frame */
.editor-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  background: #0b141a;
  overflow: hidden;
}

/* Top Bar */
.top-bar,
.color-presets-row,
.bottom-bar,
.emoji-dropdown-menu,
.header-dropdown-menu {
  user-select: none;
  -webkit-user-select: none;
}

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
  z-index: 100;
  pointer-events: auto;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  outline: none;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.active {
  background: rgba(255, 255, 255, 0.28);
  color: #00a884;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

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

/* Center Canvas Viewport */
/* Center Canvas Area: Viewport centers the photo canvas */
.canvas-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  overflow: hidden;
  background: #0b141a;
}

/* Image Wrapper occupies the full canvas viewport */
.image-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

whiteboard-element {
  display: block;
  width: 100%;
  height: 100%;
}

/* WhatsApp Vertical Color Slider on Right */
.color-slider-panel {
  position: absolute;
  top: 80px;
  right: 20px;
  width: 32px;
  height: 240px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 16px;
  padding: 4px;
  background: rgba(18, 27, 34, 0.75);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.color-slider-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px);
}

.color-gradient-track {
  position: relative;
  width: 12px;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(to bottom, 
    #ff0000 0%, 
    #ff00ff 17%, 
    #0000ff 33%, 
    #00ffff 50%, 
    #00ff00 67%, 
    #ffff00 83%, 
    #ffffff 92%, 
    #000000 100%
  );
  cursor: pointer;
}

.color-thumb {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #00a884;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
  top: 67%;
  transition: background 0.1s ease;
}

/* Quick Preset Swatches Pill */
.color-presets-row {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(11, 20, 26, 0.85);
  padding: 6px 14px;
  border-radius: 24px;
  backdrop-filter: blur(8px);
  z-index: 60;
  transition: opacity 0.2s ease;
}

.color-presets-row.hidden {
  opacity: 0;
  pointer-events: none;
}

.preset-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.preset-dot.active {
  transform: scale(1.22);
  border-color: #ffffff;
  box-shadow: 0 0 8px rgba(255,255,255,0.7);
}

/* Stroke thickness mini bar */
.thickness-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 10px;
}

.thickness-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.thickness-btn.active {
  background: rgba(255,255,255,0.2);
}

.thickness-dot {
  background: #ffffff;
  border-radius: 50%;
}

/* Top-Left Header Menu (Upload, Download, Reset) */
.header-menu-wrapper {
  position: relative;
  display: inline-block;
}

.header-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 220px;
  background: #111b21;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(0.97);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-dropdown-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #e9edef;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.12s ease;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu-item svg {
  fill: #8696a0;
  flex-shrink: 0;
  transition: fill 0.12s ease;
}

.menu-item:hover svg {
  fill: #00a884;
}

.menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 6px;
}
.emoji-menu-wrapper {
  position: relative;
  display: inline-block;
}

.emoji-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: -50px;
  width: 320px;
  max-width: 90vw;
  background: #111b21;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  padding: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.97);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.emoji-dropdown-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.emoji-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.emoji-menu-title {
  font-size: 13px;
  font-weight: 600;
  color: #e9edef;
  letter-spacing: 0.3px;
}

.emoji-menu-tabs {
  display: flex;
  gap: 4px;
}

.emoji-tab {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #8696a0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.emoji-tab:hover {
  color: #e9edef;
  background: rgba(255, 255, 255, 0.12);
}

.emoji-tab.active {
  background: #00a884;
  color: #ffffff;
}

.emoji-menu-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 6px;
}

.emoji-menu-grid::-webkit-scrollbar {
  width: 5px;
}

.emoji-menu-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.sticker-item {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  aspect-ratio: 1;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  transform: translateZ(0);
}

.sticker-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.sticker-item:hover {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.sticker-item:hover img {
  transform: scale(1.18);
}

.sticker-item:active {
  background: rgba(255, 255, 255, 0.2);
}

.sticker-item:active img {
  transform: scale(0.92);
}

/* Bottom Action Bar */
.bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 24px 20px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
}

/* Zoom Controls Dock */
.zoom-controls-dock {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(18, 27, 34, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 4px 10px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  pointer-events: auto;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  cursor: pointer;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.zoom-btn svg {
  width: 16px;
  height: 16px;
  fill: #e9edef;
}

.zoom-level-text {
  font-size: 13px;
  font-weight: 600;
  color: #e9edef;
  min-width: 44px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.12s ease;
}

.zoom-level-text:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-action-text {
  height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-action-text:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #00a884;
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 168, 132, 0.45);
  transition: background 0.15s ease, transform 0.12s ease;
  outline: none;
  flex-shrink: 0;
}

.btn-send:hover {
  background: #06cf9c;
}

.btn-send:active {
  transform: scale(0.92);
}

.btn-send svg {
  width: 22px;
  height: 22px;
  fill: #ffffff;
}

/* Sample selector overlay modal */
.photos-selector-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.photos-selector-modal.hidden {
  display: none;
}

.modal-card {
  background: #1f2c34;
  width: 100%;
  max-width: 520px;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 500;
  color: #e9edef;
}

.samples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.sample-thumb-card {
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #2a3942;
  transition: transform 0.15s, border-color 0.15s;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sample-thumb-card:hover {
  transform: translateY(-2px);
  border-color: #00a884;
}

.sample-thumb-card canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sample-badge {
  position: absolute;
  bottom: 4px;
  left: 6px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(0,0,0,0.7);
  padding: 2px 6px;
  border-radius: 4px;
  color: #e9edef;
}

.upload-btn-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background: #00a884;
  border-radius: 10px;
  cursor: pointer;
  color: white;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s;
}

.upload-btn-label:hover {
  background: #06cf9c;
}

/* Toast Notification */
.toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(17, 27, 33, 0.94);
  color: #e9edef;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 120;
}

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

/* Mobile Responsive Optimization (<= 640px) */
@media (max-width: 640px) {
  /* Compact Top Bar */
  .top-bar {
    height: 52px;
    padding: 0 10px;
  }

  .top-actions {
    gap: 4px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

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

  /* Compact Color Presets & Thickness Row */
  .color-presets-row {
    top: 56px;
    padding: 4px 10px;
    gap: 6px;
    max-width: calc(100vw - 20px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  .color-presets-row::-webkit-scrollbar {
    display: none;
  }

  .preset-dot {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .thickness-picker {
    gap: 4px;
    padding-left: 6px;
  }

  .thickness-btn {
    width: 22px;
    height: 22px;
  }

  /* Dropdown & Emoji Menus positioned cleanly on small screens */
  .header-dropdown-menu {
    width: 200px;
    top: calc(100% + 6px);
  }

  .emoji-dropdown-menu {
    width: 290px;
    max-width: 94vw;
    right: -70px;
    top: calc(100% + 6px);
  }

  .emoji-menu-grid {
    grid-template-columns: repeat(5, 1fr);
    max-height: 200px;
  }

  /* Bottom Zoom Dock */
  .bottom-bar {
    padding: 10px 16px 16px 16px;
  }

  .zoom-controls-dock {
    padding: 3px 8px;
    gap: 4px;
  }

  .zoom-btn {
    width: 28px;
    height: 28px;
  }

  .zoom-btn svg {
    width: 14px;
    height: 14px;
  }

  .zoom-level-text {
    font-size: 12px;
    min-width: 38px;
  }
}
