/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base: #110c07;
  --bg-surface: #18120b;
  --bg-elevated: #24180e;
  --bg-glass: rgba(255, 244, 229, 0.05);
  --bg-glass-hover: rgba(255, 234, 204, 0.1);

  --accent-violet: #f97316;
  --accent-cyan: #facc15;
  --accent-purple: #fb923c;
  --accent-rgb: 249 115 22;
  --accent-secondary-rgb: 250 204 21;
  --accent-highlight: #fdba74;
  --accent-highlight-soft: #fde68a;
  --accent-gradient: linear-gradient(135deg, #f97316 0%, #facc15 100%);
  --accent-gradient-hover: linear-gradient(135deg, #ea580c 0%, #eab308 100%);

  --text-primary: #fff7ed;
  --text-secondary: #d6c0a9;
  --text-muted: #8b7355;

  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 32px rgb(var(--accent-rgb) / 0.22);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --header-h: 60px;
  --left-panel-w: 360px;
  --history-h: 140px;
}

html {
  font-size: 14px;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(circle at top left, rgb(var(--accent-rgb) / 0.18), transparent 30%),
    radial-gradient(circle at top right, rgb(var(--accent-secondary-rgb) / 0.14), transparent 24%);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ===== Header ===== */
.header {
  height: var(--header-h);
  background: rgba(17, 12, 7, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.header-inner {
  max-width: 100%;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon svg {
  width: 34px;
  height: 34px;
  display: block;
  filter: drop-shadow(0 0 12px rgb(var(--accent-rgb) / 0.45));
}

.logo-text {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.logo-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.logo-sub {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-badge {
  background: rgb(var(--accent-rgb) / 0.15);
  border: 1px solid rgb(var(--accent-rgb) / 0.3);
  color: var(--accent-highlight);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: 'Space Grotesk', monospace;
  font-weight: 500;
}

.btn-api-key {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-api-key:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ===== Main Layout ===== */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ===== Left Panel ===== */
.panel-left {
  width: var(--left-panel-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Mode Tabs ===== */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 4px;
  gap: 2px;
}

.mode-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.mode-tab svg {
  flex-shrink: 0;
}

.mode-tab:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

.mode-tab.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 12px rgb(var(--accent-rgb) / 0.35);
}

/* ===== Control Sections ===== */
.control-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  background: rgb(var(--accent-rgb) / 0.18);
  color: var(--accent-highlight);
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  min-height: 120px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: visible;
}

.upload-zone:hover,
.upload-zone.dragging {
  border-color: var(--accent-violet);
  background: rgb(var(--accent-rgb) / 0.06);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.upload-icon {
  color: var(--text-muted);
  transition: all var(--transition);
}

.upload-zone:hover .upload-icon {
  color: var(--accent-violet);
  transform: translateY(-2px);
}

.upload-content p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.upload-hint {
  color: var(--text-muted) !important;
  font-size: 0.75rem !important;
}

.upload-link {
  color: var(--accent-violet);
  cursor: pointer;
  text-decoration: underline;
}

.upload-preview {
  position: relative;
  width: 100%;
}

.upload-preview img {
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  background: var(--bg-base);
  display: block;
  border-radius: calc(var(--radius) - 2px);
}

.remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.remove-image:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: transparent;
}

/* ===== Multi-Ref Grid ===== */
.multi-ref-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.multi-ref-slot {
  aspect-ratio: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.multi-ref-slot:hover {
  border-color: var(--accent-violet);
  background: rgb(var(--accent-rgb) / 0.06);
  color: var(--accent-violet);
}

.multi-ref-slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.multi-ref-slot .slot-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(0, 0, 0, 0.75);
  border: none;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  opacity: 0;
  transition: opacity var(--transition);
}

.multi-ref-slot:hover .slot-remove {
  opacity: 1;
}

/* ===== Prompt Textarea ===== */
.prompt-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 12px;
  resize: none;
  height: 120px;
  transition: all var(--transition);
}

.prompt-textarea::placeholder {
  color: var(--text-muted);
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--accent-violet);
  background: rgb(var(--accent-rgb) / 0.06);
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.1);
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
}

.btn-enhance {
  background: rgb(var(--accent-rgb) / 0.12);
  border: 1px solid rgb(var(--accent-rgb) / 0.3);
  color: var(--accent-highlight);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-enhance:hover {
  background: rgb(var(--accent-rgb) / 0.24);
  border-color: rgb(var(--accent-rgb) / 0.5);
  color: var(--accent-highlight-soft);
}

/* ===== Settings ===== */
.setting-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.setting-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 8px 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a5a80' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  transition: all var(--transition);
}

.setting-select:focus {
  outline: none;
  border-color: var(--accent-violet);
}

/* ===== Aspect Ratio Grid ===== */
.aspect-ratio-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.ar-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Space Grotesk', sans-serif;
  text-align: center;
}

.ar-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

.ar-btn.active {
  background: rgb(var(--accent-rgb) / 0.2);
  border-color: rgb(var(--accent-rgb) / 0.6);
  color: var(--accent-highlight-soft);
}

/* ===== Resolution Toggle ===== */
.resolution-toggle {
  display: flex;
  gap: 6px;
}

.res-btn {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Space Grotesk', sans-serif;
}

.res-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.res-btn.active {
  background: rgb(var(--accent-rgb) / 0.2);
  border-color: rgb(var(--accent-rgb) / 0.6);
  color: var(--accent-highlight-soft);
}

/* ===== Generate Button ===== */
.btn-generate {
  width: 100%;
  padding: 14px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgb(var(--accent-rgb) / 0.4);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
}

.btn-generate::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition);
}

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

.btn-generate:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgb(var(--accent-rgb) / 0.5);
}

.btn-generate:active {
  transform: translateY(0);
  box-shadow: 0 4px 16px rgb(var(--accent-rgb) / 0.3);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== Right Panel ===== */
.panel-right {
  flex: 1;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Canvas Area ===== */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ===== Status Bar ===== */
.status-bar {
  background: rgb(var(--accent-rgb) / 0.12);
  border-bottom: 1px solid rgb(var(--accent-rgb) / 0.2);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--accent-highlight);
}

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

.status-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgb(var(--accent-rgb) / 0.3);
  border-top-color: var(--accent-violet);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* ===== Result Container ===== */
.result-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

.placeholder-state {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 380px;
}

.placeholder-icon {
  width: 100px;
  height: 100px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.placeholder-state h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.placeholder-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.placeholder-state strong {
  color: var(--text-secondary);
}

/* ===== Generated View ===== */
.generated-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-height: 100%;
}

.generated-image-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow), var(--shadow-glow);
  max-width: 100%;
  max-height: calc(100vh - var(--header-h) - var(--history-h) - 120px);
  animation: fadeInScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

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

.generated-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.generated-text {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  max-width: 600px;
  width: 100%;
}

/* ===== Result Actions ===== */
.result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-surface);
}

.action-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.action-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* ===== History Panel ===== */
.history-panel {
  height: var(--history-h);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.history-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.btn-clear-history {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: color var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-clear-history:hover {
  color: #f87171;
}

.history-strip {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  overflow-x: auto;
  align-items: center;
  flex: 1;
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  width: 100%;
  text-align: center;
}

.history-item {
  flex-shrink: 0;
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  position: relative;
  background: var(--bg-elevated);
}

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

.history-item:hover {
  border-color: var(--accent-violet);
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgb(var(--accent-rgb) / 0.3);
}

.history-item.current {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgb(var(--accent-secondary-rgb) / 0.3);
}

.history-item-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  padding: 3px 4px;
  font-size: 0.6rem;
  color: #aaa;
  text-align: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.history-item:hover .history-item-label {
  opacity: 1;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease both;
}

.modal-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), var(--shadow-glow);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-password-wrap {
  position: relative;
}

.input-password-wrap input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  padding: 10px 40px 10px 12px;
  transition: all var(--transition);
}

.input-password-wrap input:focus {
  outline: none;
  border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.12);
}

.toggle-visibility {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.toggle-visibility:hover {
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--accent-gradient);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  color: var(--text-primary);
  padding: 12px 22px;
  border-radius: 40px;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  z-index: 9999;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  white-space: nowrap;
}

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

.toast.success {
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.toast.info {
  border-color: rgb(var(--accent-rgb) / 0.4);
  color: var(--accent-highlight-soft);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  :root {
    --left-panel-w: 300px;
  }

  .mode-tab span {
    display: none;
  }
}

/* ===== Annotation Modal ===== */
.annotation-dialog {
  width: 100vw;
  height: 100vh;
  background: #140d08;
  display: flex;
  flex-direction: column;
}

/* Toolbar */
.ann-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  height: 52px;
  background: #21160d;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.ann-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ann-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ann-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-right: 8px;
  white-space: nowrap;
  font-family: 'Space Grotesk', sans-serif;
}

.ann-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

/* Tool buttons */
.ann-tool-group {
  display: flex;
  gap: 2px;
}

.ann-tool {
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.ann-tool:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.ann-tool.active {
  background: rgb(var(--accent-rgb) / 0.25);
  border-color: rgb(var(--accent-rgb) / 0.5);
  color: var(--accent-highlight-soft);
}

/* Colors */
.ann-colors {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ann-color {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  flex-shrink: 0;
}

.ann-color:hover {
  transform: scale(1.2);
}

.ann-color.active {
  border-color: white;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
  transform: scale(1.15);
}

.ann-color-custom {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--bg-elevated);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
}

.ann-color-custom::-webkit-color-swatch-wrapper {
  padding: 0;
}

.ann-color-custom::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

/* Sliders */
.ann-size-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.ann-range {
  -webkit-appearance: none;
  width: 80px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.ann-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-violet);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.ann-size-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 28px;
  font-family: 'Space Grotesk', monospace;
}

/* Action buttons in toolbar */
.ann-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 5px 10px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.ann-action-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border);
  color: var(--text-primary);
}

/* Instruction input */
.ann-instruction-wrap {
  flex: 1;
}

.ann-instruction {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 7px 12px;
  width: 300px;
  transition: all var(--transition);
}

.ann-instruction:focus {
  outline: none;
  border-color: var(--accent-violet);
  background: rgb(var(--accent-rgb) / 0.08);
}

.ann-instruction::placeholder {
  color: var(--text-muted);
}

.ann-btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.ann-btn-cancel:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.ann-btn-confirm {
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all var(--transition);
  font-family: 'Space Grotesk', sans-serif;
  box-shadow: 0 2px 12px rgb(var(--accent-rgb) / 0.35);
  white-space: nowrap;
}

.ann-btn-confirm:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgb(var(--accent-rgb) / 0.5);
}

/* Stage — holds the canvas */
.ann-stage {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  position: relative;
}

#annCanvas {
  display: block;
  cursor: crosshair;
  /* actual size set by JS */
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  box-shadow: 0 0 40px rgb(var(--accent-rgb) / 0.15);
}

/* cursor modes */
.ann-stage.tool-eraser #annCanvas {
  cursor: cell;
}

.ann-stage.tool-text #annCanvas {
  cursor: text;
}

/* Floating text input when 'Text' tool selected */
.ann-text-input-wrap {
  position: absolute;
  z-index: 10;
  pointer-events: none;
}

.ann-text-input-wrap.active {
  pointer-events: auto;
}

.ann-text-input {
  border: 2px dashed rgb(var(--accent-rgb) / 0.7);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 18px;
  font-family: 'Inter', sans-serif;
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  min-width: 120px;
}
