* { box-sizing: border-box; }
    html, body {
      margin: 0;
      padding: 0;
      height: 100%;
      font-family: 'Segoe UI', sans-serif;
      background: #121212;
      color: #fff;
      overflow: hidden;
    }
    #top-bar {
      width: 100%;
      padding: 10px 15px;
      background: #1f1f1f;
      color: white;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
    }

    #controls, #page-controls {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-wrap: wrap;
    }
    button, .button, input[type="button"], input[type="submit"] {
  padding: 8px 14px;
  border-radius: 6px;
  min-height: 36px;
  min-width: 0;
  /* height: 36px; */ /* Removed fixed height to allow for flexible button sizes */
  box-sizing: border-box;
  text-align: center; /* Center text in all buttons */
}
#top-bar button, #top-bar input[type="button"], #top-bar input[type="submit"] {
  padding: 8px 14px;
  border-radius: 6px;
  min-height: 32px;
  max-height: 32px;
  min-width: 0;
  height: 36px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  text-align: center; /* Center text in top-bar buttons */
}
#top-bar button svg {
  width: 14px;
  height: 18.5px;
  display: inline-block;
  vertical-align: middle;
}
#go-page {
  padding: 8px 14px;
  border-radius: 6px;
  min-height: 32px;
  min-width: 0;
  height: 36px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center; /* Center text in go-page button */
}
#go-page svg {
  width: 18.68px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
}
    button {
      padding: 8px 14px;
      cursor: pointer;
      background: #ff007f;
      color: white;
      border: none;
      border-radius: 6px;
      transition: 0.2s;
    }
    button:hover {
      background: #ff3399;
    }
button:disabled {
  background-color: #aaa;
  color: #666;
  border: 1px solid #888;
  cursor: not-allowed;
  opacity: 0.6;
  transition: all 0.2s ease;
  position: relative;
}

button:disabled:hover::before {
  content: "This button is unavailable because you need to upload a file first.";
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.8em;
  white-space: nowrap;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease;
}

button:disabled:hover::before {
  opacity: 1;
  visibility: visible;
}

button:enabled:hover::before {
  opacity: 0;
  visibility: hidden;
}

    input[type="number"] {
      padding: 6px;
      width: 70px;
      border-radius: 4px;
      border: none;
    }
    input[type="file"] {
      background: #333;
      padding: 6px;
      border-radius: 4px;
      color: white;
    }
    #viewer-container {
      display: flex;
      justify-content: center;
      align-items: flex-start;
      height: calc(100% - 70px);
      overflow: hidden;
    }
    .page-wrapper {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 20px;
      width: 100%;
      height: 100%;
      flex-direction: row;
      flex-wrap: wrap;
    }
    canvas {
      background: white;
      border-radius: 8px;
      box-shadow: 0 2px 20px rgba(0,0,0,0.5);
    }

    #page-num {
      font-size: 14px;
      color: #ccc;
      white-space: nowrap;
    }
/* --- New Settings Popup Styles --- */
.popup-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.popup-overlay[style*="display: flex"] {
  display: flex !important;
}
.settings-popup {
  background: rgba(30,30,30,0.95);
  border: 1px solid #333;
  border-radius: 25px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.8);
  backdrop-filter: blur(15px);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
  animation: popupSlideIn 0.3s ease-out;
}
@keyframes popupSlideIn {
  from { opacity: 0; transform: scale(0.9) translateY(-20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.settings-popup::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #ff007f, #ff4da6, #ff007f);
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
  0%,100% { background-position: 200% 0; }
  50% { background-position: -200% 0; }
}
.popup-header {
  padding: 30px 30px 20px;
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.popup-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-icon { font-size: 24px; }
.popup-title h2 {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
}
.close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  border-radius: 8px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}
.close-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.popup-content {
  padding: 30px;
  max-height: calc(90vh - 120px);
  overflow-y: auto;
}
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  gap: 20px;
}
.setting-item:last-child { border-bottom: none; }
.setting-label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.setting-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.beta-tag {
  background: linear-gradient(135deg, #ff007f, #ff4da6);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.setting-control {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dropdown {
  background: #2a2a2a;
  border: 2px solid #444;
  border-radius: 12px;
  color: #fff;
  padding: 8px 12px;
  font-size: 14px;
  min-width: 120px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.dropdown:hover { border-color: #ff007f; }
.dropdown:focus {
  outline: none;
  border-color: #ff007f;
  box-shadow: 0 0 0 3px rgba(255,0,127,0.2);
}
.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}
.slider-value {
  font-size: 14px;
  font-weight: 600;
  color: #ff007f;
  min-width: 40px;
}
.slider {
  width: 120px;
  height: 6px;
  border-radius: 3px;
  background: #444;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff007f;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(255,0,127,0.3);
  transition: all 0.3s ease;
}
.slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(255,0,127,0.5);
}
.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff007f;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(255,0,127,0.3);
}
.setting-btn {
  background: #ff007f;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(255,0,127,0.3);
}
.setting-btn:hover {
  background: #e6006e;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255,0,127,0.4);
}
.setting-btn:active { transform: translateY(0); }
.checkbox-container {
  position: relative;
  display: flex;
  align-items: center;
}
.checkbox {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}
.checkmark {
  width: 20px;
  height: 20px;
  background: #2a2a2a;
  border: 2px solid #444;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.checkbox:checked + .checkmark {
  background: #ff007f;
  border-color: #ff007f;
}
.checkmark::after {
  content: '✓';
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.checkbox:checked + .checkmark::after {
  opacity: 1;
}
.checkmark:hover {
  border-color: #ff007f;
  transform: scale(1.05);
}
.popup-footer {
  padding: 20px 30px 30px;
  border-top: 1px solid #333;
  display: flex;
  gap: 15px;
  justify-content: flex-end;
}
.footer-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
}
.btn-primary {
  background: #ff007f;
  color: #fff;
  box-shadow: 0 4px 15px rgba(255,0,127,0.3);
}
.btn-primary:hover {
  background: #e6006e;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255,0,127,0.4);
}
.btn-secondary {
  background: #2a2a2a;
  border: 2px solid #444;
  color: #fff;
}
.btn-secondary:hover {
  background: #333;
  border-color: #555;
  transform: translateY(-2px);
}
@media (max-width: 768px) {
  .settings-popup {
    margin: 10px;
    max-width: calc(100% - 20px);
    border-radius: 20px;
  }
  .popup-header, .popup-content, .popup-footer {
    padding-left: 20px;
    padding-right: 20px;
  }
  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  .setting-control { width: 100%; justify-content: flex-end; }
  .dropdown { min-width: 150px; }
  .slider { width: 150px; }
  .popup-footer { flex-direction: column; }
  .footer-btn { width: 100%; }
}
@media (max-width: 480px) {
  .popup-title h2 { font-size: 20px; }
  .setting-title { font-size: 15px; }
  .popup-header, .popup-content, .popup-footer {
    padding-left: 15px;
    padding-right: 15px;
  }
}
/* --- End New Settings Popup Styles --- */

/* Remove old settings modal styles if present */
#settings-modal, #settings-modal.visible, #settings-modal .modal-content { display: none !important; }
#settings-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  justify-content: center;
  align-items: center;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#settings-modal.visible {
  opacity: 1;
}

#settings-modal .modal-content {
  background: #1f1f1f;
  padding: 30px;
  border-radius: 15px;
  width: 400px;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#settings-modal.visible .modal-content {
  transform: translateY(0);
  opacity: 1;
}

#settings-modal h2 {
  margin: 0;
  color: #ff007f;
  font-size: 24px;
  font-weight: 600;
  border-bottom: 2px solid #ff007f;
  padding-bottom: 10px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.settings-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  font-size: 14px;
  color: #fff;
}

#settings-modal select,
#settings-modal input[type="range"] {
  background: #333;
  border: none;
  padding: 8px;
  border-radius: 6px;
  color: white;
  width: 150px;
  transition: background 0.3s ease;
}

#settings-modal input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  background: #333;
  border-radius: 3px;
}

#settings-modal input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #ff007f;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

#settings-modal input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.3);
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.5);
}

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

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

#settings-modal button {
  padding: 10px 20px;
  border-radius: 6px;
  transition: all 0.2s;
  text-align: center; /* Center text in settings modal buttons */
}

#close-settings {
  background: transparent;
  border: 2px solid #ff007f;
  color: #ff007f;
}

#close-settings:hover {
  background: rgba(255, 0, 127, 0.1);
}

#reset-settings {
  background: #333;
  color: white;
}

#reset-settings:hover {
  background: #444;
}

#theme-toggle {
  background: white;
  color: black;
  border: 1px solid #ccc;
  padding: 5px;
  border-radius: 5px;
  font-size: 14px;
}

body.light-theme #theme-toggle {
  background: #f0f0f0;
  color: #333;
}

/* Make buttons black when on light mode */
body.light-theme button {
  background: #000000;
  color: white;
}

body.light-theme button:hover {
  background: #333333;
}

/* Keep the settings button style consistent */
body.light-theme #close-settings {
  background: transparent;
  border: 2px solid #000000;
  color: #000000;
}

body.light-theme #close-settings:hover {
  background: rgba(0, 0, 0, 0.1);
}

body.light-theme #theme-toggle {
  background: #000000;
  border: 2px solid #000000;
}

/* Keep disabled button styles consistent */
body.light-theme button:disabled {
  background-color: #ddd;
  color: #888;
  border: 1px solid #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

#theme-toggle::before {
  content: '🌙';
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  transition: all 0.3s;
}

#theme-toggle.light::before {
  content: '☀️';
  left: 35px;
}
    body.light-theme {
  background: #f4f4f4;
  color: #111;
}

body.light-theme #top-bar {
  background: #e0e0e0;
  color: #111;
}

body.light-theme #settings-modal .modal-content {
  background: #ffffff;
  color: #333333;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

body.light-theme .settings-group {
  background: rgba(0, 0, 0, 0.05);
}

body.light-theme .settings-group label {
  color: #333333;
}

body.light-theme #settings-modal select,
body.light-theme #settings-modal input[type="range"] {
  background: #ffffff;
  border: 1px solid #dddddd;
  color: #333333;
}

body.light-theme #settings-modal input[type="range"] {
  background: #dddddd;
}

body.light-theme #settings-modal input[type="range"]::-webkit-slider-thumb {
  background: #ff007f;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

body.light-theme #theme-toggle {
  background: #e0e0e0;
  border: 2px solid #ff007f;
}

body.light-theme #theme-toggle::before {
  filter: none; /* Ensures emoji is visible */
}

/* Reset and close buttons in light mode */
body.light-theme #reset-settings {
  background: #ff007f;
  color: white;
}

body.light-theme #reset-settings:hover {
  background: #ff3399;
}

body.light-theme #close-settings {
  background: transparent;
  border: 2px solid #ff007f;
  color: #ff007f;
}

body.light-theme #close-settings:hover {
  background: rgba(255, 0, 127, 0.1);
}

/* Scale value text in light mode */
body.light-theme #scale-value {
  color: #333333;
}

#scale-value {
  transition: all 0.2s ease;
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
}

#scale-value.active {
  background: rgba(255, 0, 127, 0.1);
  color: #ff007f;
}

/* Light theme adjustments */
body.light-theme #settings-modal input[type="range"]:active::-webkit-slider-thumb {
  box-shadow: 0 0 10px rgba(80, 80, 80, 0.3);
}

body.light-theme #scale-value.active {
  background: rgba(80, 80, 80, 0.1);
  color: #505050;
}

/* Settings groups title in light mode */
body.light-theme #settings-modal h2 {
  color: #ff007f;
  border-bottom-color: #ff007f;
}

body.light-theme canvas {
  background: #fff;
}

body.light-theme input[type="file"],
body.light-theme input[type="number"] {
  background: #fff;
  color: #000;
}
 
/* tghe new floating controls styles */
#floating-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: none;
  gap: 10px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#floating-controls.visible {
  opacity: 1;
  transform: translateY(0);
}

#floating-controls button,
#floating-settings {
  background: #ff007f;
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  text-align: center; /* Center text in floating controls */
}

#floating-settings {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#floating-settings.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Hover effects */
#floating-controls button:hover,
#floating-settings:hover {
  background: #ff3399;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

/* Press animation */
#floating-controls button:active,
#floating-settings:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Ripple effect */
#floating-controls button::after,
#floating-settings::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: width 0.3s ease-out, height 0.3s ease-out, opacity 0.3s ease-out;
}

#floating-controls button:active::after,
#floating-settings:active::after {
  width: 100px;
  height: 100px;
  opacity: 1;
  transition: 0s;
}

/* Light theme adjustments */
body.light-theme #floating-controls button,
body.light-theme #floating-settings {
  background: #505050;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body.light-theme #floating-controls button:hover,
body.light-theme #floating-settings:hover {
  background: #666666;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

button.hidden {
  display: none;
}

.drop-zone {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  border: 2px dashed #ff007f;
  border-radius: 15px;
  padding: 20px;
  transition: all 0.3s ease;
  gap: 40px;
  cursor: pointer; /* Add cursor pointer to indicate clickable area */
  transform-origin: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drop-zone .content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.drop-zone.dragover {
  background: rgba(255, 0, 127, 0.1);
  border-color: #ff3399;
  transform: scale(1.02);
  /* removing since its ruining the zoomin effect
  add back to shake drop zone when dragover
  animation: pulseAndBounce 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); */
}
/* removing since its ruining the zoomin effect add back to shake drop zone when dragover
@keyframes pulseAndBounce {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
  65% {
    transform: scale(0.98);
  }
  80% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
} */

.drop-zone::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 15px;
  background: rgba(255, 0, 127, 0);
  transition: background 0.3s ease;
  pointer-events: none;
}

.drop-zone.dragover::after {
  background: rgba(255, 0, 127, 0.1);
}

body.light-theme .drop-zone.dragover::after {
  background: rgba(80, 80, 80, 0.1);
}

.drop-zone .text {
  font-size: 32px;
  margin: 0 0 20px 0;
  color: #ff007f;
  font-weight: 600;
}

/* Add media query for mobile devices */
@media (max-width: 768px) {
  .drop-zone { /* THIS IS MOBILE ONLY. */
    flex-direction: column;  /* Stack vertically on mobile */
  }
  
  .drop-zone .content-wrapper { /* THIS IS MOBILE ONLY. */
    margin-right: 0;
    margin-bottom: 20px;
    align-items: center;  /* Center align on mobile */
  }
  
  .drop-zone .text { /* THIS IS MOBILE ONLY. */
    text-align: center;
  }
}
/* End of media query */

.drop-zone .text {
  font-size: 28px;
  margin: 10px 0;
  color: #ff007f;
  font-weight: 600;
}

.drop-zone button {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 500;
  align-self: flex-start;
  text-align: center; /* Center text in drop-zone buttons */
}

#file-input {
  display: none;
}

.drop-zone .icon svg {
  width: 200px;
  height: 200px;
  filter: drop-shadow(0 8px 16px rgba(255, 0, 127, 0.2));
  animation: pulse 3s ease-in-out infinite;
}

.drop-zone .text {
  font-size: 28px;
  margin: 25px 0;
  color: #ff007f;
  font-weight: 600;
}

.drop-zone button {
  margin-top: 15px;
  padding: 12px 27.25px; /* usually 12px 24px but changing to 27.25 to match old button */
  font-size: 16px;
  font-weight: 500;
}
/* The float animation has been replaced with pulse but I kept it here in case I want to use it again later. */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.page-wrapper canvas {
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.page-wrapper canvas.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Add animation for page exit */
.page-wrapper canvas.exit {
  opacity: 0;
  transform: translateX(-20px);
}

.error-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #ff007f;
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  z-index: 1000;
  animation: fadeInOut 2s ease-in-out forwards;
  /* removing because its too hard to read the text
  add this line back if you want the shake animation on the error message */
  /*
  animation: fadeInOutShake 2s ease-in-out forwards;
  */
}

@keyframes fadeInOutShake {
  0% { 
    opacity: 0; 
    transform: translate(-50%, -20px); 
  }
  15% { 
    opacity: 1; 
    transform: translate(-50%, 0); 
  }
  20%, 22%, 24% {
    transform: translate(-52%, 0);
  }
  21%, 23%, 25% {
    transform: translate(-48%, 0);
  }
  26% {
    transform: translate(-50%, 0);
  }
  85% { 
    opacity: 1; 
    transform: translate(-50%, 0); 
  }
  100% { 
    opacity: 0; 
    transform: translate(-50%, -20px); 
  }
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, -20px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -20px); }
}

/* Update light mode colors */
body.light-theme button {
  background: #505050;  /* Softer gray instead of black */
  color: white;
}

body.light-theme button:hover {
  background: #666666;
}

/* Update settings modal colors in light mode */
body.light-theme #settings-modal h2 {
  color: #505050;
  border-bottom-color: #505050;
}

body.light-theme #reset-settings {
  background: #505050;
  color: white;
}

body.light-theme #reset-settings:hover {
  background: #666666;
}

body.light-theme #close-settings {
  background: transparent;
  border: 2px solid #505050;
  color: #505050;
}

body.light-theme #close-settings:hover {
  background: rgba(80, 80, 80, 0.1);
}

/* Update drop zone colors in light mode */
body.light-theme .drop-zone {
  border-color: #505050;
}

body.light-theme .drop-zone .text {
  color: #505050;
}

body.light-theme .drop-zone .icon svg {
  stroke: #505050;  /* Update SVG color */
  filter: drop-shadow(0 8px 16px rgba(80, 80, 80, 0.2));
}

body.light-theme .drop-zone.dragover {
  background: rgba(80, 80, 80, 0.1);
  border-color: #666666;
}

/* Update error message in light mode */
body.light-theme .error-message {
  background: #505050;
}

/* Update theme toggle in light mode */
body.light-theme #theme-toggle {
  background: #505050;
  border: 2px solid #505050;
}

/* Update floating controls in light mode */
body.light-theme #floating-controls button,
body.light-theme #floating-settings {
  background: #505050;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body.light-theme #floating-controls button:hover,
body.light-theme #floating-settings:hover {
  background: #666666;
}

/* Update SVG colors in light mode */
body.light-theme .drop-zone .icon svg rect,
body.light-theme .drop-zone .icon svg path {
  stroke: #505050;  /* Gray color for light mode */
}

/* Default (dark mode) SVG styling */
.drop-zone .icon svg rect,
.drop-zone .icon svg path {
  stroke: #ff007f;  /* Pink color for dark mode */
}

/* Light mode SVG styling */
body.light-theme .drop-zone .icon svg rect,
body.light-theme .drop-zone .icon svg path {
  stroke: #505050;  /* Gray color for light mode */
}

/* Update the filter for both modes */
.drop-zone .icon svg {
  filter: drop-shadow(0 8px 16px rgba(255, 0, 127, 0.2));  /* Pink shadow for dark mode */
}

body.light-theme .drop-zone .icon svg {
  filter: drop-shadow(0 8px 16px rgba(80, 80, 80, 0.2));  /* Gray shadow for light mode */
}

/* Update range input styling in light mode */
body.light-theme #settings-modal input[type="range"] {
  background: #e0e0e0;
}

body.light-theme #settings-modal input[type="range"]::-webkit-slider-thumb {
  background: #505050;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

body.light-theme #settings-modal input[type="range"]::-webkit-slider-thumb:hover {
  background: #666666;
}

/* Update the scale value text color */
body.light-theme #scale-value {
  color: #505050;
}

/* Default (dark mode) page number styling */
#page-num {
  font-size: 14px;
  color: #ccc;
  white-space: nowrap;
}

/* Light mode page number styling */
body.light-theme #page-num {
  color: #000000;
}

/* Update input styling for light mode */
body.light-theme input[type="number"] {
  background: #505050;
  color: white;
  border: 1px solid #666666;
}

body.light-theme input[type="number"]:focus {
  outline: none;
  border-color: #666666;
  box-shadow: 0 0 0 2px rgba(80, 80, 80, 0.2);
}

#upload-btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Hover effect */
#upload-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.4);
}

/* Ripple effect */
#upload-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}

#upload-btn:active::after {
  animation: ripple 0.6s ease-out;
}

@keyframes ripple {
  0% {
    width: 0;
    height: 0;
    opacity: 0.5;
  }
  100% {
    width: 200px;
    height: 200px;
    opacity: 0;
  }
}

/* Light theme adjustments */
body.light-theme #upload-btn:hover {
  box-shadow: 0 0 20px rgba(80, 80, 80, 0.3);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  backface-visibility: hidden;
  transform-origin: center;
}

input[type="number"].invalid {
  border: 2px solid #ff007f;
  background-color: rgba(255, 0, 127, 0.1);
}

/* Light theme styling for invalid input */
body.light-theme input[type="number"].invalid {
  border: 2px solid #ff0000;
  background-color: rgba(255, 0, 0, 0.1);
}

#logout-btn {
  background: #ff3b3b;
  color: #fff;
}
#logout-btn:hover {
  background: #ff5555;
}

/* Cloud storage UI styles */
.cloud-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.cloud-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #23262f;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
  max-width: 90%;
  width: 400px;
}

.cloud-menu.visible {
  display: block;
}

.cloud-menu h2 {
  color: #ff007f;
  margin-bottom: 1rem;
}

.cloud-file-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 1rem 0;
}

.cloud-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cloud-file-item button {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  text-align: center; /* Center text in cloud file item buttons */
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  display: none;
}

/* Google Drive UI styles */
.drive-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #23262f;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
  max-width: 90%;
  width: 400px;
}

.drive-menu.visible {
  display: block;
}

.drive-menu h2 {
  color: #ff007f;
  margin-bottom: 1rem;
}

.drive-file-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 1rem 0;
}

.drive-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.drive-file-item button {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  text-align: center; /* Center text in drive file item buttons */
}

body.light-theme .cloud-menu {
  background: #fff;
  box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.1);
}

body.light-theme .cloud-file-item {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .drive-menu {
  background: #fff;
  box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.1);
}

body.light-theme .drive-file-item {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}
    .success-message {
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%);
      background-color: #4CAF50;
      color: white;
      padding: 15px 30px;
      border-radius: 4px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
      z-index: 1000;
      animation: slide-down 0.3s ease-out;
    }

    @keyframes slide-down {
      0% { transform: translate(-50%, -100%); opacity: 0; }
      100% { transform: translate(-50%, 0); opacity: 1; }
    }

/* Style the toolbar hiding checkbox */
#hide-toolbar-toggle {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s;
}

#hide-toolbar-toggle:checked {
  background: #ff007f;
  border-color: #ff007f;
}

/* Light theme styles */
body.light-theme #hide-toolbar-toggle {
  background: #f0f0f0;
  border-color: #ddd;
}

body.light-theme #hide-toolbar-toggle:checked {
  background: #333;
  border-color: #333;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
}

.loading-overlay.visible {
    display: flex !important;
}

.loading-overlay p {
    color: white;
    font-size: 16px;
    margin: 0;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: #ff007f;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Light theme */
body.light-theme .loading-overlay {
    background: rgba(255, 255, 255, 0.95);
}

body.light-theme .loading-overlay p {
    color: #333;
}

body.light-theme .loader {
    border: 5px solid #333;
    border-bottom-color: #ff007f;
}

.annotation-toolbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(44, 62, 80, 0.95);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  gap: 10px;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.annotation-toolbar.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(100px);
}

.annotation-toolbar button {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 6px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 1.2em;
  transition: all 0.2s ease;
  text-align: center; /* Center text in annotation toolbar buttons */
}

.annotation-toolbar button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.annotation-toolbar button.active {
  background: #48c6ef;
}

.annotation-toolbar input[type="color"] {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  background: none;
}

.annotation-toolbar input[type="range"] {
  width: 100px;
  cursor: pointer;
}

.annotation-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 25px;
  background: #48c6ef;
  border: none;
  color: white;
  font-size: 1.5em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.annotation-toggle:hover {
  transform: scale(1.1);
}

.annotation-canvas {
  position: absolute !important;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
  touch-action: none;
}

.annotation-canvas.active {
  pointer-events: all;
}

/* Disable user selection when drawing */
.drawing {
  user-select: none;
  -webkit-user-select: none;
}

/* Fix some mobile-specific issues */
@media (max-width: 768px) {
  .annotation-toolbar {
    padding: 8px;
    gap: 8px;
    bottom: 80px; /* Move up to avoid overlap with floating controls */
  }
  
  .annotation-toolbar button {
    width: 36px;
    height: 36px;
    font-size: 1em;
  }
  
  .annotation-toolbar input[type="range"] {
    width: 60px;
  }
  
  .annotation-toggle {
    bottom: 80px;
  }
}

.page-canvas-wrapper {
  position: relative;
  margin: 10px 0;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Ensure PDF pages and annotations align properly */
.page-canvas-wrapper canvas {
  display: block;
  margin: 0;
  padding: 0;
}

/* Position annotation canvas exactly over PDF canvas */
.page-canvas-wrapper .annotation-canvas {
  position: absolute !important;
  top: 0;
  left: 0;
  pointer-events: none;
}

.premium-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  animation: premium-glow 1.5s infinite alternate;
}

.premium-button {
  align-items: center;
}

.premium-message > div {
  background: linear-gradient(135deg, #fffbe6 0%, #fff8dc 100%);
  padding: 2.5rem 2.5rem 2.2rem 2.5rem;
  border-radius: 24px;
  max-width: 440px;
  box-shadow: 0 8px 40px #bfa14a88, 0 2px 0 #fffbe6 inset, 0 0 0 4px #ffd70044;
  text-align: center;
  position: relative;
  border: 3px solid #ffd700;
  color: #7a5c00;
  font-family: 'Segoe UI', 'Arial', sans-serif;
  overflow: visible;
}
.premium-message > div::before {
  content: '👑';
  font-size: 2.5rem;
  position: absolute;
  top: -1.7rem;
  left: 50%;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 8px #ffd70088);
  animation: premium-crown 1.2s infinite alternate;
}
@keyframes premium-glow {
  from { box-shadow: 0 8px 40px #bfa14a88, 0 2px 0 #fffbe6 inset, 0 0 0 4px #ffd70044; }
  to { box-shadow: 0 12px 60px #ffd700cc, 0 2px 0 #fffbe6 inset, 0 0 0 8px #ffd70066; }
}
@keyframes premium-crown {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.12) rotate(-6deg); }
}
.premium-message .premium-title {
  font-size: 1.5em;
  font-weight: 900;
  color: #bfa14a;
  margin-bottom: 0.7em;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 8px #ffd70044;
}
.premium-message .premium-btn {
  background: linear-gradient(90deg, #ffd700 0%, #ffed4e 100%);
  color: #7a5c00;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.1em;
  padding: 0.8em 2.2em;
  margin-top: 1.2em;
  box-shadow: 0 2px 12px #ffd70055;
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}
.premium-message .premium-btn:hover {
  background: linear-gradient(90deg, #ffe066 0%, #ffd700 100%);
  box-shadow: 0 4px 24px #ffd70099;
  transform: scale(1.05);
}
.premium-message ul {
  margin: 1.5em auto 1em auto;
  padding: 0 0 0 1.2em;
  text-align: left;
  max-width: 350px;
  color: #7a5c00;
  font-size: 1.08em;
  font-weight: 500;
}
.premium-message li {
  margin-bottom: 0.7em;
  position: relative;
  padding-left: 1.2em;
}
.premium-message li::before {
  content: '✨';
  position: absolute;
  left: 0;
  color: #ffd700;
  font-size: 1.1em;
  filter: drop-shadow(0 0 4px #ffd70088);
}

/* === Annotation Toolbar Styles (Native Look, Top Bar) === */
#annotation-toolbar {
  position: relative;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--modal-bg, #23272e);
  border-bottom: 1px solid var(--modal-border, #2c3e50);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 2px 16px #0001;
  padding: 8px 18px 8px 18px;
  z-index: 1200;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 1rem;
  justify-content: flex-end;
}
#annotation-toolbar button {
  background: #2c3e50;
  color: #fff;
  border: 1px solid #34495e;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
  min-width: 40px;
  min-height: 36px;
  box-shadow: 0 1px 2px #0001;
  outline: none;
  text-align: center; /* Center text in annotation toolbar buttons */
}
#annotation-toolbar button.selected {
  background: #ffe082;
  color: #7a5c00;
  border: 1px solid #ffd700;
}
#annotation-toolbar button:hover, #annotation-toolbar button:focus {
  background: #34495e;
  color: #ffe082;
}
#annotation-toolbar input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  box-shadow: 0 1px 2px #0001;
}
#annotation-toolbar input[type="range"] {
  width: 80px;
  accent-color: #ffe082;
  vertical-align: middle;
}

#annotate-btn {
  background: #ffe082;
  color: #7a5c00;
  border: 1px solid #ffd700;
  border-radius: 6px;
  margin-left: 10px;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  min-width: 40px;
  min-height: 36px;
  font-family: inherit;
  vertical-align: middle;
  text-align: center; /* Center text in annotate button */
}
#annotate-btn.active {
  background: #ffd700;
  color: #23272e;
}
#annotate-btn:hover, #annotate-btn:focus {
  background: #ffd700;
  color: #23272e;
}

.fabric-canvas {
  position: absolute !important;
  left: 0;
  top: 0;
  pointer-events: auto;
  z-index: 1100;
}

body.light-theme #annotation-toolbar {
  background: #fff;
  border-bottom: 1px solid #bbb;
}
body.light-theme #annotation-toolbar button {
  background: #f5f5f5;
  color: #222;
  border: 1px solid #bbb;
}
body.light-theme #annotation-toolbar button.selected {
  background: #ffe082;
  color: #7a5c00;
  border: 1px solid #ffd700;
}
body.light-theme #annotation-toolbar button:hover, body.light-theme #annotation-toolbar button:focus {
  background: #ffe082;
  color: #7a5c00;
}
body.light-theme #annotate-btn {
  background: #ffe082;
  color: #7a5c00;
  border: 1px solid #ffd700;
}
body.light-theme #annotate-btn.active {
  background: #ffd700;
  color: #23272e;
}
body.light-theme #annotate-btn:hover, body.light-theme #annotate-btn:focus {
  background: #ffd700;
  color: #23272e;
}

/* === Annotation FAB and Toolbar Styles (FAB bottom right, toolbar center top) === */
#annotate-fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 1500;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffe082;
  color: #7a5c00;
  border: 1px solid #ffd700;
  font-size: 2rem;
  box-shadow: 0 2px 12px #0003;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  outline: none;
}
#annotate-fab.active {
  background: #ffd700;
  color: #23272e;
}
#annotate-fab:hover, #annotate-fab:focus {
  background: #ffd700;
  color: #23272e;
}

#annotation-toolbar {
  position: fixed !important;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1400;
  display: none;
  width: auto;
  max-width: 90vw;
  justify-content: center;
  background: var(--modal-bg, #23272e);
  border-bottom: 1px solid var(--modal-border, #2c3e50);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 2px 16px #0001;
  padding: 8px 18px 8px 18px;
  gap: 10px;
  align-items: center;
  font-size: 1rem;
}
#annotation-toolbar button {
  background: #2c3e50;
  color: #fff;
  border: 1px solid #34495e;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
  min-width: 40px;
  min-height: 36px;
  box-shadow: 0 1px 2px #0001;
  outline: none;
  text-align: center; /* Center text in annotation toolbar buttons */
}
#annotation-toolbar button.selected {
  background: #ffe082;
  color: #7a5c00;
  border: 1px solid #ffd700;
}
#annotation-toolbar button:hover, #annotation-toolbar button:focus {
  background: #34495e;
  color: #ffe082;
}
#annotation-toolbar input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  box-shadow: 0 1px 2px #0001;
}
#annotation-toolbar input[type="range"] {
  width: 80px;
  accent-color: #ffe082;
  vertical-align: middle;
}

body.light-theme #annotate-fab {
  background: #ffe082;
  color: #7a5c00;
  border: 1px solid #ffd700;
}
body.light-theme #annotate-fab.active {
  background: #ffd700;
  color: #23272e;
}
body.light-theme #annotate-fab:hover, body.light-theme #annotate-fab:focus {
  background: #ffd700;
  color: #23272e;
}
body.light-theme #annotation-toolbar {
  background: #fff;
  border-bottom: 1px solid #bbb;
}
body.light-theme #annotation-toolbar button {
  background: #f5f5f5;
  color: #222;
  border: 1px solid #bbb;
}
body.light-theme #annotation-toolbar button.selected {
  background: #ffe082;
  color: #7a5c00;
  border: 1px solid #ffd700;
}
body.light-theme #annotation-toolbar button:hover, body.light-theme #annotation-toolbar button:focus {
  background: #ffe082;
  color: #7a5c00;
}

#annotation-toolbar {
  box-sizing: border-box;
}

/* === THEME VARIABLES === */
:root {
  --color-bg: #121212;
  --color-fg: #fff;
  --color-accent: #ff007f;
  --color-accent2: #48c6ef;
  --color-border: #444;
  --color-modal-bg: #1f1f1f;
  --color-modal-title: #ff007f;
  --color-dropzone-bg: #121212;
  --color-dropzone-border: #ff007f;
  --color-dropzone-text: #ff007f;
  --color-svg: #ff007f;
}
body.light-theme {
  --color-bg: #f4f4f4;
  --color-fg: #111;
  --color-accent: #505050;
  --color-accent2: #ff007f;
  --color-border: #bbb;
  --color-modal-bg: #fff;
  --color-modal-title: #505050;
  --color-dropzone-bg: #fff;
  --color-dropzone-border: #505050;
  --color-dropzone-text: #505050;
  --color-svg: #505050;
}
body.midnight-theme {
  --color-bg: #181a20;
  --color-fg: #fff;
  --color-accent: #0a7cff;
  --color-accent2: #fff;
  --color-border: #0a7cff;
  --color-modal-bg: #23242a;
  --color-modal-title: #0a7cff;
  --color-dropzone-bg: #23242a;
  --color-dropzone-border: #0a7cff;
  --color-dropzone-text: #0a7cff;
  --color-svg: #0a7cff;
}

html, body {
  background: var(--color-bg);
  color: var(--color-fg);
}
#settings-modal {
  background: rgba(18, 18, 22, 0.85) !important;
}
#settings-modal .modal-content {
  background: var(--color-modal-bg);
  color: var(--color-fg);
}
#settings-modal h2 {
  color: var(--color-modal-title);
  border-bottom: 2px solid var(--color-modal-title);
}
.settings-group {
  background: rgba(255,255,255,0.05);
}
.settings-group label {
  color: var(--color-fg);
}
#settings-modal select,
#settings-modal input[type="range"] {
  background: var(--color-modal-bg);
  border: 1px solid var(--color-border);
  color: var(--color-fg);
}
#settings-modal input[type="range"]::-webkit-slider-thumb {
  background: var(--color-accent);
}
#scale-value {
  color: var(--color-modal-title);
}
/* Drop zone and SVG */
.drop-zone {
  background: var(--color-dropzone-bg);
  border: 2px dashed var(--color-dropzone-border);
  color: var(--color-dropzone-text);
}
.drop-zone .text {
  color: var(--color-dropzone-text);
}
.drop-zone .icon svg rect,
.drop-zone .icon svg path {
  stroke: var(--color-svg) !important;
}
.drop-zone .icon svg {
  filter: drop-shadow(0 8px 16px var(--color-svg)33);
}
/* Theme popup improvements */
.theme-popup {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000;
  animation: fadeIn 0.2s;
}
.theme-popup-content {
  background: var(--color-modal-bg);
  color: var(--color-fg);
  border-radius: 18px;
  box-shadow: 0 8px 32px #0005;
  padding: 2.2rem 2.5rem 2rem 2.5rem;
  min-width: 340px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
}
.theme-popup-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  color: var(--color-modal-title);
  text-align: center;
}
.theme-swatches {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-bottom: 1.5rem;
}
.theme-swatch {
  cursor: pointer;
  border-radius: 10px;
  padding: 0.7em 0.5em 0.7em 0.5em;
  border: 2.5px solid transparent;
  transition: border 0.2s, box-shadow 0.2s;
  background: none;
}
.theme-swatch.selected {
  border: 2.5px solid var(--color-accent);
  box-shadow: 0 2px 12px var(--color-accent)33;
}
.theme-popup-actions {
  display: flex;
  gap: 16px;
  margin-top: 1.2rem;
  width: 100%;
  justify-content: center;
}
.deep-blue-btn {
  background: var(--color-accent2);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7em 2.2em;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.deep-blue-btn:hover {
  background: var(--color-accent);
}
.close-theme-popup {
  position: absolute;
  top: 12px;
  right: 18px;
  font-size: 1.7rem;
  background: none;
  border: none;
  color: var(--color-fg);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.close-theme-popup:hover { opacity: 1; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.default-theme #scale-value,
#scale-value {
  color: #fff;
}

.theme-popup-actions button,
.theme-popup-actions .deep-blue-btn {
  background: #ff007f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7em 2.2em;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center; /* Center text in theme popup actions */
}

.theme-popup-actions button:hover,
.theme-popup-actions .deep-blue-btn:hover {
  background: #c8005f;
}

body.midnight-theme #top-bar button,
body.midnight-theme #top-bar .menu-btn,
body.midnight-theme .settings-actions button {
  background: #0a7cff;
  color: #fff;
  border: 2px solid #0a7cff;
}

body.midnight-theme #close-settings {
  background: transparent;
  background: #0a7cff;
  color: #fff;
  border: 2px solid #0a7cff;
}

body.midnight-theme #close-settings:hover {
  background: rgba(10, 124, 255, 0.1)
}

body.midnight-theme #top-bar button:hover,
body.midnight-theme #top-bar .menu-btn:hover,
body.midnight-theme .settings-actions button:hover {
  background: #095bb5;
  border-color: #095bb5;
}

body.midnight-theme .theme-popup-actions button,
body.midnight-theme .theme-popup-actions .deep-blue-btn {
  background: #fff;
  color: #0a7cff;
  border: 2px solid #0a7cff;
}

body.midnight-theme .theme-popup-actions button:hover,
body.midnight-theme .theme-popup-actions .deep-blue-btn:hover {
  background: #e6f0ff;
  color: #095bb5;
  border-color: #095bb5;
}

body.midnight-theme #hide-toolbar-toggle:checked {
  background: #0a7cff;
  border-color: #0a7cff;
}

body.midnight-theme #floating-controls button,
body.midnight-theme #floating-settings {
  background: #0a7cff;
  color: #fff;
}
body.midnight-theme #floating-controls button:hover,
body.midnight-theme #floating-settings:hover {
  background: #095bb5;
}

body.midnight-theme #settings-modal .modal-content {
  background: #23242a;
  color: #fff;
}

.drop-zone button {
  background: #ff007f;
  color: #fff;
}
.drop-zone button:hover {
  background: #c8005f;
}
body.midnight-theme .drop-zone button {
  background: #0a7cff;
  color: #fff;
}
body.midnight-theme .drop-zone button:hover {
  background: #095bb5;
}
/*
body.midnight-theme button,
body.midnight-theme #top-bar button,
body.midnight-theme #top-bar .menu-btn,
body.midnight-theme .settings-actions button,
body.midnight-theme #floating-controls button,
body.midnight-theme #floating-settings,
body.midnight-theme .theme-popup-actions button,
body.midnight-theme .theme-popup-actions .deep-blue-btn,
body.midnight-theme .drop-zone button {
  border-radius: 6px;
  min-width: unset;
  width: unset;
}
  */
body.midnight-theme #top-bar button,
body.midnight-theme #top-bar .menu-btn {
  height: auto;
}
body.midnight-theme .drop-zone {
  background: #121212;
}

/* === Annotation Toolbar Styles (Native Look, Top Bar) === */
        .topbar-container {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 1000;
            animation: slideDown 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        }

        @keyframes slideDown {
            from {
                opacity: 0;
                transform: translateX(-50%) translateY(-30px);
            }
            to {
                opacity: 1;
                transform: translateX(-50%) translateY(0);
            }
        }

        .annotation-topbar {
            background: rgba(20, 20, 20, 0.98);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 16px;
            box-shadow: 
                0 20px 60px rgba(0, 0, 0, 0.9),
                0 8px 25px rgba(0, 0, 0, 0.7),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(20px);
            padding: 16px 24px;
            display: flex;
            align-items: center;
            gap: 20px;
            position: relative;
            overflow: visible;
        }

        .tool-section {
            display: flex;
            align-items: center;
            gap: 12px;
            position: relative;
        }

        .tool-section:not(:last-child)::after {
            content: '';
            position: absolute;
            right: -10px;
            top: 50%;
            transform: translateY(-50%);
            width: 1px;
            height: 32px;
            background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.2), transparent);
        }

        .tool-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            position: relative;
        }

        .tool-btn {
            background: rgba(255, 255, 255, 0.05);
            border: 2px solid rgba(255, 255, 255, 0.1);
            color: #ccc;
            cursor: pointer;
            padding: 0;
            border-radius: 12px;
            transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
            display: flex;
            align-items: center;
            justify-content: center;
            width: 48px;
            height: 48px;
            position: relative;
            font-size: 20px;
            overflow: hidden;
        }

        .tool-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, rgba(255, 0, 127, 0.1), rgba(255, 77, 166, 0.1));
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .tool-btn:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 0, 127, 0.4);
            color: #ffffff;
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
        }

        .tool-btn:hover::before {
            opacity: 1;
        }

        .tool-btn.active {
            background: rgba(255, 0, 127, 0.15);
            border-color: #ff007f;
            color: #ff007f;
            box-shadow: 
                0 0 0 1px rgba(255, 0, 127, 0.3),
                0 8px 25px rgba(255, 0, 127, 0.2);
        }

        .tool-btn.active::before {
            opacity: 1;
        }

        .tool-label {
            font-size: 11px;
            font-weight: 600;
            color: #888;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            transition: color 0.3s ease;
        }

        .tool-item:hover .tool-label,
        .tool-item.active .tool-label {
            color: #ff007f;
        }

        /* Color indicator on tool button */
        .color-indicator {
            position: absolute;
            bottom: 2px;
            right: 2px;
            width: 12px;
            height: 12px;
            border-radius: 6px;
            border: 2px solid rgba(255, 255, 255, 0.8);
            cursor: pointer;
            transition: all 0.3s ease;
            z-index: 10;
        }

        .color-indicator:hover {
            transform: scale(1.2);
            border-color: #ffffff;
        }

        /* Color dropdown */
        .color-dropdown {
            position: absolute;
            top: 60px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(15, 15, 15, 0.98);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 12px;
            padding: 8px;
            display: none;
            gap: 6px;
            backdrop-filter: blur(20px);
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
            z-index: 1002;
        }

        .color-dropdown.show {
            display: flex;
        }

        .color-option {
            width: 24px;
            height: 24px;
            border-radius: 12px;
            border: 2px solid rgba(255, 255, 255, 0.2);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .color-option:hover {
            transform: scale(1.15);
            border-color: rgba(255, 255, 255, 0.6);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        }

        .color-option.selected {
            border-color: #ffffff;
            box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
        }

        /* Action buttons */
        .action-btn {
            background: rgba(255, 255, 255, 0.05);
            border: 2px solid rgba(255, 255, 255, 0.15);
            color: #ffffff;
            cursor: pointer;
            padding: 12px 20px;
            border-radius: 12px;
            font-size: 13px;
            font-weight: 600;
            transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
            display: flex;
            align-items: center;
            gap: 8px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            position: relative;
            overflow: hidden;
        }

        .action-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .cancel-btn {
            border-color: rgba(239, 68, 68, 0.3);
            color: #ef4444;
        }

        .cancel-btn:hover {
            background: rgba(239, 68, 68, 0.1);
            border-color: #ef4444;
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(239, 68, 68, 0.2);
        }

        .cancel-btn:hover::before {
            opacity: 1;
        }

        .save-btn {
            border-color: rgba(255, 0, 127, 0.4);
            color: #ff007f;
            box-shadow: 0 4px 15px rgba(255, 0, 127, 0.1);
        }

        .save-btn:hover {
            background: rgba(255, 0, 127, 0.15);
            border-color: #ff007f;
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(255, 0, 127, 0.3);
        }

        .save-btn.saving {
            background: rgba(255, 0, 127, 0.2);
            border-color: #ff007f;
            color: #ffffff;
            cursor: not-allowed;
        }

        /* Tooltip styles - only show on hover, positioned to not interfere */
        .tooltip {
            position: absolute;
            top: -45px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.95);
            color: #ffffff;
            padding: 8px 12px;
            border-radius: 8px;
            font-size: 12px;
            font-weight: 500;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: all 0.3s ease;
            z-index: 1003;
            border: 1px solid rgba(255, 255, 255, 0.15);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(10px);
        }

        .tooltip::after {
            content: '';
            position: absolute;
            bottom: -6px;
            left: 50%;
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-top: 6px solid rgba(0, 0, 0, 0.95);
        }

        .tool-item:hover .tooltip,
        .action-btn:hover .tooltip {
            opacity: 1;
            transform: translateX(-50%) translateY(-5px);
        }

        /* Hide tooltip when color dropdown is open */
        .tool-item.dropdown-open .tooltip {
            opacity: 0 !important;
        }

        /* Mobile responsive */
        @media (max-width: 768px) {
            .topbar-container {
                top: 10px;
                left: 10px;
                right: 10px;
                transform: none;
                width: calc(100% - 20px);
            }

            .annotation-topbar {
                border-radius: 14px;
                padding: 12px 16px;
                gap: 16px;
                width: 100%;
            }

            .tool-section {
                gap: 8px;
            }

            .tool-btn {
                width: 44px;
                height: 44px;
                font-size: 18px;
            }

            .tool-label {
                font-size: 10px;
            }

            .action-btn {
                padding: 10px 16px;
                font-size: 12px;
            }

            .color-indicator {
                width: 10px;
                height: 10px;
            }

            .tooltip {
                font-size: 11px;
                padding: 6px 10px;
            }
        }

        @media (max-width: 480px) {
            .annotation-topbar {
                padding: 10px 12px;
                gap: 12px;
                flex-wrap: wrap;
                justify-content: center;
            }

            .tool-section:not(:last-child)::after {
                display: none;
            }

            .tool-btn {
                width: 40px;
                height: 40px;
                font-size: 16px;
            }

            .action-btn {
                padding: 8px 12px;
                font-size: 11px;
                flex: 1;
                justify-content: center;
            }
        }

        /* Hide/show animation */
        .topbar-hidden {
            animation: slideUp 0.4s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
        }

        @keyframes slideUp {
            from {
                opacity: 1;
                transform: translateX(-50%) translateY(0);
            }
            to {
                opacity: 0;
                transform: translateX(-50%) translateY(-30px);
            }
        }