:root {
  --bg-dark: #080c14;
  --bg-card: rgba(15, 23, 42, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --border-card: rgba(255, 255, 255, 0.08);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #00f0ff;
  --accent-purple: #8b5cf6;
  --accent-rose: #f43f5e;
  --accent-green: #10b981;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
}

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

html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  /* overflow: hidden; Page fits 100% in viewport without any scrollbar */
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-family);
}

/* Lucide Icons styling */
[data-lucide], svg.lucide {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.18em;
  stroke-width: 2.2px;
  display: inline-block;
}

.logo-icon [data-lucide], .logo-icon svg.lucide {
  width: 26px;
  height: 26px;
  stroke: var(--accent-cyan);
}

/* Background glows */
.background-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.2;
}

.glow-1 {
  width: 50vw;
  height: 50vh;
  background: radial-gradient(circle, #3b82f6, #8b5cf6);
  top: -10vh;
  left: -10vw;
}

.glow-2 {
  width: 50vw;
  height: 50vh;
  background: radial-gradient(circle, #d95f5f, #00f0ff);
  bottom: -10vh;
  right: -10vw;
}

/* Single 100vh App Container */
.app-container {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Glassmorphism card */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
}

/* Main Header (Compact 44px) */
.main-header {
  height: 44px;
  padding: 4px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

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

.logo-icon {
  font-size: 1.3rem;
}

.header-brand h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

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

.subtitle code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  color: #60a5fa;
  font-family: monospace;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 4px 10px;
  border-radius: 16px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-green);
  border-radius: 50%;
}

/* Main Workspace Flex: 100% Height minus Header & Footer */
.workspace-grid {
  display: flex;
  flex: 1;
  gap: 8px;
  min-height: 0; /* Critical for flex child height fitting */
  height: calc(100vh - 72px);
  height: calc(100dvh - 72px);
}

/* Left Sidebar Controls (Fixed 290px width) */
.controls-panel {
  width: 35vh;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  height: 100%;
  min-height: 0;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-section h2 {
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
}

.divider {
  border: 0;
  height: 1px;
  background: var(--border-card);
}

/* Presets Grid */
.presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-primary);
}

.preset-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.preset-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-cyan);
}

.preset-name {
  font-size: 0.7rem;
  font-weight: 600;
}

.preset-swatches {
  display: flex;
  gap: 3px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Color Pickers List */
.color-pickers-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-card);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  gap: 8px;
}

.picker-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.label-title {
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.orig-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: monospace;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2px 7px 2px 5px;
  border-radius: 12px;
  width: fit-content;
}

.orig-dot {
  display: inline-block !important;
  width: 12px !important;
  height: 12px !important;
  min-width: 12px !important;
  min-height: 12px !important;
  border-radius: 50% !important;
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5) !important;
  flex-shrink: 0 !important;
}

.orig-text {
  opacity: 0.9;
  font-size: 0.66rem;
}



.picker-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

input[type="color"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  background: none;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

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

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

input[type="text"] {
  width: 64px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.75rem;
  padding: 2px 4px;
  text-transform: uppercase;
  text-align: center;
}

/* Download Box */
.download-box {
  padding: 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.3);
  margin-top: auto;
}

.primary-btn {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

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

.download-note {
  font-size: 0.68rem;
  color: var(--text-secondary);
}

/* Main Preview Panel: Fills 100% height and remaining width */
.preview-panel {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

/* Top bar: Country & compare switch */
.preview-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.country-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 420px;
}

.country-select-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.country-select-dropdown {
  flex: 1;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.82rem;
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
}

.country-select-dropdown optgroup { background: #0f172a; color: var(--accent-cyan); }
.country-select-dropdown option { background: #1e293b; color: #fff; }

.icon-btn {
  white-space: nowrap;
  font-size: 0.78rem;
  padding: 5px 10px;
}

/* Tabs (Compact) */
.sample-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-card);
  padding-bottom: 6px;
  flex-shrink: 0;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.04); }
.tab-btn.active {
  color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.3);
}

/* Viewport Stage Wrap: Takes 100% remaining vertical height */
.viewport-stage-wrap {
  flex: 1;
  min-height: 0; /* CRITICAL to prevent overflow! */
  height: 100%;
  background: rgba(2, 6, 23, 0.4);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.preview-stage {
  width: 100%;
  height: 100%;
  display: flex;
  gap: 8px;
  align-items: stretch;
  justify-content: center;
  min-height: 0;
}

.preview-stage.hidden { display: none; }

.map-view-card {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 4px;
}

.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 2px 6px;
  border-radius: 10px;
  z-index: 2;
}

.card-badge.original {
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
  border-color: rgba(156, 163, 175, 0.3);
}

.map-view-card.hidden { display: none; }

/* SVG Container: Dynamically scales to 100% of available viewport space */
.svg-container {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.svg-container svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5));
}

/* Spinner Overlay */
.spinner-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.spinner-overlay.hidden { display: none; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

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

/* Footer (Compact) */
.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding-top: 2px;
}

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

.map-filename {
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--accent-cyan);
}

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

.secondary-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden { display: none; }

.modal-card {
  width: 340px;
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.modal-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #00f0ff);
  transition: width 0.15s ease-out;
  border-radius: 4px;
}

.main-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 2px;
  flex-shrink: 0;
}
