/* CSS Reset & Variables */
:root {
  /* onleeSentinel Identity (Slate & Blue) */
  --bg-primary: #020617;
  /* Slate 950 */
  --bg-secondary: #0f172a;
  /* Slate 900 */
  --bg-tertiary: #1e293b;
  /* Slate 800 */

  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  /* Slate 400 */

  --accent-primary: #2563eb;
  /* Blue 600 */
  --accent-hover: #1d4ed8;
  /* Blue 700 */
  --accent-secondary: #0f172a;
  /* Slate 900 */

  --glass-bg: rgba(15, 23, 42, 0.95);
  /* Increased opacity */
  --glass-border: #1e293b;

  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 0.75rem;
}

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

body {
  font-family: var(--font-family);
  background-color: #020617;
  /* Fallback */
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Sidebars */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

#sidebar-right {
  border-left: 1px solid var(--bg-tertiary);
  border-right: none;
  width: 300px;
}

.sidebar-header {
  height: 64px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--bg-tertiary);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.logo span {
  color: var(--accent-primary);
}

.sidebar-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Image Grid */
.image-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--bg-tertiary);
  transition: var(--transition);
}

.gallery-item:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Buttons */
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: #334155;
  border-color: #475569;
}

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

.btn-icon-only {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid transparent;
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-only:hover:not(:disabled) {
  background: var(--accent-primary);
  color: white;
}

.btn-full {
  width: 100%;
}

.btn-text-only {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  margin-top: 0.5rem;
  font-weight: 600;
  text-decoration: underline;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--bg-tertiary);
  background-color: var(--bg-secondary);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.top-bar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--bg-tertiary);
  background: var(--bg-secondary);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Menu Dropdown */
.menu-wrapper {
  position: relative;
}

.menu-trigger.open {
  background: var(--accent-primary);
  color: white;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 0.75rem;
  padding: 0.5rem;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.menu-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.menu-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.5rem 0.25rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  border-radius: 0.375rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.menu-item:hover {
  background: var(--bg-tertiary);
  color: white;
}

.menu-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.menu-item:disabled:hover {
  background: none;
}

.menu-divider {
  height: 1px;
  background: var(--bg-tertiary);
  margin: 0.375rem 0;
}

/* Token Usage */
.token-usage-display {
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.token-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0;
}


.token-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.token-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Monthly Consumption Widget */
.monthly-consumption {
  border-top: 1px solid var(--bg-tertiary);
  margin-top: 0.25rem;
  padding-top: 0.3rem;
}

.consumption-badge {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: block;
}

.consumption-badge a {
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 0.7rem;
}

.consumption-badge a:hover {
  text-decoration: underline;
}

.consumption-detail {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--bg-tertiary);
}

.consumption-month {
  margin-bottom: 0.5rem;
}

.consumption-month-header {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.consumption-model-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(30, 41, 59, 0.5);
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.consumption-model-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quick Save Button */
#btn-quick-save {
  animation: pulse-save 2s ease-in-out infinite;
}

@keyframes pulse-save {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.menu-item:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


.workspace-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Chat */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chat-welcome {
  text-align: center;
  color: var(--text-secondary);
  margin-top: 15vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.chat-welcome svg {
  color: var(--accent-primary);
  opacity: 0.8;
  width: 64px;
  height: 64px;
}

.chat-welcome h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message {
  display: flex;
  gap: 1rem;
  max-width: 80%;
  width: fit-content;
  animation: fadeIn 0.3s ease-out;
  position: relative;
}

.msg-delete-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 5;
  padding: 0;
}

.message:hover .msg-delete-btn {
  opacity: 1;
}

.msg-delete-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
}

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-content {
  background: var(--bg-tertiary);
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  border-top-left-radius: 0.25rem;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message.user .message-content {
  background: var(--accent-primary);
  color: white;
  border-top-left-radius: 1rem;
  border-top-right-radius: 0.25rem;
}

.message-image {
  border-radius: 0.5rem;
  max-width: 512px;
  width: 100%;
  cursor: zoom-in;
  border: 1px solid var(--bg-tertiary);
}

/* Copy-prompt button on user messages */
.msg-copy-btn {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 5;
  padding: 0;
}

.message:hover .msg-copy-btn {
  opacity: 1;
}

.msg-copy-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Input Area */
.input-area {
  padding: 0.5rem 1.5rem;
  border-top: 1px solid var(--bg-tertiary);
  background: var(--bg-secondary);
}

.input-container {
  background: var(--bg-tertiary);
  border-radius: 0.75rem;
  padding: 0.5rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  transition: var(--transition);
}

.input-container:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

textarea {
  background: transparent;
  border: none;
  color: var(--text-primary);
  resize: none;
  font-family: inherit;
  width: 100%;
  min-height: 52px;
  /* Roughly 2 lines with padding */
  max-height: 240px;
  /* Roughly 10 lines */
  overflow-y: auto;
  outline: none;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0.25rem 0.5rem;
}

textarea::placeholder {
  color: var(--text-secondary);
}

/* Tool Chips */
.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.tool-chip:hover {
  background: #334155;
}

.tool-chip.active {
  background: var(--accent-primary);
  color: white;
}

.input-actions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* Controls */
.control-group {
  margin-bottom: 1rem;
}

.control-group.compact {
  margin-bottom: 0.75rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--bg-tertiary);
  margin: 0.5rem 0;
}

.control-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.text-input,
.select-input,
.text-input-area {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  padding: 0.75rem;
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition);
}

.text-input:focus,
.select-input:focus,
.text-input-area:focus {
  border-color: var(--accent-primary);
}



/* Color Picker */
.color-picker-group {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.color-picker-group label {
  font-size: 0.875rem;
  color: var(--text-primary);
  width: 80px;
  /* Fixed width for alignment */
  flex-shrink: 0;
  margin-right: 0;
}

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.text-input.small {
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  width: 80px;
  /* Fixed small width */
  flex: initial;
  /* Don't expand */
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  /* Less rounded (Square-ish) */
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--bg-tertiary);
  border-radius: 4px;
}

/* Aspect Ratio */
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ratio-btn {
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: var(--transition);
}

.ratio-btn.active,
.ratio-btn:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.ratio-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  min-width: 100%;
  z-index: 100;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  margin-top: 0.25rem;
}

.ratio-dropdown-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
}

.ratio-dropdown-item:hover {
  background: var(--bg-tertiary);
}

/* Tools */
.tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 0.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.tool-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.tool-btn.loading {
  position: relative;
  pointer-events: none;
  color: transparent;
}

.tool-btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-secondary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Paid Lock */
.paid-lock {
  color: var(--text-secondary);
  margin-left: 0.25rem;
  vertical-align: middle;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.paid-lock svg {
  width: 14px;
  height: 14px;
}

/* Tooltip for lock */
.paid-lock:hover::after {
  content: 'For paid user only';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  pointer-events: none;
}

/* Remove hover tooltip if it is an unlocked icon (meaning they are paid) */
.paid-lock[data-is-paid="true"]:hover::after {
  display: none;
}

/* Radio Group (for rotate modal) */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition: var(--transition);
}

.radio-group label:hover {
  background: var(--bg-tertiary);
}

.radio-group input[type="radio"] {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
}

/* Tooltip */
.tooltip-container {
  position: relative;
  display: inline-block;
}

.tooltip-container .info-icon {
  width: 14px;
  height: 14px;
  cursor: help;
  color: var(--text-secondary);
}

.tooltip-text {
  visibility: hidden;
  width: 200px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  text-align: center;
  border-radius: 0.5rem;
  padding: 0.75rem;
  position: absolute;
  z-index: 9999;
  top: 100%;
  right: 0;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.75rem;
  font-weight: 400;
  border: 1px solid var(--bg-tertiary);
  box-shadow: var(--shadow-lg);
  text-transform: none;
}

.tooltip-container:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 1rem;
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center bottom;
}

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

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: white;
  margin: 0;
}

.modal-content {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.btn-icon-only.x-small {
  width: 28px;
  height: 28px;
}

/* Loading Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Button Loading State */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading .spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  animation: spin 0.8s linear infinite;
  /* Ensure animation runs */
}

/* Center spinner in loading button */
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: calc(50% - 8px);
  left: calc(50% - 8px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Annotation Modal Adjustments */
#annotation-modal .modal-container {
  padding: 1rem;
}

#annotation-modal .modal-header {
  margin-bottom: 0.5rem;
}

#annotation-modal .modal-content {
  margin-bottom: 0;
  background: var(--bg-primary);
  border-radius: 0.5rem;
  border: 1px dashed var(--bg-tertiary);
}

/* Improved Ingredient Remove Button */
.gallery-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(220, 38, 38, 0.9);
  /* Red 600 */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}

.gallery-item:hover .gallery-remove-btn {
  opacity: 1;
}

.gallery-remove-btn:hover {
  background: #ef4444;
  /* Red 500 */
  transform: scale(1.1);
}

/* Annotation System enhancements */
.annotation-text-box {
  position: absolute;
  width: 200px;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.4;
  z-index: 2010;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  resize: vertical;
  height: 60px;
  /* Approximately 2 lines */
}

.annotation-text-box::placeholder {
  color: var(--text-secondary);
}

.annotation-text-box:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Editor Specific Styles */
.editor-overlay-container {
  position: absolute;
  cursor: move;
  border: 1px dashed rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
  pointer-events: auto; /* Ensure it catches mousedown for dragging */
}
.editor-overlay-container:hover, .editor-overlay-container.active {
  border-color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.1);
}
.editor-overlay-container img {
  width: 100%;
  height: 100%;
  object-fit: fill; 
  pointer-events: none;
  display: block;
}

/* Resize Handles */
.editor-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: var(--accent-primary);
  border: 1px solid white;
  border-radius: 50%;
  z-index: 20;
  pointer-events: auto;
}
.handle-tl { top: -5px; left: -5px; cursor: nw-resize; }
.handle-tr { top: -5px; right: -5px; cursor: ne-resize; }
.handle-bl { bottom: -5px; left: -5px; cursor: sw-resize; }
.handle-br { bottom: -5px; right: -5px; cursor: se-resize; }

.editor-overlay-delete {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 21;
}
.editor-overlay-container:hover .editor-overlay-delete {
  opacity: 1;
}