/* ═══════════════════════════════════════════════════════
   PokéBorder — Card Centering & Dewarp Tool
   Design System & Styles
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Surface colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a28;
  --bg-elevated: #22223a;
  --bg-glass: rgba(20, 20, 35, 0.75);
  --bg-glass-hover: rgba(30, 30, 50, 0.85);

  /* Accent colors */
  --accent-primary: #6c5ce7;
  --accent-secondary: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --accent-warm: #fd79a8;
  --accent-gold: #ffeaa7;

  /* Pokemon brand-inspired gradient */
  --gradient-brand: linear-gradient(135deg, #ee5a24 0%, #f0932b 25%, #fad390 50%, #6c5ce7 75%, #a29bfe 100%);
  --gradient-subtle: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(253, 121, 168, 0.15));

  /* Text colors */
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b85;
  --text-accent: #a29bfe;

  /* Point colors */
  --point-top: #FF6B6B;
  --point-bottom: #4ECDC4;
  --point-left: #45B7D1;
  --point-right: #96CEB4;
  --point-center-top: #FFEAA7;
  --point-center-bottom: #DDA0DD;
  --point-center-left: #98D8C8;
  --point-center-right: #F7DC6F;

  /* Grading colors */
  --grade-gem: #00b894;
  --grade-mint: #55efc4;
  --grade-nm-mt: #ffeaa7;
  --grade-nm: #fdcb6e;
  --grade-below: #e17055;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(108, 92, 231, 0.3);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.2);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Animated Background ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 20%, rgba(108, 92, 231, 0.08), transparent),
    radial-gradient(ellipse 500px 350px at 80% 80%, rgba(253, 121, 168, 0.06), transparent),
    radial-gradient(ellipse 400px 300px at 50% 50%, rgba(78, 205, 196, 0.04), transparent);
  pointer-events: none;
  z-index: 0;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}

/* ── Header ── */
.app-header {
  position: relative;
  z-index: 100;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: visible;
}

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

.app-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-glow);
}

.app-logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-actions .btn {
  padding: 6px 12px;
  font-size: 12px;
}

/* ── Tab Bar ── */
.tab-bar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 4px;
  background: rgba(10, 10, 20, 0.6);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 36px;
  overflow-x: auto;
}

.tab-list {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
}

.card-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px 6px 0 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
}

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

.card-tab.active {
  background: rgba(255,255,255,0.1);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.card-tab .tab-side {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
}

.card-tab.active .tab-side {
  background: var(--accent-primary);
  color: #fff;
}

.card-tab .tab-close {
  font-size: 14px;
  opacity: 0.3;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.card-tab .tab-close:hover {
  opacity: 1;
  color: #ff6b6b;
}

.tab-add-btn, .tab-add-inline {
  padding: 4px 12px;
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
}

.tab-add-btn:hover, .tab-add-inline:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(99,102,241,0.1);
}

/* ── Card Lookup Bar ── */
.card-lookup-bar {
  padding: 4px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lookup-bar-inner {
  display: flex;
  gap: 6px;
  align-items: center;
}
.lookup-bar-input {
  flex: 1;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.lookup-bar-input:focus {
  border-color: var(--accent-primary);
}
.lookup-bar-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}

/* ── Front/Back Toggle ── */
.btn-side-toggle {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 14px;
}

.btn-side-toggle.back-active {
  background: rgba(255,107,107,0.15);
  border-color: rgba(255,107,107,0.3);
  color: #ff6b6b;
}

/* ── Export Dropdown ── */
.export-dropdown {
  position: relative;
  display: inline-block;
}

.export-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 200px;
  background: rgba(20, 20, 35, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 6px;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.export-menu.open {
  display: flex;
  flex-direction: column;
}

.export-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s;
}

.export-menu button:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.export-menu-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 4px 8px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  white-space: nowrap;
  user-select: none;
}

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

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background: #7c6cf0;
  border-color: #7c6cf0;
  box-shadow: var(--shadow-glow);
}

.btn-danger {
  color: var(--point-top);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.3);
  color: var(--point-top);
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
  justify-content: center;
}

.btn-group {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--border-subtle);
}

.btn-group .btn {
  border: none;
  border-radius: 6px;
  background: transparent;
  backdrop-filter: none;
}

.btn-group .btn.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-group .btn:hover:not(.active) {
  background: var(--bg-elevated);
}

/* ── Main Layout ── */
.app-main {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  height: calc(100vh - 145px);
}

/* ── Panels ── */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-left {
  border-right: 1px solid var(--border-subtle);
}

.panel-center {
  border-right: 1px solid var(--border-subtle);
}

.panel-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  min-height: 48px;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px transparent; }
}

.panel-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}

.panel-right .panel-body {
  overflow-y: auto;
  align-items: flex-start;
}

/* ── Upload Zone ── */
.upload-zone {
  position: absolute;
  inset: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-accent);
  border-radius: var(--radius-xl);
  background: var(--gradient-subtle);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  z-index: 5;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-primary);
  background: rgba(108, 92, 231, 0.1);
  transform: scale(1.01);
}

.upload-zone.drag-over {
  box-shadow: var(--shadow-glow), inset 0 0 30px rgba(108, 92, 231, 0.1);
}

.upload-zone.hidden {
  display: none;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.upload-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.upload-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.upload-input {
  display: none;
}

/* ── Canvas Container ── */
.canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.canvas-container.active {
  display: flex;
}

.canvas-wrapper {
  position: relative;
  cursor: crosshair;
  box-shadow: var(--shadow-lg);
  will-change: transform;
  transition: none;
}

.canvas-wrapper canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: -webkit-optimize-contrast;
}

/* ── Toolbar Hint ── */
.toolbar-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Smoothness Control ── */
.smoothness-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.smoothness-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #fff;
  box-shadow: 0 0 6px var(--accent-glow);
  cursor: grab;
  transition: transform 0.15s ease;
}

.smoothness-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.smoothness-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #fff;
  cursor: grab;
}

.smoothness-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}

/* ── Brightness Control ── */
.brightness-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brightness-icon {
  font-size: 13px;
  color: var(--text-muted);
  cursor: default;
  user-select: none;
}

.brightness-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 70px;
  height: 3px;
  border-radius: 2px;
  background: var(--bg-elevated);
  outline: none;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.brightness-slider:hover {
  opacity: 1;
}

.brightness-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-secondary);
  border: 1.5px solid #fff;
  cursor: grab;
  transition: transform 0.15s ease, background 0.15s ease;
}

.brightness-slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
  background: var(--accent-primary);
}

.brightness-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-secondary);
  border: 1.5px solid #fff;
  cursor: grab;
}

/* ── Brightness Label ── */
.brightness-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  margin-right: 4px;
}

/* ── Hatch Toggle Button ── */
.hatch-toggle-btn {
  font-size: 11px !important;
  padding: 3px 10px !important;
  margin-left: 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.04);
  transition: all 0.2s;
  white-space: nowrap;
  cursor: pointer;
}
.hatch-toggle-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
}
.hatch-toggle-btn.active {
  color: #FF2020;
  border-color: rgba(255, 32, 32, 0.4);
  background: rgba(255, 32, 32, 0.1);
}

/* ── Guide Banner ── */
.guide-banner {
  position: absolute;
  top: 70%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  max-width: 380px;
  width: 90%;
  background: rgba(10, 10, 25, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-top: 4px solid var(--accent-primary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  font-size: 14px;
  color: var(--text-primary);
}

.guide-banner .btn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Nudge Pad ── */
#nudge-pad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 2px;
  background: rgba(10, 10, 25, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.nudge-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  padding: 0;
  line-height: 1;
}
.nudge-btn:hover, .nudge-btn:active {
  background: rgba(108, 92, 231, 0.3);
  color: #fff;
  border-color: var(--accent-primary);
}
.nudge-up { grid-area: up; }
.nudge-down { grid-area: down; }
.nudge-left { grid-area: left; }
.nudge-right { grid-area: right; }

.guide-step {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 16px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  white-space: nowrap;
}

@keyframes edgePulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.6); opacity: 0.2; }
}

/* ── Card Lookup ── */
.card-lookup-panel {
  border-top: 1px solid var(--border-subtle);
}

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

.lookup-title {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-secondary);
}

.ref-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--accent-primary);
}

.lookup-body { padding: 10px 16px; }

.lookup-search {
  display: flex; gap: 8px;
}

.lookup-input {
  flex: 1; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated); color: var(--text-primary);
  font-size: 12px; font-family: inherit;
}
.lookup-input:focus { outline: none; border-color: var(--accent-primary); }

.lookup-results {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px; margin-top: 10px; max-height: 200px; overflow-y: auto;
}

.lookup-card {
  cursor: pointer; border-radius: 6px; overflow: hidden;
  border: 2px solid transparent; transition: border-color 0.2s;
  background: var(--bg-elevated);
}
.lookup-card:hover { border-color: var(--accent-primary); }
.lookup-card img { width: 100%; display: block; }
.lookup-card-name {
  padding: 3px 5px; font-size: 9px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ref-controls {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.ref-toggle {
  font-size: 12px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}

/* ── Slab Customization ── */
.slab-customization {
  border-top: 1px solid var(--border-subtle);
}

.customize-body {
  padding: 10px 16px;
}

.customize-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.customize-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.backdrop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.backdrop-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.backdrop-option:hover {
  background: rgba(255,255,255,0.04);
}

.backdrop-option.active {
  border-color: var(--accent-primary);
  background: rgba(108, 92, 231, 0.1);
}

.backdrop-swatch {
  width: 100%;
  height: 32px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.08);
}

.backdrop-option span {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Slab Preview ── */
.slab-preview-section {
  border-top: 1px solid var(--border-subtle);
  flex: 1;
}

.slab-showcase {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 260px;
}

.slab-showcase-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 12px;
  gap: 10px;
}

.slab-showcase-right {
  width: 120px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 14px;
  border-left: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.15);
}

.slab-settings-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.slab-settings-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 2px;
}

.slab-flip-btn-main {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.slab-flip-btn-main:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.25);
}

.slab-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  perspective: 1200px;
}

.slab-flipper {
  position: relative;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.slab-flipper.flipped {
  transform: rotateY(180deg);
}

.slab-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.slab-face-front {
  position: relative;
}

.slab-face-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(180deg);
}

.slab-face canvas {
  display: block;
  border-radius: 4px;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.4);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

/* ── Output Panel ── */
.output-empty {
  text-align: center;
  padding: 40px;
}

.output-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.output-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.output-empty-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 260px;
  margin: 0 auto;
}

/* ── Results Container ── */
.results-container {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
  flex: 1;
}

.results-container.active {
  display: flex;
}

.result-canvas-area {
  flex: 1;
  position: relative;
  overflow: auto;
  display: block;
}

.result-canvas-inner {
  display: inline-flex;
  min-width: 100%;
  min-height: 100%;
  padding: 20px;
  box-sizing: border-box;
}

.result-canvas-inner::before,
.result-canvas-inner::after {
  content: '';
  margin: auto;
}

.result-canvas-wrapper {
  position: relative;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  margin: auto;
}

.result-canvas-wrapper canvas {
  display: block;
}

/* ── Floating Centering Overlay ── */
.centering-float {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(10, 10, 20, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px;
  pointer-events: auto;
  z-index: 50;
  display: none;
  opacity: 0.25;
  transition: opacity 0.2s ease;
}

.centering-float:hover {
  opacity: 1;
}

.cf-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  margin-bottom: 3px;
  border-left: 3px solid transparent;
}

.cf-section.active {
  background: rgba(255,255,255,0.04);
  border-left-color: var(--accent-primary);
}

.cf-section.cf-no-data {
  opacity: 0.3;
}

.cf-side-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  width: 24px;
  flex-shrink: 0;
  text-align: center;
}

.cf-grade {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  min-width: 28px;
  text-align: center;
  line-height: 1;
}

.cf-metrics {
  display: flex;
  gap: 8px;
}

.cf-metric {
  display: flex;
  align-items: center;
  gap: 3px;
}

.cf-mlabel {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
}

.cf-mvalue {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.cf-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 4px 0;
}

.cf-combined .cf-grade {
  font-size: 22px;
}

.cf-grade-name {
  font-size: 8px;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

/* ── Weight Distribution Bars ── */
.cf-weight-bars {
  padding: 4px 0 2px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cf-weight-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cf-weight-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  width: 10px;
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.cf-weight-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  position: relative;
  overflow: visible;
}
.cf-weight-track::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255,255,255,0.12);
}
.cf-weight-marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid rgba(255,255,255,0.5);
  transform: translate(-50%, -50%);
  transition: left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 0 6px rgba(162,155,254,0.4);
}
.cf-weight-val {
  font-size: 13px;
  font-weight: 800;
  color: rgba(255,255,255,0.7);
  width: 32px;
  text-align: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.weight-panel {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}
.weight-panel-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.weight-panel .cf-weight-row {
  gap: 8px;
}
.weight-panel .cf-weight-track {
  height: 8px;
  border-radius: 4px;
}
.weight-panel .cf-weight-marker {
  width: 12px;
  height: 12px;
}

.centering-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.centering-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.centering-grade {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  animation: gradeReveal 0.5s var(--ease-out);
}

@keyframes gradeReveal {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.centering-grade.gem { background: rgba(0, 184, 148, 0.15); color: var(--grade-gem); border: 1px solid rgba(0, 184, 148, 0.3); }
.centering-grade.mint { background: rgba(85, 239, 196, 0.15); color: var(--grade-mint); border: 1px solid rgba(85, 239, 196, 0.3); }
.centering-grade.nm-mt { background: rgba(255, 234, 167, 0.15); color: var(--grade-nm-mt); border: 1px solid rgba(255, 234, 167, 0.3); }
.centering-grade.nm { background: rgba(253, 203, 110, 0.15); color: var(--grade-nm); border: 1px solid rgba(253, 203, 110, 0.3); }
.centering-grade.below { background: rgba(225, 112, 85, 0.15); color: var(--grade-below); border: 1px solid rgba(225, 112, 85, 0.3); }

.centering-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  position: relative;
  overflow: hidden;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-primary);
  margin-top: 8px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.8s var(--ease-out), background 0.3s ease;
}

/* ── Toolbar ── */
.toolbar {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.toolbar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-right: 4px;
}

/* ── Side Toggle (FRONT / BACK) ── */
.side-toggle {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  user-select: none;
}
.side-toggle-opt {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.03);
  transition: all 0.2s;
}
.side-toggle-opt:first-child {
  border-right: 1px solid rgba(255,255,255,0.08);
}
.side-toggle-opt:hover {
  color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.06);
}
.side-toggle-opt.active {
  color: #fff;
  background: var(--accent-primary);
}

/* ── Point Legend ── */
.point-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  margin-left: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

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

/* ── Status Bar ── */
.status-bar {
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-dot.ready { background: var(--grade-gem); }
.status-dot.processing { background: var(--accent-gold); animation: pulse 1s infinite; }
.status-dot.error { background: var(--point-top); }

/* ── Overlay Lines (edge/centering line previews) ── */
.edge-line {
  position: absolute;
  pointer-events: none;
  z-index: 15;
}

.edge-line-h {
  height: 1px;
  left: 0;
  right: 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 4px, currentColor 4px, currentColor 8px);
  opacity: 0.5;
}

.edge-line-v {
  width: 1px;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 4px, currentColor 4px, currentColor 8px);
  opacity: 0.5;
}

/* ── Grid Overlay on Output ── */
.grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.grid-overlay.visible {
  opacity: 1;
}

/* ── Zoom Controls ── */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 30;
}

.zoom-controls .btn {
  padding: 6px;
  min-width: 32px;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.zoom-level {
  text-align: center;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  padding: 2px;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .point-legend {
    display: none;
  }

  .toolbar {
    padding: 8px 12px;
  }
}

/* ── Animations ── */
.fade-in {
  animation: fadeIn 0.4s var(--ease-out);
}

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

.scale-in {
  animation: scaleIn 0.3s var(--ease-spring);
}

@keyframes scaleIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── No-image placeholder for output ── */
.no-centering-data {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
