:root {
  --bg-dark: #0b1120;
  --bg-panel: #1e293b;
  --bg-subtle: #334155;
  --border-color: #475569;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --warning: #f59e0b;
  --color-number: #f59e0b;
  --color-sentence: #fbbf24;
  --color-yaxis: #10b981;
  --color-xaxis: #06b6d4;
  --color-title: #8b5cf6;
  --color-logo: #ec4899;
  --color-text: #94a3b8;
  --color-manual: #3b82f6;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  user-select: none;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 580px;
}

/* --- Topbar --- */
.topbar {
  height: 54px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 25;
}

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

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.app-title {
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: -0.2px;
  color: #fff;
}

.badge {
  font-size: 0.7rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.spacer {
  flex: 1;
}

.divider {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 4px;
}

.tool-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn.btn-icon {
  padding: 6px 8px;
}

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

.tool-btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  color: var(--text-main);
}

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

.btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--primary);
  color: #04101e;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: #475569;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.78rem;
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.76rem;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover {
  text-decoration: underline;
}

/* --- Main Workspace Layout --- */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* --- Left Tool Rail (Figma/Photoshop Style) --- */
.tool-rail {
  width: 50px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 6px;
  z-index: 20;
  flex-shrink: 0;
}

.rail-btn {
  width: 38px;
  height: 38px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.rail-btn svg {
  width: 18px;
  height: 18px;
}

.rail-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.rail-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border-color: rgba(56, 189, 248, 0.4);
}

.rail-divider {
  width: 28px;
  height: 1px;
  background: var(--border-color);
  margin: 6px 0;
}

.rail-tooltip {
  position: absolute;
  left: 54px;
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: opacity 0.15s ease;
  z-index: 100;
}

.rail-btn:hover .rail-tooltip {
  opacity: 1;
}

/* --- Canvas Viewport --- */
.canvas-viewport {
  flex: 1;
  position: relative;
  background: #060913;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.canvas-viewport-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
}

.canvas-container {
  position: relative;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
  background: #fff;
  user-select: none;
  pointer-events: auto;
  transform-origin: center center;
  flex-shrink: 0;
}

#imageCanvas {
  display: block;
}

#overlayCanvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  cursor: default;
  touch-action: none;
}

/* Empty State / Dropzone (Clickable everywhere) */
.drop-zone {
  position: absolute;
  inset: 24px;
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.4);
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
}

.drop-zone:hover {
  border-color: var(--primary);
  background: rgba(30, 41, 59, 0.6);
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.15);
}

.drop-content {
  text-align: center;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.drop-icon svg {
  width: 52px;
  height: 52px;
  color: var(--primary);
  opacity: 0.85;
}

.drop-content h2 {
  font-size: 1.25rem;
  font-weight: 500;
}

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

.privacy-note {
  font-size: 0.75rem;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.25);
  margin-top: 6px;
}

.global-drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.overlay-drop-box {
  border: 3px dashed var(--primary);
  border-radius: 16px;
  padding: 40px 60px;
  text-align: center;
  color: #fff;
}

.overlay-drop-box svg {
  width: 54px;
  height: 54px;
  color: var(--primary);
  margin-bottom: 12px;
}

/* Floating Zoom Pill (Bottom Right) */
.zoom-floating-pill {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 15;
}

.zoom-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1rem;
  font-weight: 700;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
}
.zoom-btn:hover {
  background: var(--bg-subtle);
  color: #fff;
}

.zoom-level-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  min-width: 44px;
  text-align: center;
  cursor: pointer;
}
.zoom-level-text:hover {
  color: var(--primary);
}

.zoom-btn-fit {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.zoom-btn-fit:hover {
  color: #fff;
  border-color: var(--primary);
}

/* Crop Action Bar */
.crop-action-bar {
  position: absolute;
  top: 16px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  z-index: 15;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

/* Scan Loader Overlay */
.scan-loader {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 30;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.scan-loader p {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-main);
}

/* Floating Tooltip */
.box-tooltip {
  position: fixed;
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  white-space: nowrap;
}

/* --- Sidebar Controls --- */
.sidebar {
  width: 340px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 12px;
  padding: 14px;
  flex-shrink: 0;
}

.panel-section {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-header h3, .panel-section h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.count-badge {
  font-size: 0.72rem;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 600;
}

.section-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Category Checkbox List */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 0.82rem;
}

.checkbox-row:hover {
  background: rgba(51, 65, 85, 0.4);
}

.checkbox-row input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--primary);
}

.color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-number { background: var(--color-number); }
.dot-sentence { background: var(--color-sentence); }
.dot-yaxis { background: var(--color-yaxis); }
.dot-xaxis { background: var(--color-xaxis); }
.dot-title { background: var(--color-title); }
.dot-logo { background: var(--color-logo); }
.dot-text { background: var(--color-text); }

.cat-label {
  flex: 1;
}

.cat-glyph {
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-muted);
  padding: 1px 4px;
  border-radius: 3px;
  min-width: 18px;
  text-align: center;
}

.cat-count {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-group-tight {
  display: flex;
  gap: 12px;
  padding-left: 6px;
}

/* Inspector Section */
.inspector-section {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(14, 165, 233, 0.05);
}

.inspector-override-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inspector-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}

.inspector-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.inspector-actions button {
  flex: 1;
}

/* Mode Selector Radio Cards */
.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.3);
  transition: all 0.15s ease;
}

.radio-card:hover {
  background: rgba(51, 65, 85, 0.3);
}

.radio-card input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--primary);
}

.radio-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-content strong {
  font-size: 0.82rem;
  font-weight: 600;
}

.radio-content span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Sliders */
.slider-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.slider-control input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.text-input, .select-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
}
.text-input:focus, .select-input:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

/* Collapsible Accordion */
.panel-accordion {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
  list-style: none;
  user-select: none;
}
.accordion-summary::-webkit-details-marker {
  display: none;
}
.accordion-summary:hover {
  background: rgba(51, 65, 85, 0.3);
}

.chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

details[open] .chevron {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 10px 12px;
  border-top: 1px solid rgba(71, 85, 105, 0.4);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- Bottom Status Bar --- */
.bottom-status-bar {
  height: 26px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 0.74rem;
  color: var(--text-muted);
  z-index: 10;
}

.status-hint {
  color: #cbd5e1;
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

.modal-card.modal-lg {
  max-width: 600px;
}

.modal-card.modal-xl {
  max-width: 1080px;
  height: 85vh;
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close-btn:hover {
  background: var(--bg-subtle);
  color: #fff;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.45;
}

.preview-modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  gap: 12px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-image-container {
  flex: 1;
  background: #060913;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 10px;
}

.preview-image-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.preview-loader {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 32, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-main);
  font-size: 0.9rem;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Export Safety Notices */
.export-summary-box {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-main);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  margin-top: 10px;
  line-height: 1.4;
}

/* Shortcuts Cheat Sheet */
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(71, 85, 105, 0.3);
}

kbd {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 600;
}

/* --- Toasts --- */
.toast-container {
  position: fixed;
  bottom: 34px;
  left: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.2s ease forwards;
  pointer-events: auto;
}

.toast.toast-success { border-color: #10b981; }
.toast.toast-danger { border-color: var(--danger); }
.toast.toast-info { border-color: var(--primary); }
.toast.toast-secondary { border-color: #64748b; color: #cbd5e1; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- New Public UI, Ad Slots (CLS-Safe) & Mobile Responsive Rules --- */
.badge-btn {
  cursor: pointer;
  transition: background 0.15s ease;
}
.badge-btn:hover {
  background: rgba(56, 189, 248, 0.28);
}

.drop-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compare-floating-pill {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 15;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: all 0.15s ease;
}
.compare-floating-pill:hover, .compare-floating-pill.active {
  border-color: var(--primary);
  color: var(--primary);
}

.loader-stage {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-link {
  font-size: 0.74rem;
}

.mobile-drawer-toggle {
  display: none;
  width: 100%;
  background: var(--bg-subtle);
  color: var(--text-main);
  border: none;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  border-radius: 6px 6px 0 0;
}

/* Dedicated CLS-Safe Ad Slots */
.ad-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  align-self: flex-end;
}

.ad-placeholder-text {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

.ad-slot-sidebar {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ad-box-300x250 {
  width: 300px;
  min-height: 250px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-right-rail {
  width: 184px;
  background: var(--bg-dark);
  border-left: 1px solid var(--border-color);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  flex-shrink: 0;
}

.ad-box-160x600 {
  width: 160px;
  height: 600px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.ad-bottom-dock {
  background: var(--bg-dark);
  border-top: 1px solid var(--border-color);
  padding: 5px 12px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 12;
}

.ad-bottom-inner {
  width: min(728px, 100%);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ad-bottom-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ad-close-btn {
  background: transparent;
  border: 1px solid rgba(71, 85, 105, 0.5);
  color: var(--text-muted);
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ad-close-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
}

.ad-box-bottom-leaderboard {
  width: 100%;
  height: 90px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-slot-loader {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.ad-box-inline {
  width: 320px;
  min-height: 100px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot-modal {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ad-box-modal-banner {
  width: 100%;
  min-height: 60px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Responsive Media Queries --- */
@media (max-width: 1280px) {
  .topbar-primary button span {
    display: none;
  }
  .topbar-primary button {
    padding: 6px 8px;
  }
  .ad-right-rail {
    display: none;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    width: 290px;
  }
  .ad-box-300x250 {
    width: 100%;
    min-height: 220px;
  }
}

@media (max-width: 768px) {
  .workspace {
    flex-direction: column;
  }
  .topbar {
    padding: 0 10px;
    gap: 6px;
  }
  .badge {
    display: none;
  }
  .tool-rail {
    order: 2;
    width: 100%;
    height: 48px;
    flex-direction: row;
    justify-content: space-around;
    padding: 0 8px;
    border-right: none;
    border-top: 1px solid var(--border-color);
  }
  .rail-divider, .rail-tooltip {
    display: none;
  }
  .canvas-viewport {
    order: 1;
    flex: 1;
  }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 26px;
    width: 100%;
    max-height: 55vh;
    z-index: 40;
    border-left: none;
    border-top: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    transform: translateY(calc(100% - 38px));
    transition: transform 0.25s ease;
    padding-top: 0;
  }
  .sidebar.mobile-open {
    transform: translateY(0);
  }
  .mobile-drawer-toggle {
    display: block;
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .ad-slot-sidebar, .ad-right-rail, .status-hint {
    display: none;
  }
  .ad-bottom-dock {
    padding: 4px 8px;
  }
  .ad-bottom-inner {
    width: min(320px, 100%);
  }
  .ad-box-bottom-leaderboard {
    height: 50px;
  }
  .compare-floating-pill {
    bottom: 62px;
    left: 10px;
    padding: 4px 8px;
    font-size: 0.72rem;
  }
  .zoom-floating-pill {
    bottom: 62px;
    right: 10px;
  }
}


/* --- Below-the-Fold SEO Guide, In-Content Ad & Footer --- */
.seo-section {
  background: #0f172a;
  border-top: 1px solid var(--border-color);
  padding: 56px 24px 48px;
  user-select: text;
}

.seo-container {
  max-width: 1080px;
  margin: 0 auto;
}

.seo-hero {
  text-align: center;
  max-width: 780px;
  margin: 0 auto 40px;
}

.seo-hero h1 {
  font-size: 1.95rem;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 12px;
}

.seo-subtitle {
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 36px;
}

.seo-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
}

.seo-card h2 {
  font-size: 1.05rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.seo-card p {
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.55;
}

.seo-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 36px;
}

.seo-block {
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(71, 85, 105, 0.7);
  border-radius: 10px;
  padding: 22px;
}

.seo-block h2 {
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 12px;
}

.seo-block p,
.seo-block li {
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.6;
}

.seo-block ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seo-links-inline {
  margin-top: 14px;
  font-size: 0.88rem;
}

.seo-links-inline a {
  color: var(--primary);
  text-decoration: none;
}

.seo-links-inline a:hover {
  text-decoration: underline;
}

.ad-incontent-slot {
  margin: 0 auto 36px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  text-align: center;
}

.ad-box-incontent {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seo-faq {
  margin-bottom: 40px;
}

.seo-faq h2 {
  font-size: 1.35rem;
  margin-bottom: 16px;
  color: var(--text-main);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 18px;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.96rem;
  color: var(--text-main);
}

.faq-item p {
  margin-top: 10px;
  color: #cbd5e1;
  font-size: 0.9rem;
  line-height: 1.6;
}

.site-footer-main {
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  text-align: center;
}

.footer-links-main {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 10px;
}

.footer-links-main a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.footer-links-main a:hover {
  color: var(--primary);
}

.footer-copy {
  color: var(--text-muted);
  font-size: 0.82rem;
}
